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.48 by elmex, Sat Jun 3 21:59:55 2006 UTC vs.
Revision 1.56 by root, Mon Jun 12 13:26:14 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},
56sub button_down { 63sub 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->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) = @_;
70 $::CFG->{map_shift_x} = $bw + $x - $ox; 93 $::CFG->{map_shift_x} = $bw + $x - $ox;
71 $::CFG->{map_shift_y} = $bh + $y - $oy; 94 $::CFG->{map_shift_y} = $bh + $y - $oy;
72 95
73 $self->update; 96 $self->update;
74 }; 97 };
75 } elsif ($ev->{button} == 1) {
76 my ($ox, $oy) = ($ev->{x}, $ev->{y});
77
78 my $fx = int ((($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale})) + 0.99);
79 my $fy = int ((($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale})) + 0.99);
80 $fx += $::MAP->x;
81 $fy += $::MAP->y;
82
83 $::CONN->send (sprintf "lookat %d %d", $fx, $fy);
84
85 warn "FOOX: $fx (".$::MAP->ox.")\n";
86 warn "FOOY: $fy (".$::MAP->oy.")\n";
87 } 98 }
88 99
89 1 100 1
90} 101}
91 102
234 245
235 if (delete $self->{need_update}) { 246 if (delete $self->{need_update}) {
236 glNewList $self->{list}; 247 glNewList $self->{list};
237 248
238 if ($::MAP) { 249 if ($::MAP) {
239 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; 250 my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
240 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; 251 my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
241 252
242 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};
243 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;
244 257
245 glPushMatrix; 258 glPushMatrix;
246 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 259 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
247 260
248 glTranslate $sx0 - 32, $sy0 - 32, 0; 261 glTranslate $sx0, $sy0;
249 262
250 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);
251 264
252 if ($::CFG->{fow_enable}) { 265 if ($::CFG->{fow_enable}) {
253 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
255 glConvolutionFilter2D ( 268 glConvolutionFilter2D (
256 GL_CONVOLUTION_2D, 269 GL_CONVOLUTION_2D,
257 GL_ALPHA, 270 GL_ALPHA,
258 3, 3, 271 3, 3,
259 GL_ALPHA, GL_FLOAT, 272 GL_ALPHA, GL_FLOAT,
260 pack "f*", 273 (pack "f*", @{ $self->{smooth_matrix} }),
261 0.05, 0.13, 0.05,
262 0.13, 0.30, 0.13,
263 0.05, 0.13, 0.05,
264 ); 274 );
265 glEnable GL_CONVOLUTION_2D; 275 glEnable GL_CONVOLUTION_2D;
266 } 276 }
267 277
268 $self->{fow_texture_name} ||= glGenTexture; 278 $self->{fow_texture_name} ||= glGenTexture;
462 472
463 if ($ev->{sym} == 13) { 473 if ($ev->{sym} == 13) {
464 if (exists $self->{select}) { 474 if (exists $self->{select}) {
465 $self->{last_command} = $self->{select}; 475 $self->{last_command} = $self->{select};
466 $::CONN->user_send ($self->{select}); 476 $::CONN->user_send ($self->{select});
477
478 unshift @{$self->{history}}, $self->{select};
479 $self->{hist_ptr} = 0;
480
467 $self->hide; 481 $self->hide;
468 } 482 }
469 } elsif ($ev->{sym} == 27) { 483 } elsif ($ev->{sym} == 27) {
484 $self->{hist_ptr} = 0;
470 $self->hide; 485 $self->hide;
471 return; 486 return;
472 } 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 {
473 ++$self->{select_offset} 495 ++$self->{select_offset}
474 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 496 if $self->{select_offset} < $#{ $self->{last_match} || [] };
497 }
475 $self->update_labels; 498 $self->update_labels;
476 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 499 } elsif ($ev->{sym} == CFClient::SDLK_UP) {
500 if ($self->{select_offset}) {
477 --$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}}) {
478 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 }
479 $self->update_labels; 512 $self->update_labels;
480 } else { 513 } else {
481 return 0; 514 return 0;
482 } 515 }
483 516

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines