package GCE::PickWindow; =head1 NAME GCE::PickWindow - the arch picker window class for gce =cut use strict; use Gtk2; use Gtk2::Gdk::Keysyms; use Crossfire; use Crossfire::MapWidget; sub new { my $class = shift; my $self = { @_ }; bless $self, $class; return $self; } sub init { my ($self) = @_; $self->{earchs} = editor_archs (); for (keys %{$self->{earchs}}) { my @a = split /\//; push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}}; } my $w = $self->{w} = Gtk2::Window->new ('toplevel'); $w->set_title ("gce - picker"); $w->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->{map}->set_map ( arch2pickmap sort { ${$a}->{_name} cmp ${$b}->{_name} } $self->{toplevel_archs}->{$arch} ); $self->{map}->enable_tooltip; }); $hb->pack_start (my $map = $self->{map} = new Crossfire::MapWidget, 1, 1, 0); $map->signal_connect (button_press_event => sub { my ($f, $event) = @_; if ($event->button == 1 && $event->state & "shift-mask") { my ($mx, $my) = $map->coord ($event->x, $event->y); my $s = map_get_tile_stack ($map, $mx, $my); my $arch = $s->[-1] or return; $self->{arch_edit_cb} and $self->{arch_edit_cb}->($arch); } elsif ($event->button == 1) { my ($mx, $my) = $map->coord ($event->x, $event->y); my $s = map_get_tile_stack ($map, $mx, $my); my $arch = $s->[-1] or return; $self->{set_sel_cb} and $self->{set_sel_cb}->($arch); } }); $w->show_all; } =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ Robin Redeker http://www.ta-sa.org/ =cut 1;