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{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 |
if (-e "$Crossfire::VARDIR/gdeconfig") { |
126 |
read_cfg "$Crossfire::VARDIR/gdeconfig"; |
127 |
} else { |
128 |
read_cfg "$Crossfire::VARDIR/gceconfig"; |
129 |
} |
130 |
|
131 |
$LIBDIR = $ENV{CROSSFIRE_LIBDIR}; |
132 |
$LIBDIR ||= $CFG->{LIBDIR}; |
133 |
|
134 |
$MAPDIR = $ENV{CROSSFIRE_MAPDIR}; |
135 |
$MAPDIR ||= $CFG->{MAPDIR}; |
136 |
$MAPDIR ||= File::Spec->catfile ($ENV{CROSSFIRE_LIBDIR}, 'maps'); |
137 |
|
138 |
# must be done after changing the libdir path: |
139 |
Crossfire::set_libdir ($LIBDIR); |
140 |
Crossfire::load_archetypes; |
141 |
Crossfire::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 and use the tool with |
408 |
the left mouse button. |
409 |
|
410 |
There are two modifiers: Holding down the Meta/Alt-key temporarily |
411 |
switches to the pick tool. Holding down the Ctrl-key temporarily switched |
412 |
to the erase tool. Both will use their current settings. To change them, |
413 |
you need to select the tools using the toolbox first. |
414 |
|
415 |
There exists a context menu on right click: |
416 |
|
417 |
=over 4 |
418 |
|
419 |
=item Follow |
420 |
|
421 |
This context menu entry lets you follow an exit. It will open |
422 |
a new map editor with the map. See Follow Exit tool. |
423 |
|
424 |
=item object stack |
425 |
|
426 |
Below the context menu entrys that are documented above there is a seperator |
427 |
that seperates the object stack menu items. |
428 |
|
429 |
Each object stack item is a submenu that offers following functionality: |
430 |
|
431 |
=over 4 |
432 |
|
433 |
=item Add inventory |
434 |
|
435 |
It allows you to add the current arch in the attribute editor |
436 |
(a copy of it) to the object as inventory item. |
437 |
|
438 |
=item Find in picker |
439 |
|
440 |
This function tries to determine the picker group that this |
441 |
object is in and opens a new picker pointing at that group. |
442 |
|
443 |
=back |
444 |
|
445 |
=back |
446 |
|
447 |
=head2 THE ATTRIBUTE EDITOR |
448 |
|
449 |
The attribute editor display the archetype name followed by the object |
450 |
name and the type of the object in parentheses. |
451 |
|
452 |
The 'reset to defaults' button erases all changes on the object and resets |
453 |
it's value to the values of the archetype. |
454 |
|
455 |
Since there are often many attributes for a given object, they are sorted |
456 |
into different categories/tabs. |
457 |
|
458 |
The lore and msg tabs let you edit the text attributes of the object. |
459 |
|
460 |
Both field labels and value widgets have tool tips enabled. Tool tips on |
461 |
the labels explain the attribute in more detail. The tool tips on the |
462 |
value widgets show the default value from the archetype. |
463 |
|
464 |
On the right side of the attribute editor you will find the inventory, you |
465 |
can drag stuff there or just use the context menu von the pick window (see below) |
466 |
to add inventory. |
467 |
|
468 |
=head2 THE PICK WINDOW |
469 |
|
470 |
Pick windows are used to quickly pick archetypes from specific categories. |
471 |
|
472 |
Left click creates an object from the archetype and makes it the currently |
473 |
selected object for the tools and the attribute editor. |
474 |
|
475 |
You can change the attributes of the currently selected object in the |
476 |
attribute editor. |
477 |
|
478 |
Right click opens the context menu, where you can add the selected arch as |
479 |
inventory to the object which is currently visible in the attribute editor. |
480 |
|
481 |
You can open multiple pick windows. |
482 |
|
483 |
=head1 MAP EDITING |
484 |
|
485 |
=head2 SHOP PROPERTIES |
486 |
|
487 |
There are 5 map properties related to shops that can be present in a map. |
488 |
Any given map may have some, all or none of them (although in the later case, |
489 |
it isn't considered to be a shop). |
490 |
|
491 |
=over 4 |
492 |
|
493 |
=item Music |
494 |
|
495 |
This field constains a list of comma seperated music paths. <path> |
496 |
will become /music/<path>.ogg. Example: |
497 |
|
498 |
km/piece1,km/piece2 |
499 |
|
500 |
=item Shopmin |
501 |
|
502 |
This is an integer value. It is the minimum value that the object must have in |
503 |
order to be considered by purchase for a shop. This is not the same as the price |
504 |
offered, which can be substantially below shopmin. |
505 |
|
506 |
=item Shopmax |
507 |
|
508 |
This is an integer value. It uses value like shopmin does, however it is not a |
509 |
fixed upper limit. |
510 |
|
511 |
The value is adjusted downwards if it is in excess of one half of shopmax. The |
512 |
output value is the minimum of shopmax and one half of shopmax plus the square root |
513 |
of one half of shopmax |
514 |
|
515 |
Note that the value is only an aspect of the final price, and the actual price offered for an item |
516 |
can be substantially less than shopmax, even when the item's value in in excess of that. |
517 |
|
518 |
=item Shoprace |
519 |
|
520 |
if the player matches shoprace, this has no effect, if they do not, the price offered |
521 |
is only 80% of what it would otherwise be. |
522 |
|
523 |
=item Shopgreed |
524 |
|
525 |
This is a multiplier on all prices offered, items brought from the player are done |
526 |
so at a price divided by the greed, items sold to a player are overcharged by a factor of shopgreed. |
527 |
|
528 |
=item Shopitems |
529 |
|
530 |
This is a semi-colon deliminated list of item types and values. |
531 |
each entry is a name of an item type (from the array in common/item.c) |
532 |
followed by an optional colon then a value in the range -100 to 100. |
533 |
(if this is missing, the default value of 0 is used. |
534 |
This value is a measure of how much items of that type are preffered. |
535 |
Neutrality is represented by 0 (so a theoretical 'general' store would |
536 |
have 0 for everything), a positive preference for certain item types |
537 |
is a positive value, and negative preference for item types is a negative value. |
538 |
|
539 |
As a special note, the character * may be used once to set a preference for |
540 |
everything not explicitly listed otherwise (this value would in most cases be negative) |
541 |
|
542 |
for example, a typical magic shop might have the string: |
543 |
|
544 |
shopitems amulet:25;ring:40;potion:40;book:35;scroll:40;spellbook:40;skillscroll:50;wand:40;*:-50 |
545 |
|
546 |
and an armour shop might have the string: |
547 |
|
548 |
shopitems armour:50;shield:50;helmet:40;cloak:40;boots:40;gloves:40;bracers:50;girdle:50;*:-50 |
549 |
|
550 |
all possible name values for items are listed in common/item.c, however there are only some |
551 |
that are likely to be used (doors are not sold very often....) this list is not definitive or |
552 |
neccesarily up-to-date, but is a reasonable starting point for constructing a new shop. |
553 |
|
554 |
rod |
555 |
book |
556 |
horn |
557 |
amulet |
558 |
potion |
559 |
ring |
560 |
inorganic |
561 |
spellbook |
562 |
wand |
563 |
scroll |
564 |
power_crystal |
565 |
|
566 |
arrow |
567 |
bow |
568 |
weapon |
569 |
|
570 |
armour |
571 |
shield |
572 |
helmet |
573 |
cloak |
574 |
boots |
575 |
gloves |
576 |
bracers |
577 |
girdle |
578 |
|
579 |
flesh |
580 |
food |
581 |
drink |
582 |
treasure |
583 |
gem |
584 |
skill tool |
585 |
lighter |
586 |
light source |
587 |
lamp |
588 |
tool |
589 |
container |
590 |
item_transformer |
591 |
|
592 |
armour improver |
593 |
weapon improver |
594 |
skillscroll |
595 |
|
596 |
building material |
597 |
|
598 |
=back |
599 |
|
600 |
=head1 AUTHOR |
601 |
|
602 |
All of the editor GUI: |
603 |
|
604 |
Robin Redeker <elmex@ta-sa.org> |
605 |
http://www.ta-sa.org/ |
606 |
|
607 |
The Deliantra map handling module and map widget: |
608 |
|
609 |
Marc Lehmann <schmorp@schmorp.de> |
610 |
http://home.schmorp.de/ |
611 |
|
612 |
=cut |