… | |
… | |
22 | my $self = $class->SUPER::new ( |
22 | my $self = $class->SUPER::new ( |
23 | z => -1, |
23 | z => -1, |
24 | can_focus => 1, |
24 | can_focus => 1, |
25 | list => glGenList, |
25 | list => glGenList, |
26 | tilesize => 32, |
26 | tilesize => 32, |
27 | |
|
|
28 | smooth_matrix => [ |
|
|
29 | 0.30, 0.50, 0.30, |
|
|
30 | 0.50, 0.50, 0.50, |
|
|
31 | 0.30, 0.50, 0.30, |
|
|
32 | ], |
|
|
33 | |
|
|
34 | @_ |
27 | @_ |
35 | ); |
28 | ); |
36 | |
29 | |
37 | $self->{completer} = new CFPlus::MapWidget::Command:: |
30 | $self->{completer} = new CFPlus::MapWidget::Command:: |
38 | command => $self->{command}, |
31 | command => $self->{command}, |
… | |
… | |
308 | $self->{need_update} = 1; |
301 | $self->{need_update} = 1; |
309 | $self->SUPER::update; |
302 | $self->SUPER::update; |
310 | } |
303 | } |
311 | |
304 | |
312 | my %DIR = ( |
305 | my %DIR = ( |
313 | CFPlus::SDLK_KP5, [0, "stay fire"], |
306 | ( "," . CFPlus::SDLK_KP5 ), [0, "stay fire"], |
314 | CFPlus::SDLK_KP8, [1, "north"], |
307 | ( "," . CFPlus::SDLK_KP8 ), [1, "north"], |
315 | CFPlus::SDLK_KP9, [2, "northeast"], |
308 | ( "," . CFPlus::SDLK_KP9 ), [2, "northeast"], |
316 | CFPlus::SDLK_KP6, [3, "east"], |
309 | ( "," . CFPlus::SDLK_KP6 ), [3, "east"], |
317 | CFPlus::SDLK_KP3, [4, "southeast"], |
310 | ( "," . CFPlus::SDLK_KP3 ), [4, "southeast"], |
318 | CFPlus::SDLK_KP2, [5, "south"], |
311 | ( "," . CFPlus::SDLK_KP2 ), [5, "south"], |
319 | CFPlus::SDLK_KP1, [6, "southwest"], |
312 | ( "," . CFPlus::SDLK_KP1 ), [6, "southwest"], |
320 | CFPlus::SDLK_KP4, [7, "west"], |
313 | ( "," . CFPlus::SDLK_KP4 ), [7, "west"], |
321 | CFPlus::SDLK_KP7, [8, "northwest"], |
314 | ( "," . CFPlus::SDLK_KP7 ), [8, "northwest"], |
322 | |
315 | |
323 | CFPlus::SDLK_UP, [1, "north"], |
316 | ( "," . CFPlus::SDLK_UP ), [1, "north"], |
|
|
317 | ("1," . CFPlus::SDLK_UP ), [2, "northeast"], |
324 | CFPlus::SDLK_RIGHT, [3, "east"], |
318 | ( "," . CFPlus::SDLK_RIGHT), [3, "east"], |
|
|
319 | ("1," . CFPlus::SDLK_RIGHT), [4, "southeast"], |
325 | CFPlus::SDLK_DOWN, [5, "south"], |
320 | ( "," . CFPlus::SDLK_DOWN ), [5, "south"], |
|
|
321 | ("1," . CFPlus::SDLK_DOWN ), [6, "southwest"], |
326 | CFPlus::SDLK_LEFT, [7, "west"], |
322 | ( "," . CFPlus::SDLK_LEFT ), [7, "west"], |
|
|
323 | ("1," . CFPlus::SDLK_LEFT ), [8, "northwest"], |
327 | ); |
324 | ); |
328 | |
325 | |
329 | sub invoke_key_down { |
326 | sub invoke_key_down { |
330 | my ($self, $ev) = @_; |
327 | my ($self, $ev) = @_; |
331 | |
328 | |
… | |
… | |
334 | my $uni = $ev->{unicode}; |
331 | my $uni = $ev->{unicode}; |
335 | |
332 | |
336 | $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; |
333 | $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; |
337 | |
334 | |
338 | if ($sym == 9) { |
335 | if ($sym == 9) { |
339 | ($mod & CFPlus::KMOD_SHIFT ? $::CONSOLE->{window} : $::PL_WINDOW)->toggle_visibility; |
336 | ($mod & CFPlus::KMOD_SHIFT ? $::MESSAGE_WINDOW : $::PL_WINDOW)->toggle_visibility; |
340 | } elsif ($sym == CFPlus::SDLK_F1 && !$mod) { |
337 | } elsif ($sym == CFPlus::SDLK_F1 && !$mod) { |
341 | $::HELP_WINDOW->toggle_visibility; |
338 | $::HELP_WINDOW->toggle_visibility; |
342 | } elsif ($sym == CFPlus::SDLK_F2 && !$mod) { |
339 | } elsif ($sym == CFPlus::SDLK_F2 && !$mod) { |
343 | ::toggle_player_page ($::STATS_PAGE); |
340 | ::toggle_player_page ($::STATS_PAGE); |
344 | } elsif ($sym == CFPlus::SDLK_F3 && !$mod) { |
341 | } elsif ($sym == CFPlus::SDLK_F3 && !$mod) { |
… | |
… | |
374 | $self->{completer}->set_prefix ("$::CFG->{say_command} "); |
371 | $self->{completer}->set_prefix ("$::CFG->{say_command} "); |
375 | $self->{completer}->show; |
372 | $self->{completer}->show; |
376 | } elsif ($uni == ord "'") { |
373 | } elsif ($uni == ord "'") { |
377 | $self->{completer}->set_prefix (""); |
374 | $self->{completer}->set_prefix (""); |
378 | $self->{completer}->show; |
375 | $self->{completer}->show; |
379 | } elsif (exists $DIR{$sym}) { |
376 | } elsif (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"}) { |
380 | if ($mod & CFPlus::KMOD_SHIFT) { |
377 | if ($mod & CFPlus::KMOD_SHIFT) { |
381 | $self->{shft}++; |
378 | $self->{shft}++; |
382 | if ($DIR{$sym}[0] != $self->{fire_dir}) { |
379 | if ($dir->[0] != $self->{fire_dir}) { |
383 | $::CONN->user_send ("fire $DIR{$sym}[0]"); |
380 | $::CONN->user_send ("fire $dir->[0]"); |
384 | } |
381 | } |
385 | $self->{fire_dir} = $DIR{$sym}[0]; |
382 | $self->{fire_dir} = $DIR{$sym}[0]; |
386 | } elsif ($mod & CFPlus::KMOD_CTRL) { |
383 | } elsif ($mod & CFPlus::KMOD_CTRL) { |
387 | $self->{ctrl}++; |
384 | $self->{ctrl}++; |
388 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
385 | $::CONN->user_send ("run $dir->[0]"); |
389 | } else { |
386 | } else { |
390 | $::CONN->user_send ("$DIR{$sym}[1]"); |
387 | $::CONN->user_send ("$dir->[1]"); |
391 | } |
388 | } |
392 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
389 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
393 | $self->{completer}->inject_key_down ($ev); |
390 | $self->{completer}->inject_key_down ($ev); |
394 | $self->{completer}->show; |
391 | $self->{completer}->show; |
395 | } else { |
392 | } else { |
… | |
… | |
470 | |
467 | |
471 | my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx; |
468 | my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx; |
472 | my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy; |
469 | my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy; |
473 | |
470 | |
474 | if ($::CFG->{fow_enable}) { |
471 | if ($::CFG->{fow_enable}) { |
475 | my ($w, $h, $data) = $::MAP->fow_texture ( |
472 | my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh); |
476 | $dx, $dy, $sw, $sh, |
|
|
477 | $::CFG->{fow_smooth}, |
|
|
478 | pack "f*", @{ $self->{smooth_matrix} }, |
|
|
479 | ); |
|
|
480 | |
473 | |
481 | $self->{fow_texture} = new CFPlus::Texture |
474 | $self->{fow_texture} = new CFPlus::Texture |
482 | w => $w, |
475 | w => $w, |
483 | h => $h, |
476 | h => $h, |
484 | data => $data, |
477 | data => $data, |
… | |
… | |
498 | |
491 | |
499 | glScale $self->{tilesize}, $self->{tilesize}; |
492 | glScale $self->{tilesize}, $self->{tilesize}; |
500 | |
493 | |
501 | if (my $tex = $self->{fow_texture}) { |
494 | if (my $tex = $self->{fow_texture}) { |
502 | glPushMatrix; |
495 | glPushMatrix; |
503 | #glScale 1/3, 1/3 if $::CFG->{fow_smooth}; |
496 | glScale 1/3, 1/3; |
504 | glEnable GL_TEXTURE_2D; |
497 | glEnable GL_TEXTURE_2D; |
505 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
498 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
506 | |
499 | |
507 | glColor +($::CFG->{fow_intensity}) x 3, 0.9; |
500 | glColor +($::CFG->{fow_intensity}) x 3, 0.9; |
508 | $self->{fow_texture}->draw_quad_alpha (0, 0); |
501 | $self->{fow_texture}->draw_quad_alpha (0, 0); |
… | |
… | |
575 | |
568 | |
576 | use Time::HiRes qw(time); |
569 | use Time::HiRes qw(time); |
577 | use CFPlus::OpenGL; |
570 | use CFPlus::OpenGL; |
578 | |
571 | |
579 | sub size_request { |
572 | sub size_request { |
580 | ($::HEIGHT * 0.25, $::HEIGHT * 0.25) |
573 | ($::HEIGHT * 0.2, $::HEIGHT * 0.2) |
581 | } |
574 | } |
582 | |
575 | |
583 | sub refresh_hook { |
576 | sub refresh_hook { |
584 | my ($self) = @_; |
577 | my ($self) = @_; |
585 | |
578 | |