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