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