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