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.156 by root, Sat Dec 19 05:06:57 2009 UTC vs.
Revision 1.157 by root, Mon Dec 21 03:30:23 2009 UTC

396} 396}
397 397
398sub scroll { 398sub scroll {
399 my ($self, $dx, $dy) = @_; 399 my ($self, $dx, $dy) = @_;
400 400
401 $::MAP->scroll ($dx, $dy);
402 $self->movement_update; 401 $self->movement_update;
403 402
404 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement 403 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement
405 $self->{sdy} += $dy * $self->{tilesize}; 404 $self->{sdy} += $dy * $self->{tilesize};
406 405
406 # save old fow texture, if applicable
407 $self->{last_fow_texture} = $self->{fow_texture}; 407 $self->{last_fow_texture} = $self->{fow_texture}
408 if $::CFG->{smooth_transitions};
409 $self->{lfdx} = $dx;
410 $self->{lfdy} = $dy;
408 $self->{ldx} = $self->{sdx}; 411 $self->{lmdx} = $self->{dx};
409 $self->{ldy} = $self->{sdy}; 412 $self->{lmdy} = $self->{dy};
410 413
414 $::MAP->scroll ($dx, $dy);
411} 415}
412 416
413sub set_magicmap { 417sub set_magicmap {
414 my ($self, $w, $h, $x, $y, $data) = @_; 418 my ($self, $w, $h, $x, $y, $data) = @_;
415 419
486 490
487 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx; 491 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx;
488 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; 492 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy;
489 493
490 if ($::CFG->{fow_enable}) { 494 if ($::CFG->{fow_enable}) {
491 my ($sdx_t, $sdy_t);#d# do not anchor at player
492
493 my ($w, $h, $data) = $::MAP->fow_texture ( 495 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
494 $dx + (min 0, $sdx_t),
495 $dy + (min 0, $sdy_t),
496 $sw + abs $sdx_t,
497 $sh + abs $sdy_t
498 );
499 496
500 $self->{fow_texture} = new DC::Texture 497 $self->{fow_texture} = new DC::Texture
501 w => $w, 498 w => $w,
502 h => $h, 499 h => $h,
503 data => $data, 500 data => $data,
517 $::MAP->draw ($dx, $dy, $sw, $sh, 514 $::MAP->draw ($dx, $dy, $sw, $sh,
518 $self->{tilesize}, 515 $self->{tilesize},
519 $::CONN->{player}{tag}, 516 $::CONN->{player}{tag},
520 -$self->{sdx}, -$self->{sdy}); 517 -$self->{sdx}, -$self->{sdy});
521 518
522 #d#glTranslate -$self->{sdx}, -$self->{sdy}; # anchor fow at player
523 glScale $self->{tilesize}, $self->{tilesize}; 519 glScale $self->{tilesize}, $self->{tilesize};
524 520
525 if (my $tex = $self->{fow_texture}) { 521 if (my $tex = $self->{fow_texture}) {
526 if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture} && 0) {#d# 522 if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d#
527 my $d1 = ($self->{sdx} ** 2 + $self->{sdy} ** 2) ** 0.5; 523 my $d1 = DC::distance $self->{sdx}, $self->{sdy};
528 my $d2 = ($self->{ldx} ** 2 + $self->{ldy} ** 2) ** 0.5; 524 my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize;
529 525
530 if ($d1 * $d2) { 526 if ($d1 * $d2) {
531 DC::Texture::draw_fow_texture 527 DC::Texture::draw_fow_texture
532 $::CFG->{fow_intensity}, 528 $::CFG->{fow_intensity},
533 @{$self->{fow_texture}}{qw(name s t w h)}, 529 @{$self->{fow_texture}}{qw(name s t w h)},
534 $d1 / $d2, 530 (min 1, $d1 / $d2),
535 $sdx_t - $self->{ldx} / $tilesize, $sdy_t - $self->{ldy} / $tilesize, 531 $self->{lmdx} - $dx - $self->{lfdx},
532 $self->{lmdy} - $dy - $self->{lfdy},
536 @{$self->{last_fow_texture}}{qw(name s t w h)}; 533 @{$self->{last_fow_texture}}{qw(name s t w h)};
537 } else { 534 } else {
538 delete $self->{last_fow_texture}; 535 delete $self->{last_fow_texture};
539
540 # same as a few lines below :/
541 DC::Texture::draw_fow_texture
542 $::CFG->{fow_intensity},
543 @{$self->{fow_texture}}{qw(name s t w h)};
544 } 536 }
545 } else { 537 }
546 #d#glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); # anchor at player 538
539 unless ($self->{last_fow_texture}) {
547 DC::Texture::draw_fow_texture 540 DC::Texture::draw_fow_texture
548 $::CFG->{fow_intensity}, 541 $::CFG->{fow_intensity},
549 @{$self->{fow_texture}}{qw(name s t w h)}; 542 @{$self->{fow_texture}}{qw(name s t w h)};
550 } 543 }
551 } 544 }
556 $x += $::MAP->ox + $self->{dx}; 549 $x += $::MAP->ox + $self->{dx};
557 $y += $::MAP->oy + $self->{dy}; 550 $y += $::MAP->oy + $self->{dy};
558 551
559 glTranslate - $x - 1, - $y - 1; 552 glTranslate - $x - 1, - $y - 1;
560 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; 553 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
561 $::MAP->draw_magicmap ($x, $y, $w, $h, $data); 554 $::MAP->draw_magicmap ($w, $h, $data);
562 } 555 }
563 556
564 glPopMatrix; 557 glPopMatrix;
565 glEndList; 558 glEndList;
566 } 559 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines