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

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