… | |
… | |
14 | |
14 | |
15 | my $self = $class->SUPER::new ( |
15 | my $self = $class->SUPER::new ( |
16 | z => -1, |
16 | z => -1, |
17 | can_focus => 1, |
17 | can_focus => 1, |
18 | list => glGenList, |
18 | list => glGenList, |
|
|
19 | |
|
|
20 | smooth_matrix => [ |
|
|
21 | 0.05, 0.13, 0.05, |
|
|
22 | 0.13, 0.30, 0.13, |
|
|
23 | 0.05, 0.13, 0.05, |
|
|
24 | ], |
|
|
25 | |
19 | @_ |
26 | @_ |
20 | ); |
27 | ); |
21 | |
28 | |
22 | $self->{completer} = new CFClient::MapWidget::Command:: |
29 | $self->{completer} = new CFClient::MapWidget::Command:: |
23 | command => $self->{command}, |
30 | command => $self->{command}, |
… | |
… | |
56 | sub button_down { |
63 | sub button_down { |
57 | my ($self, $ev, $x, $y) = @_; |
64 | my ($self, $ev, $x, $y) = @_; |
58 | |
65 | |
59 | $self->focus_in; |
66 | $self->focus_in; |
60 | |
67 | |
61 | if ($ev->{button} == 2) { |
68 | if ($ev->{button} == 1) { |
|
|
69 | my $x = int +($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale}); |
|
|
70 | my $y = int +($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale}); |
|
|
71 | |
|
|
72 | $x += int 0.5 * ($::MAP->w - $self->{sw} - 1); |
|
|
73 | $y += int 0.5 * ($::MAP->h - $self->{sh} - 1); |
|
|
74 | |
|
|
75 | $x -= int 0.5 * $::MAP->w; |
|
|
76 | $y -= int 0.5 * $::MAP->h; |
|
|
77 | |
|
|
78 | $x += 1; |
|
|
79 | $y += 1; |
|
|
80 | |
|
|
81 | $::CONN->send ("lookat $x $y") |
|
|
82 | if $::CONN; |
|
|
83 | |
|
|
84 | } elsif ($ev->{button} == 2) { |
62 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
85 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
63 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
86 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
64 | |
87 | |
65 | $self->{motion} = sub { |
88 | $self->{motion} = sub { |
66 | my ($ev, $x, $y) = @_; |
89 | my ($ev, $x, $y) = @_; |
… | |
… | |
222 | |
245 | |
223 | if (delete $self->{need_update}) { |
246 | if (delete $self->{need_update}) { |
224 | glNewList $self->{list}; |
247 | glNewList $self->{list}; |
225 | |
248 | |
226 | if ($::MAP) { |
249 | if ($::MAP) { |
227 | my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; |
250 | my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; |
228 | my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; |
251 | my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; |
229 | |
252 | |
230 | my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; |
253 | my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; |
231 | my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; |
254 | my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; |
|
|
255 | my $sx0 = $self->{sx0} = ($sx & 31) - 32; $sx = $self->{sx} = ($sx - $sx0) / 32; |
|
|
256 | my $sy0 = $self->{sy0} = ($sy & 31) - 32; $sy = $self->{sy} = ($sy - $sy0) / 32; |
232 | |
257 | |
233 | glPushMatrix; |
258 | glPushMatrix; |
234 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
259 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
235 | |
260 | |
236 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
261 | glTranslate $sx0, $sy0; |
237 | |
262 | |
238 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
263 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
239 | |
264 | |
240 | if ($::CFG->{fow_enable}) { |
265 | if ($::CFG->{fow_enable}) { |
241 | if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war |
266 | if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war |
… | |
… | |
243 | glConvolutionFilter2D ( |
268 | glConvolutionFilter2D ( |
244 | GL_CONVOLUTION_2D, |
269 | GL_CONVOLUTION_2D, |
245 | GL_ALPHA, |
270 | GL_ALPHA, |
246 | 3, 3, |
271 | 3, 3, |
247 | GL_ALPHA, GL_FLOAT, |
272 | GL_ALPHA, GL_FLOAT, |
248 | pack "f*", |
273 | (pack "f*", @{ $self->{smooth_matrix} }), |
249 | 0.05, 0.13, 0.05, |
|
|
250 | 0.13, 0.30, 0.13, |
|
|
251 | 0.05, 0.13, 0.05, |
|
|
252 | ); |
274 | ); |
253 | glEnable GL_CONVOLUTION_2D; |
275 | glEnable GL_CONVOLUTION_2D; |
254 | } |
276 | } |
255 | |
277 | |
256 | $self->{fow_texture_name} ||= glGenTexture; |
278 | $self->{fow_texture_name} ||= glGenTexture; |
… | |
… | |
450 | |
472 | |
451 | if ($ev->{sym} == 13) { |
473 | if ($ev->{sym} == 13) { |
452 | if (exists $self->{select}) { |
474 | if (exists $self->{select}) { |
453 | $self->{last_command} = $self->{select}; |
475 | $self->{last_command} = $self->{select}; |
454 | $::CONN->user_send ($self->{select}); |
476 | $::CONN->user_send ($self->{select}); |
|
|
477 | |
|
|
478 | unshift @{$self->{history}}, $self->{select}; |
|
|
479 | $self->{hist_ptr} = 0; |
|
|
480 | |
455 | $self->hide; |
481 | $self->hide; |
456 | } |
482 | } |
457 | } elsif ($ev->{sym} == 27) { |
483 | } elsif ($ev->{sym} == 27) { |
|
|
484 | $self->{hist_ptr} = 0; |
458 | $self->hide; |
485 | $self->hide; |
459 | return; |
486 | return; |
460 | } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { |
487 | } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { |
|
|
488 | if ($self->{hist_ptr} > 1) { |
|
|
489 | $self->{hist_ptr}--; |
|
|
490 | $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); |
|
|
491 | } elsif ($self->{hist_ptr} > 0) { |
|
|
492 | $self->{hist_ptr}--; |
|
|
493 | $self->{entry}->set_text ($self->{hist_saveback}); |
|
|
494 | } else { |
461 | ++$self->{select_offset} |
495 | ++$self->{select_offset} |
462 | if $self->{select_offset} < $#{ $self->{last_match} || [] }; |
496 | if $self->{select_offset} < $#{ $self->{last_match} || [] }; |
|
|
497 | } |
463 | $self->update_labels; |
498 | $self->update_labels; |
464 | } elsif ($ev->{sym} == CFClient::SDLK_UP) { |
499 | } elsif ($ev->{sym} == CFClient::SDLK_UP) { |
|
|
500 | if ($self->{select_offset}) { |
465 | --$self->{select_offset} |
501 | --$self->{select_offset} |
|
|
502 | } else { |
|
|
503 | unless ($self->{hist_ptr}) { |
|
|
504 | $self->{hist_saveback} = $self->{entry}->get_text; |
|
|
505 | } |
|
|
506 | if ($self->{hist_ptr} <= $#{$self->{history}}) { |
466 | if $self->{select_offset}; |
507 | $self->{hist_ptr}++; |
|
|
508 | } |
|
|
509 | $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]) |
|
|
510 | if exists $self->{history}->[$self->{hist_ptr} - 1]; |
|
|
511 | } |
467 | $self->update_labels; |
512 | $self->update_labels; |
468 | } else { |
513 | } else { |
469 | return 0; |
514 | return 0; |
470 | } |
515 | } |
471 | |
516 | |