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.52 by elmex, Thu Jun 8 18:18:16 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 $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;
73 my $fy = int +($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale}) - 0.5 * $sh + 0.99;
74
75 $::CONN->send (sprintf "lookat %d %d", $fx, $fy);
76
77 } elsif ($ev->{button} == 2) {
62 my ($ox, $oy) = ($ev->{x}, $ev->{y}); 78 my ($ox, $oy) = ($ev->{x}, $ev->{y});
63 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); 79 my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y});
64 80
65 $self->{motion} = sub { 81 $self->{motion} = sub {
66 my ($ev, $x, $y) = @_; 82 my ($ev, $x, $y) = @_;
70 $::CFG->{map_shift_x} = $bw + $x - $ox; 86 $::CFG->{map_shift_x} = $bw + $x - $ox;
71 $::CFG->{map_shift_y} = $bh + $y - $oy; 87 $::CFG->{map_shift_y} = $bh + $y - $oy;
72 88
73 $self->update; 89 $self->update;
74 }; 90 };
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 } 91 }
88 92
89 1 93 1
90} 94}
91 95
255 glConvolutionFilter2D ( 259 glConvolutionFilter2D (
256 GL_CONVOLUTION_2D, 260 GL_CONVOLUTION_2D,
257 GL_ALPHA, 261 GL_ALPHA,
258 3, 3, 262 3, 3,
259 GL_ALPHA, GL_FLOAT, 263 GL_ALPHA, GL_FLOAT,
260 pack "f*", 264 (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 ); 265 );
265 glEnable GL_CONVOLUTION_2D; 266 glEnable GL_CONVOLUTION_2D;
266 } 267 }
267 268
268 $self->{fow_texture_name} ||= glGenTexture; 269 $self->{fow_texture_name} ||= glGenTexture;
462 463
463 if ($ev->{sym} == 13) { 464 if ($ev->{sym} == 13) {
464 if (exists $self->{select}) { 465 if (exists $self->{select}) {
465 $self->{last_command} = $self->{select}; 466 $self->{last_command} = $self->{select};
466 $::CONN->user_send ($self->{select}); 467 $::CONN->user_send ($self->{select});
468
469 unshift @{$self->{history}}, $self->{select};
470 $self->{hist_ptr} = 0;
471
467 $self->hide; 472 $self->hide;
468 } 473 }
469 } elsif ($ev->{sym} == 27) { 474 } elsif ($ev->{sym} == 27) {
475 $self->{hist_ptr} = 0;
470 $self->hide; 476 $self->hide;
471 return; 477 return;
472 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 478 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) {
479 if ($self->{hist_ptr} > 1) {
480 $self->{hist_ptr}--;
481 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
482 } elsif ($self->{hist_ptr} > 0) {
483 $self->{hist_ptr}--;
484 $self->{entry}->set_text ($self->{hist_saveback});
485 } else {
473 ++$self->{select_offset} 486 ++$self->{select_offset}
474 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 487 if $self->{select_offset} < $#{ $self->{last_match} || [] };
488 }
475 $self->update_labels; 489 $self->update_labels;
476 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 490 } elsif ($ev->{sym} == CFClient::SDLK_UP) {
491 if ($self->{select_offset}) {
477 --$self->{select_offset} 492 --$self->{select_offset}
493 } else {
494 unless ($self->{hist_ptr}) {
495 $self->{hist_saveback} = $self->{entry}->get_text;
496 }
497 if ($self->{hist_ptr} <= $#{$self->{history}}) {
478 if $self->{select_offset}; 498 $self->{hist_ptr}++;
499 }
500 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1])
501 if exists $self->{history}->[$self->{hist_ptr} - 1];
502 }
479 $self->update_labels; 503 $self->update_labels;
480 } else { 504 } else {
481 return 0; 505 return 0;
482 } 506 }
483 507

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines