#!/opt/bin/perl =head1 NAME gce - gtk (perl) crossfire editor =head1 SYNOPSIS gce [] =head1 FEATURES gce is a map editor for crossfire. Main features are: - more 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 =head1 DESCRIPTION =head2 THE MAIN WINDOW This is the main window of gce. It provides the display of the picked arch and the tools. The buttons are providing the selection of the editing tool: =over 4 =item * Pick This tool is the simplest of all. It lets the user just pick the topmost object of a map cell in the map window and updates the stack view, the picked arch and the attribute editor. 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 trys to do the most usual thing with the picked arch. If you picked a floor arch, it will try to replace the existing floor or set the floor below all items. If you picked a monster or other arch, it will place it on top. If you picked a wall, it will put the wall above the floor and propably replace other walls. =item top Places the picked arch on the top of the stack of the map cell. =item above floor Places the picked arch just right above the floor (or the bottom of the stack). =item below floor Places the picked arch just right below the floor (or the bottom of the stack). =item bottom Places the picked arch on the bottom of the stack. =item place clean (checkbox) This is a flag, that when enabled, will let the placement tool only place an unmodified object on the map. This is useful when you have a modified arch in the picker (eg. special monster with modified hp) but want a unmodified monster being placed. =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 object with the same name as the picked arch from the stack. =item exclude walls (checkbox) This excludes erasing of walls in any erase action (except when erasing walls) =item exclude monsters (checkbox) This excludes erasing of monsters in any erase action. =back Shortcut-key in map editor: e =item * Select This is the select tool. You can select rectangular areas with it and operate on that area in following ways: =over 4 =item copy This just copies all selected stacks. Shortcut-key in map editor: c =item paste This function pastes the copied stacks. The pasting beginns at the top left cell which is selected. Shortcut-key in map editor: p =item invoke This functions is a very mighty one. It can iterate the selected tool over the selected area. For example: It can be used to fill a map with floor 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 insert a perl snippet that can manipulate the stack. Shortcut-key in map editor: l =item * Connect Exit This tool connectes two exits or teleporters. You can either connect two exits to each other, or just direct 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 on a map. It will open the map you go to. Shortcut-key in map editor: f =back =head2 THE STACK VIEW This window displays the stack of the picked map cell. You can swap two objects on the stack and delete a object from the stack. By clicking on an item on the stack you can transfer it to the picker and the attribute editor. =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 with the middle mouse button and use the tool with the left mouse button. There are two modifiers: You can hold the Alt-key to switch quickly to the pick tool and hold the Ctrl-key to switch to the erase tool. The settings from the tool in the main window will be used. =head2 THE ATTRIBUTE EDITOR This is the attribute editing window. On the top will be the name of the arch followed by the name of the object and the type of the arch in parents. The first tabs are the different aspects of the object. The lore and msg tab lets you edit the text attributes of the object. The inventory tab lets you add stuff to the inventory by dragging them from the picked arch in the main window to the top most button with the image in the inventory. (the inventory editor is subject to change and improvement) Tool tips on the labels in the attribute editor show the documentation of the attribute and the tool tips over the editing widget show the default value from the archetypes. =head2 THE PICK WINDOW You can pick archetypes from this window. The left click puts the object in the picker in the main window and the attribute editor. You can change the attributes of the picked arch in the attribute editor and will let you place that modifies object on the map. You can open multiple pick windows. =cut our $VERSION = '0.1'; 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 Crossfire; our $PICKDIR = "$Crossfire::LIB/maps/editor/picks"; our $CFG; our $MAINWIN; use GCE::MainWindow; use Data::Dumper; use File::Spec; 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; =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ Robin Redeker http://www.ta-sa.org/ =cut