#!/opt/bin/perl our $VERSION = '0.2'; BEGIN { if (%PAR::LibCache) { while (my ($filename, $zip) = each %PAR::LibCache) { for ($zip->memberNames) { next unless /^\/root\/(.*)/; $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1") unless -e "$ENV{PAR_TEMP}/$1"; } } $ENV{CROSSFIRE_LIBDIR} ||= $ENV{PAR_TEMP}; if ($^O eq "MSWin32") { $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc"; } } } use Gtk2 -init; use Data::Dumper; use File::Spec; use Crossfire; use GCE::MainWindow; our $CFG; our $MAINWIN; our $DOCUMENTATION = join ("\n", do { local $/; }); sub read_cfg { my ($file) = @_; open CFG, $file or return; $CFG = eval join '', ; close CFG; } sub write_cfg { my ($file) = @_; open CFG, ">$file" or return; { local $Data::Dumper::Purity = 1; print CFG Data::Dumper->Dump ([$CFG], [qw/CFG/]); } close CFG; } # following 2 functions are taken from CV :) sub find_rcfile($) { my $path; for (@INC) { $path = "$_/GCE/$_[0]"; return $path if -r $path; } die "FATAL: can't find required file $_[0]\n"; } sub require_image($) { new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; } sub get_pos_and_size { my ($window) = @_; my ($x, $y) = $window->get_position; my ($w, $h) = $window->get_size; return [$x, $y, $w, $h]; } sub set_pos_and_size { my ($window, $p_and_s, $default_w, $default_h, $default_x, $default_y) = @_; $window->set_default_size ($p_and_s->[2] || $default_w, $p_and_s->[3] || $default_h); # FIXME: This sucks, moving it after showing it can't be a good thing. $window->show_all; $window->move ($p_and_s->[0] || $default_x, $p_and_s->[1] || $default_y); } read_cfg "$Crossfire::VARDIR/gceconfig"; $CFG->{LIBDIR} ||= $ENV{CROSSFIRE_LIBDIR}; $CFG->{MAPDIR} ||= File::Spec->catfile ($CFG->{LIBDIR}, 'maps'); # must be done after changing the libdir path: Crossfire::set_libdir ($CFG->{LIBDIR}); Crossfire::load_archetypes; Crossfire::load_tilecache; my $w = GCE::MainWindow->new; $w->load_layout; $w->show_all; Gtk2->main; __DATA__ =head1 NAME gce - gtk (perl) crossfire editor =head1 SYNOPSIS gce [...] =head1 FEATURES gce is a map editor for crossfire. Its main features are: - higher map editing comfort - intelligent placement tool - intelligent connection tool - intelligent erase tool - faster and smaller than the java editor - map normalizing (removal of old deprecated attributes) - exit following - world map navigation - easier installation (on windows) =head1 DESCRIPTION =head2 THE TOOLBOX WINDOW The toolbox window is the main window of gce. It provides the display of the currently selected object and the tools. The buttons select of the editing tool: =over 4 =item * Pick This tool is the simplest of all. It lets the user select the topmost object of a map cell in the map window and updates the stack view for the current space. If the pick attr flag is set only the attribute editor and the stack view are updated. This is useful when you want to put an object in the attribute editor and want to place an object from the map, you picked before, in an inventory of a different object (you just picked). This is a very special thing. It will propably go away. Shortcut-key in map editor: i =item * Place This is the intelligent placement tool. It has many modes: =over 4 =item auto This mode implements DWIM (do-what-I-mean) by trying to do the the right thing(tm) with the selected object: If you place a floor arch, it will try to replace the existing floor or set the floor below all items. If you place a monster or other arch, it will place it on top. If you place a wall, it will put the wall above the floor and propably replace other walls. =item top Places the arch on the top of the stack of the map cell. =item above floor Places the arch just right above the floor (or the bottom of the stack). =item below floor Places the arch just right below the floor (or the bottom of the stack). =item bottom Places the arch on the bottom of the stack. =item place clean (checkbox) Setting this is a flag lets the placement tool place an unmodified object on the map only. This is useful when you have modified the currently selected object in the attribute editor (e.g. a special monster with modified hp) but your want to place an unmodified monster. =back Shortcut-key in map editor: p =item * Erase This is the tool that lets you erase an arch. It has following modes: =over 4 =item top Erases the topmost object on the stack. =item walls Erases all walls in the stack (and only walls). =item above floor Erases the first object above the floor. =item floor Erases all floor from the stack (and only the floor). =item below floor Erases the first object below the floor. =item bottom Erases the first object on the bottom of the stack. =item pick match This erases all objects from the stack that match the currently selected object. =item protect walls (checkbox) This protects walls from being erased (except when erasing walls). =item protect monsters (checkbox) This protects monsters from being erased. =back Shortcut-key in map editor: e =item * Select This is the selection tool. It can be used to select rectangular areas and operate on that area in various ways: =over 4 =item copy This just copies all objects from the selected area into an internal buffer for later paste operations. Shortcut-key in map editor: c =item paste This function pastes the internal buffer into the map, beginning in the top left corner of the selected area. The size of the selection has no relevance to the result: IT always places the whole internal buffer onto the map. Shortcut-key in map editor: p =item invoke This function is a very powerful one. It can apply another tool (such as the place tool) on all spaces of the selected area. It can, for example, be used to fill a map with floor tiles or erase everything. Shortcut-key in map editor: n =back Shortcut-key in map editor: s =item * Eval This is a very special tool which isn't finished yet. It lets you specify a perl snippet that can manipulate the stack. Shortcut-key in map editor: l =item * Connect Exit This tool connects two exits or teleporters. You can either connect two exits to each other, or just point an exit to a certain location on a map. Shortcut-key in map editor: x =item * Follow Exit With this tool you can follow exits and teleporters by opening the target map in a new window (or presents an existing window). Shortcut-key in map editor: f =back =head2 THE STACK VIEW This window displays the stack of a map space/coordinate. You can swap two objects on the stack and delete a object from the stack by dragging one object over another. By clicking on an item on the stack you can make it the currently selected object. =head2 THE MAP EDITOR This window just displays the map and lets you use the tools. The shortcuts are documented above in the tool descriptions. You can pan the map using the middle mouse button and use the tool with the left mouse button. There are two modifiers: Holding down the Meta/Alt-key temporarily switches to the pick tool. Holding down the Ctrl-key temporarily switched to the erase tool. Both will use their current settings. To change them, you need to select the tools using the toolbox first. =head2 THE ATTRIBUTE EDITOR The attribute editor display the archetype name followed by the object name and the type of the object in parentheses. Since there are often many attributes for a given object, they are sorted into different categories/tabs. The lore and msg tabs let you edit the text attributes of the object. The inventory tab lets you add stuff to the inventory by dragging them from the selected object in the toolbox to the top most button with the image in the inventory (the inventory editor is subject to change and improvement). Both field labels and value widgets have tool tips enabled. Tool tips on the labels explain the attribute in more detail. The tool tips on the value widgets show the default value from the archetype. =head2 THE PICK WINDOW Pick windows are used to quickly pick archetypes from specific categories. Left click creates an object from the archetype and makes it the currently selected object for the tools and the attribute editor. You can change the attributes of the currently selected object in the attribute editor. You can open multiple pick windows. =head1 AUTHOR The editor GUI: Robin Redeker http://www.ta-sa.org/ The Crossfire backend module: Marc Lehmann http://home.schmorp.de/ =cut