ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/PickWindow.pm
Revision: 1.10
Committed: Tue Feb 21 18:06:35 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
Changes since 1.9: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 elmex 1.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 elmex 1.8 use Gtk2::SimpleMenu;
12 elmex 1.1
13 elmex 1.2 use Crossfire;
14     use Crossfire::MapWidget;
15 elmex 1.1
16 elmex 1.8 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 elmex 1.2
29 elmex 1.8 sub INIT_INSTANCE {
30 elmex 1.4 my ($self) = @_;
31 elmex 1.3
32 elmex 1.4 $self->{earchs} = editor_archs ();
33 elmex 1.1
34 elmex 1.2 for (keys %{$self->{earchs}}) {
35 elmex 1.4
36 elmex 1.2 my @a = split /\//;
37     push @{$self->{toplevel_archs}->{$a[0]}}, @{$self->{earchs}->{$_}};
38     }
39    
40 elmex 1.8 $self->set_title ("gce - picker");
41 elmex 1.2
42 elmex 1.8 $self->add (my $hb = Gtk2::VBox->new);
43 elmex 1.4
44 root 1.6 $hb->pack_start (my $cb = Gtk2::ComboBox->new_text, 0, 1, 0);
45 elmex 1.4
46 root 1.6 for (sort keys %{$self->{toplevel_archs}}) {
47 elmex 1.5
48 root 1.6 $cb->append_text ($_);
49     }
50 elmex 1.4
51 root 1.6 $cb->signal_connect (changed => sub {
52 elmex 1.4
53 root 1.6 my $arch = $cb->get_active_text;
54 elmex 1.8 $self->set_selection ($arch);
55 root 1.6 });
56 elmex 1.3
57 root 1.6 $hb->pack_start (my $map = $self->{map} = new Crossfire::MapWidget, 1, 1, 0);
58 elmex 1.4
59 root 1.6 $map->set_size_request (TILESIZE * 10, TILESIZE * 10);
60 elmex 1.4
61 root 1.6 $map->signal_connect (button_press_event => sub {
62     my ($f, $event) = @_;
63 elmex 1.4
64 elmex 1.8 if ($event->button == 3) {
65 elmex 1.4
66 root 1.6 my ($mx, $my) = $map->coord ($event->x, $event->y);
67 root 1.7 my $as = $map->get ($mx, $my);
68 elmex 1.4
69 root 1.7 my $arch = $as->[-1]
70 root 1.6 or return;
71 elmex 1.4
72 root 1.10 $::MAINWIN->update_attr_editor ($arch);
73 elmex 1.4
74 root 1.6 } elsif ($event->button == 1) {
75 elmex 1.4
76 root 1.6 my ($mx, $my) = $map->coord ($event->x, $event->y);
77 root 1.7 my $as = $map->get ($mx, $my);
78 elmex 1.2
79 root 1.7 my $arch = $as->[-1]
80 root 1.6 or return;
81    
82 root 1.10 $::MAINWIN->set_pick ($arch);
83 root 1.6 }
84     });
85 elmex 1.8 }
86    
87     sub set_selection {
88     my ($self, $arch) = @_;
89    
90     return unless defined $arch;
91    
92     $self->{map}->set_map (
93     new_pickmap Crossfire::Map $self->{toplevel_archs}->{$arch}
94     );
95    
96     $self->{last_selection} = $arch;
97 elmex 1.2
98 elmex 1.8 $self->{map}->enable_tooltip;
99 elmex 1.1 }
100    
101 elmex 1.2
102 elmex 1.1 =head1 AUTHOR
103    
104     Marc Lehmann <schmorp@schmorp.de>
105     http://home.schmorp.de/
106    
107     Robin Redeker <elmex@ta-sa.org>
108     http://www.ta-sa.org/
109    
110     =cut
111     1;