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