ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/PickWindow.pm
Revision: 1.5
Committed: Thu Feb 9 15:45:52 2006 UTC (18 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.4: +3 -0 lines
Log Message:
improved attribute editor

File Contents

# Content
1
2 package GCE::PickWindow;
3
4 =head1 NAME
5
6 GCE::PickWindow - the arch picker window class for gce
7
8 =cut
9
10 use strict;
11 use Gtk2;
12 use Gtk2::Gdk::Keysyms;
13
14 use Crossfire;
15 use Crossfire::MapWidget;
16
17 sub new {
18 my $class = shift;
19 my $self = { @_ };
20 bless $self, $class;
21 return $self;
22 }
23
24 sub init {
25 my ($self) = @_;
26
27 $self->{earchs} = editor_archs ();
28
29 for (keys %{$self->{earchs}}) {
30
31 my @a = split /\//;
32 push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}};
33 }
34
35 my $w = $self->{w} = Gtk2::Window->new ('toplevel');
36 $w->set_title ("gce - picker");
37
38 $w->add (my $hb = Gtk2::VBox->new);
39
40 $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0);
41
42 for (sort keys %{$self->{toplevel_archs}}) {
43
44 $cb->append_text ($_);
45 }
46
47 $cb->signal_connect (changed => sub {
48
49 my $arch = $cb->get_active_text;
50 $self->{map}->set_map (
51 arch2pickmap
52 sort {
53 ${$a}->{_name} cmp ${$b}->{_name}
54 } $self->{toplevel_archs}->{$arch}
55 );
56
57 $self->{map}->enable_tooltip;
58 });
59
60 $hb->pack_start (my $map = $self->{map} = new Crossfire::MapWidget, 1, 1, 0);
61 $map->signal_connect (button_press_event => sub {
62 my ($f, $event) = @_;
63
64 if ($event->button == 1 && $event->state & "shift-mask") {
65
66 my ($mx, $my) = $map->coord ($event->x, $event->y);
67 my $s = map_get_tile_stack ($map, $mx, $my);
68
69 my $arch = $s->[-1]
70 or return;
71
72 $self->{arch_edit_cb} and $self->{arch_edit_cb}->($arch);
73
74 } elsif ($event->button == 1) {
75
76 my ($mx, $my) = $map->coord ($event->x, $event->y);
77 my $s = map_get_tile_stack ($map, $mx, $my);
78
79 my $arch = $s->[-1]
80 or return;
81
82 $self->{set_sel_cb} and $self->{set_sel_cb}->($arch);
83 }
84 });
85
86
87 $w->show_all;
88 }
89
90
91 =head1 AUTHOR
92
93 Marc Lehmann <schmorp@schmorp.de>
94 http://home.schmorp.de/
95
96 Robin Redeker <elmex@ta-sa.org>
97 http://www.ta-sa.org/
98
99 =cut
100 1;