ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.28
Committed: Tue Aug 15 17:29:35 2006 UTC (17 years, 9 months ago) by elmex
Branch: MAIN
Changes since 1.27: +0 -18 lines
Log Message:
removed the safe flag, was a broken design

File Contents

# Content
1 #!/opt/bin/perl
2
3 our $VERSION = '1.2';
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 $ENV{CROSSFIRE_LIBDIR} = $CFG->{LIBDIR}
104 if $CFG->{LIBDIR};
105
106 $CFG->{MAPDIR} ||= File::Spec->catfile ($ENV{CROSSFIRE_LIBDIR}, 'maps');
107
108 # must be done after changing the libdir path:
109 Crossfire::set_libdir ($ENV{CROSSFIRE_LIBDIR});
110 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
123 =head1 NAME
124
125 gce - gtk (perl) crossfire editor
126
127 =head1 SYNOPSIS
128
129 gce [<map-filename>...]
130
131 =head1 FEATURES
132
133 gce is a map editor for crossfire.
134
135 Its main features are:
136
137 - higher map editing comfort
138 - 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 - easier installation (on windows)
146 - auto joining of walls (see Placement tool -> auto setting)
147
148 =head1 DESCRIPTION
149
150 =head2 THE TOOLBOX WINDOW
151
152 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
156 =over 4
157
158 =item * Pick
159
160 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 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 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
182 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 =item top
188
189 Places the arch on the top of the stack of the map cell.
190
191 =item above floor
192
193 Places the arch just right above the floor (or the bottom of the stack).
194
195 =item below floor
196
197 Places the arch just right below the floor (or the bottom of the stack).
198
199 =item bottom
200
201 Places the arch on the bottom of the stack.
202
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
211 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 Erases all walls in the stack (and only walls).
222
223 =item above floor
224
225 Erases the first object above the floor.
226
227 =item floor
228
229 Erases all floor from the stack (and only the floor).
230
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 This erases all objects from the stack that match the currently selected
242 object.
243
244 =item protect walls (checkbox)
245
246 This protects walls from being erased (except when erasing walls).
247
248 =item protect monsters (checkbox)
249
250 This protects monsters from being erased.
251
252 =back
253
254 Shortcut-key in map editor: e
255
256 =item * Select
257
258 This is the selection tool. It can be used to select rectangular areas and
259 operate on that area in various ways:
260
261 =over 4
262
263 =item copy
264
265 This just copies all objects from the selected area into an internal
266 buffer for later paste operations.
267
268 Shortcut-key in map editor: c
269
270 =item paste
271
272 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
277 Shortcut-key in map editor: p
278
279 =item invoke
280
281 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
287 Shortcut-key in map editor: n
288
289 =back
290
291 Shortcut-key in map editor: s
292
293 =item * Eval
294
295 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
298 Shortcut-key in map editor: l
299
300 =item * Connect
301
302 This tool connects two exits, teleporters or adds the configures
303 connection value to the connectors.
304
305 This tool has 3 modes:
306
307 =over 4
308
309 =item auto
310
311 The auto mode tries to find exits first, and if it found one, it will
312 go into the exit connect mode. If no exit is found but a connectable
313 object is found, it will just add the connection value to the object.
314 (Note: This maybe gets in the way if you want to connect teleporters.
315 The auto mode will only connect teleporters as if they are exits and not
316 touch the connection value).
317
318 =item exit
319
320 This mode wont set any connection values.
321
322 =item connect
323
324 In this mode the connect tool will only set connection values and not
325 try to connect exits.
326
327 =back
328
329 You can either connect two exits to each other, or just point an exit to
330 a certain location on a map.
331
332 After clicking on an exit the first time you will see a string like this
333 in the tool dialoge in the main window: 'src: (12,9) teleporter'.
334 It tells you that you selected a source destination and that the next click will
335 connect the exit with another exit or just let it point where you clicked (if there
336 is no connectable object (in auto mode)).
337
338 To connect two exits, just click at the first and then at the second, and
339 the editor will try to find a path (map path) that fits the crossfire conventions.
340 It will also adjust the (x,y) coords so that the exits point at each other.
341
342 If something doesn't work as expected make sure you saved both maps
343 in a subdirectory of the crossfire map path (which you configured via
344 File->Preferences in the main window).
345
346 If the tile you edited with the connect tool contained a connectable
347 object, the currently configured connect value (set by the spin buttons in
348 the main window) will be set on them.
349
350 Shortcut-key in map editor: t
351
352 =item * Follow Exit
353
354 With this tool you can follow exits and teleporters by opening the target
355 map in a new window (or presents an existing window).
356
357 Shortcut-key in map editor: f
358
359 =back
360
361 =head2 THE STACK VIEW
362
363 This window displays the stack of a map space/coordinate.
364
365 You can swap two objects on the stack and delete a object from the stack
366 by dragging one object over another.
367
368 By clicking on an item on the stack you can make it the currently selected
369 object.
370
371 =head2 THE MAP EDITOR
372
373 This window just displays the map and lets you use the tools. The shortcuts are
374 documented above in the tool descriptions.
375
376 You can pan the map using the middle mouse button and use the tool with
377 the left mouse button.
378
379 There are two modifiers: Holding down the Meta/Alt-key temporarily
380 switches to the pick tool. Holding down the Ctrl-key temporarily switched
381 to the erase tool. Both will use their current settings. To change them,
382 you need to select the tools using the toolbox first.
383
384 There exists a context menu on right click:
385
386 =over 4
387
388 =item Follow
389
390 This context menu entry lets you follow an exit. It will open
391 a new map editor with the map. See Follow Exit tool.
392
393 =item Add inventory
394
395 This is a submenu of the context menu, that shows the objects
396 on the stack below the mouse cursor. It allows you to add the current
397 arch in the attribute editor (a copy of it) to the object as inventory item.
398
399 =back
400
401 =head2 THE ATTRIBUTE EDITOR
402
403 The attribute editor display the archetype name followed by the object
404 name and the type of the object in parentheses.
405
406 The 'reset to defaults' button erases all changes on the object and resets
407 it's value to the values of the archetype.
408
409 Since there are often many attributes for a given object, they are sorted
410 into different categories/tabs.
411
412 The lore and msg tabs let you edit the text attributes of the object.
413
414 Both field labels and value widgets have tool tips enabled. Tool tips on
415 the labels explain the attribute in more detail. The tool tips on the
416 value widgets show the default value from the archetype.
417
418 On the right side of the attribute editor you will find the inventory, you
419 can drag stuff there or just use the context menu von the pick window (see below)
420 to add inventory.
421
422 =head2 THE PICK WINDOW
423
424 Pick windows are used to quickly pick archetypes from specific categories.
425
426 Left click creates an object from the archetype and makes it the currently
427 selected object for the tools and the attribute editor.
428
429 You can change the attributes of the currently selected object in the
430 attribute editor.
431
432 Right click opens the context menu, where you can add the selected arch as
433 inventory to the object which is currently visible in the attribute editor.
434
435 You can open multiple pick windows.
436
437 =head1 MAP EDITING
438
439 =head2 SHOP PROPERTIES
440
441 There are 5 map properties related to shops that can be present in a map.
442 Any given map may have some, all or none of them (although in the later case,
443 it isn't considered to be a shop).
444
445 =over 4
446
447 =item Shopmin
448
449 This is an integer value. It is the minimum value that the object must have in
450 order to be considered by purchase for a shop. This is not the same as the price
451 offered, which can be substantially below shopmin.
452
453 =item Shopmax
454
455 This is an integer value. It uses value like shopmin does, however it is not a
456 fixed upper limit.
457
458 The value is adjusted downwards if it is in excess of one half of shopmax. The
459 output value is the minimum of shopmax and one half of shopmax plus the square root
460 of one half of shopmax
461
462 Note that the value is only an aspect of the final price, and the actual price offered for an item
463 can be substantially less than shopmax, even when the item's value in in excess of that.
464
465 =item Shoprace
466
467 if the player matches shoprace, this has no effect, if they do not, the price offered
468 is only 80% of what it would otherwise be.
469
470 =item Shopgreed
471
472 This is a multiplier on all prices offered, items brought from the player are done
473 so at a price divided by the greed, items sold to a player are overcharged by a factor of shopgreed.
474
475 =item Shopitems
476
477 This is a semi-colon deliminated list of item types and values.
478 each entry is a name of an item type (from the array in common/item.c)
479 followed by an optional colon then a value in the range -100 to 100.
480 (if this is missing, the default value of 0 is used.
481 This value is a measure of how much items of that type are preffered.
482 Neutrality is represented by 0 (so a theoretical 'general' store would
483 have 0 for everything), a positive preference for certain item types
484 is a positive value, and negative preference for item types is a negative value.
485
486 As a special note, the character * may be used once to set a preference for
487 everything not explicitly listed otherwise (this value would in most cases be negative)
488
489 for example, a typical magic shop might have the string:
490
491 shopitems amulet:25;ring:40;potion:40;book:35;scroll:40;spellbook:40;skillscroll:50;wand:40;*:-50
492
493 and an armour shop might have the string:
494
495 shopitems armour:50;shield:50;helmet:40;cloak:40;boots:40;gloves:40;bracers:50;girdle:50;*:-50
496
497 all possible name values for items are listed in common/item.c, however there are only some
498 that are likely to be used (doors are not sold very often....) this list is not definitive or
499 neccesarily up-to-date, but is a reasonable starting point for constructing a new shop.
500
501 rod
502 book
503 horn
504 amulet
505 potion
506 ring
507 inorganic
508 spellbook
509 wand
510 scroll
511 power_crystal
512
513 arrow
514 bow
515 weapon
516
517 armour
518 shield
519 helmet
520 cloak
521 boots
522 gloves
523 bracers
524 girdle
525
526 flesh
527 food
528 drink
529 treasure
530 gem
531 skill tool
532 lighter
533 light source
534 lamp
535 tool
536 container
537 item_transformer
538
539 armour improver
540 weapon improver
541 skillscroll
542
543 building material
544
545 =back
546
547 =head1 AUTHOR
548
549 All of the editor GUI:
550
551 Robin Redeker <elmex@ta-sa.org>
552 http://www.ta-sa.org/
553
554 The Crossfire map handling module and map widget:
555
556 Marc Lehmann <schmorp@schmorp.de>
557 http://home.schmorp.de/
558
559 =cut