ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/gde/bin/gce
Revision: 1.22
Committed: Fri Apr 21 18:54:48 2006 UTC (20 years, 5 months ago) by elmex
Branch: MAIN
Changes since 1.21: +5 -3 lines
Log Message:
hopefully fixed the libdir bug

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2 root 1.16
3 elmex 1.20 our $VERSION = '1.1';
4 elmex 1.12
5     BEGIN {
6     if (%PAR::LibCache) {
7 root 1.16 @INC = grep ref, @INC; # weed out all paths except pars loader refs
8    
9 elmex 1.12 while (my ($filename, $zip) = each %PAR::LibCache) {
10     for ($zip->memberNames) {
11     next unless /^\/root\/(.*)/;
12     $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
13     unless -e "$ENV{PAR_TEMP}/$1";
14     }
15     }
16    
17     $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
18    
19     if ($^O eq "MSWin32") {
20     $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
21     }
22     }
23     }
24    
25     use Gtk2 -init;
26    
27     use Data::Dumper;
28     use File::Spec;
29    
30     use Crossfire;
31    
32     use GCE::MainWindow;
33    
34     our $CFG;
35     our $MAINWIN;
36    
37     our $DOCUMENTATION = join ("\n", do { local $/; <DATA> });
38    
39     sub read_cfg {
40     my ($file) = @_;
41    
42     open CFG, $file
43     or return;
44    
45     $CFG = eval join '', <CFG>;
46    
47     close CFG;
48     }
49    
50     sub write_cfg {
51     my ($file) = @_;
52    
53     open CFG, ">$file"
54     or return;
55    
56     {
57     local $Data::Dumper::Purity = 1;
58 elmex 1.19 $CFG->{VERSION} = $VERSION;
59 elmex 1.12 print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
60     }
61    
62     close CFG;
63     }
64    
65     # following 2 functions are taken from CV :)
66     sub find_rcfile($) {
67     my $path;
68    
69     for (@INC) {
70    
71     $path = "$_/GCE/$_[0]";
72     return $path if -r $path;
73     }
74    
75     die "FATAL: can't find required file $_[0]\n";
76     }
77    
78     sub require_image($) {
79     new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
80     }
81    
82     sub get_pos_and_size {
83     my ($window) = @_;
84    
85     my ($x, $y) = $window->get_position;
86     my ($w, $h) = $window->get_size;
87    
88     return [$x, $y, $w, $h];
89     }
90    
91     sub set_pos_and_size {
92     my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_;
93    
94     $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h);
95    
96     # FIXME: This sucks, moving it after showing it can't be a good thing.
97     $window->show_all;
98     $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y);
99     }
100    
101     read_cfg "$Crossfire::VARDIR/gceconfig";
102    
103 elmex 1.22 $ENV{CROSSFIRE_LIBDIR} = $CFG->{LIBDIR}
104     if $CFG->{LIBDIR};
105    
106     $CFG->{MAPDIR} ||= File::Spec->catfile ($ENV{CROSSFIRE_LIBDIR}, 'maps');
107 elmex 1.12
108     # must be done after changing the libdir path:
109 elmex 1.22 Crossfire::set_libdir ($ENV{CROSSFIRE_LIBDIR});
110 elmex 1.12 Crossfire::load_archetypes;
111     Crossfire::load_tilecache;
112    
113     my $w = GCE::MainWindow->new;
114    
115     $w->load_layout;
116    
117     $w->show_all;
118    
119     Gtk2->main;
120    
121     __DATA__
122 root 1.7
123 root 1.1 =head1 NAME
124    
125     gce - gtk (perl) crossfire editor
126    
127 elmex 1.10 =head1 SYNOPSIS
128    
129 root 1.11 gce [<map-filename>...]
130 elmex 1.10
131     =head1 FEATURES
132    
133     gce is a map editor for crossfire.
134    
135 root 1.11 Its main features are:
136    
137     - higher map editing comfort
138 elmex 1.10 - intelligent placement tool
139     - intelligent connection tool
140     - intelligent erase tool
141     - faster and smaller than the java editor
142     - map normalizing (removal of old deprecated attributes)
143     - exit following
144     - world map navigation
145 root 1.11 - easier installation (on windows)
146 elmex 1.18 - auto joining of walls (see Placement tool -> auto setting)
147 elmex 1.10
148     =head1 DESCRIPTION
149    
150 root 1.13 =head2 THE TOOLBOX WINDOW
151 elmex 1.10
152 root 1.13 The toolbox window is the main window of gce. It provides the display of
153     the currently selected object and the tools. The buttons select of the
154     editing tool:
155 elmex 1.10
156     =over 4
157    
158     =item * Pick
159    
160 root 1.11 This tool is the simplest of all. It lets the user select the topmost
161     object of a map cell in the map window and updates the stack view for the
162     current space.
163    
164 elmex 1.10 Shortcut-key in map editor: i
165    
166     =item * Place
167    
168     This is the intelligent placement tool. It has many modes:
169    
170     =over 4
171    
172     =item auto
173    
174 root 1.11 This mode implements DWIM (do-what-I-mean) by trying to do the the right
175     thing(tm) with the selected object:
176    
177     If you place a floor arch, it will try to replace the existing floor or
178     set the floor below all items. If you place a monster or other arch, it
179     will place it on top. If you place a wall, it will put the wall above the
180     floor and propably replace other walls.
181 elmex 1.10
182 elmex 1.18 Autojoin also works only in this mode. To draw an wall with autojoining pick
183     the wall arch which name looks like: <wallname>_0. It's the single point wall
184     tile which has no connections.
185     When you place this arch now, it will autoconnect the walls you are drawing.
186    
187 elmex 1.10 =item top
188    
189 root 1.11 Places the arch on the top of the stack of the map cell.
190 elmex 1.10
191     =item above floor
192    
193 root 1.11 Places the arch just right above the floor (or the bottom of the stack).
194 elmex 1.10
195     =item below floor
196    
197 root 1.11 Places the arch just right below the floor (or the bottom of the stack).
198 elmex 1.10
199     =item bottom
200    
201 root 1.11 Places the arch on the bottom of the stack.
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 elmex 1.21 The 'reset to defaults' button erases all changes on the object and resets
347     it's value to the values of the archetype.
348    
349 root 1.11 Since there are often many attributes for a given object, they are sorted
350     into different categories/tabs.
351 elmex 1.10
352 root 1.11 The lore and msg tabs let you edit the text attributes of the object.
353 elmex 1.10
354 root 1.11 Both field labels and value widgets have tool tips enabled. Tool tips on
355     the labels explain the attribute in more detail. The tool tips on the
356     value widgets show the default value from the archetype.
357 elmex 1.10
358 elmex 1.21 On the right side of the attribute editor you will find the inventory, you
359     can drag stuff there or just use the context menu von the pick window (see below)
360     to add inventory.
361 elmex 1.10
362     =head2 THE PICK WINDOW
363    
364 root 1.11 Pick windows are used to quickly pick archetypes from specific categories.
365    
366     Left click creates an object from the archetype and makes it the currently
367     selected object for the tools and the attribute editor.
368    
369     You can change the attributes of the currently selected object in the
370     attribute editor.
371 elmex 1.10
372 elmex 1.21 Right click opens the context menu, where you can add the selected arch as
373     inventory to the object which is currently visible in the attribute editor.
374    
375 elmex 1.10 You can open multiple pick windows.
376    
377 elmex 1.12 =head1 AUTHOR
378 root 1.1
379 root 1.15 All of the editor GUI:
380 root 1.4
381 elmex 1.12 Robin Redeker <elmex@ta-sa.org>
382     http://www.ta-sa.org/
383 root 1.6
384 root 1.15 The Crossfire map handling module and map widget:
385 root 1.1
386     Marc Lehmann <schmorp@schmorp.de>
387     http://home.schmorp.de/
388    
389     =cut