ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.70 by elmex, Sun Jul 2 19:32:55 2006 UTC vs.
Revision 1.76 by elmex, Sat Jul 22 12:36:17 2006 UTC

60 60
61sub clr_commands { 61sub clr_commands {
62 my ($self) = @_; 62 my ($self) = @_;
63 63
64 %{$self->{completer}{command}} = (); 64 %{$self->{completer}{command}} = ();
65
66 $self->{completer}->hide
67 if $self->{completer};
65} 68}
66 69
67sub invoke_button_down { 70sub invoke_button_down {
68 my ($self, $ev, $x, $y) = @_; 71 my ($self, $ev, $x, $y) = @_;
69 72
70 return unless $::CONN;
71
72 $self->grab_focus;
73
74 if ($ev->{button} == 1) { 73 if ($ev->{button} == 1) {
74 $self->grab_focus;
75 return unless $::CONN;
76
75 my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 77 my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx};
76 my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 78 my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy};
77 79
78 $x -= int 0.5 * $self->{sw}; 80 $x -= int 0.5 * $self->{sw};
79 $y -= int 0.5 * $self->{sh}; 81 $y -= int 0.5 * $self->{sh};
80 82
81 $::CONN->lookat ($x, $y) 83 $::CONN->lookat ($x, $y)
82 if $::CONN; 84 if $::CONN;
83 85
84 } elsif ($ev->{button} == 2) { 86 } elsif ($ev->{button} == 2) {
87 $self->grab_focus;
88 return unless $::CONN;
89
85 my ($ox, $oy) = ($ev->{x}, $ev->{y}); 90 my ($ox, $oy) = ($ev->{x}, $ev->{y});
86 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); 91 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
87 92
88 $self->{motion} = sub { 93 $self->{motion} = sub {
89 my ($ev, $x, $y) = @_; 94 my ($ev, $x, $y) = @_;
93 $::CFG->{map_shift_x} = $bw + $x - $ox; 98 $::CFG->{map_shift_x} = $bw + $x - $ox;
94 $::CFG->{map_shift_y} = $bh + $y - $oy; 99 $::CFG->{map_shift_y} = $bh + $y - $oy;
95 100
96 $self->update; 101 $self->update;
97 }; 102 };
103 } elsif ($ev->{button} == 3) {
104 (new CFClient::UI::Menu
105 items => [
106 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }],
107 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }],
108 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
109 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
110 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }],
111 ["Setup… \tF9", sub { $::SETUP_DIALOG->toggle_visibility }],
112 ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }],
113 [
114 $::PICKUP_ENABLE->{state}
115 ? "Disable automatic pickup"
116 : "Enable automatic pickup",
117 sub { $::PICKUP_ENABLE->toggle }
118 ],
119 ],
120 )->popup ($ev);
98 } 121 }
99 122
100 1 123 1
101} 124}
102 125
151); 174);
152 175
153sub invoke_key_down { 176sub invoke_key_down {
154 my ($self, $ev) = @_; 177 my ($self, $ev) = @_;
155 178
156 return 0 unless $::CONN;
157
158 my $mod = $ev->{mod}; 179 my $mod = $ev->{mod};
159 my $sym = $ev->{sym}; 180 my $sym = $ev->{sym};
160 my $uni = $ev->{unicode}; 181 my $uni = $ev->{unicode};
161 182
183 $mod &= CFClient::KMOD_CTRL | CFClient::KMOD_ALT | CFClient::KMOD_SHIFT;
184
185 if ($uni == ord "\t") {
186 $::PL_WINDOW->toggle_visibility;
187 } elsif ($sym == CFClient::SDLK_F1 && !$mod) {
188 $::HELP_WINDOW->toggle_visibility;
189 } elsif ($sym == CFClient::SDLK_F2 && !$mod) {
190 ::toggle_player_page ($::STATS_PAGE);
191 } elsif ($sym == CFClient::SDLK_F3 && !$mod) {
192 ::toggle_player_page ($::SKILL_PAGE);
193 } elsif ($sym == CFClient::SDLK_F4 && !$mod) {
194 ::toggle_player_page ($::SPELL_PAGE);
195 } elsif ($sym == CFClient::SDLK_F5 && !$mod) {
196 ::toggle_player_page ($::INVENTORY_PAGE);
197 } elsif ($sym == CFClient::SDLK_F9 && !$mod) {
198 $::SETUP_DIALOG->toggle_visibility;
199 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) {
200 $::BIND_EDITOR->set_binding (undef, undef, [],
201 sub {
202 my ($mod, $sym, $cmds) = @_;
203 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
204 });
205 $::BIND_EDITOR->start;
206 $::BIND_EDITOR->show;
207 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) {
208 $::BIND_EDITOR->stop;
209 $::BIND_EDITOR->ask_for_bind_and_commit;
210 $::BIND_EDITOR->hide;
211 } elsif (!$::CONN) {
212 return 0; # bindings further down need a valid connection
213
162 if ($sym == CFClient::SDLK_KP5) { 214 } elsif ($sym == CFClient::SDLK_KP5 && !$mod) {
163 $::CONN->user_send ("stay fire"); 215 $::CONN->user_send ("stay fire");
164 } elsif ($uni == ord ",") { 216 } elsif ($uni == ord ",") {
165 $::CONN->user_send ("take"); 217 $::CONN->user_send ("take");
166 } elsif ($uni == ord " ") { 218 } elsif ($uni == ord " ") {
167 $::CONN->user_send ("apply"); 219 $::CONN->user_send ("apply");
168 } elsif ($uni == ord ".") { 220 } elsif ($uni == ord ".") {
169 $::CONN->user_send ($self->{completer}{last_command}) 221 $::CONN->user_send ($self->{completer}{last_command})
170 if exists $self->{completer}{last_command}; 222 if exists $self->{completer}{last_command};
171 } elsif ($uni == ord "\t") { 223 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
172 $::PL_WINDOW->toggle_visibility; 224 $::CONN->user_send ($_) for @$bind_cmd;
173 $::PL_NOTEBOOK->set_current_page ("Inventory");
174 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { 225 } elsif (($sym == CFClient::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
175 $::CONN->user_send ("rotateshoottype +"); 226 $::CONN->user_send ("rotateshoottype +");
176 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { 227 } elsif (($sym == CFClient::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
177 $::CONN->user_send ("rotateshoottype -"); 228 $::CONN->user_send ("rotateshoottype -");
178 } elsif ($uni == ord '"') { 229 } elsif ($uni == ord '"') {
179 $self->{completer}->set_prefix ("$::CFG->{say_command} "); 230 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
180 $self->{completer}->show; 231 $self->{completer}->show;
181 } elsif ($uni == ord "'") { 232 } elsif ($uni == ord "'") {
192 $self->{ctrl}++; 243 $self->{ctrl}++;
193 $::CONN->user_send ("run $DIR{$sym}[0]"); 244 $::CONN->user_send ("run $DIR{$sym}[0]");
194 } else { 245 } else {
195 $::CONN->user_send ("$DIR{$sym}[1]"); 246 $::CONN->user_send ("$DIR{$sym}[1]");
196 } 247 }
197 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) {
198 $::BIND_EDITOR->set_binding (undef, undef, [],
199 sub {
200 my ($mod, $sym, $cmds) = @_;
201 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
202 });
203 $::BIND_EDITOR->start;
204 $::BIND_EDITOR->show;
205 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) {
206 $::BIND_EDITOR->stop;
207 $::BIND_EDITOR->ask_for_bind_and_commit;
208 $::BIND_EDITOR->hide;
209 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
210 $::CONN->user_send ($_) for @$bind_cmd;
211 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 248 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) {
212 $self->{completer}->invoke_key_down ($ev); 249 $self->{completer}->invoke_key_down ($ev);
213 $self->{completer}->show; 250 $self->{completer}->show;
214 } else { 251 } else {
215 return 0; 252 return 0;
582} 619}
583 620
584sub hide { 621sub hide {
585 my ($self) = @_; 622 my ($self) = @_;
586 623
624 $self->{hist_ptr} = 0;
625
587 $self->SUPER::hide; 626 $self->SUPER::hide;
588 $self->{entry}->set_text (""); 627 $self->{entry}->set_text ("");
589} 628}
590 629
591sub invoke_key_down { 630sub invoke_key_down {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines