ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.7
Committed: Fri Feb 24 21:19:37 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
Changes since 1.6: +11 -9 lines
Log Message:
*** empty log message ***

File Contents

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