… | |
… | |
64 | my ($self, $ev, $x, $y) = @_; |
64 | my ($self, $ev, $x, $y) = @_; |
65 | |
65 | |
66 | $self->focus_in; |
66 | $self->focus_in; |
67 | |
67 | |
68 | if ($ev->{button} == 1) { |
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; |
69 | my $x = int +($ev->{x} - $::CFG->{map_shift_x}) / (32 * $::CFG->{map_scale}); |
73 | my $fy = int +($ev->{y} - $::CFG->{map_shift_y}) / (32 * $::CFG->{map_scale}) - 0.5 * $sh + 0.99; |
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 | |
74 | |
|
|
75 | $x -= int 0.5 * $::MAP->w; |
|
|
76 | $y -= int 0.5 * $::MAP->h; |
|
|
77 | |
|
|
78 | $x += 1; |
|
|
79 | $y += 1; |
|
|
80 | |
75 | $::CONN->send (sprintf "lookat %d %d", $fx, $fy) |
81 | $::CONN->send (sprintf "lookat %d %d", $x, $y) |
76 | if $::CONN; |
82 | if $::CONN; |
77 | |
83 | |
78 | } elsif ($ev->{button} == 2) { |
84 | } elsif ($ev->{button} == 2) { |
79 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
85 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
80 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
86 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
… | |
… | |
239 | |
245 | |
240 | if (delete $self->{need_update}) { |
246 | if (delete $self->{need_update}) { |
241 | glNewList $self->{list}; |
247 | glNewList $self->{list}; |
242 | |
248 | |
243 | if ($::MAP) { |
249 | if ($::MAP) { |
244 | my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; |
250 | my $sw = $self->{sw} = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; |
245 | my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; |
251 | my $sh = $self->{sh} = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; |
246 | |
252 | |
247 | 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}; |
248 | 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; |
249 | |
257 | |
250 | glPushMatrix; |
258 | glPushMatrix; |
251 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
259 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
252 | |
260 | |
253 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
261 | glTranslate $sx0, $sy0; |
254 | |
262 | |
255 | 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); |
256 | |
264 | |
257 | if ($::CFG->{fow_enable}) { |
265 | if ($::CFG->{fow_enable}) { |
258 | 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 |