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.51 by root, Thu Jun 8 01:51:32 2006 UTC vs.
Revision 1.54 by root, Sun Jun 11 20:05:55 2006 UTC

64 my ($self, $ev, $x, $y) = @_; 64 my ($self, $ev, $x, $y) = @_;
65 65
66 $self->focus_in; 66 $self->focus_in;
67 67
68 if ($ev->{button} == 1) { 68 if ($ev->{button} == 1) {
69 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
70 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
71
72 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});
73 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);
74 74
75 $x -= int 0.5 * $::MAP->w;
76 $y -= int 0.5 * $::MAP->h;
77
78 $x += 1;
79 $y += 1;
80
75 $::CONN->send (sprintf "lookat %d %d", $fx, $fy); 81 $::CONN->send (sprintf "lookat %d %d", $x, $y)
82 if $::CONN;
76 83
77 } elsif ($ev->{button} == 2) { 84 } elsif ($ev->{button} == 2) {
78 my ($ox, $oy) = ($ev->{x}, $ev->{y}); 85 my ($ox, $oy) = ($ev->{x}, $ev->{y});
79 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); 86 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
80 87
238 245
239 if (delete $self->{need_update}) { 246 if (delete $self->{need_update}) {
240 glNewList $self->{list}; 247 glNewList $self->{list};
241 248
242 if ($::MAP) { 249 if ($::MAP) {
243 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; 250 my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
244 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; 251 my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
245 252
246 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};
247 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;
248 257
249 glPushMatrix; 258 glPushMatrix;
250 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 259 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
251 260
252 glTranslate $sx0 - 32, $sy0 - 32, 0; 261 glTranslate $sx0, $sy0;
253 262
254 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);
255 264
256 if ($::CFG->{fow_enable}) { 265 if ($::CFG->{fow_enable}) {
257 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
463 472
464 if ($ev->{sym} == 13) { 473 if ($ev->{sym} == 13) {
465 if (exists $self->{select}) { 474 if (exists $self->{select}) {
466 $self->{last_command} = $self->{select}; 475 $self->{last_command} = $self->{select};
467 $::CONN->user_send ($self->{select}); 476 $::CONN->user_send ($self->{select});
477
478 unshift @{$self->{history}}, $self->{select};
479 $self->{hist_ptr} = 0;
480
468 $self->hide; 481 $self->hide;
469 } 482 }
470 } elsif ($ev->{sym} == 27) { 483 } elsif ($ev->{sym} == 27) {
484 $self->{hist_ptr} = 0;
471 $self->hide; 485 $self->hide;
472 return; 486 return;
473 } 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 {
474 ++$self->{select_offset} 495 ++$self->{select_offset}
475 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 496 if $self->{select_offset} < $#{ $self->{last_match} || [] };
497 }
476 $self->update_labels; 498 $self->update_labels;
477 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 499 } elsif ($ev->{sym} == CFClient::SDLK_UP) {
500 if ($self->{select_offset}) {
478 --$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}}) {
479 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 }
480 $self->update_labels; 512 $self->update_labels;
481 } else { 513 } else {
482 return 0; 514 return 0;
483 } 515 }
484 516

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines