ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gde
Revision: 1.8
Committed: Fri Mar 19 20:57:54 2010 UTC (14 years, 2 months ago) by elmex
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +6 -0 lines
Log Message:
added env var for text editor.

File Contents

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