--- deliantra/Deliantra-Client/DC/MapWidget.pm 2006/06/03 21:59:55 1.48 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2006/06/11 20:09:12 1.55 @@ -16,6 +16,13 @@ z => -1, can_focus => 1, list => glGenList, + + smooth_matrix => [ + 0.05, 0.13, 0.05, + 0.13, 0.30, 0.13, + 0.05, 0.13, 0.05, + ], + @_ ); @@ -58,7 +65,23 @@ $self->focus_in; - if ($ev->{button} == 2) { + if ($ev->{button} == 1) { + my $x = int +($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale}); + my $y = int +($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale}); + + $x += int 0.5 * ($::MAP->w - $self->{sw} - 1); + $y += int 0.5 * ($::MAP->h - $self->{sh} - 1); + + $x -= int 0.5 * $::MAP->w; + $y -= int 0.5 * $::MAP->h; + + $x += 1; + $y += 1; + + $::CONN->send ("lookat $x $y") + if $::CONN; + + } elsif ($ev->{button} == 2) { my ($ox, $oy) = ($ev->{x}, $ev->{y}); my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); @@ -72,18 +95,6 @@ $self->update; }; - } elsif ($ev->{button} == 1) { - my ($ox, $oy) = ($ev->{x}, $ev->{y}); - - my $fx = int ((($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale})) + 0.99); - my $fy = int ((($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale})) + 0.99); - $fx += $::MAP->x; - $fy += $::MAP->y; - - $::CONN->send (sprintf "lookat %d %d", $fx, $fy); - - warn "FOOX: $fx (".$::MAP->ox.")\n"; - warn "FOOY: $fy (".$::MAP->oy.")\n"; } 1 @@ -236,16 +247,18 @@ glNewList $self->{list}; if ($::MAP) { - my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; - my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; + my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; + my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; - my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; - my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; + my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; + my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; + my $sx0 = $self->{sx0} = ($sx & 31) - 32; $sx = $self->{sx} = ($sx - $sx0) / 32; + my $sy0 = $self->{sy0} = ($sy & 31) - 32; $sy = $self->{sy} = ($sy - $sy0) / 32; glPushMatrix; glScale $::CFG->{map_scale}, $::CFG->{map_scale}; - glTranslate $sx0 - 32, $sy0 - 32, 0; + glTranslate $sx0, $sy0; my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); @@ -257,10 +270,7 @@ GL_ALPHA, 3, 3, GL_ALPHA, GL_FLOAT, - pack "f*", - 0.05, 0.13, 0.05, - 0.13, 0.30, 0.13, - 0.05, 0.13, 0.05, + (pack "f*", @{ $self->{smooth_matrix} }), ); glEnable GL_CONVOLUTION_2D; } @@ -464,18 +474,41 @@ if (exists $self->{select}) { $self->{last_command} = $self->{select}; $::CONN->user_send ($self->{select}); + + unshift @{$self->{history}}, $self->{select}; + $self->{hist_ptr} = 0; + $self->hide; } } elsif ($ev->{sym} == 27) { + $self->{hist_ptr} = 0; $self->hide; return; } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { - ++$self->{select_offset} - if $self->{select_offset} < $#{ $self->{last_match} || [] }; + if ($self->{hist_ptr} > 1) { + $self->{hist_ptr}--; + $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); + } elsif ($self->{hist_ptr} > 0) { + $self->{hist_ptr}--; + $self->{entry}->set_text ($self->{hist_saveback}); + } else { + ++$self->{select_offset} + if $self->{select_offset} < $#{ $self->{last_match} || [] }; + } $self->update_labels; } elsif ($ev->{sym} == CFClient::SDLK_UP) { - --$self->{select_offset} - if $self->{select_offset}; + if ($self->{select_offset}) { + --$self->{select_offset} + } else { + unless ($self->{hist_ptr}) { + $self->{hist_saveback} = $self->{entry}->get_text; + } + if ($self->{hist_ptr} <= $#{$self->{history}}) { + $self->{hist_ptr}++; + } + $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]) + if exists $self->{history}->[$self->{hist_ptr} - 1]; + } $self->update_labels; } else { return 0;