1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | our $VERSION = '0.2'; |
|
|
3 | |
|
|
4 | BEGIN { |
|
|
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 | |
|
|
22 | use Gtk2 -init; |
|
|
23 | |
|
|
24 | use Data::Dumper; |
|
|
25 | use File::Spec; |
|
|
26 | |
|
|
27 | use Crossfire; |
|
|
28 | |
|
|
29 | use GCE::MainWindow; |
|
|
30 | |
|
|
31 | our $CFG; |
|
|
32 | our $MAINWIN; |
|
|
33 | |
|
|
34 | our $DOCUMENTATION = join ("\n", do { local $/; <DATA> }); |
|
|
35 | |
|
|
36 | sub 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 | |
|
|
47 | sub 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 :) |
|
|
62 | sub 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 | |
|
|
74 | sub require_image($) { |
|
|
75 | new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; |
|
|
76 | } |
|
|
77 | |
|
|
78 | sub 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 | |
|
|
87 | sub 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 | |
|
|
97 | read_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: |
|
|
103 | Crossfire::set_libdir ($CFG->{LIBDIR}); |
|
|
104 | Crossfire::load_archetypes; |
|
|
105 | Crossfire::load_tilecache; |
|
|
106 | |
|
|
107 | my $w = GCE::MainWindow->new; |
|
|
108 | |
|
|
109 | $w->load_layout; |
|
|
110 | |
|
|
111 | $w->show_all; |
|
|
112 | |
|
|
113 | Gtk2->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 | |
… | |
… | |
254 | You can change the attributes of the currently selected object in the |
368 | You can change the attributes of the currently selected object in the |
255 | attribute editor. |
369 | attribute editor. |
256 | |
370 | |
257 | You can open multiple pick windows. |
371 | You can open multiple pick windows. |
258 | |
372 | |
259 | =cut |
|
|
260 | |
|
|
261 | our $VERSION = '0.1'; |
|
|
262 | |
|
|
263 | BEGIN { |
|
|
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 | |
|
|
281 | use Gtk2 -init; |
|
|
282 | |
|
|
283 | use Data::Dumper; |
|
|
284 | use File::Spec; |
|
|
285 | |
|
|
286 | use Crossfire; |
|
|
287 | |
|
|
288 | use GCE::MainWindow; |
|
|
289 | |
|
|
290 | our $CFG; |
|
|
291 | our $MAINWIN; |
|
|
292 | |
|
|
293 | sub 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 | |
|
|
304 | sub 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 :) |
|
|
319 | sub 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 | |
|
|
331 | sub require_image($) { |
|
|
332 | new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; |
|
|
333 | } |
|
|
334 | |
|
|
335 | sub 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 | |
|
|
344 | sub 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 | |
|
|
354 | read_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: |
|
|
360 | Crossfire::set_libdir ($CFG->{LIBDIR}); |
|
|
361 | Crossfire::load_archetypes; |
|
|
362 | Crossfire::load_tilecache; |
|
|
363 | |
|
|
364 | my $w = GCE::MainWindow->new; |
|
|
365 | |
|
|
366 | $w->load_layout; |
|
|
367 | |
|
|
368 | $w->show_all; |
|
|
369 | |
|
|
370 | Gtk2->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 |