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.14 by root, Mon Apr 24 11:54:26 2006 UTC vs.
Revision 1.18 by root, Tue Apr 25 12:56:34 2006 UTC

81 81
82 if (delete $self->{need_update}) { 82 if (delete $self->{need_update}) {
83 glNewList $self->{list}; 83 glNewList $self->{list};
84 84
85 if ($::MAP) { 85 if ($::MAP) {
86 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}); 86 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
87 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}); 87 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
88
89 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
90 88
91 my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; 89 my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32;
92 my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; 90 my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32;
91
92 glPushMatrix;
93 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
93 94
94 glTranslate $sx0 - 32, $sy0 - 32, 0; 95 glTranslate $sx0 - 32, $sy0 - 32, 0;
95 96
96 my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); 97 my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1);
97 98
130 131
131 glDisable GL_TEXTURE_2D; 132 glDisable GL_TEXTURE_2D;
132 glDisable GL_BLEND; 133 glDisable GL_BLEND;
133 } 134 }
134 135
135 # HACK BEGIN 136 glPopMatrix;
136 {
137 glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove
138
139 glTranslate 0, 30;
140 my ($w, $h) = (250, 250);
141
142 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
143
144 glEnable GL_BLEND;
145 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
146 glEnable GL_TEXTURE_2D;
147 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
148
149 $self->{mapmap_texture} =
150 new CFClient::Texture
151 w => $w,
152 h => $h,
153 data => $::MAP->mapmap (- $w * 0.5, - $h * 0.5, $w, $h),
154 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
155
156 $self->{mapmap_texture}->draw_quad (0, 0);
157
158 glDisable GL_TEXTURE_2D;
159
160 glTranslate 0.375, 0.375;
161
162 glColor 1, 1, 0, 1;
163 glBegin GL_LINE_LOOP;
164 glVertex $w * 0.5 - $sx , $h * 0.5 - $sy ;
165 glVertex $w * 0.5 - $sx , $h * 0.5 - $sy + $sh;
166 glVertex $w * 0.5 - $sx + $sw, $h * 0.5 - $sy + $sh;
167 glVertex $w * 0.5 - $sx + $sw, $h * 0.5 - $sy ;
168 glEnd;
169
170 glDisable GL_BLEND;
171 }
172 # HACK END
173 } 137 }
174 138
175 glEndList; 139 glEndList;
176 } 140 }
177 141
276 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; 240 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g;
277 241
278 push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb]; 242 push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb];
279} 243}
280 244
245package CFClient::MapWidget::MapMap;
246
247use base CFClient::UI::Base::;
248
249use Time::HiRes qw(time);
250use CFClient::OpenGL;
251
252sub size_request {
253 ($::HEIGHT * 0.25, $::HEIGHT * 0.25)
254}
255
256sub size_allocate {
257 my ($self, $w, $h) = @_;
258
259 $self->SUPER::size_allocate ($w, $h);
260 $self->update;
261}
262
263sub update {
264 my ($self) = @_;
265
266 delete $self->{texture_atime};
267 $self->SUPER::update;
268}
269
270sub _draw {
271 my ($self) = @_;
272
273 $::MAP or return;
274
275 my ($w, $h) = @$self{qw(w h)};
276
277 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99;
278 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99;
279
280 my $sx = int $::CFG->{map_shift_x} / 32;
281 my $sy = int $::CFG->{map_shift_y} / 32;
282
283 my $ox = 0.5 * ($w - $sw);
284 my $oy = 0.5 * ($h - $sh);
285
286 glEnable GL_BLEND;
287 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
288 glEnable GL_TEXTURE_2D;
289 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
290
291 if ($self->{texture_atime} < time) {
292 $self->{texture_atime} = time + 1/3;
293
294 $self->{texture} =
295 new CFClient::Texture
296 w => $w,
297 h => $h,
298 data => $::MAP->mapmap (-$ox, -$oy, $w, $h),
299 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
300 }
301
302 $self->{texture}->draw_quad (0, 0);
303
304 glDisable GL_TEXTURE_2D;
305
306 glTranslate 0.375, 0.375;
307
308 #TODO: map scale is completely borked
309
310 my $x0 = int $ox - $sx + 0.5;
311 my $y0 = int $oy - $sy + 0.5;
312
313 glColor 1, 1, 0, 1;
314 glBegin GL_LINE_LOOP;
315 glVertex $x0 , $y0 ;
316 glVertex $x0 , $y0 + $sh;
317 glVertex $x0 + $sw, $y0 + $sh;
318 glVertex $x0 + $sw, $y0 ;
319 glEnd;
320
321 glDisable GL_BLEND;
322}
323
281package CFClient::MapWidget::Command; 324package CFClient::MapWidget::Command;
282 325
283use strict; 326use strict;
284 327
285use CFClient::OpenGL; 328use CFClient::OpenGL;
320 my @found; 363 my @found;
321 364
322 for (@$command) { 365 for (@$command) {
323 if ($_->[0] =~ $search_abbrev) { 366 if ($_->[0] =~ $search_abbrev) {
324 push @found, [$_->[0], $_]; 367 push @found, [$_->[0], $_];
325 } elsif ($_[1] =~ $search_full) { 368 } elsif ($_->[1] =~ $search_full) {
326 push @found, [$_->[1], $_]; 369 push @found, [$_->[1], $_];
327 } 370 }
328 } 371 }
329 372
330 @found = sort { $a->[0] cmp $b->[0] } @found; 373 @found = sort { $a->[0] cmp $b->[0] } @found;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines