ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra/MapWidget.pm (file contents):
Revision 1.12 by root, Tue Feb 7 17:13:00 2006 UTC vs.
Revision 1.13 by root, Tue Feb 7 17:41:25 2006 UTC

328} 328}
329 329
330sub update_map { 330sub update_map {
331 my ($self, $x, $y, $w, $h) = @_; 331 my ($self, $x, $y, $w, $h) = @_;
332 332
333 delete $self->{tipinfo}; $self->update_tooltip;
334
335 push @{ $self->{queue_draw_areay} }, [$x * TILESIZE - $self->{x},
336 $y * TILESIZE - $self->{y},
337 $w * TILESIZE, $h * TILESIZE];
338
339 $self->{update_map} ||= add Glib::Idle sub {
340 delete $self->{update_map};
333 delete $self->{overlay}; 341 delete $self->{overlay};
334 342
335 my $map = $self->{map}{map}; 343 my $map = $self->{map}{map};
336 my $ov = $self->{face} ||= []; 344 my $ov = $self->{face} ||= [];
337 345
338 $x = 0; $w = $self->{map}{width}; 346 my ($x, $w) = (0, $self->{map}{width});
339 $y = 0; $h = $self->{map}{height}; 347 my ($y, $h) = (0, $self->{map}{height});
340 348
341 my @x = ($x .. $x + $w - 1); 349 my @x = ($x .. $x + $w - 1);
342 my @y = ($y .. $y + $h - 1); 350 my @y = ($y .. $y + $h - 1);
343 351
344 my $TC = \%Crossfire::Tilecache::TILECACHE; 352 my $TC = \%Crossfire::Tilecache::TILECACHE;
345 353
346 my @ov; 354 my @ov;
347 355
348 # update overlay map with bigfaces and chained faces 356 # update overlay map with bigfaces and chained faces
349 my $a; 357 my $a;
350 for my $x (@x) { 358 for my $x (@x) {
351 my $ass = $self->{map}{map}[$x]; 359 my $ass = $self->{map}{map}[$x];
352 my $oss = $ov->[$x] ||= []; 360 my $oss = $ov->[$x] ||= [];
353 for my $y (@y) { 361 for my $y (@y) {
354 my $os = $oss->[$y] = []; 362 my $os = $oss->[$y] = [];
355 for my $a (@{ $ass->[$y] || [] }) { 363 for my $a (@{ $ass->[$y] || [] }) {
356 my $o = $ARCH->{$a->{_name}} 364 my $o = $ARCH->{$a->{_name}}
357 or (warn "arch '$a->{_name}' not found at ($x|$y)\n"), next; 365 or (warn "arch '$a->{_name}' not found at ($x|$y)\n"), next;
358 366
359 my $tile = $TC->{$a->{face} || $o->{face}} 367 my $tile = $TC->{$a->{face} || $o->{face}}
360 or (warn "no gfx found for arch '$a->{_name}' at ($x|$y)\n"), next; 368 or (warn "no gfx found for arch '$a->{_name}' at ($x|$y)\n"), next;
361 369
362 if ($tile->{w} > 1 || $tile->{h} > 1) { 370 if ($tile->{w} > 1 || $tile->{h} > 1) {
363 # bigfaces 371 # bigfaces
364 for my $ox (0 .. $tile->{w} - 1) { 372 for my $ox (0 .. $tile->{w} - 1) {
365 for my $oy (0 .. $tile->{h} - 1) { 373 for my $oy (0 .. $tile->{h} - 1) {
366 push @ov, [$x + $ox, $y + $oy, 374 push @ov, [$x + $ox, $y + $oy,
367 $tile->{idx} + $ox + $oy * $tile->{w}]; 375 $tile->{idx} + $ox + $oy * $tile->{w}];
376 }
368 } 377 }
378
379 } elsif ($o->{more}) {
380 # linked faces
381 do {
382 my $tile = $TC->{$o->{face}}
383 or (warn "no gfx found for arch '$a->{_name}' at ($x*|$y*)\n"), next;
384 push @ov, [$x + $o->{x}, $y + $o->{y}, $tile->{idx}];
385 } while $o = $o->{more};
386
387 } else {
388 # single face
389 push @$os, $tile->{idx};
390
369 } 391 }
370
371 } elsif ($o->{more}) {
372 # linked faces
373 do {
374 my $tile = $TC->{$o->{face}}
375 or (warn "no gfx found for arch '$a->{_name}' at ($x*|$y*)\n"), next;
376 push @ov, [$x + $o->{x}, $y + $o->{y}, $tile->{idx}];
377 } while $o = $o->{more};
378
379 } else {
380 # single face
381 push @$os, $tile->{idx};
382
383 } 392 }
384 } 393 }
385 } 394 }
386 }
387 395
388 # bigger faces always on top, I don't give a shit to those who think otherwise 396 # bigger faces always on top, I don't give a shit to those who think otherwise
389 for (@ov) { 397 for (@ov) {
390 my ($x, $y, $idx) = @$_; 398 my ($x, $y, $idx) = @$_;
391 399
392 push @{ $ov->[$x][$y] }, $idx; 400 push @{ $ov->[$x][$y] }, $idx;
401 }
402
403 $self->queue_draw_area (@$_)
404 for @{ delete $self->{queue_draw_areay} };
405
406 0
393 } 407 };
394
395 delete $self->{tipinfo}; $self->update_tooltip;
396
397 $self->queue_draw_area ($x * TILESIZE - $self->{x},
398 $y * TILESIZE - $self->{y},
399 $w * TILESIZE, $h * TILESIZE);
400} 408}
401 409
402sub expose { 410sub expose {
403 my ($self, $event) = @_; 411 my ($self, $event) = @_;
404 412

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines