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