ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.9
Committed: Mon Mar 20 01:13:28 2006 UTC (18 years, 2 months ago) by root
Branch: MAIN
Changes since 1.8: +6 -2 lines
Log Message:
*** empty log message ***

File Contents

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