1 |
root |
1.1 |
#!/opt/bin/perl |
2 |
root |
1.16 |
|
3 |
elmex |
1.14 |
our $VERSION = '0.9'; |
4 |
elmex |
1.12 |
|
5 |
|
|
BEGIN { |
6 |
|
|
if (%PAR::LibCache) { |
7 |
root |
1.16 |
@INC = grep ref, @INC; # weed out all paths except pars loader refs |
8 |
|
|
|
9 |
elmex |
1.12 |
while (my ($filename, $zip) = each %PAR::LibCache) { |
10 |
|
|
for ($zip->memberNames) { |
11 |
|
|
next unless /^\/root\/(.*)/; |
12 |
|
|
$zip->extractMember ($_, "$ENV{PAR_TEMP}/$1") |
13 |
|
|
unless -e "$ENV{PAR_TEMP}/$1"; |
14 |
|
|
} |
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
$ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP}; |
18 |
|
|
|
19 |
|
|
if ($^O eq "MSWin32") { |
20 |
|
|
$ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc"; |
21 |
|
|
} |
22 |
|
|
} |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
use Gtk2 -init; |
26 |
|
|
|
27 |
|
|
use Data::Dumper; |
28 |
|
|
use File::Spec; |
29 |
|
|
|
30 |
|
|
use Crossfire; |
31 |
|
|
|
32 |
|
|
use GCE::MainWindow; |
33 |
|
|
|
34 |
|
|
our $CFG; |
35 |
|
|
our $MAINWIN; |
36 |
|
|
|
37 |
|
|
our $DOCUMENTATION = join ("\n", do { local $/; <DATA> }); |
38 |
|
|
|
39 |
|
|
sub read_cfg { |
40 |
|
|
my ($file) = @_; |
41 |
|
|
|
42 |
|
|
open CFG, $file |
43 |
|
|
or return; |
44 |
|
|
|
45 |
|
|
$CFG = eval join '', <CFG>; |
46 |
|
|
|
47 |
|
|
close CFG; |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
sub write_cfg { |
51 |
|
|
my ($file) = @_; |
52 |
|
|
|
53 |
|
|
open CFG, ">$file" |
54 |
|
|
or return; |
55 |
|
|
|
56 |
|
|
{ |
57 |
|
|
local $Data::Dumper::Purity = 1; |
58 |
|
|
print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]); |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
close CFG; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
# following 2 functions are taken from CV :) |
65 |
|
|
sub find_rcfile($) { |
66 |
|
|
my $path; |
67 |
|
|
|
68 |
|
|
for (@INC) { |
69 |
|
|
|
70 |
|
|
$path = "$_/GCE/$_[0]"; |
71 |
|
|
return $path if -r $path; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
die "FATAL: can't find required file $_[0]\n"; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
sub require_image($) { |
78 |
|
|
new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
sub get_pos_and_size { |
82 |
|
|
my ($window) = @_; |
83 |
|
|
|
84 |
|
|
my ($x, $y) = $window->get_position; |
85 |
|
|
my ($w, $h) = $window->get_size; |
86 |
|
|
|
87 |
|
|
return [$x, $y, $w, $h]; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
sub set_pos_and_size { |
91 |
|
|
my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_; |
92 |
|
|
|
93 |
|
|
$window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h); |
94 |
|
|
|
95 |
|
|
# FIXME: This sucks, moving it after showing it can't be a good thing. |
96 |
|
|
$window->show_all; |
97 |
|
|
$window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
read_cfg "$Crossfire::VARDIR/gceconfig"; |
101 |
|
|
|
102 |
|
|
$CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR}; |
103 |
|
|
$CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps'); |
104 |
|
|
|
105 |
|
|
# must be done after changing the libdir path: |
106 |
|
|
Crossfire::set_libdir ($CFG->{LIBDIR}); |
107 |
|
|
Crossfire::load_archetypes; |
108 |
|
|
Crossfire::load_tilecache; |
109 |
|
|
|
110 |
|
|
my $w = GCE::MainWindow->new; |
111 |
|
|
|
112 |
|
|
$w->load_layout; |
113 |
|
|
|
114 |
|
|
$w->show_all; |
115 |
|
|
|
116 |
|
|
Gtk2->main; |
117 |
|
|
|
118 |
|
|
__DATA__ |
119 |
root |
1.7 |
|
120 |
root |
1.1 |
=head1 NAME |
121 |
|
|
|
122 |
|
|
gce - gtk (perl) crossfire editor |
123 |
|
|
|
124 |
elmex |
1.10 |
=head1 SYNOPSIS |
125 |
|
|
|
126 |
root |
1.11 |
gce [<map-filename>...] |
127 |
elmex |
1.10 |
|
128 |
|
|
=head1 FEATURES |
129 |
|
|
|
130 |
|
|
gce is a map editor for crossfire. |
131 |
|
|
|
132 |
root |
1.11 |
Its main features are: |
133 |
|
|
|
134 |
|
|
- higher map editing comfort |
135 |
elmex |
1.10 |
- intelligent placement tool |
136 |
|
|
- intelligent connection tool |
137 |
|
|
- intelligent erase tool |
138 |
|
|
- faster and smaller than the java editor |
139 |
|
|
- map normalizing (removal of old deprecated attributes) |
140 |
|
|
- exit following |
141 |
|
|
- world map navigation |
142 |
root |
1.11 |
- easier installation (on windows) |
143 |
elmex |
1.18 |
- auto joining of walls (see Placement tool -> auto setting) |
144 |
elmex |
1.10 |
|
145 |
|
|
=head1 DESCRIPTION |
146 |
|
|
|
147 |
root |
1.13 |
=head2 THE TOOLBOX WINDOW |
148 |
elmex |
1.10 |
|
149 |
root |
1.13 |
The toolbox window is the main window of gce. It provides the display of |
150 |
|
|
the currently selected object and the tools. The buttons select of the |
151 |
|
|
editing tool: |
152 |
elmex |
1.10 |
|
153 |
|
|
=over 4 |
154 |
|
|
|
155 |
|
|
=item * Pick |
156 |
|
|
|
157 |
root |
1.11 |
This tool is the simplest of all. It lets the user select the topmost |
158 |
|
|
object of a map cell in the map window and updates the stack view for the |
159 |
|
|
current space. |
160 |
|
|
|
161 |
|
|
If the pick attr flag is set only the attribute editor and the stack |
162 |
|
|
view are updated. This is useful when you want to put an object in the |
163 |
|
|
attribute editor and want to place an object from the map, you picked |
164 |
|
|
before, in an inventory of a different object (you just picked). This is a |
165 |
|
|
very special thing. It will propably go away. |
166 |
elmex |
1.10 |
|
167 |
|
|
Shortcut-key in map editor: i |
168 |
|
|
|
169 |
|
|
=item * Place |
170 |
|
|
|
171 |
|
|
This is the intelligent placement tool. It has many modes: |
172 |
|
|
|
173 |
|
|
=over 4 |
174 |
|
|
|
175 |
|
|
=item auto |
176 |
|
|
|
177 |
root |
1.11 |
This mode implements DWIM (do-what-I-mean) by trying to do the the right |
178 |
|
|
thing(tm) with the selected object: |
179 |
|
|
|
180 |
|
|
If you place a floor arch, it will try to replace the existing floor or |
181 |
|
|
set the floor below all items. If you place a monster or other arch, it |
182 |
|
|
will place it on top. If you place a wall, it will put the wall above the |
183 |
|
|
floor and propably replace other walls. |
184 |
elmex |
1.10 |
|
185 |
elmex |
1.18 |
Autojoin also works only in this mode. To draw an wall with autojoining pick |
186 |
|
|
the wall arch which name looks like: <wallname>_0. It's the single point wall |
187 |
|
|
tile which has no connections. |
188 |
|
|
When you place this arch now, it will autoconnect the walls you are drawing. |
189 |
|
|
|
190 |
elmex |
1.10 |
=item top |
191 |
|
|
|
192 |
root |
1.11 |
Places the arch on the top of the stack of the map cell. |
193 |
elmex |
1.10 |
|
194 |
|
|
=item above floor |
195 |
|
|
|
196 |
root |
1.11 |
Places the arch just right above the floor (or the bottom of the stack). |
197 |
elmex |
1.10 |
|
198 |
|
|
=item below floor |
199 |
|
|
|
200 |
root |
1.11 |
Places the arch just right below the floor (or the bottom of the stack). |
201 |
elmex |
1.10 |
|
202 |
|
|
=item bottom |
203 |
|
|
|
204 |
root |
1.11 |
Places the arch on the bottom of the stack. |
205 |
elmex |
1.10 |
|
206 |
|
|
=back |
207 |
|
|
|
208 |
|
|
Shortcut-key in map editor: p |
209 |
|
|
|
210 |
|
|
=item * Erase |
211 |
|
|
|
212 |
|
|
This is the tool that lets you erase an arch. |
213 |
root |
1.11 |
|
214 |
elmex |
1.10 |
It has following modes: |
215 |
|
|
|
216 |
|
|
=over 4 |
217 |
|
|
|
218 |
|
|
=item top |
219 |
|
|
|
220 |
|
|
Erases the topmost object on the stack. |
221 |
|
|
|
222 |
|
|
=item walls |
223 |
|
|
|
224 |
root |
1.11 |
Erases all walls in the stack (and only walls). |
225 |
elmex |
1.10 |
|
226 |
|
|
=item above floor |
227 |
|
|
|
228 |
|
|
Erases the first object above the floor. |
229 |
|
|
|
230 |
|
|
=item floor |
231 |
|
|
|
232 |
root |
1.11 |
Erases all floor from the stack (and only the floor). |
233 |
elmex |
1.10 |
|
234 |
|
|
=item below floor |
235 |
|
|
|
236 |
|
|
Erases the first object below the floor. |
237 |
|
|
|
238 |
|
|
=item bottom |
239 |
|
|
|
240 |
|
|
Erases the first object on the bottom of the stack. |
241 |
|
|
|
242 |
|
|
=item pick match |
243 |
|
|
|
244 |
root |
1.11 |
This erases all objects from the stack that match the currently selected |
245 |
|
|
object. |
246 |
elmex |
1.10 |
|
247 |
root |
1.11 |
=item protect walls (checkbox) |
248 |
elmex |
1.10 |
|
249 |
root |
1.11 |
This protects walls from being erased (except when erasing walls). |
250 |
elmex |
1.10 |
|
251 |
root |
1.11 |
=item protect monsters (checkbox) |
252 |
elmex |
1.10 |
|
253 |
root |
1.11 |
This protects monsters from being erased. |
254 |
elmex |
1.10 |
|
255 |
|
|
=back |
256 |
|
|
|
257 |
|
|
Shortcut-key in map editor: e |
258 |
|
|
|
259 |
|
|
=item * Select |
260 |
|
|
|
261 |
root |
1.11 |
This is the selection tool. It can be used to select rectangular areas and |
262 |
|
|
operate on that area in various ways: |
263 |
elmex |
1.10 |
|
264 |
|
|
=over 4 |
265 |
|
|
|
266 |
|
|
=item copy |
267 |
|
|
|
268 |
root |
1.11 |
This just copies all objects from the selected area into an internal |
269 |
|
|
buffer for later paste operations. |
270 |
elmex |
1.10 |
|
271 |
|
|
Shortcut-key in map editor: c |
272 |
|
|
|
273 |
|
|
=item paste |
274 |
|
|
|
275 |
root |
1.11 |
This function pastes the internal buffer into the map, beginning in the |
276 |
|
|
top left corner of the selected area. The size of the selection has no |
277 |
|
|
relevance to the result: IT always places the whole internal buffer onto |
278 |
|
|
the map. |
279 |
elmex |
1.10 |
|
280 |
|
|
Shortcut-key in map editor: p |
281 |
|
|
|
282 |
|
|
=item invoke |
283 |
|
|
|
284 |
root |
1.11 |
This function is a very powerful one. It can apply another tool (such as |
285 |
|
|
the place tool) on all spaces of the selected area. |
286 |
|
|
|
287 |
|
|
It can, for example, be used to fill a map with floor tiles or erase |
288 |
|
|
everything. |
289 |
elmex |
1.10 |
|
290 |
|
|
Shortcut-key in map editor: n |
291 |
|
|
|
292 |
|
|
=back |
293 |
|
|
|
294 |
|
|
Shortcut-key in map editor: s |
295 |
|
|
|
296 |
|
|
=item * Eval |
297 |
|
|
|
298 |
root |
1.11 |
This is a very special tool which isn't finished yet. It lets you specify |
299 |
|
|
a perl snippet that can manipulate the stack. |
300 |
elmex |
1.10 |
|
301 |
|
|
Shortcut-key in map editor: l |
302 |
|
|
|
303 |
|
|
=item * Connect Exit |
304 |
|
|
|
305 |
root |
1.11 |
This tool connects two exits or teleporters. |
306 |
|
|
|
307 |
|
|
You can either connect two exits to each other, or just point an exit to |
308 |
|
|
a certain location on a map. |
309 |
elmex |
1.10 |
|
310 |
|
|
Shortcut-key in map editor: x |
311 |
|
|
|
312 |
|
|
=item * Follow Exit |
313 |
|
|
|
314 |
root |
1.11 |
With this tool you can follow exits and teleporters by opening the target |
315 |
|
|
map in a new window (or presents an existing window). |
316 |
elmex |
1.10 |
|
317 |
|
|
Shortcut-key in map editor: f |
318 |
|
|
|
319 |
|
|
=back |
320 |
|
|
|
321 |
|
|
=head2 THE STACK VIEW |
322 |
|
|
|
323 |
root |
1.11 |
This window displays the stack of a map space/coordinate. |
324 |
elmex |
1.10 |
|
325 |
root |
1.11 |
You can swap two objects on the stack and delete a object from the stack |
326 |
|
|
by dragging one object over another. |
327 |
|
|
|
328 |
|
|
By clicking on an item on the stack you can make it the currently selected |
329 |
|
|
object. |
330 |
elmex |
1.10 |
|
331 |
|
|
=head2 THE MAP EDITOR |
332 |
|
|
|
333 |
|
|
This window just displays the map and lets you use the tools. The shortcuts are |
334 |
|
|
documented above in the tool descriptions. |
335 |
|
|
|
336 |
root |
1.11 |
You can pan the map using the middle mouse button and use the tool with |
337 |
|
|
the left mouse button. |
338 |
elmex |
1.10 |
|
339 |
root |
1.11 |
There are two modifiers: Holding down the Meta/Alt-key temporarily |
340 |
|
|
switches to the pick tool. Holding down the Ctrl-key temporarily switched |
341 |
|
|
to the erase tool. Both will use their current settings. To change them, |
342 |
|
|
you need to select the tools using the toolbox first. |
343 |
elmex |
1.10 |
|
344 |
|
|
=head2 THE ATTRIBUTE EDITOR |
345 |
|
|
|
346 |
root |
1.11 |
The attribute editor display the archetype name followed by the object |
347 |
|
|
name and the type of the object in parentheses. |
348 |
|
|
|
349 |
|
|
Since there are often many attributes for a given object, they are sorted |
350 |
|
|
into different categories/tabs. |
351 |
elmex |
1.10 |
|
352 |
root |
1.11 |
The lore and msg tabs let you edit the text attributes of the object. |
353 |
elmex |
1.10 |
|
354 |
root |
1.11 |
The inventory tab lets you add stuff to the inventory by dragging them |
355 |
|
|
from the selected object in the toolbox to the top most button with the |
356 |
|
|
image in the inventory (the inventory editor is subject to change and |
357 |
|
|
improvement). |
358 |
|
|
|
359 |
|
|
Both field labels and value widgets have tool tips enabled. Tool tips on |
360 |
|
|
the labels explain the attribute in more detail. The tool tips on the |
361 |
|
|
value widgets show the default value from the archetype. |
362 |
elmex |
1.10 |
|
363 |
|
|
|
364 |
|
|
=head2 THE PICK WINDOW |
365 |
|
|
|
366 |
root |
1.11 |
Pick windows are used to quickly pick archetypes from specific categories. |
367 |
|
|
|
368 |
|
|
Left click creates an object from the archetype and makes it the currently |
369 |
|
|
selected object for the tools and the attribute editor. |
370 |
|
|
|
371 |
|
|
You can change the attributes of the currently selected object in the |
372 |
|
|
attribute editor. |
373 |
elmex |
1.10 |
|
374 |
|
|
You can open multiple pick windows. |
375 |
|
|
|
376 |
elmex |
1.12 |
=head1 AUTHOR |
377 |
root |
1.1 |
|
378 |
root |
1.15 |
All of the editor GUI: |
379 |
root |
1.4 |
|
380 |
elmex |
1.12 |
Robin Redeker <elmex@ta-sa.org> |
381 |
|
|
http://www.ta-sa.org/ |
382 |
root |
1.6 |
|
383 |
root |
1.15 |
The Crossfire map handling module and map widget: |
384 |
root |
1.1 |
|
385 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
386 |
|
|
http://home.schmorp.de/ |
387 |
|
|
|
388 |
|
|
=cut |