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