ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.35
Committed: Fri Aug 10 12:20:51 2007 UTC (16 years, 9 months ago) by elmex
Branch: MAIN
Changes since 1.34: +7 -0 lines
Log Message:
added music to map properties and documented it in the editor manual a bit.

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2 root 1.16
3 elmex 1.26 our $VERSION = '1.2';
4 elmex 1.12
5 root 1.29 my $startup_done = sub { };
6    
7     # do splash-screen thingy on win32
8     BEGIN {
9 root 1.32 if (%PAR::LibCache && $^O eq "MSWin32") {
10 root 1.29 while (my ($filename, $zip) = each %PAR::LibCache) {
11     $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
12     }
13    
14     require Win32::GUI::SplashScreen;
15    
16     Win32::GUI::SplashScreen::Show (
17     -file => "$ENV{PAR_TEMP}/SPLASH.bmp",
18     );
19    
20     $startup_done = sub {
21     Win32::GUI::SplashScreen::Done (1);
22     };
23     }
24     }
25    
26 elmex 1.12 BEGIN {
27     if (%PAR::LibCache) {
28 root 1.16 @INC = grep ref, @INC; # weed out all paths except pars loader refs
29    
30 elmex 1.12 while (my ($filename, $zip) = each %PAR::LibCache) {
31     for ($zip->memberNames) {
32     next unless /^\/root\/(.*)/;
33     $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
34     unless -e "$ENV{PAR_TEMP}/$1";
35     }
36     }
37    
38     $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP};
39 root 1.30 }
40     }
41 elmex 1.12
42 root 1.30 BEGIN {
43 root 1.31 $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc"
44 root 1.30 if %PAR::LibCache && $^O eq "MSWin32";
45 elmex 1.12 }
46    
47     use Gtk2 -init;
48    
49     use Data::Dumper;
50     use File::Spec;
51    
52     use Crossfire;
53    
54     use GCE::MainWindow;
55    
56     our $CFG;
57 elmex 1.33 our $MAPDIR;
58     our $LIBDIR;
59 elmex 1.12 our $MAINWIN;
60    
61     our $DOCUMENTATION = join ("\n", do { local $/; <DATA> });
62    
63     sub read_cfg {
64     my ($file) = @_;
65    
66     open CFG, $file
67     or return;
68    
69     $CFG = eval join '', <CFG>;
70    
71     close CFG;
72     }
73    
74     sub write_cfg {
75     my ($file) = @_;
76    
77     open CFG, ">$file"
78     or return;
79    
80     {
81     local $Data::Dumper::Purity = 1;
82 elmex 1.19 $CFG->{VERSION} = $VERSION;
83 elmex 1.12 print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]);
84     }
85    
86     close CFG;
87     }
88    
89     # following 2 functions are taken from CV :)
90     sub find_rcfile($) {
91     my $path;
92    
93     for (@INC) {
94    
95     $path = "$_/GCE/$_[0]";
96     return $path if -r $path;
97     }
98    
99     die "FATAL: can't find required file $_[0]\n";
100     }
101    
102     sub require_image($) {
103     new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
104     }
105    
106     sub get_pos_and_size {
107     my ($window) = @_;
108    
109     my ($x, $y) = $window->get_position;
110     my ($w, $h) = $window->get_size;
111    
112     return [$x, $y, $w, $h];
113     }
114    
115     sub set_pos_and_size {
116     my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_;
117    
118     $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h);
119    
120     # FIXME: This sucks, moving it after showing it can't be a good thing.
121     $window->show_all;
122     $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y);
123     }
124    
125     read_cfg "$Crossfire::VARDIR/gceconfig";
126    
127 elmex 1.33 $LIBDIR = $ENV{CROSSFIRE_LIBDIR};
128     $LIBDIR ||= $CFG->{LIBDIR};
129 elmex 1.22
130 elmex 1.33 $MAPDIR = $ENV{CROSSFIRE_MAPDIR};
131     $MAPDIR ||= $CFG->{MAPDIR};
132     $MAPDIR ||= File::Spec->catfile ($ENV{CROSSFIRE_LIBDIR}, 'maps');
133 elmex 1.12
134     # must be done after changing the libdir path:
135 elmex 1.33 Crossfire::set_libdir ($LIBDIR);
136 elmex 1.12 Crossfire::load_archetypes;
137     Crossfire::load_tilecache;
138    
139     my $w = GCE::MainWindow->new;
140    
141     $w->load_layout;
142    
143     $w->show_all;
144    
145 root 1.29 $startup_done->();
146    
147 elmex 1.12 Gtk2->main;
148    
149     __DATA__
150 root 1.7
151 root 1.1 =head1 NAME
152    
153     gce - gtk (perl) crossfire editor
154    
155 elmex 1.10 =head1 SYNOPSIS
156    
157 root 1.11 gce [<map-filename>...]
158 elmex 1.10
159     =head1 FEATURES
160    
161     gce is a map editor for crossfire.
162    
163 root 1.11 Its main features are:
164    
165     - higher map editing comfort
166 elmex 1.10 - intelligent placement tool
167     - intelligent connection tool
168     - intelligent erase tool
169     - faster and smaller than the java editor
170     - map normalizing (removal of old deprecated attributes)
171     - exit following
172     - world map navigation
173 root 1.11 - easier installation (on windows)
174 elmex 1.18 - auto joining of walls (see Placement tool -> auto setting)
175 elmex 1.10
176     =head1 DESCRIPTION
177    
178 root 1.13 =head2 THE TOOLBOX WINDOW
179 elmex 1.10
180 root 1.13 The toolbox window is the main window of gce. It provides the display of
181     the currently selected object and the tools. The buttons select of the
182     editing tool:
183 elmex 1.10
184     =over 4
185    
186     =item * Pick
187    
188 root 1.11 This tool is the simplest of all. It lets the user select the topmost
189     object of a map cell in the map window and updates the stack view for the
190     current space.
191    
192 elmex 1.10 Shortcut-key in map editor: i
193    
194     =item * Place
195    
196     This is the intelligent placement tool. It has many modes:
197    
198     =over 4
199    
200     =item auto
201    
202 root 1.11 This mode implements DWIM (do-what-I-mean) by trying to do the the right
203     thing(tm) with the selected object:
204    
205     If you place a floor arch, it will try to replace the existing floor or
206     set the floor below all items. If you place a monster or other arch, it
207     will place it on top. If you place a wall, it will put the wall above the
208     floor and propably replace other walls.
209 elmex 1.10
210 elmex 1.18 Autojoin also works only in this mode. To draw an wall with autojoining pick
211     the wall arch which name looks like: <wallname>_0. It's the single point wall
212     tile which has no connections.
213     When you place this arch now, it will autoconnect the walls you are drawing.
214    
215 elmex 1.10 =item top
216    
217 root 1.11 Places the arch on the top of the stack of the map cell.
218 elmex 1.10
219     =item above floor
220    
221 root 1.11 Places the arch just right above the floor (or the bottom of the stack).
222 elmex 1.10
223     =item below floor
224    
225 root 1.11 Places the arch just right below the floor (or the bottom of the stack).
226 elmex 1.10
227     =item bottom
228    
229 root 1.11 Places the arch on the bottom of the stack.
230 elmex 1.10
231     =back
232    
233     Shortcut-key in map editor: p
234    
235     =item * Erase
236    
237     This is the tool that lets you erase an arch.
238 root 1.11
239 elmex 1.10 It has following modes:
240    
241     =over 4
242    
243     =item top
244    
245     Erases the topmost object on the stack.
246    
247     =item walls
248    
249 root 1.11 Erases all walls in the stack (and only walls).
250 elmex 1.10
251     =item above floor
252    
253     Erases the first object above the floor.
254    
255     =item floor
256    
257 root 1.11 Erases all floor from the stack (and only the floor).
258 elmex 1.10
259     =item below floor
260    
261     Erases the first object below the floor.
262    
263     =item bottom
264    
265     Erases the first object on the bottom of the stack.
266    
267     =item pick match
268    
269 root 1.11 This erases all objects from the stack that match the currently selected
270     object.
271 elmex 1.10
272 root 1.11 =item protect walls (checkbox)
273 elmex 1.10
274 root 1.11 This protects walls from being erased (except when erasing walls).
275 elmex 1.10
276 root 1.11 =item protect monsters (checkbox)
277 elmex 1.10
278 root 1.11 This protects monsters from being erased.
279 elmex 1.10
280     =back
281    
282     Shortcut-key in map editor: e
283    
284     =item * Select
285    
286 root 1.11 This is the selection tool. It can be used to select rectangular areas and
287     operate on that area in various ways:
288 elmex 1.10
289     =over 4
290    
291     =item copy
292    
293 root 1.11 This just copies all objects from the selected area into an internal
294     buffer for later paste operations.
295 elmex 1.10
296     Shortcut-key in map editor: c
297    
298     =item paste
299    
300 root 1.11 This function pastes the internal buffer into the map, beginning in the
301     top left corner of the selected area. The size of the selection has no
302     relevance to the result: IT always places the whole internal buffer onto
303     the map.
304 elmex 1.10
305     Shortcut-key in map editor: p
306    
307     =item invoke
308    
309 root 1.11 This function is a very powerful one. It can apply another tool (such as
310     the place tool) on all spaces of the selected area.
311    
312     It can, for example, be used to fill a map with floor tiles or erase
313     everything.
314 elmex 1.10
315     Shortcut-key in map editor: n
316    
317     =back
318    
319     Shortcut-key in map editor: s
320    
321     =item * Eval
322    
323 root 1.11 This is a very special tool which isn't finished yet. It lets you specify
324     a perl snippet that can manipulate the stack.
325 elmex 1.10
326     Shortcut-key in map editor: l
327    
328 elmex 1.23 =item * Connect
329 elmex 1.10
330 elmex 1.23 This tool connects two exits, teleporters or adds the configures
331     connection value to the connectors.
332    
333     This tool has 3 modes:
334    
335     =over 4
336    
337     =item auto
338    
339     The auto mode tries to find exits first, and if it found one, it will
340     go into the exit connect mode. If no exit is found but a connectable
341     object is found, it will just add the connection value to the object.
342     (Note: This maybe gets in the way if you want to connect teleporters.
343     The auto mode will only connect teleporters as if they are exits and not
344     touch the connection value).
345    
346     =item exit
347    
348     This mode wont set any connection values.
349    
350     =item connect
351    
352     In this mode the connect tool will only set connection values and not
353     try to connect exits.
354    
355     =back
356 root 1.11
357     You can either connect two exits to each other, or just point an exit to
358     a certain location on a map.
359 elmex 1.10
360 elmex 1.23 After clicking on an exit the first time you will see a string like this
361     in the tool dialoge in the main window: 'src: (12,9) teleporter'.
362     It tells you that you selected a source destination and that the next click will
363     connect the exit with another exit or just let it point where you clicked (if there
364     is no connectable object (in auto mode)).
365    
366     To connect two exits, just click at the first and then at the second, and
367     the editor will try to find a path (map path) that fits the crossfire conventions.
368     It will also adjust the (x,y) coords so that the exits point at each other.
369    
370     If something doesn't work as expected make sure you saved both maps
371     in a subdirectory of the crossfire map path (which you configured via
372     File->Preferences in the main window).
373    
374     If the tile you edited with the connect tool contained a connectable
375     object, the currently configured connect value (set by the spin buttons in
376     the main window) will be set on them.
377    
378     Shortcut-key in map editor: t
379 elmex 1.10
380     =item * Follow Exit
381    
382 root 1.11 With this tool you can follow exits and teleporters by opening the target
383     map in a new window (or presents an existing window).
384 elmex 1.10
385     Shortcut-key in map editor: f
386    
387     =back
388    
389     =head2 THE STACK VIEW
390    
391 root 1.11 This window displays the stack of a map space/coordinate.
392 elmex 1.10
393 root 1.11 You can swap two objects on the stack and delete a object from the stack
394     by dragging one object over another.
395    
396     By clicking on an item on the stack you can make it the currently selected
397     object.
398 elmex 1.10
399     =head2 THE MAP EDITOR
400    
401     This window just displays the map and lets you use the tools. The shortcuts are
402     documented above in the tool descriptions.
403    
404 root 1.11 You can pan the map using the middle mouse button and use the tool with
405     the left mouse button.
406 elmex 1.10
407 root 1.11 There are two modifiers: Holding down the Meta/Alt-key temporarily
408     switches to the pick tool. Holding down the Ctrl-key temporarily switched
409     to the erase tool. Both will use their current settings. To change them,
410     you need to select the tools using the toolbox first.
411 elmex 1.10
412 elmex 1.24 There exists a context menu on right click:
413    
414     =over 4
415    
416     =item Follow
417    
418     This context menu entry lets you follow an exit. It will open
419     a new map editor with the map. See Follow Exit tool.
420    
421 elmex 1.34 =item object stack
422    
423     Below the context menu entrys that are documented above there is a seperator
424     that seperates the object stack menu items.
425    
426     Each object stack item is a submenu that offers following functionality:
427    
428     =over 4
429    
430 elmex 1.24 =item Add inventory
431    
432 elmex 1.34 It allows you to add the current arch in the attribute editor
433     (a copy of it) to the object as inventory item.
434    
435     =item Find in picker
436    
437     This function tries to determine the picker group that this
438     object is in and opens a new picker pointing at that group.
439    
440     =back
441 elmex 1.24
442     =back
443    
444 elmex 1.10 =head2 THE ATTRIBUTE EDITOR
445    
446 root 1.11 The attribute editor display the archetype name followed by the object
447     name and the type of the object in parentheses.
448    
449 elmex 1.21 The 'reset to defaults' button erases all changes on the object and resets
450     it's value to the values of the archetype.
451    
452 root 1.11 Since there are often many attributes for a given object, they are sorted
453     into different categories/tabs.
454 elmex 1.10
455 root 1.11 The lore and msg tabs let you edit the text attributes of the object.
456 elmex 1.10
457 root 1.11 Both field labels and value widgets have tool tips enabled. Tool tips on
458     the labels explain the attribute in more detail. The tool tips on the
459     value widgets show the default value from the archetype.
460 elmex 1.10
461 elmex 1.21 On the right side of the attribute editor you will find the inventory, you
462     can drag stuff there or just use the context menu von the pick window (see below)
463     to add inventory.
464 elmex 1.10
465     =head2 THE PICK WINDOW
466    
467 root 1.11 Pick windows are used to quickly pick archetypes from specific categories.
468    
469     Left click creates an object from the archetype and makes it the currently
470     selected object for the tools and the attribute editor.
471    
472     You can change the attributes of the currently selected object in the
473     attribute editor.
474 elmex 1.10
475 elmex 1.21 Right click opens the context menu, where you can add the selected arch as
476     inventory to the object which is currently visible in the attribute editor.
477    
478 elmex 1.10 You can open multiple pick windows.
479    
480 elmex 1.25 =head1 MAP EDITING
481    
482     =head2 SHOP PROPERTIES
483    
484     There are 5 map properties related to shops that can be present in a map.
485     Any given map may have some, all or none of them (although in the later case,
486     it isn't considered to be a shop).
487    
488     =over 4
489    
490 elmex 1.35 =item Music
491    
492     This field constains a list of comma seperated music paths. <path>
493     will become /music/<path>.ogg. Example:
494    
495     km/piece1,km/piece2
496    
497 elmex 1.25 =item Shopmin
498    
499     This is an integer value. It is the minimum value that the object must have in
500     order to be considered by purchase for a shop. This is not the same as the price
501     offered, which can be substantially below shopmin.
502    
503     =item Shopmax
504    
505     This is an integer value. It uses value like shopmin does, however it is not a
506     fixed upper limit.
507    
508     The value is adjusted downwards if it is in excess of one half of shopmax. The
509     output value is the minimum of shopmax and one half of shopmax plus the square root
510     of one half of shopmax
511    
512     Note that the value is only an aspect of the final price, and the actual price offered for an item
513     can be substantially less than shopmax, even when the item's value in in excess of that.
514    
515     =item Shoprace
516    
517     if the player matches shoprace, this has no effect, if they do not, the price offered
518     is only 80% of what it would otherwise be.
519    
520     =item Shopgreed
521    
522     This is a multiplier on all prices offered, items brought from the player are done
523     so at a price divided by the greed, items sold to a player are overcharged by a factor of shopgreed.
524    
525     =item Shopitems
526    
527     This is a semi-colon deliminated list of item types and values.
528     each entry is a name of an item type (from the array in common/item.c)
529     followed by an optional colon then a value in the range -100 to 100.
530     (if this is missing, the default value of 0 is used.
531     This value is a measure of how much items of that type are preffered.
532     Neutrality is represented by 0 (so a theoretical 'general' store would
533     have 0 for everything), a positive preference for certain item types
534     is a positive value, and negative preference for item types is a negative value.
535    
536     As a special note, the character * may be used once to set a preference for
537     everything not explicitly listed otherwise (this value would in most cases be negative)
538    
539     for example, a typical magic shop might have the string:
540    
541     shopitems amulet:25;ring:40;potion:40;book:35;scroll:40;spellbook:40;skillscroll:50;wand:40;*:-50
542    
543     and an armour shop might have the string:
544    
545     shopitems armour:50;shield:50;helmet:40;cloak:40;boots:40;gloves:40;bracers:50;girdle:50;*:-50
546    
547     all possible name values for items are listed in common/item.c, however there are only some
548     that are likely to be used (doors are not sold very often....) this list is not definitive or
549     neccesarily up-to-date, but is a reasonable starting point for constructing a new shop.
550    
551     rod
552     book
553     horn
554     amulet
555     potion
556     ring
557     inorganic
558     spellbook
559     wand
560     scroll
561     power_crystal
562    
563     arrow
564     bow
565     weapon
566    
567     armour
568     shield
569     helmet
570     cloak
571     boots
572     gloves
573     bracers
574     girdle
575    
576     flesh
577     food
578     drink
579     treasure
580     gem
581     skill tool
582     lighter
583     light source
584     lamp
585     tool
586     container
587     item_transformer
588    
589     armour improver
590     weapon improver
591     skillscroll
592    
593     building material
594    
595     =back
596    
597 elmex 1.12 =head1 AUTHOR
598 root 1.1
599 root 1.15 All of the editor GUI:
600 root 1.4
601 elmex 1.12 Robin Redeker <elmex@ta-sa.org>
602     http://www.ta-sa.org/
603 root 1.6
604 root 1.15 The Crossfire map handling module and map widget:
605 root 1.1
606     Marc Lehmann <schmorp@schmorp.de>
607     http://home.schmorp.de/
608    
609     =cut