package GCE::PickWindow; =head1 NAME GCE::PickWindow - the arch picker window class for gce =cut use Gtk2; use Gtk2::Gdk::Keysyms; use Gtk2::SimpleMenu; use Crossfire; use Crossfire::MapWidget; use GCE::AttrEdit; use GCE::MapEditor; use GCE::StackView; use GCE::EditAction; use GCE::PickWindow; use GCE::AttrTypemap; use Glib::Object::Subclass Gtk2::Window; use strict; sub INIT_INSTANCE { my ($self) = @_; $self->{earchs} = editor_archs (); for (keys %{$self->{earchs}}) { my @a = split /\//; push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}}; } $self->set_title ("gce - picker"); $self->add (my $hb = Gtk2::VBox->new); $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0); for (sort keys %{$self->{toplevel_archs}}) { $cb->append_text ($_); } $cb->signal_connect (changed => sub { my $arch = $cb->get_active_text; $self->set_selection ($arch); }); $hb->pack_start (my $map = $self->{map} = new Crossfire::MapWidget, 1, 1, 0); $map->set_size_request (TILESIZE * 10, TILESIZE * 10); $map->signal_connect (button_press_event => sub { my ($f, $event) = @_; if ($event->button == 3) { my ($mx, $my) = $map->coord ($event->x, $event->y); my $as = $map->get ($mx, $my); my $arch = $as->[-1] or return; $GCE::MainWindow::MAINWIN->update_attr_editor ($arch, 1); } elsif ($event->button == 1) { my ($mx, $my) = $map->coord ($event->x, $event->y); my $as = $map->get ($mx, $my); my $arch = $as->[-1] or return; $GCE::MainWindow::MAINWIN->set_pick ($arch); } }); } sub set_selection { my ($self, $arch) = @_; return unless defined $arch; $self->{map}->set_map ( new_pickmap Crossfire::Map $self->{toplevel_archs}->{$arch} ); $self->{last_selection} = $arch; $self->{map}->enable_tooltip; } =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ Robin Redeker http://www.ta-sa.org/ =cut 1;