ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.21
Committed: Tue Apr 4 13:05:52 2006 UTC (18 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.20: +9 -11 lines
Log Message:
Implemented a different inventory editor, added context menu to picker to
add stuff to the inventory (drag&drop doesn't work yet, will be done later).

File Contents

# Content
1 #!/opt/bin/perl
2
3 our $VERSION = '1.1';
4
5 BEGIN {
6 if (%PAR::LibCache) {
7 @INC = grep ref, @INC; # weed out all paths except pars loader refs
8
9 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 $CFG->{VERSION} = $VERSION;
59 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 $CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR};
104 $CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps');
105
106 # must be done after changing the libdir path:
107 Crossfire::set_libdir ($CFG->{LIBDIR});
108 Crossfire::load_archetypes;
109 Crossfire::load_tilecache;
110
111 my $w = GCE::MainWindow->new;
112
113 $w->load_layout;
114
115 $w->show_all;
116
117 Gtk2->main;
118
119 __DATA__
120
121 =head1 NAME
122
123 gce - gtk (perl) crossfire editor
124
125 =head1 SYNOPSIS
126
127 gce [<map-filename>...]
128
129 =head1 FEATURES
130
131 gce is a map editor for crossfire.
132
133 Its main features are:
134
135 - higher map editing comfort
136 - intelligent placement tool
137 - intelligent connection tool
138 - intelligent erase tool
139 - faster and smaller than the java editor
140 - map normalizing (removal of old deprecated attributes)
141 - exit following
142 - world map navigation
143 - easier installation (on windows)
144 - auto joining of walls (see Placement tool -> auto setting)
145
146 =head1 DESCRIPTION
147
148 =head2 THE TOOLBOX WINDOW
149
150 The toolbox window is the main window of gce. It provides the display of
151 the currently selected object and the tools. The buttons select of the
152 editing tool:
153
154 =over 4
155
156 =item * Pick
157
158 This tool is the simplest of all. It lets the user select the topmost
159 object of a map cell in the map window and updates the stack view for the
160 current space.
161
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 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
180 Autojoin also works only in this mode. To draw an wall with autojoining pick
181 the wall arch which name looks like: <wallname>_0. It's the single point wall
182 tile which has no connections.
183 When you place this arch now, it will autoconnect the walls you are drawing.
184
185 =item top
186
187 Places the arch on the top of the stack of the map cell.
188
189 =item above floor
190
191 Places the arch just right above the floor (or the bottom of the stack).
192
193 =item below floor
194
195 Places the arch just right below the floor (or the bottom of the stack).
196
197 =item bottom
198
199 Places the arch on the bottom of the stack.
200
201 =back
202
203 Shortcut-key in map editor: p
204
205 =item * Erase
206
207 This is the tool that lets you erase an arch.
208
209 It has following modes:
210
211 =over 4
212
213 =item top
214
215 Erases the topmost object on the stack.
216
217 =item walls
218
219 Erases all walls in the stack (and only walls).
220
221 =item above floor
222
223 Erases the first object above the floor.
224
225 =item floor
226
227 Erases all floor from the stack (and only the floor).
228
229 =item below floor
230
231 Erases the first object below the floor.
232
233 =item bottom
234
235 Erases the first object on the bottom of the stack.
236
237 =item pick match
238
239 This erases all objects from the stack that match the currently selected
240 object.
241
242 =item protect walls (checkbox)
243
244 This protects walls from being erased (except when erasing walls).
245
246 =item protect monsters (checkbox)
247
248 This protects monsters from being erased.
249
250 =back
251
252 Shortcut-key in map editor: e
253
254 =item * Select
255
256 This is the selection tool. It can be used to select rectangular areas and
257 operate on that area in various ways:
258
259 =over 4
260
261 =item copy
262
263 This just copies all objects from the selected area into an internal
264 buffer for later paste operations.
265
266 Shortcut-key in map editor: c
267
268 =item paste
269
270 This function pastes the internal buffer into the map, beginning in the
271 top left corner of the selected area. The size of the selection has no
272 relevance to the result: IT always places the whole internal buffer onto
273 the map.
274
275 Shortcut-key in map editor: p
276
277 =item invoke
278
279 This function is a very powerful one. It can apply another tool (such as
280 the place tool) on all spaces of the selected area.
281
282 It can, for example, be used to fill a map with floor tiles or erase
283 everything.
284
285 Shortcut-key in map editor: n
286
287 =back
288
289 Shortcut-key in map editor: s
290
291 =item * Eval
292
293 This is a very special tool which isn't finished yet. It lets you specify
294 a perl snippet that can manipulate the stack.
295
296 Shortcut-key in map editor: l
297
298 =item * Connect Exit
299
300 This tool connects two exits or teleporters.
301
302 You can either connect two exits to each other, or just point an exit to
303 a certain location on a map.
304
305 Shortcut-key in map editor: x
306
307 =item * Follow Exit
308
309 With this tool you can follow exits and teleporters by opening the target
310 map in a new window (or presents an existing window).
311
312 Shortcut-key in map editor: f
313
314 =back
315
316 =head2 THE STACK VIEW
317
318 This window displays the stack of a map space/coordinate.
319
320 You can swap two objects on the stack and delete a object from the stack
321 by dragging one object over another.
322
323 By clicking on an item on the stack you can make it the currently selected
324 object.
325
326 =head2 THE MAP EDITOR
327
328 This window just displays the map and lets you use the tools. The shortcuts are
329 documented above in the tool descriptions.
330
331 You can pan the map using the middle mouse button and use the tool with
332 the left mouse button.
333
334 There are two modifiers: Holding down the Meta/Alt-key temporarily
335 switches to the pick tool. Holding down the Ctrl-key temporarily switched
336 to the erase tool. Both will use their current settings. To change them,
337 you need to select the tools using the toolbox first.
338
339 =head2 THE ATTRIBUTE EDITOR
340
341 The attribute editor display the archetype name followed by the object
342 name and the type of the object in parentheses.
343
344 The 'reset to defaults' button erases all changes on the object and resets
345 it's value to the values of the archetype.
346
347 Since there are often many attributes for a given object, they are sorted
348 into different categories/tabs.
349
350 The lore and msg tabs let you edit the text attributes of the object.
351
352 Both field labels and value widgets have tool tips enabled. Tool tips on
353 the labels explain the attribute in more detail. The tool tips on the
354 value widgets show the default value from the archetype.
355
356 On the right side of the attribute editor you will find the inventory, you
357 can drag stuff there or just use the context menu von the pick window (see below)
358 to add inventory.
359
360 =head2 THE PICK WINDOW
361
362 Pick windows are used to quickly pick archetypes from specific categories.
363
364 Left click creates an object from the archetype and makes it the currently
365 selected object for the tools and the attribute editor.
366
367 You can change the attributes of the currently selected object in the
368 attribute editor.
369
370 Right click opens the context menu, where you can add the selected arch as
371 inventory to the object which is currently visible in the attribute editor.
372
373 You can open multiple pick windows.
374
375 =head1 AUTHOR
376
377 All of the editor GUI:
378
379 Robin Redeker <elmex@ta-sa.org>
380 http://www.ta-sa.org/
381
382 The Crossfire map handling module and map widget:
383
384 Marc Lehmann <schmorp@schmorp.de>
385 http://home.schmorp.de/
386
387 =cut