ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/PickWindow.pm
Revision: 1.11
Committed: Sun Mar 12 12:18:55 2006 UTC (18 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.10: +4 -0 lines
Log Message:
Implemented first parts of the new attribute editor.

File Contents

# Content
1 package GCE::PickWindow;
2
3 =head1 NAME
4
5 GCE::PickWindow - the arch picker window class for gce
6
7 =cut
8
9 use Gtk2;
10 use Gtk2::Gdk::Keysyms;
11 use Gtk2::SimpleMenu;
12
13 use Crossfire;
14 use Crossfire::MapWidget;
15
16 use GCE::AttrEdit;
17 use GCE::MapEditor;
18 use GCE::StackView;
19 use GCE::EditAction;
20 use GCE::PickWindow;
21
22 use GCE::AttrTypemap;
23
24 use Glib::Object::Subclass
25 Gtk2::Window;
26
27 use strict;
28
29 sub INIT_INSTANCE {
30 my ($self) = @_;
31
32 $self->{earchs} = editor_archs ();
33
34 for (keys %{$self->{earchs}}) {
35
36 my @a = split /\//;
37 push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}};
38 }
39
40 $self->set_title ("gce - picker");
41
42 $self->add (my $hb = Gtk2::VBox->new);
43
44 $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0);
45
46 for (sort keys %{$self->{toplevel_archs}}) {
47
48 $cb->append_text ($_);
49 }
50
51 $cb->signal_connect (changed => sub {
52
53 my $arch = $cb->get_active_text;
54 $self->set_selection ($arch);
55 });
56
57 $hb->pack_start (my $map = $self->{map} = new Crossfire::MapWidget, 1, 1, 0);
58
59 $map->set_size_request (TILESIZE * 10, TILESIZE * 10);
60
61 $map->signal_connect (button_press_event => sub {
62 my ($f, $event) = @_;
63
64 if ($event->button == 3) {
65
66 my ($mx, $my) = $map->coord ($event->x, $event->y);
67 my $as = $map->get ($mx, $my);
68
69 my $arch = $as->[-1]
70 or return;
71
72 $::MAINWIN->update_attr_editor ($arch);
73
74 } elsif ($event->button == 1) {
75
76 my ($mx, $my) = $map->coord ($event->x, $event->y);
77 my $as = $map->get ($mx, $my);
78
79 my $arch = $as->[-1]
80 or return;
81
82 if ($arch->{_virtual}) {
83 $arch = $arch->{_virtual};
84 }
85
86 $::MAINWIN->set_pick ($arch);
87 }
88 });
89 }
90
91 sub set_selection {
92 my ($self, $arch) = @_;
93
94 return unless defined $arch;
95
96 $self->{map}->set_map (
97 new_pickmap Crossfire::Map $self->{toplevel_archs}->{$arch}
98 );
99
100 $self->{last_selection} = $arch;
101
102 $self->{map}->enable_tooltip;
103 }
104
105
106 =head1 AUTHOR
107
108 Marc Lehmann <schmorp@schmorp.de>
109 http://home.schmorp.de/
110
111 Robin Redeker <elmex@ta-sa.org>
112 http://www.ta-sa.org/
113
114 =cut
115 1;