ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gde
Revision: 1.6
Committed: Tue Jan 13 08:32:17 2009 UTC (15 years, 4 months ago) by root
Branch: MAIN
CVS Tags: pre_cursor_branch
Branch point for: cursor
Changes since 1.5: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

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