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

Comparing deliantra/gde/gce (file contents):
Revision 1.9 by elmex, Mon Feb 6 09:21:33 2006 UTC vs.
Revision 1.15 by root, Tue Feb 21 18:06:35 2006 UTC

10use Gtk2 -init; 10use Gtk2 -init;
11 11
12use Crossfire; 12use Crossfire;
13use Crossfire::Tilecache; 13use Crossfire::Tilecache;
14 14
15my $VARDIR = "$ENV{HOME}/.gcfedit"; 15our $VARDIR = "$ENV{HOME}/.gcfedit";
16 16
17mkdir $VARDIR; 17mkdir $VARDIR;
18our $PICKDIR = "$Crossfire::LIB/maps/editor/picks"; 18our $PICKDIR = "$Crossfire::LIB/maps/editor/picks";
19 19our $CFG;
20Crossfire::init $VARDIR; 20our $MAINWIN;
21Crossfire::Tilecache::init_tilecache "$VARDIR/tilecache";
22 21
23use GCE::MainWindow; 22use GCE::MainWindow;
24use GCE::PickWindow; 23use Data::Dumper;
25 24
25read_cfg ($VARDIR . '/config');
26my $w = GCE::MainWindow->new; 26my $w = GCE::MainWindow->new;
27 27
28$w->signal_connect (open_pick => sub { 28$w->load_layout;
29 # XXX: How to give pick window the pickname ?
30 my $p = GCE::PickWindow->new;
31 $p->show_all;
32});
33
34# XXX: signals don't feel right => move this stuff to MainWindow, it should
35# deal with all the stuff it does
36$w->signal_connect (update_stack_view => sub {
37 my ($t, $x, $y, $a) = @_;
38 print "$x $y: " . join (',', map { $_->{_name} } @$a) . "\n";
39});
40 29
41$w->show_all; 30$w->show_all;
42 31
43Gtk2->main; 32Gtk2->main;
33
34sub 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
45sub 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 :)
60sub 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
72sub require_image($) {
73 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
74}
75
76sub 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
85sub 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}
44 94
45=head1 AUTHOR 95=head1 AUTHOR
46 96
47 Marc Lehmann <schmorp@schmorp.de> 97 Marc Lehmann <schmorp@schmorp.de>
48 http://home.schmorp.de/ 98 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines