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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines