ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/bin/gce
Revision: 1.33
Committed: Sat Oct 14 15:18:46 2006 UTC (17 years, 7 months ago) by elmex
Branch: MAIN
Changes since 1.32: +8 -4 lines
Log Message:
added meta data loading, adjusted environment variable handling

File Contents

# Content
1 #!/opt/bin/perl
2
3 our $VERSION = '1.2';
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{CROSSFIRE_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 Crossfire;
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 read_cfg "$Crossfire::VARDIR/gceconfig";
126
127 $LIBDIR = $ENV{CROSSFIRE_LIBDIR};
128 $LIBDIR ||= $CFG->{LIBDIR};
129
130 $MAPDIR = $ENV{CROSSFIRE_MAPDIR};
131 $MAPDIR ||= $CFG->{MAPDIR};
132 $MAPDIR ||= File::Spec->catfile ($ENV{CROSSFIRE_LIBDIR}, 'maps');
133
134 # must be done after changing the libdir path:
135 Crossfire::set_libdir ($LIBDIR);
136 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 $startup_done->();
146
147 Gtk2->main;
148
149 __DATA__
150
151 =head1 NAME
152
153 gce - gtk (perl) crossfire editor
154
155 =head1 SYNOPSIS
156
157 gce [<map-filename>...]
158
159 =head1 FEATURES
160
161 gce is a map editor for crossfire.
162
163 Its main features are:
164
165 - higher map editing comfort
166 - 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 - easier installation (on windows)
174 - auto joining of walls (see Placement tool -> auto setting)
175
176 =head1 DESCRIPTION
177
178 =head2 THE TOOLBOX WINDOW
179
180 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
184 =over 4
185
186 =item * Pick
187
188 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 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 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
210 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 =item top
216
217 Places the arch on the top of the stack of the map cell.
218
219 =item above floor
220
221 Places the arch just right above the floor (or the bottom of the stack).
222
223 =item below floor
224
225 Places the arch just right below the floor (or the bottom of the stack).
226
227 =item bottom
228
229 Places the arch on the bottom of the stack.
230
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
239 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 Erases all walls in the stack (and only walls).
250
251 =item above floor
252
253 Erases the first object above the floor.
254
255 =item floor
256
257 Erases all floor from the stack (and only the floor).
258
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 This erases all objects from the stack that match the currently selected
270 object.
271
272 =item protect walls (checkbox)
273
274 This protects walls from being erased (except when erasing walls).
275
276 =item protect monsters (checkbox)
277
278 This protects monsters from being erased.
279
280 =back
281
282 Shortcut-key in map editor: e
283
284 =item * Select
285
286 This is the selection tool. It can be used to select rectangular areas and
287 operate on that area in various ways:
288
289 =over 4
290
291 =item copy
292
293 This just copies all objects from the selected area into an internal
294 buffer for later paste operations.
295
296 Shortcut-key in map editor: c
297
298 =item paste
299
300 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
305 Shortcut-key in map editor: p
306
307 =item invoke
308
309 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
315 Shortcut-key in map editor: n
316
317 =back
318
319 Shortcut-key in map editor: s
320
321 =item * Eval
322
323 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
326 Shortcut-key in map editor: l
327
328 =item * Connect
329
330 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
357 You can either connect two exits to each other, or just point an exit to
358 a certain location on a map.
359
360 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
380 =item * Follow Exit
381
382 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
385 Shortcut-key in map editor: f
386
387 =back
388
389 =head2 THE STACK VIEW
390
391 This window displays the stack of a map space/coordinate.
392
393 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
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 You can pan the map using the middle mouse button and use the tool with
405 the left mouse button.
406
407 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
412 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 =item Add inventory
422
423 This is a submenu of the context menu, that shows the objects
424 on the stack below the mouse cursor. It allows you to add the current
425 arch in the attribute editor (a copy of it) to the object as inventory item.
426
427 =back
428
429 =head2 THE ATTRIBUTE EDITOR
430
431 The attribute editor display the archetype name followed by the object
432 name and the type of the object in parentheses.
433
434 The 'reset to defaults' button erases all changes on the object and resets
435 it's value to the values of the archetype.
436
437 Since there are often many attributes for a given object, they are sorted
438 into different categories/tabs.
439
440 The lore and msg tabs let you edit the text attributes of the object.
441
442 Both field labels and value widgets have tool tips enabled. Tool tips on
443 the labels explain the attribute in more detail. The tool tips on the
444 value widgets show the default value from the archetype.
445
446 On the right side of the attribute editor you will find the inventory, you
447 can drag stuff there or just use the context menu von the pick window (see below)
448 to add inventory.
449
450 =head2 THE PICK WINDOW
451
452 Pick windows are used to quickly pick archetypes from specific categories.
453
454 Left click creates an object from the archetype and makes it the currently
455 selected object for the tools and the attribute editor.
456
457 You can change the attributes of the currently selected object in the
458 attribute editor.
459
460 Right click opens the context menu, where you can add the selected arch as
461 inventory to the object which is currently visible in the attribute editor.
462
463 You can open multiple pick windows.
464
465 =head1 MAP EDITING
466
467 =head2 SHOP PROPERTIES
468
469 There are 5 map properties related to shops that can be present in a map.
470 Any given map may have some, all or none of them (although in the later case,
471 it isn't considered to be a shop).
472
473 =over 4
474
475 =item Shopmin
476
477 This is an integer value. It is the minimum value that the object must have in
478 order to be considered by purchase for a shop. This is not the same as the price
479 offered, which can be substantially below shopmin.
480
481 =item Shopmax
482
483 This is an integer value. It uses value like shopmin does, however it is not a
484 fixed upper limit.
485
486 The value is adjusted downwards if it is in excess of one half of shopmax. The
487 output value is the minimum of shopmax and one half of shopmax plus the square root
488 of one half of shopmax
489
490 Note that the value is only an aspect of the final price, and the actual price offered for an item
491 can be substantially less than shopmax, even when the item's value in in excess of that.
492
493 =item Shoprace
494
495 if the player matches shoprace, this has no effect, if they do not, the price offered
496 is only 80% of what it would otherwise be.
497
498 =item Shopgreed
499
500 This is a multiplier on all prices offered, items brought from the player are done
501 so at a price divided by the greed, items sold to a player are overcharged by a factor of shopgreed.
502
503 =item Shopitems
504
505 This is a semi-colon deliminated list of item types and values.
506 each entry is a name of an item type (from the array in common/item.c)
507 followed by an optional colon then a value in the range -100 to 100.
508 (if this is missing, the default value of 0 is used.
509 This value is a measure of how much items of that type are preffered.
510 Neutrality is represented by 0 (so a theoretical 'general' store would
511 have 0 for everything), a positive preference for certain item types
512 is a positive value, and negative preference for item types is a negative value.
513
514 As a special note, the character * may be used once to set a preference for
515 everything not explicitly listed otherwise (this value would in most cases be negative)
516
517 for example, a typical magic shop might have the string:
518
519 shopitems amulet:25;ring:40;potion:40;book:35;scroll:40;spellbook:40;skillscroll:50;wand:40;*:-50
520
521 and an armour shop might have the string:
522
523 shopitems armour:50;shield:50;helmet:40;cloak:40;boots:40;gloves:40;bracers:50;girdle:50;*:-50
524
525 all possible name values for items are listed in common/item.c, however there are only some
526 that are likely to be used (doors are not sold very often....) this list is not definitive or
527 neccesarily up-to-date, but is a reasonable starting point for constructing a new shop.
528
529 rod
530 book
531 horn
532 amulet
533 potion
534 ring
535 inorganic
536 spellbook
537 wand
538 scroll
539 power_crystal
540
541 arrow
542 bow
543 weapon
544
545 armour
546 shield
547 helmet
548 cloak
549 boots
550 gloves
551 bracers
552 girdle
553
554 flesh
555 food
556 drink
557 treasure
558 gem
559 skill tool
560 lighter
561 light source
562 lamp
563 tool
564 container
565 item_transformer
566
567 armour improver
568 weapon improver
569 skillscroll
570
571 building material
572
573 =back
574
575 =head1 AUTHOR
576
577 All of the editor GUI:
578
579 Robin Redeker <elmex@ta-sa.org>
580 http://www.ta-sa.org/
581
582 The Crossfire map handling module and map widget:
583
584 Marc Lehmann <schmorp@schmorp.de>
585 http://home.schmorp.de/
586
587 =cut