ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/gce
(Generate patch)

Comparing deliantra/gde/gce (file contents):
Revision 1.3 by root, Sun Feb 5 04:30:17 2006 UTC vs.
Revision 1.14 by elmex, Mon Feb 20 13:30:28 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines