--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/14 20:27:35 1.107 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/15 02:10:22 1.111 @@ -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,15 +1708,19 @@ sub draw { my ($self) = @_; - $self->{need_update}++;#d# if (delete $self->{need_update}) { glNewList $self->{list}, GL_COMPILE; - my $sw = int $::WIDTH / 32; - my $sh = int $::HEIGHT / 32; - if ($::MAP) { - my ($w, $h, $data) = $::MAP->draw (0, 0, $sw, $sh); + my $sw = int $::WIDTH / 32; + my $sh = int $::HEIGHT / 32; + + my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; + my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; + + glTranslate $sx0 - 32, $sy0 - 32, 0; + + my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); if ($::CFG->{fow_enable}) { if ($::CFG->{fow_smooth}) { # smooth fog of war @@ -1710,6 +1748,7 @@ glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; glEnable GL_BLEND; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; glEnable GL_TEXTURE_2D; glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; @@ -1719,12 +1758,36 @@ glDisable GL_TEXTURE_2D; glDisable GL_BLEND; } + + # HACK BEGIN + { + glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove + my ($w, $h) = (250, 250); + + glEnable GL_BLEND; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; + glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + + CFClient::Texture->new ( + w => $w, + h => $h, + data => $::MAP->mapmap ($w, $h), + type => GL_UNSIGNED_INT_8_8_8_8_REV + )->draw_quad (100, 100); + + glDisable GL_TEXTURE_2D; + glDisable GL_BLEND; + } + # HACK END } glEndList; } + glPushMatrix; glCallList $self->{list}; + glPopMatrix; if ($FOCUS != $self) { glColor 64/255, 64/255, 64/255;