ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.12
Committed: Mon Mar 20 04:06:05 2006 UTC (18 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.11: +119 -114 lines
Log Message:
put in changes

File Contents

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