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.50 by root, Sat Jun 3 23:47:47 2006 UTC vs.
Revision 1.55 by root, Sun Jun 11 20:09:12 2006 UTC

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},
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} == 1) { 68 if ($ev->{button} == 1) {
62 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
63 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
64
65 my $fx = int +($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale}) - 0.5 * $sw + 0.99; 69 my $x = int +($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale});
66 my $fy = int +($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale}) - 0.5 * $sh + 0.99; 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);
67 74
68 $::CONN->send (sprintf "lookat %d %d", $fx, $fy); 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;
69 83
70 } elsif ($ev->{button} == 2) { 84 } elsif ($ev->{button} == 2) {
71 my ($ox, $oy) = ($ev->{x}, $ev->{y}); 85 my ($ox, $oy) = ($ev->{x}, $ev->{y});
72 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); 86 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
73 87
231 245
232 if (delete $self->{need_update}) { 246 if (delete $self->{need_update}) {
233 glNewList $self->{list}; 247 glNewList $self->{list};
234 248
235 if ($::MAP) { 249 if ($::MAP) {
236 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; 250 my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
237 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; 251 my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
238 252
239 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};
240 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;
241 257
242 glPushMatrix; 258 glPushMatrix;
243 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 259 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
244 260
245 glTranslate $sx0 - 32, $sy0 - 32, 0; 261 glTranslate $sx0, $sy0;
246 262
247 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);
248 264
249 if ($::CFG->{fow_enable}) { 265 if ($::CFG->{fow_enable}) {
250 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
252 glConvolutionFilter2D ( 268 glConvolutionFilter2D (
253 GL_CONVOLUTION_2D, 269 GL_CONVOLUTION_2D,
254 GL_ALPHA, 270 GL_ALPHA,
255 3, 3, 271 3, 3,
256 GL_ALPHA, GL_FLOAT, 272 GL_ALPHA, GL_FLOAT,
257 pack "f*", 273 (pack "f*", @{ $self->{smooth_matrix} }),
258 0.05, 0.13, 0.05,
259 0.13, 0.30, 0.13,
260 0.05, 0.13, 0.05,
261 ); 274 );
262 glEnable GL_CONVOLUTION_2D; 275 glEnable GL_CONVOLUTION_2D;
263 } 276 }
264 277
265 $self->{fow_texture_name} ||= glGenTexture; 278 $self->{fow_texture_name} ||= glGenTexture;
459 472
460 if ($ev->{sym} == 13) { 473 if ($ev->{sym} == 13) {
461 if (exists $self->{select}) { 474 if (exists $self->{select}) {
462 $self->{last_command} = $self->{select}; 475 $self->{last_command} = $self->{select};
463 $::CONN->user_send ($self->{select}); 476 $::CONN->user_send ($self->{select});
477
478 unshift @{$self->{history}}, $self->{select};
479 $self->{hist_ptr} = 0;
480
464 $self->hide; 481 $self->hide;
465 } 482 }
466 } elsif ($ev->{sym} == 27) { 483 } elsif ($ev->{sym} == 27) {
484 $self->{hist_ptr} = 0;
467 $self->hide; 485 $self->hide;
468 return; 486 return;
469 } 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 {
470 ++$self->{select_offset} 495 ++$self->{select_offset}
471 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 496 if $self->{select_offset} < $#{ $self->{last_match} || [] };
497 }
472 $self->update_labels; 498 $self->update_labels;
473 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 499 } elsif ($ev->{sym} == CFClient::SDLK_UP) {
500 if ($self->{select_offset}) {
474 --$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}}) {
475 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 }
476 $self->update_labels; 512 $self->update_labels;
477 } else { 513 } else {
478 return 0; 514 return 0;
479 } 515 }
480 516

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines