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.78 by root, Sun Jul 23 16:11:12 2006 UTC vs.
Revision 1.82 by root, Fri Sep 29 00:56:06 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) }],
115 $::PICKUP_ENABLE->{state} 108 $::PICKUP_ENABLE->{state}
116 ? "Disable automatic pickup" 109 ? "Disable automatic pickup"
117 : "Enable automatic pickup", 110 : "Enable automatic pickup",
118 sub { $::PICKUP_ENABLE->toggle } 111 sub { $::PICKUP_ENABLE->toggle }
119 ], 112 ],
113 ["Quit",
114 sub {
115 if ($::CONN) {
116 &::open_quit_dialog;
117 } else {
118 exit;
119 }
120 }
121 ],
120 ], 122 ],
121 )->popup ($ev); 123 )->popup ($ev);
122 } 124 }
123 125
124 1 126 1
144 1 146 1
145} 147}
146 148
147sub size_request { 149sub size_request {
148 ( 150 (
149 32 * CFClient::ceil $::WIDTH / 32, 151 32 * CFPlus::ceil $::WIDTH / 32,
150 32 * CFClient::ceil $::HEIGHT / 32, 152 32 * CFPlus::ceil $::HEIGHT / 32,
151 ) 153 )
152} 154}
153 155
154sub update { 156sub update {
155 my ($self) = @_; 157 my ($self) = @_;
157 $self->{need_update} = 1; 159 $self->{need_update} = 1;
158 $self->SUPER::update; 160 $self->SUPER::update;
159} 161}
160 162
161my %DIR = ( 163my %DIR = (
162 CFClient::SDLK_KP8, [1, "north"], 164 CFPlus::SDLK_KP8, [1, "north"],
163 CFClient::SDLK_KP9, [2, "northeast"], 165 CFPlus::SDLK_KP9, [2, "northeast"],
164 CFClient::SDLK_KP6, [3, "east"], 166 CFPlus::SDLK_KP6, [3, "east"],
165 CFClient::SDLK_KP3, [4, "southeast"], 167 CFPlus::SDLK_KP3, [4, "southeast"],
166 CFClient::SDLK_KP2, [5, "south"], 168 CFPlus::SDLK_KP2, [5, "south"],
167 CFClient::SDLK_KP1, [6, "southwest"], 169 CFPlus::SDLK_KP1, [6, "southwest"],
168 CFClient::SDLK_KP4, [7, "west"], 170 CFPlus::SDLK_KP4, [7, "west"],
169 CFClient::SDLK_KP7, [8, "northwest"], 171 CFPlus::SDLK_KP7, [8, "northwest"],
170 172
171 CFClient::SDLK_UP, [1, "north"], 173 CFPlus::SDLK_UP, [1, "north"],
172 CFClient::SDLK_RIGHT, [3, "east"], 174 CFPlus::SDLK_RIGHT, [3, "east"],
173 CFClient::SDLK_DOWN, [5, "south"], 175 CFPlus::SDLK_DOWN, [5, "south"],
174 CFClient::SDLK_LEFT, [7, "west"], 176 CFPlus::SDLK_LEFT, [7, "west"],
175); 177);
176 178
177sub invoke_key_down { 179sub invoke_key_down {
178 my ($self, $ev) = @_; 180 my ($self, $ev) = @_;
179 181
180 my $mod = $ev->{mod}; 182 my $mod = $ev->{mod};
181 my $sym = $ev->{sym}; 183 my $sym = $ev->{sym};
182 my $uni = $ev->{unicode}; 184 my $uni = $ev->{unicode};
183 185
184 $mod &= CFClient::KMOD_CTRL | CFClient::KMOD_ALT | CFClient::KMOD_SHIFT; 186 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
185 187
186 if ($uni == ord "\t") { 188 if ($uni == ord "\t") {
187 $::PL_WINDOW->toggle_visibility; 189 $::PL_WINDOW->toggle_visibility;
188 } elsif ($sym == CFClient::SDLK_F1 && !$mod) { 190 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
189 $::HELP_WINDOW->toggle_visibility; 191 $::HELP_WINDOW->toggle_visibility;
190 } elsif ($sym == CFClient::SDLK_F2 && !$mod) { 192 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
191 ::toggle_player_page ($::STATS_PAGE); 193 ::toggle_player_page ($::STATS_PAGE);
192 } elsif ($sym == CFClient::SDLK_F3 && !$mod) { 194 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
193 ::toggle_player_page ($::SKILL_PAGE); 195 ::toggle_player_page ($::SKILL_PAGE);
194 } elsif ($sym == CFClient::SDLK_F4 && !$mod) { 196 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
195 ::toggle_player_page ($::SPELL_PAGE); 197 ::toggle_player_page ($::SPELL_PAGE);
196 } elsif ($sym == CFClient::SDLK_F5 && !$mod) { 198 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
197 ::toggle_player_page ($::INVENTORY_PAGE); 199 ::toggle_player_page ($::INVENTORY_PAGE);
198 } elsif ($sym == CFClient::SDLK_F9 && !$mod) { 200 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
199 $::SETUP_DIALOG->toggle_visibility; 201 $::SETUP_DIALOG->toggle_visibility;
200 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 202 } elsif ($sym == CFPlus::SDLK_INSERT && $mod & CFPlus::KMOD_CTRL) {
201 $::BIND_EDITOR->set_binding (undef, undef, [], 203 $::BIND_EDITOR->set_binding (undef, undef, [],
202 sub { 204 sub {
203 my ($mod, $sym, $cmds) = @_; 205 my ($mod, $sym, $cmds) = @_;
204 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); 206 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
205 }); 207 });
206 $::BIND_EDITOR->start; 208 $::BIND_EDITOR->start;
207 $::BIND_EDITOR->show; 209 $::BIND_EDITOR->show;
210#TODO: elmex, what was this supposed to do? it currently crashes the client.
208 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { 211# } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) {
209 $::BIND_EDITOR->stop; 212# $::BIND_EDITOR->stop;
210 $::BIND_EDITOR->ask_for_bind_and_commit; 213# $::BIND_EDITOR->ask_for_bind_and_commit;
211 $::BIND_EDITOR->hide; 214# $::BIND_EDITOR->hide;
212 } elsif (!$::CONN) { 215 } elsif (!$::CONN) {
213 return 0; # bindings further down need a valid connection 216 return 0; # bindings further down need a valid connection
214 217
215 } elsif ($sym == CFClient::SDLK_KP5 && !$mod) { 218 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) {
216 $::CONN->user_send ("stay fire"); 219 $::CONN->user_send ("stay fire");
217 } elsif ($uni == ord ",") { 220 } elsif ($uni == ord ",") {
218 $::CONN->user_send ("take"); 221 $::CONN->user_send ("take");
219 } elsif ($uni == ord " ") { 222 } elsif ($uni == ord " ") {
220 $::CONN->user_send ("apply"); 223 $::CONN->user_send ("apply");
224 } elsif ($uni == 13) {
225 $::CONN->user_send ("examine");
221 } elsif ($uni == ord ".") { 226 } elsif ($uni == ord ".") {
222 $::CONN->user_send ($self->{completer}{last_command}) 227 $::CONN->user_send ($self->{completer}{last_command})
223 if exists $self->{completer}{last_command}; 228 if exists $self->{completer}{last_command};
224 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { 229 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
225 $::CONN->user_send ($_) for @$bind_cmd; 230 $::CONN->user_send ($_) for @$bind_cmd;
226 } elsif (($sym == CFClient::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { 231 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
227 $::CONN->user_send ("rotateshoottype +"); 232 $::CONN->user_send ("rotateshoottype +");
228 } elsif (($sym == CFClient::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { 233 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
229 $::CONN->user_send ("rotateshoottype -"); 234 $::CONN->user_send ("rotateshoottype -");
230 } elsif ($uni == ord '"') { 235 } elsif ($uni == ord '"') {
231 $self->{completer}->set_prefix ("$::CFG->{say_command} "); 236 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
232 $self->{completer}->show; 237 $self->{completer}->show;
233 } elsif ($uni == ord "'") { 238 } elsif ($uni == ord "'") {
234 $self->{completer}->set_prefix (""); 239 $self->{completer}->set_prefix ("");
235 $self->{completer}->show; 240 $self->{completer}->show;
236 } elsif (exists $DIR{$sym}) { 241 } elsif (exists $DIR{$sym}) {
237 if ($mod & CFClient::KMOD_SHIFT) { 242 if ($mod & CFPlus::KMOD_SHIFT) {
238 $self->{shft}++; 243 $self->{shft}++;
239 if ($DIR{$sym}[0] != $self->{fire_dir}) { 244 if ($DIR{$sym}[0] != $self->{fire_dir}) {
240 $::CONN->user_send ("fire $DIR{$sym}[0]"); 245 $::CONN->user_send ("fire $DIR{$sym}[0]");
241 } 246 }
242 $self->{fire_dir} = $DIR{$sym}[0]; 247 $self->{fire_dir} = $DIR{$sym}[0];
243 } elsif ($mod & CFClient::KMOD_CTRL) { 248 } elsif ($mod & CFPlus::KMOD_CTRL) {
244 $self->{ctrl}++; 249 $self->{ctrl}++;
245 $::CONN->user_send ("run $DIR{$sym}[0]"); 250 $::CONN->user_send ("run $DIR{$sym}[0]");
246 } else { 251 } else {
247 $::CONN->user_send ("$DIR{$sym}[1]"); 252 $::CONN->user_send ("$DIR{$sym}[1]");
248 } 253 }
262 my $res = 0; 267 my $res = 0;
263 my $mod = $ev->{mod}; 268 my $mod = $ev->{mod};
264 my $sym = $ev->{sym}; 269 my $sym = $ev->{sym};
265 270
266 if ($::CFG->{shift_fire_stop}) { 271 if ($::CFG->{shift_fire_stop}) {
267 if (!($mod & CFClient::KMOD_SHIFT) && delete $self->{shft}) { 272 if (!($mod & CFPlus::KMOD_SHIFT) && delete $self->{shft}) {
268 $::CONN->user_send ("fire_stop"); 273 $::CONN->user_send ("fire_stop");
269 delete $self->{fire_dir}; 274 delete $self->{fire_dir};
270 $res = 1; 275 $res = 1;
271 } 276 }
272 } else { 277 } else {
273 if (exists $DIR{$sym} && delete $self->{shft}) { 278 if (exists $DIR{$sym} && delete $self->{shft}) {
274 $::CONN->user_send ("fire_stop"); 279 $::CONN->user_send ("fire_stop");
275 delete $self->{fire_dir}; 280 delete $self->{fire_dir};
276 $res = 1; 281 $res = 1;
277 } elsif (($sym == CFClient::SDLK_LSHIFT || $sym == CFClient::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok? 282 } elsif (($sym == CFPlus::SDLK_LSHIFT || $sym == CFPlus::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok?
278 $::CONN->user_send ("fire_stop"); 283 $::CONN->user_send ("fire_stop");
279 delete $self->{fire_dir}; 284 delete $self->{fire_dir};
280 $res = 1; 285 $res = 1;
281 } 286 }
282 } 287 }
283 288
284 if (!($mod & CFClient::KMOD_CTRL ) && delete $self->{ctrl}) { 289 if (!($mod & CFPlus::KMOD_CTRL ) && delete $self->{ctrl}) {
285 $::CONN->user_send ("run_stop"); 290 $::CONN->user_send ("run_stop");
286 $res = 1; 291 $res = 1;
287 } 292 }
288 293
289 $res 294 $res
303sub draw { 308sub draw {
304 my ($self) = @_; 309 my ($self) = @_;
305 310
306 return unless $::MAP; 311 return unless $::MAP;
307 312
308 my $focused = $CFClient::UI::FOCUS == $self 313 my $focused = $CFPlus::UI::FOCUS == $self
309 || $CFClient::UI::FOCUS == $self->{completer}{entry}; 314 || $CFPlus::UI::FOCUS == $self->{completer}{entry};
310 315
311 return 316 return
312 unless $focused || !$::FAST; 317 unless $focused || !$::FAST;
313 318
314 if (delete $self->{need_update}) { 319 if (delete $self->{need_update}) {
315 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 320 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale};
316 321
317 my $sx = $self->{sx} = CFClient::ceil $::CFG->{map_shift_x} / $tilesize; 322 my $sx = $self->{sx} = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
318 my $sy = $self->{sy} = CFClient::ceil $::CFG->{map_shift_y} / $tilesize; 323 my $sy = $self->{sy} = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
319 324
320 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 325 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
321 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 326 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
322 327
323 my $sw = $self->{sw} = 1 + CFClient::ceil $self->{w} / $tilesize; 328 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
324 my $sh = $self->{sh} = 1 + CFClient::ceil $self->{h} / $tilesize; 329 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
325 330
326 if ($::CFG->{fow_enable}) { 331 if ($::CFG->{fow_enable}) {
327 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); 332 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh);
328 333
329 if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war 334 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
330 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 335 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
331 glConvolutionFilter2D ( 336 glConvolutionFilter2D (
332 GL_CONVOLUTION_2D, 337 GL_CONVOLUTION_2D,
333 GL_ALPHA, 338 GL_ALPHA,
334 3, 3, 339 3, 3,
336 (pack "f*", @{ $self->{smooth_matrix} }), 341 (pack "f*", @{ $self->{smooth_matrix} }),
337 ); 342 );
338 glEnable GL_CONVOLUTION_2D; 343 glEnable GL_CONVOLUTION_2D;
339 } 344 }
340 345
341 $self->{fow_texture} = new CFClient::Texture 346 $self->{fow_texture} = new CFPlus::Texture
342 w => $w, 347 w => $w,
343 h => $h, 348 h => $h,
344 data => $data, 349 data => $data,
345 internalformat => GL_ALPHA, 350 internalformat => GL_ALPHA,
346 format => GL_ALPHA; 351 format => GL_ALPHA;
408 glDeleteList $self->{list}; 413 glDeleteList $self->{list};
409 414
410 $self->SUPER::DESTROY; 415 $self->SUPER::DESTROY;
411} 416}
412 417
413package CFClient::MapWidget::MapMap; 418package CFPlus::MapWidget::MapMap;
414 419
415our @ISA = CFClient::UI::Base::; 420our @ISA = CFPlus::UI::Base::;
416 421
417use Time::HiRes qw(time); 422use Time::HiRes qw(time);
418use CFClient::OpenGL; 423use CFPlus::OpenGL;
419 424
420sub size_request { 425sub size_request {
421 ($::HEIGHT * 0.25, $::HEIGHT * 0.25) 426 ($::HEIGHT * 0.25, $::HEIGHT * 0.25)
422} 427}
423 428
459 464
460 if ($self->{texture_atime} < time) { 465 if ($self->{texture_atime} < time) {
461 $self->{texture_atime} = time + 1/3; 466 $self->{texture_atime} = time + 1/3;
462 467
463 $self->{texture} = 468 $self->{texture} =
464 new CFClient::Texture 469 new CFPlus::Texture
465 w => $w, 470 w => $w,
466 h => $h, 471 h => $h,
467 data => $::MAP->mapmap (-$ox, -$oy, $w, $h), 472 data => $::MAP->mapmap (-$ox, -$oy, $w, $h),
468 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; 473 type => $CFPlus::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
469 } 474 }
470 475
471 $self->{texture}->draw_quad (0, 0); 476 $self->{texture}->draw_quad (0, 0);
472 477
473 glDisable GL_TEXTURE_2D; 478 glDisable GL_TEXTURE_2D;
488 glEnd; 493 glEnd;
489 494
490 glDisable GL_BLEND; 495 glDisable GL_BLEND;
491} 496}
492 497
493package CFClient::MapWidget::Command; 498package CFPlus::MapWidget::Command;
494 499
495use strict; 500use strict;
496 501
497use CFClient::OpenGL; 502use CFPlus::OpenGL;
498 503
499our @ISA = CFClient::UI::Frame::; 504our @ISA = CFPlus::UI::Frame::;
500 505
501sub new { 506sub new {
502 my $class = shift; 507 my $class = shift;
503 508
504 my $self = $class->SUPER::new ( 509 my $self = $class->SUPER::new (
505 bg => [0, 0, 0, 0.8], 510 bg => [0, 0, 0, 0.8],
506 @_, 511 @_,
507 ); 512 );
508 513
509 $self->add ($self->{vbox} = new CFClient::UI::VBox); 514 $self->add ($self->{vbox} = new CFPlus::UI::VBox);
510 515
511 $self->{label} = [ 516 $self->{label} = [
512 map 517 map
513 CFClient::UI::Label->new ( 518 CFPlus::UI::Label->new (
514 can_hover => 1, 519 can_hover => 1,
515 can_events => 1, 520 can_events => 1,
516 tooltip_width => 0.33, 521 tooltip_width => 0.33,
517 fontsize => $_, 522 fontsize => $_,
518 ), (0.8) x 16 523 ), (0.8) x 16
519 ]; 524 ];
520 525
521 $self->{entry} = new CFClient::UI::Entry 526 $self->{entry} = new CFPlus::UI::Entry
522 on_changed => sub { 527 on_changed => sub {
523 $self->update_labels; 528 $self->update_labels;
524 0 529 0
525 }, 530 },
526 on_button_down => sub { 531 on_button_down => sub {
527 my ($entry, $ev, $x, $y) = @_; 532 my ($entry, $ev, $x, $y) = @_;
528 533
529 if ($ev->{button} == 3) { 534 if ($ev->{button} == 3) {
530 (new CFClient::UI::Menu 535 (new CFPlus::UI::Menu
531 items => [ 536 items => [
532 ["bind <i>" . (CFClient::asxml $self->{select}) . "</i> to a key" 537 ["bind <i>" . (CFPlus::asxml $self->{select}) . "</i> to a key"
533 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 538 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
534 ], 539 ],
535 )->popup ($ev); 540 )->popup ($ev);
536 return 1; 541 return 1;
537 } 542 }
553 $self->hide; 558 $self->hide;
554 } 559 }
555 } elsif ($ev->{sym} == 27) { 560 } elsif ($ev->{sym} == 27) {
556 $self->{hist_ptr} = 0; 561 $self->{hist_ptr} = 0;
557 $self->hide; 562 $self->hide;
558 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 563 } elsif ($ev->{sym} == CFPlus::SDLK_DOWN) {
559 if ($self->{hist_ptr} > 1) { 564 if ($self->{hist_ptr} > 1) {
560 $self->{hist_ptr}--; 565 $self->{hist_ptr}--;
561 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); 566 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
562 } elsif ($self->{hist_ptr} > 0) { 567 } elsif ($self->{hist_ptr} > 0) {
563 $self->{hist_ptr}--; 568 $self->{hist_ptr}--;
565 } else { 570 } else {
566 ++$self->{select_offset} 571 ++$self->{select_offset}
567 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 572 if $self->{select_offset} < $#{ $self->{last_match} || [] };
568 } 573 }
569 $self->update_labels; 574 $self->update_labels;
570 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 575 } elsif ($ev->{sym} == CFPlus::SDLK_UP) {
571 if ($self->{select_offset}) { 576 if ($self->{select_offset}) {
572 --$self->{select_offset} 577 --$self->{select_offset}
573 } else { 578 } else {
574 unless ($self->{hist_ptr}) { 579 unless ($self->{hist_ptr}) {
575 $self->{hist_saveback} = $self->{entry}->get_text; 580 $self->{hist_saveback} = $self->{entry}->get_text;
733 738
734sub _draw { 739sub _draw {
735 my ($self) = @_; 740 my ($self) = @_;
736 741
737 # hack 742 # hack
738 local $CFClient::UI::FOCUS = $self->{entry}; 743 local $CFPlus::UI::FOCUS = $self->{entry};
739 744
740 $self->SUPER::_draw; 745 $self->SUPER::_draw;
741} 746}
742 747
7431 7481

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines