ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
(Generate patch)

Comparing deliantra/gde/bin/gce (file contents):
Revision 1.11 by root, Mon Mar 20 04:02:30 2006 UTC vs.
Revision 1.12 by elmex, Mon Mar 20 04:06:05 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2our $VERSION = '0.2';
3
4BEGIN {
5 if (%PAR::LibCache) {
6 while (my ($filename, $zip) = each %PAR::LibCache) {
7 for ($zip->memberNames) {
8 next unless /^\/root\/(.*)/;
9 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
10 unless -e "$ENV{PAR_TEMP}/$1";
11 }
12 }
13
14 $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
15
16 if ($^O eq "MSWin32") {
17 $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
18 }
19 }
20}
21
22use Gtk2 -init;
23
24use Data::Dumper;
25use File::Spec;
26
27use Crossfire;
28
29use GCE::MainWindow;
30
31our $CFG;
32our $MAINWIN;
33
34our $DOCUMENTATION = join ("\n", do { local $/; <DATA> });
35
36sub read_cfg {
37 my ($file) = @_;
38
39 open CFG, $file
40 or return;
41
42 $CFG = eval join '', <CFG>;
43
44 close CFG;
45}
46
47sub write_cfg {
48 my ($file) = @_;
49
50 open CFG, ">$file"
51 or return;
52
53 {
54 local $Data::Dumper::Purity = 1;
55 print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
56 }
57
58 close CFG;
59}
60
61# following 2 functions are taken from CV :)
62sub find_rcfile($) {
63 my $path;
64
65 for (@INC) {
66
67 $path = "$_/GCE/$_[0]";
68 return $path if -r $path;
69 }
70
71 die "FATAL: can't find required file $_[0]\n";
72}
73
74sub require_image($) {
75 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
76}
77
78sub get_pos_and_size {
79 my ($window) = @_;
80
81 my ($x, $y) = $window->get_position;
82 my ($w, $h) = $window->get_size;
83
84 return [$x, $y, $w, $h];
85}
86
87sub set_pos_and_size {
88 my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_;
89
90 $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h);
91
92 # FIXME: This sucks, moving it after showing it can't be a good thing.
93 $window->show_all;
94 $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y);
95}
96
97read_cfg "$Crossfire::VARDIR/gceconfig";
98
99$CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR};
100$CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps');
101
102# must be done after changing the libdir path:
103Crossfire::set_libdir ($CFG->{LIBDIR});
104Crossfire::load_archetypes;
105Crossfire::load_tilecache;
106
107my $w = GCE::MainWindow->new;
108
109$w->load_layout;
110
111$w->show_all;
112
113Gtk2->main;
114
115__DATA__
2 116
3=head1 NAME 117=head1 NAME
4 118
5 gce - gtk (perl) crossfire editor 119 gce - gtk (perl) crossfire editor
6 120
254You can change the attributes of the currently selected object in the 368You can change the attributes of the currently selected object in the
255attribute editor. 369attribute editor.
256 370
257You can open multiple pick windows. 371You can open multiple pick windows.
258 372
259=cut
260
261our $VERSION = '0.1';
262
263BEGIN {
264 if (%PAR::LibCache) {
265 while (my ($filename, $zip) = each %PAR::LibCache) {
266 for ($zip->memberNames) {
267 next unless /^\/root\/(.*)/;
268 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
269 unless -e "$ENV{PAR_TEMP}/$1";
270 }
271 }
272
273 $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
274
275 if ($^O eq "MSWin32") {
276 $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
277 }
278 }
279}
280
281use Gtk2 -init;
282
283use Data::Dumper;
284use File::Spec;
285
286use Crossfire;
287
288use GCE::MainWindow;
289
290our $CFG;
291our $MAINWIN;
292
293sub read_cfg {
294 my ($file) = @_;
295
296 open CFG, $file
297 or return;
298
299 $CFG = eval join '', <CFG>;
300
301 close CFG;
302}
303
304sub write_cfg {
305 my ($file) = @_;
306
307 open CFG, ">$file"
308 or return;
309
310 {
311 local $Data::Dumper::Purity = 1;
312 print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
313 }
314
315 close CFG;
316}
317
318# following 2 functions are taken from CV :)
319sub find_rcfile($) {
320 my $path;
321
322 for (@INC) {
323
324 $path = "$_/GCE/$_[0]";
325 return $path if -r $path;
326 }
327
328 die "FATAL: can't find required file $_[0]\n";
329}
330
331sub require_image($) {
332 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
333}
334
335sub get_pos_and_size {
336 my ($window) = @_;
337
338 my ($x, $y) = $window->get_position;
339 my ($w, $h) = $window->get_size;
340
341 return [$x, $y, $w, $h];
342}
343
344sub set_pos_and_size {
345 my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_;
346
347 $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h);
348
349 # FIXME: This sucks, moving it after showing it can't be a good thing.
350 $window->show_all;
351 $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y);
352}
353
354read_cfg "$Crossfire::VARDIR/gceconfig";
355
356$CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR};
357$CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps');
358
359# must be done after changing the libdir path:
360Crossfire::set_libdir ($CFG->{LIBDIR});
361Crossfire::load_archetypes;
362Crossfire::load_tilecache;
363
364my $w = GCE::MainWindow->new;
365
366$w->load_layout;
367
368$w->show_all;
369
370Gtk2->main;
371
372=head1 AUTHOR 373=head1 AUTHOR
374
375 The editor GUI:
376
377 Robin Redeker <elmex@ta-sa.org>
378 http://www.ta-sa.org/
379
380 The Crossfire backend module:
373 381
374 Marc Lehmann <schmorp@schmorp.de> 382 Marc Lehmann <schmorp@schmorp.de>
375 http://home.schmorp.de/ 383 http://home.schmorp.de/
376 384
377 Robin Redeker <elmex@ta-sa.org>
378 http://www.ta-sa.org/
379
380=cut 385=cut

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines