ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/PickWindow.pm
(Generate patch)

Comparing deliantra/gde/GCE/PickWindow.pm (file contents):
Revision 1.2 by elmex, Mon Feb 6 23:06:52 2006 UTC vs.
Revision 1.3 by elmex, Tue Feb 7 14:28:23 2006 UTC

20 bless $self, $class; 20 bless $self, $class;
21 return $self; 21 return $self;
22} 22}
23 23
24sub init { 24sub init {
25 my ($self) = @_; 25 my ($self, $set_sel_cb) = @_;
26
27 $self->{setselcb} = $set_sel_cb;
26 28
27 $self->{earchs} = editor_archs (); 29 $self->{earchs} = editor_archs ();
28 for (keys %{$self->{earchs}}) { 30 for (keys %{$self->{earchs}}) {
29 my @a = split /\//; 31 my @a = split /\//;
30 push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}}; 32 push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}};
31 } 33 }
32 34
33 my $w = $self->{w} = Gtk2::Window->new ('toplevel'); 35 my $w = $self->{w} = Gtk2::Window->new ('toplevel');
36 $w->set_title ("gce - picker");
34 37
35 $w->add (my $hb = Gtk2::VBox->new); 38 $w->add (my $hb = Gtk2::VBox->new);
36 $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0); 39 $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0);
37 for (sort keys %{$self->{toplevel_archs}}) { 40 for (sort keys %{$self->{toplevel_archs}}) {
38 $cb->append_text ($_); 41 $cb->append_text ($_);
39 } 42 }
40 $cb->signal_connect (changed => sub { 43 $cb->signal_connect (changed => sub {
41 my $arch = $cb->get_active_text; 44 my $arch = $cb->get_active_text;
42 $self->{map}->set_map (arch2pickmap sort { ${$a}->{_name} cmp ${$b}->{_name} } $self->{toplevel_archs}->{$arch}); 45 $self->{map}->set_map (arch2pickmap sort { ${$a}->{_name} cmp ${$b}->{_name} } $self->{toplevel_archs}->{$arch});
43 }); 46 });
44 $hb->pack_start (my $map = new Crossfire::MapWidget, 0, 1, 0); 47 $hb->pack_start (my $map = new Crossfire::MapWidget, 1, 1, 0);
45 $self->{map} = $map; 48 $self->{map} = $map;
49 $map->signal_connect (button_release_event => sub {
50 my ($f, $event) = @_;
51
52 if ($event->button == 1 && $event->state & "shift-mask") {
53 my ($mx, $my) = $map->coord ($event->x, $event->y);
54 my $s = map_get_tile_stack ($map, $mx, $my);
55 my $arch = $s->[-1];
56 return unless $arch;
57
58 $self->{arch_edit_cb} and $self->{arch_edit_cb}->($arch);
59
60 } elsif ($event->button == 1) {
61 my ($mx, $my) = $map->coord ($event->x, $event->y);
62 my $s = map_get_tile_stack ($map, $mx, $my);
63 my $arch = $s->[-1];
64 return unless $arch;
65
66 $self->{set_sel_cb} and $self->{set_sel_cb}->($arch);
67 }
68 });
46 69
47 70
48 $w->show_all; 71 $w->show_all;
49} 72}
50 73

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines