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.79 by elmex, Mon Jul 24 12:25:09 2006 UTC vs.
Revision 1.81 by root, Sun Aug 13 15:14:17 2006 UTC

1package CFClient::MapWidget; 1package CFPlus::MapWidget;
2 2
3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6use List::Util qw(min max); 6use List::Util qw(min max);
7 7
8use CFClient; 8use CFPlus;
9use CFClient::OpenGL; 9use CFPlus::OpenGL;
10use CFClient::UI; 10use CFPlus::UI;
11 11
12our @ISA = CFClient::UI::Base::; 12our @ISA = CFPlus::UI::Base::;
13 13
14my $magicmap_tex = 14my $magicmap_tex =
15 new_from_file CFClient::Texture CFClient::find_rcfile "magicmap.png", 15 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png",
16 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 16 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
17 17
18sub new { 18sub new {
19 my $class = shift; 19 my $class = shift;
20 20
30 ], 30 ],
31 31
32 @_ 32 @_
33 ); 33 );
34 34
35 $self->{completer} = new CFClient::MapWidget::Command:: 35 $self->{completer} = new CFPlus::MapWidget::Command::
36 command => $self->{command}, 36 command => $self->{command},
37 tooltip => "<b>The Command Completer</b>\n\n" 37 tooltip => "#completer_help",
38 . "This is your central interface to send text commands to the server. "
39 . "To enter a verbatim command to send to the server, just type the command, "
40 . "followed by a space, and press return. "
41 . "Typing the initial letters of words (or just any letters) displays guesses "
42 . "for commands you might want to use.\n"
43 . "You can use the cursor-up and cursor-down keys to select between those guesses.\n"
44 . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining key bindings.",
45 ; 38 ;
46 39
47 $self 40 $self
48} 41}
49 42
73 66
74 if ($ev->{button} == 1) { 67 if ($ev->{button} == 1) {
75 $self->grab_focus; 68 $self->grab_focus;
76 return unless $::CONN; 69 return unless $::CONN;
77 70
78 my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 71 my $x = 1 + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx};
79 my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 72 my $y = 1 + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy};
80 73
81 $x -= int 0.5 * $self->{sw}; 74 $x -= int 0.5 * $self->{sw};
82 $y -= int 0.5 * $self->{sh}; 75 $y -= int 0.5 * $self->{sh};
83 76
84 $::CONN->lookat ($x, $y) 77 $::CONN->lookat ($x, $y)
100 $::CFG->{map_shift_y} = $bh + $y - $oy; 93 $::CFG->{map_shift_y} = $bh + $y - $oy;
101 94
102 $self->update; 95 $self->update;
103 }; 96 };
104 } elsif ($ev->{button} == 3) { 97 } elsif ($ev->{button} == 3) {
105 (new CFClient::UI::Menu 98 (new CFPlus::UI::Menu
106 items => [ 99 items => [
107 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }], 100 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }],
108 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }], 101 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }],
109 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }], 102 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
110 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }], 103 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
153 1 146 1
154} 147}
155 148
156sub size_request { 149sub size_request {
157 ( 150 (
158 32 * CFClient::ceil $::WIDTH / 32, 151 32 * CFPlus::ceil $::WIDTH / 32,
159 32 * CFClient::ceil $::HEIGHT / 32, 152 32 * CFPlus::ceil $::HEIGHT / 32,
160 ) 153 )
161} 154}
162 155
163sub update { 156sub update {
164 my ($self) = @_; 157 my ($self) = @_;
166 $self->{need_update} = 1; 159 $self->{need_update} = 1;
167 $self->SUPER::update; 160 $self->SUPER::update;
168} 161}
169 162
170my %DIR = ( 163my %DIR = (
171 CFClient::SDLK_KP8, [1, "north"], 164 CFPlus::SDLK_KP8, [1, "north"],
172 CFClient::SDLK_KP9, [2, "northeast"], 165 CFPlus::SDLK_KP9, [2, "northeast"],
173 CFClient::SDLK_KP6, [3, "east"], 166 CFPlus::SDLK_KP6, [3, "east"],
174 CFClient::SDLK_KP3, [4, "southeast"], 167 CFPlus::SDLK_KP3, [4, "southeast"],
175 CFClient::SDLK_KP2, [5, "south"], 168 CFPlus::SDLK_KP2, [5, "south"],
176 CFClient::SDLK_KP1, [6, "southwest"], 169 CFPlus::SDLK_KP1, [6, "southwest"],
177 CFClient::SDLK_KP4, [7, "west"], 170 CFPlus::SDLK_KP4, [7, "west"],
178 CFClient::SDLK_KP7, [8, "northwest"], 171 CFPlus::SDLK_KP7, [8, "northwest"],
179 172
180 CFClient::SDLK_UP, [1, "north"], 173 CFPlus::SDLK_UP, [1, "north"],
181 CFClient::SDLK_RIGHT, [3, "east"], 174 CFPlus::SDLK_RIGHT, [3, "east"],
182 CFClient::SDLK_DOWN, [5, "south"], 175 CFPlus::SDLK_DOWN, [5, "south"],
183 CFClient::SDLK_LEFT, [7, "west"], 176 CFPlus::SDLK_LEFT, [7, "west"],
184); 177);
185 178
186sub invoke_key_down { 179sub invoke_key_down {
187 my ($self, $ev) = @_; 180 my ($self, $ev) = @_;
188 181
189 my $mod = $ev->{mod}; 182 my $mod = $ev->{mod};
190 my $sym = $ev->{sym}; 183 my $sym = $ev->{sym};
191 my $uni = $ev->{unicode}; 184 my $uni = $ev->{unicode};
192 185
193 $mod &= CFClient::KMOD_CTRL | CFClient::KMOD_ALT | CFClient::KMOD_SHIFT; 186 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
194 187
195 if ($uni == ord "\t") { 188 if ($uni == ord "\t") {
196 $::PL_WINDOW->toggle_visibility; 189 $::PL_WINDOW->toggle_visibility;
197 } elsif ($sym == CFClient::SDLK_F1 && !$mod) { 190 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
198 $::HELP_WINDOW->toggle_visibility; 191 $::HELP_WINDOW->toggle_visibility;
199 } elsif ($sym == CFClient::SDLK_F2 && !$mod) { 192 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
200 ::toggle_player_page ($::STATS_PAGE); 193 ::toggle_player_page ($::STATS_PAGE);
201 } elsif ($sym == CFClient::SDLK_F3 && !$mod) { 194 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
202 ::toggle_player_page ($::SKILL_PAGE); 195 ::toggle_player_page ($::SKILL_PAGE);
203 } elsif ($sym == CFClient::SDLK_F4 && !$mod) { 196 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
204 ::toggle_player_page ($::SPELL_PAGE); 197 ::toggle_player_page ($::SPELL_PAGE);
205 } elsif ($sym == CFClient::SDLK_F5 && !$mod) { 198 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
206 ::toggle_player_page ($::INVENTORY_PAGE); 199 ::toggle_player_page ($::INVENTORY_PAGE);
207 } elsif ($sym == CFClient::SDLK_F9 && !$mod) { 200 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
208 $::SETUP_DIALOG->toggle_visibility; 201 $::SETUP_DIALOG->toggle_visibility;
209 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 202 } elsif ($sym == CFPlus::SDLK_INSERT && $mod & CFPlus::KMOD_CTRL) {
210 $::BIND_EDITOR->set_binding (undef, undef, [], 203 $::BIND_EDITOR->set_binding (undef, undef, [],
211 sub { 204 sub {
212 my ($mod, $sym, $cmds) = @_; 205 my ($mod, $sym, $cmds) = @_;
213 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); 206 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
214 }); 207 });
215 $::BIND_EDITOR->start; 208 $::BIND_EDITOR->start;
216 $::BIND_EDITOR->show; 209 $::BIND_EDITOR->show;
217 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { 210 } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) {
218 $::BIND_EDITOR->stop; 211 $::BIND_EDITOR->stop;
219 $::BIND_EDITOR->ask_for_bind_and_commit; 212 $::BIND_EDITOR->ask_for_bind_and_commit;
220 $::BIND_EDITOR->hide; 213 $::BIND_EDITOR->hide;
221 } elsif (!$::CONN) { 214 } elsif (!$::CONN) {
222 return 0; # bindings further down need a valid connection 215 return 0; # bindings further down need a valid connection
223 216
224 } elsif ($sym == CFClient::SDLK_KP5 && !$mod) { 217 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) {
225 $::CONN->user_send ("stay fire"); 218 $::CONN->user_send ("stay fire");
226 } elsif ($uni == ord ",") { 219 } elsif ($uni == ord ",") {
227 $::CONN->user_send ("take"); 220 $::CONN->user_send ("take");
228 } elsif ($uni == ord " ") { 221 } elsif ($uni == ord " ") {
229 $::CONN->user_send ("apply"); 222 $::CONN->user_send ("apply");
230 } elsif ($uni == ord ".") { 223 } elsif ($uni == ord ".") {
231 $::CONN->user_send ($self->{completer}{last_command}) 224 $::CONN->user_send ($self->{completer}{last_command})
232 if exists $self->{completer}{last_command}; 225 if exists $self->{completer}{last_command};
233 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { 226 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
234 $::CONN->user_send ($_) for @$bind_cmd; 227 $::CONN->user_send ($_) for @$bind_cmd;
235 } elsif (($sym == CFClient::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { 228 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
236 $::CONN->user_send ("rotateshoottype +"); 229 $::CONN->user_send ("rotateshoottype +");
237 } elsif (($sym == CFClient::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { 230 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
238 $::CONN->user_send ("rotateshoottype -"); 231 $::CONN->user_send ("rotateshoottype -");
239 } elsif ($uni == ord '"') { 232 } elsif ($uni == ord '"') {
240 $self->{completer}->set_prefix ("$::CFG->{say_command} "); 233 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
241 $self->{completer}->show; 234 $self->{completer}->show;
242 } elsif ($uni == ord "'") { 235 } elsif ($uni == ord "'") {
243 $self->{completer}->set_prefix (""); 236 $self->{completer}->set_prefix ("");
244 $self->{completer}->show; 237 $self->{completer}->show;
245 } elsif (exists $DIR{$sym}) { 238 } elsif (exists $DIR{$sym}) {
246 if ($mod & CFClient::KMOD_SHIFT) { 239 if ($mod & CFPlus::KMOD_SHIFT) {
247 $self->{shft}++; 240 $self->{shft}++;
248 if ($DIR{$sym}[0] != $self->{fire_dir}) { 241 if ($DIR{$sym}[0] != $self->{fire_dir}) {
249 $::CONN->user_send ("fire $DIR{$sym}[0]"); 242 $::CONN->user_send ("fire $DIR{$sym}[0]");
250 } 243 }
251 $self->{fire_dir} = $DIR{$sym}[0]; 244 $self->{fire_dir} = $DIR{$sym}[0];
252 } elsif ($mod & CFClient::KMOD_CTRL) { 245 } elsif ($mod & CFPlus::KMOD_CTRL) {
253 $self->{ctrl}++; 246 $self->{ctrl}++;
254 $::CONN->user_send ("run $DIR{$sym}[0]"); 247 $::CONN->user_send ("run $DIR{$sym}[0]");
255 } else { 248 } else {
256 $::CONN->user_send ("$DIR{$sym}[1]"); 249 $::CONN->user_send ("$DIR{$sym}[1]");
257 } 250 }
271 my $res = 0; 264 my $res = 0;
272 my $mod = $ev->{mod}; 265 my $mod = $ev->{mod};
273 my $sym = $ev->{sym}; 266 my $sym = $ev->{sym};
274 267
275 if ($::CFG->{shift_fire_stop}) { 268 if ($::CFG->{shift_fire_stop}) {
276 if (!($mod & CFClient::KMOD_SHIFT) && delete $self->{shft}) { 269 if (!($mod & CFPlus::KMOD_SHIFT) && delete $self->{shft}) {
277 $::CONN->user_send ("fire_stop"); 270 $::CONN->user_send ("fire_stop");
278 delete $self->{fire_dir}; 271 delete $self->{fire_dir};
279 $res = 1; 272 $res = 1;
280 } 273 }
281 } else { 274 } else {
282 if (exists $DIR{$sym} && delete $self->{shft}) { 275 if (exists $DIR{$sym} && delete $self->{shft}) {
283 $::CONN->user_send ("fire_stop"); 276 $::CONN->user_send ("fire_stop");
284 delete $self->{fire_dir}; 277 delete $self->{fire_dir};
285 $res = 1; 278 $res = 1;
286 } elsif (($sym == CFClient::SDLK_LSHIFT || $sym == CFClient::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok? 279 } elsif (($sym == CFPlus::SDLK_LSHIFT || $sym == CFPlus::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok?
287 $::CONN->user_send ("fire_stop"); 280 $::CONN->user_send ("fire_stop");
288 delete $self->{fire_dir}; 281 delete $self->{fire_dir};
289 $res = 1; 282 $res = 1;
290 } 283 }
291 } 284 }
292 285
293 if (!($mod & CFClient::KMOD_CTRL ) && delete $self->{ctrl}) { 286 if (!($mod & CFPlus::KMOD_CTRL ) && delete $self->{ctrl}) {
294 $::CONN->user_send ("run_stop"); 287 $::CONN->user_send ("run_stop");
295 $res = 1; 288 $res = 1;
296 } 289 }
297 290
298 $res 291 $res
312sub draw { 305sub draw {
313 my ($self) = @_; 306 my ($self) = @_;
314 307
315 return unless $::MAP; 308 return unless $::MAP;
316 309
317 my $focused = $CFClient::UI::FOCUS == $self 310 my $focused = $CFPlus::UI::FOCUS == $self
318 || $CFClient::UI::FOCUS == $self->{completer}{entry}; 311 || $CFPlus::UI::FOCUS == $self->{completer}{entry};
319 312
320 return 313 return
321 unless $focused || !$::FAST; 314 unless $focused || !$::FAST;
322 315
323 if (delete $self->{need_update}) { 316 if (delete $self->{need_update}) {
324 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 317 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale};
325 318
326 my $sx = $self->{sx} = CFClient::ceil $::CFG->{map_shift_x} / $tilesize; 319 my $sx = $self->{sx} = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
327 my $sy = $self->{sy} = CFClient::ceil $::CFG->{map_shift_y} / $tilesize; 320 my $sy = $self->{sy} = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
328 321
329 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 322 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
330 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 323 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
331 324
332 my $sw = $self->{sw} = 1 + CFClient::ceil $self->{w} / $tilesize; 325 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
333 my $sh = $self->{sh} = 1 + CFClient::ceil $self->{h} / $tilesize; 326 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
334 327
335 if ($::CFG->{fow_enable}) { 328 if ($::CFG->{fow_enable}) {
336 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); 329 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh);
337 330
338 if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war 331 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
339 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 332 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
340 glConvolutionFilter2D ( 333 glConvolutionFilter2D (
341 GL_CONVOLUTION_2D, 334 GL_CONVOLUTION_2D,
342 GL_ALPHA, 335 GL_ALPHA,
343 3, 3, 336 3, 3,
345 (pack "f*", @{ $self->{smooth_matrix} }), 338 (pack "f*", @{ $self->{smooth_matrix} }),
346 ); 339 );
347 glEnable GL_CONVOLUTION_2D; 340 glEnable GL_CONVOLUTION_2D;
348 } 341 }
349 342
350 $self->{fow_texture} = new CFClient::Texture 343 $self->{fow_texture} = new CFPlus::Texture
351 w => $w, 344 w => $w,
352 h => $h, 345 h => $h,
353 data => $data, 346 data => $data,
354 internalformat => GL_ALPHA, 347 internalformat => GL_ALPHA,
355 format => GL_ALPHA; 348 format => GL_ALPHA;
417 glDeleteList $self->{list}; 410 glDeleteList $self->{list};
418 411
419 $self->SUPER::DESTROY; 412 $self->SUPER::DESTROY;
420} 413}
421 414
422package CFClient::MapWidget::MapMap; 415package CFPlus::MapWidget::MapMap;
423 416
424our @ISA = CFClient::UI::Base::; 417our @ISA = CFPlus::UI::Base::;
425 418
426use Time::HiRes qw(time); 419use Time::HiRes qw(time);
427use CFClient::OpenGL; 420use CFPlus::OpenGL;
428 421
429sub size_request { 422sub size_request {
430 ($::HEIGHT * 0.25, $::HEIGHT * 0.25) 423 ($::HEIGHT * 0.25, $::HEIGHT * 0.25)
431} 424}
432 425
468 461
469 if ($self->{texture_atime} < time) { 462 if ($self->{texture_atime} < time) {
470 $self->{texture_atime} = time + 1/3; 463 $self->{texture_atime} = time + 1/3;
471 464
472 $self->{texture} = 465 $self->{texture} =
473 new CFClient::Texture 466 new CFPlus::Texture
474 w => $w, 467 w => $w,
475 h => $h, 468 h => $h,
476 data => $::MAP->mapmap (-$ox, -$oy, $w, $h), 469 data => $::MAP->mapmap (-$ox, -$oy, $w, $h),
477 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; 470 type => $CFPlus::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
478 } 471 }
479 472
480 $self->{texture}->draw_quad (0, 0); 473 $self->{texture}->draw_quad (0, 0);
481 474
482 glDisable GL_TEXTURE_2D; 475 glDisable GL_TEXTURE_2D;
497 glEnd; 490 glEnd;
498 491
499 glDisable GL_BLEND; 492 glDisable GL_BLEND;
500} 493}
501 494
502package CFClient::MapWidget::Command; 495package CFPlus::MapWidget::Command;
503 496
504use strict; 497use strict;
505 498
506use CFClient::OpenGL; 499use CFPlus::OpenGL;
507 500
508our @ISA = CFClient::UI::Frame::; 501our @ISA = CFPlus::UI::Frame::;
509 502
510sub new { 503sub new {
511 my $class = shift; 504 my $class = shift;
512 505
513 my $self = $class->SUPER::new ( 506 my $self = $class->SUPER::new (
514 bg => [0, 0, 0, 0.8], 507 bg => [0, 0, 0, 0.8],
515 @_, 508 @_,
516 ); 509 );
517 510
518 $self->add ($self->{vbox} = new CFClient::UI::VBox); 511 $self->add ($self->{vbox} = new CFPlus::UI::VBox);
519 512
520 $self->{label} = [ 513 $self->{label} = [
521 map 514 map
522 CFClient::UI::Label->new ( 515 CFPlus::UI::Label->new (
523 can_hover => 1, 516 can_hover => 1,
524 can_events => 1, 517 can_events => 1,
525 tooltip_width => 0.33, 518 tooltip_width => 0.33,
526 fontsize => $_, 519 fontsize => $_,
527 ), (0.8) x 16 520 ), (0.8) x 16
528 ]; 521 ];
529 522
530 $self->{entry} = new CFClient::UI::Entry 523 $self->{entry} = new CFPlus::UI::Entry
531 on_changed => sub { 524 on_changed => sub {
532 $self->update_labels; 525 $self->update_labels;
533 0 526 0
534 }, 527 },
535 on_button_down => sub { 528 on_button_down => sub {
536 my ($entry, $ev, $x, $y) = @_; 529 my ($entry, $ev, $x, $y) = @_;
537 530
538 if ($ev->{button} == 3) { 531 if ($ev->{button} == 3) {
539 (new CFClient::UI::Menu 532 (new CFPlus::UI::Menu
540 items => [ 533 items => [
541 ["bind <i>" . (CFClient::asxml $self->{select}) . "</i> to a key" 534 ["bind <i>" . (CFPlus::asxml $self->{select}) . "</i> to a key"
542 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 535 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
543 ], 536 ],
544 )->popup ($ev); 537 )->popup ($ev);
545 return 1; 538 return 1;
546 } 539 }
562 $self->hide; 555 $self->hide;
563 } 556 }
564 } elsif ($ev->{sym} == 27) { 557 } elsif ($ev->{sym} == 27) {
565 $self->{hist_ptr} = 0; 558 $self->{hist_ptr} = 0;
566 $self->hide; 559 $self->hide;
567 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 560 } elsif ($ev->{sym} == CFPlus::SDLK_DOWN) {
568 if ($self->{hist_ptr} > 1) { 561 if ($self->{hist_ptr} > 1) {
569 $self->{hist_ptr}--; 562 $self->{hist_ptr}--;
570 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); 563 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
571 } elsif ($self->{hist_ptr} > 0) { 564 } elsif ($self->{hist_ptr} > 0) {
572 $self->{hist_ptr}--; 565 $self->{hist_ptr}--;
574 } else { 567 } else {
575 ++$self->{select_offset} 568 ++$self->{select_offset}
576 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 569 if $self->{select_offset} < $#{ $self->{last_match} || [] };
577 } 570 }
578 $self->update_labels; 571 $self->update_labels;
579 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 572 } elsif ($ev->{sym} == CFPlus::SDLK_UP) {
580 if ($self->{select_offset}) { 573 if ($self->{select_offset}) {
581 --$self->{select_offset} 574 --$self->{select_offset}
582 } else { 575 } else {
583 unless ($self->{hist_ptr}) { 576 unless ($self->{hist_ptr}) {
584 $self->{hist_saveback} = $self->{entry}->get_text; 577 $self->{hist_saveback} = $self->{entry}->get_text;
742 735
743sub _draw { 736sub _draw {
744 my ($self) = @_; 737 my ($self) = @_;
745 738
746 # hack 739 # hack
747 local $CFClient::UI::FOCUS = $self->{entry}; 740 local $CFPlus::UI::FOCUS = $self->{entry};
748 741
749 $self->SUPER::_draw; 742 $self->SUPER::_draw;
750} 743}
751 744
7521 7451

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines