ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/gde/bin/gce
Revision: 1.4
Committed: Thu Feb 23 14:54:39 2006 UTC (20 years, 7 months ago) by root
Branch: MAIN
Changes since 1.3: +18 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2     =head1 NAME
3    
4     gce - gtk (perl) crossfire editor
5    
6     =cut
7    
8 root 1.4 our $VERSION = '0.1';
9    
10     BEGIN {
11     if ($^O eq "MSWin32") {
12     require PAR;
13    
14     while (my ($filename, $zip) = each %PAR::LibCache) {
15     for ($zip->memberNames) {
16     next unless /^\/root\/(.*)/;
17     warn "extract $_ => $ENV{PAR_TEMP}/$1\n";#d#
18     $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
19     unless -e "$ENV{PAR_TEMP}/$1";
20     }
21     }
22    
23     $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
24     }
25     }
26 root 1.1
27     use Gtk2 -init;
28    
29     use Crossfire;
30     use Crossfire::Tilecache;
31    
32     our $PICKDIR = "$Crossfire::LIB/maps/editor/picks";
33     our $CFG;
34     our $MAINWIN;
35    
36     use GCE::MainWindow;
37     use Data::Dumper;
38    
39 root 1.3 read_cfg ("$Crossfire::VARDIR/gceconfig");
40 root 1.1 my $w = GCE::MainWindow->new;
41    
42     $w->load_layout;
43    
44     $w->show_all;
45    
46     Gtk2->main;
47    
48     sub read_cfg {
49     my ($file) = @_;
50    
51     open CFG, $file
52     or return;
53    
54     $CFG = eval join '', <CFG>;
55    
56     close CFG;
57     }
58    
59     sub write_cfg {
60     my ($file) = @_;
61    
62     open CFG, ">$file"
63     or return;
64    
65     {
66     local $Data::Dumper::Purity = 1;
67     print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
68     }
69    
70     close CFG;
71     }
72    
73     # following 2 functions are taken from CV :)
74     sub find_rcfile($) {
75     my $path;
76    
77     for (@INC) {
78    
79     $path = "$_/GCE/$_[0]";
80     return $path if -r $path;
81     }
82    
83     die "FATAL: can't find required file $_[0]\n";
84     }
85    
86     sub require_image($) {
87     new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
88     }
89    
90     sub get_pos_and_size {
91     my ($window) = @_;
92    
93     my ($x, $y) = $window->get_position;
94     my ($w, $h) = $window->get_size;
95    
96     return [$x, $y, $w, $h];
97     }
98    
99     sub set_pos_and_size {
100     my ($window, $p_and_s) = @_;
101    
102     $window->set_default_size ($p_and_s->[2], $p_and_s->[3]);
103    
104     # FIXME: This sucks, moving it after showing it can't be a good thing.
105     $window->show_all;
106     $window->move ($p_and_s->[0], $p_and_s->[1]);
107     }
108    
109     =head1 AUTHOR
110    
111     Marc Lehmann <schmorp@schmorp.de>
112     http://home.schmorp.de/
113    
114     Robin Redeker <elmex@ta-sa.org>
115     http://www.ta-sa.org/
116    
117     =cut