--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/14 20:27:35 1.107 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/14 23:32:29 1.108 @@ -1657,6 +1657,40 @@ sub key_up { } +sub button_down { + my ($self, $ev, $x, $y) = @_; + + $self->focus_in; + + if ($ev->button == 2) { + my ($ox, $oy) = ($ev->button_x, $ev->button_y); + my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); + + $self->{motion} = sub { + my ($ev, $x, $y) = @_; + + ($x, $y) = ($ev->motion_x, $ev->motion_y); + + $::CFG->{map_shift_x} = $bw + $x - $ox; + $::CFG->{map_shift_y} = $bh + $y - $oy; + + $self->update; + }; + } +} + +sub button_up { + my ($self, $ev, $x, $y) = @_; + + delete $self->{motion}; +} + +sub mouse_motion { + my ($self, $ev, $x, $y) = @_; + + $self->{motion}->($ev, $x, $y) if $self->{motion}; +} + sub size_request { ( 1 + 32 * int $::WIDTH / 32, @@ -1674,7 +1708,6 @@ sub draw { my ($self) = @_; - $self->{need_update}++;#d# if (delete $self->{need_update}) { glNewList $self->{list}, GL_COMPILE; @@ -1682,7 +1715,12 @@ my $sh = int $::HEIGHT / 32; if ($::MAP) { - my ($w, $h, $data) = $::MAP->draw (0, 0, $sw, $sh); + my $sx = $::CFG->{map_shift_x}; + my $sy = $::CFG->{map_shift_y}; + + glTranslate +($sx & 31) - 32, ($sy & 31) - 32, 0; + + my ($w, $h, $data) = $::MAP->draw ($sx >> 5, $sy >> 5, 0, 0, $sw + 1, $sh + 1); if ($::CFG->{fow_enable}) { if ($::CFG->{fow_smooth}) { # smooth fog of war @@ -1724,7 +1762,9 @@ glEndList; } + glPushMatrix; glCallList $self->{list}; + glPopMatrix; if ($FOCUS != $self) { glColor 64/255, 64/255, 64/255;