ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/gce
Revision: 1.14
Committed: Mon Feb 20 13:30:28 2006 UTC (18 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.13: +66 -3 lines
Log Message:
implemented edit actions and layout saving

File Contents

# User Rev Content
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 elmex 1.2
21 elmex 1.1 use GCE::MainWindow;
22 elmex 1.14 use Data::Dumper;
23 root 1.3
24 elmex 1.14 read_cfg ($VARDIR . '/config');
25 elmex 1.1 my $w = GCE::MainWindow->new;
26    
27 elmex 1.14 $w->load_layout;
28 root 1.12
29 elmex 1.1 $w->show_all;
30    
31     Gtk2->main;
32    
33 elmex 1.14 sub 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    
44     sub 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 :)
59     sub 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    
71     sub require_image($) {
72     new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
73     }
74    
75     sub 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    
84     sub 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     }
93    
94 elmex 1.1 =head1 AUTHOR
95    
96     Marc Lehmann <schmorp@schmorp.de>
97     http://home.schmorp.de/
98    
99     Robin Redeker <elmex@ta-sa.org>
100     http://www.ta-sa.org/
101    
102     =cut