ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/gde/bin/gce
Revision: 1.11
Committed: Mon Mar 20 04:02:30 2006 UTC (20 years, 6 months ago) by root
Branch: MAIN
Changes since 1.10: +99 -77 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 elmex 1.10 =head1 SYNOPSIS
8    
9 root 1.11 gce [<map-filename>...]
10 elmex 1.10
11     =head1 FEATURES
12    
13     gce is a map editor for crossfire.
14    
15 root 1.11 Its main features are:
16    
17     - higher map editing comfort
18 elmex 1.10 - intelligent placement tool
19     - intelligent connection tool
20     - intelligent erase tool
21     - faster and smaller than the java editor
22     - map normalizing (removal of old deprecated attributes)
23     - exit following
24     - world map navigation
25 root 1.11 - easier installation (on windows)
26 elmex 1.10
27     =head1 DESCRIPTION
28    
29     =head2 THE MAIN WINDOW
30    
31 root 1.11 The main window of gce provides the display of the currently selected
32     object and the tools. The buttons select of the editing tool:
33 elmex 1.10
34     =over 4
35    
36     =item * Pick
37    
38 root 1.11 This tool is the simplest of all. It lets the user select the topmost
39     object of a map cell in the map window and updates the stack view for the
40     current space.
41    
42     If the pick attr flag is set only the attribute editor and the stack
43     view are updated. This is useful when you want to put an object in the
44     attribute editor and want to place an object from the map, you picked
45     before, in an inventory of a different object (you just picked). This is a
46     very special thing. It will propably go away.
47 elmex 1.10
48     Shortcut-key in map editor: i
49    
50     =item * Place
51    
52     This is the intelligent placement tool. It has many modes:
53    
54     =over 4
55    
56     =item auto
57    
58 root 1.11 This mode implements DWIM (do-what-I-mean) by trying to do the the right
59     thing(tm) with the selected object:
60    
61     If you place a floor arch, it will try to replace the existing floor or
62     set the floor below all items. If you place a monster or other arch, it
63     will place it on top. If you place a wall, it will put the wall above the
64     floor and propably replace other walls.
65 elmex 1.10
66     =item top
67    
68 root 1.11 Places the arch on the top of the stack of the map cell.
69 elmex 1.10
70     =item above floor
71    
72 root 1.11 Places the arch just right above the floor (or the bottom of the stack).
73 elmex 1.10
74     =item below floor
75    
76 root 1.11 Places the arch just right below the floor (or the bottom of the stack).
77 elmex 1.10
78     =item bottom
79    
80 root 1.11 Places the arch on the bottom of the stack.
81 elmex 1.10
82     =item place clean (checkbox)
83    
84 root 1.11 Setting this is a flag lets the placement tool place an unmodified object
85     on the map only. This is useful when you have modified the currently
86     selected object in the attribute editor (e.g. a special monster with
87     modified hp) but your want to place an unmodified monster.
88 elmex 1.10
89     =back
90    
91     Shortcut-key in map editor: p
92    
93     =item * Erase
94    
95     This is the tool that lets you erase an arch.
96 root 1.11
97 elmex 1.10 It has following modes:
98    
99     =over 4
100    
101     =item top
102    
103     Erases the topmost object on the stack.
104    
105     =item walls
106    
107 root 1.11 Erases all walls in the stack (and only walls).
108 elmex 1.10
109     =item above floor
110    
111     Erases the first object above the floor.
112    
113     =item floor
114    
115 root 1.11 Erases all floor from the stack (and only the floor).
116 elmex 1.10
117     =item below floor
118    
119     Erases the first object below the floor.
120    
121     =item bottom
122    
123     Erases the first object on the bottom of the stack.
124    
125     =item pick match
126    
127 root 1.11 This erases all objects from the stack that match the currently selected
128     object.
129 elmex 1.10
130 root 1.11 =item protect walls (checkbox)
131 elmex 1.10
132 root 1.11 This protects walls from being erased (except when erasing walls).
133 elmex 1.10
134 root 1.11 =item protect monsters (checkbox)
135 elmex 1.10
136 root 1.11 This protects monsters from being erased.
137 elmex 1.10
138     =back
139    
140     Shortcut-key in map editor: e
141    
142     =item * Select
143    
144 root 1.11 This is the selection tool. It can be used to select rectangular areas and
145     operate on that area in various ways:
146 elmex 1.10
147     =over 4
148    
149     =item copy
150    
151 root 1.11 This just copies all objects from the selected area into an internal
152     buffer for later paste operations.
153 elmex 1.10
154     Shortcut-key in map editor: c
155    
156     =item paste
157    
158 root 1.11 This function pastes the internal buffer into the map, beginning in the
159     top left corner of the selected area. The size of the selection has no
160     relevance to the result: IT always places the whole internal buffer onto
161     the map.
162 elmex 1.10
163     Shortcut-key in map editor: p
164    
165     =item invoke
166    
167 root 1.11 This function is a very powerful one. It can apply another tool (such as
168     the place tool) on all spaces of the selected area.
169    
170     It can, for example, be used to fill a map with floor tiles or erase
171     everything.
172 elmex 1.10
173     Shortcut-key in map editor: n
174    
175     =back
176    
177     Shortcut-key in map editor: s
178    
179     =item * Eval
180    
181 root 1.11 This is a very special tool which isn't finished yet. It lets you specify
182     a perl snippet that can manipulate the stack.
183 elmex 1.10
184     Shortcut-key in map editor: l
185    
186     =item * Connect Exit
187    
188 root 1.11 This tool connects two exits or teleporters.
189    
190     You can either connect two exits to each other, or just point an exit to
191     a certain location on a map.
192 elmex 1.10
193     Shortcut-key in map editor: x
194    
195     =item * Follow Exit
196    
197 root 1.11 With this tool you can follow exits and teleporters by opening the target
198     map in a new window (or presents an existing window).
199 elmex 1.10
200     Shortcut-key in map editor: f
201    
202     =back
203    
204     =head2 THE STACK VIEW
205    
206 root 1.11 This window displays the stack of a map space/coordinate.
207 elmex 1.10
208 root 1.11 You can swap two objects on the stack and delete a object from the stack
209     by dragging one object over another.
210    
211     By clicking on an item on the stack you can make it the currently selected
212     object.
213 elmex 1.10
214     =head2 THE MAP EDITOR
215    
216     This window just displays the map and lets you use the tools. The shortcuts are
217     documented above in the tool descriptions.
218    
219 root 1.11 You can pan the map using the middle mouse button and use the tool with
220     the left mouse button.
221 elmex 1.10
222 root 1.11 There are two modifiers: Holding down the Meta/Alt-key temporarily
223     switches to the pick tool. Holding down the Ctrl-key temporarily switched
224     to the erase tool. Both will use their current settings. To change them,
225     you need to select the tools using the toolbox first.
226 elmex 1.10
227     =head2 THE ATTRIBUTE EDITOR
228    
229 root 1.11 The attribute editor display the archetype name followed by the object
230     name and the type of the object in parentheses.
231    
232     Since there are often many attributes for a given object, they are sorted
233     into different categories/tabs.
234 elmex 1.10
235 root 1.11 The lore and msg tabs let you edit the text attributes of the object.
236 elmex 1.10
237 root 1.11 The inventory tab lets you add stuff to the inventory by dragging them
238     from the selected object in the toolbox to the top most button with the
239     image in the inventory (the inventory editor is subject to change and
240     improvement).
241    
242     Both field labels and value widgets have tool tips enabled. Tool tips on
243     the labels explain the attribute in more detail. The tool tips on the
244     value widgets show the default value from the archetype.
245 elmex 1.10
246    
247     =head2 THE PICK WINDOW
248    
249 root 1.11 Pick windows are used to quickly pick archetypes from specific categories.
250    
251     Left click creates an object from the archetype and makes it the currently
252     selected object for the tools and the attribute editor.
253    
254     You can change the attributes of the currently selected object in the
255     attribute editor.
256 elmex 1.10
257     You can open multiple pick windows.
258    
259 root 1.1 =cut
260    
261 root 1.4 our $VERSION = '0.1';
262    
263     BEGIN {
264 root 1.6 if (%PAR::LibCache) {
265 root 1.4 while (my ($filename, $zip) = each %PAR::LibCache) {
266     for ($zip->memberNames) {
267     next unless /^\/root\/(.*)/;
268     $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
269     unless -e "$ENV{PAR_TEMP}/$1";
270     }
271     }
272    
273     $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
274 root 1.6
275     if ($^O eq "MSWin32") {
276     $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
277     }
278 root 1.4 }
279     }
280 root 1.1
281     use Gtk2 -init;
282    
283 root 1.11 use Data::Dumper;
284     use File::Spec;
285    
286 root 1.1 use Crossfire;
287    
288 root 1.11 use GCE::MainWindow;
289    
290 root 1.1 our $CFG;
291     our $MAINWIN;
292    
293     sub read_cfg {
294     my ($file) = @_;
295    
296     open CFG, $file
297     or return;
298    
299     $CFG = eval join '', <CFG>;
300    
301     close CFG;
302     }
303    
304     sub write_cfg {
305     my ($file) = @_;
306    
307     open CFG, ">$file"
308     or return;
309    
310     {
311     local $Data::Dumper::Purity = 1;
312     print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
313     }
314    
315     close CFG;
316     }
317    
318     # following 2 functions are taken from CV :)
319     sub find_rcfile($) {
320     my $path;
321    
322     for (@INC) {
323    
324     $path = "$_/GCE/$_[0]";
325     return $path if -r $path;
326     }
327    
328     die "FATAL: can't find required file $_[0]\n";
329     }
330    
331     sub require_image($) {
332     new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
333     }
334    
335     sub get_pos_and_size {
336     my ($window) = @_;
337    
338     my ($x, $y) = $window->get_position;
339     my ($w, $h) = $window->get_size;
340    
341     return [$x, $y, $w, $h];
342     }
343    
344     sub set_pos_and_size {
345 elmex 1.8 my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_;
346 root 1.1
347 elmex 1.8 $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h);
348 root 1.1
349     # FIXME: This sucks, moving it after showing it can't be a good thing.
350     $window->show_all;
351 elmex 1.8 $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y);
352 root 1.1 }
353    
354 root 1.9 read_cfg "$Crossfire::VARDIR/gceconfig";
355    
356 elmex 1.10 $CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR};
357     $CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps');
358    
359 root 1.9 # must be done after changing the libdir path:
360 elmex 1.10 Crossfire::set_libdir ($CFG->{LIBDIR});
361 root 1.9 Crossfire::load_archetypes;
362     Crossfire::load_tilecache;
363 root 1.7
364     my $w = GCE::MainWindow->new;
365    
366     $w->load_layout;
367    
368     $w->show_all;
369    
370     Gtk2->main;
371    
372 root 1.1 =head1 AUTHOR
373    
374     Marc Lehmann <schmorp@schmorp.de>
375     http://home.schmorp.de/
376    
377     Robin Redeker <elmex@ta-sa.org>
378     http://www.ta-sa.org/
379    
380     =cut