ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.29
Committed: Sun Oct 8 21:29:03 2006 UTC (17 years, 7 months ago) by root
Branch: MAIN
Changes since 1.28: +23 -0 lines
Log Message:
*** empty log message ***

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