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