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.157 by root, Mon Dec 21 03:30:23 2009 UTC vs.
Revision 1.162 by root, Sat Apr 3 02:58:25 2010 UTC

1package DC::MapWidget; 1package DC::MapWidget;
2 2
3use strict; 3use common::sense;
4use utf8;
5 4
6use List::Util qw(min max); 5use List::Util qw(min max);
7 6
8use DC; 7use DC;
9use DC::OpenGL; 8use DC::OpenGL;
10use DC::UI; 9use DC::UI;
11use DC::Macro; 10use DC::Macro;
12 11
13our @ISA = DC::UI::Base::; 12our @ISA = DC::UI::Base::;
13
14our @TEX_HIDDEN = map {
15 new_from_resource DC::Texture # MUST be POT
16 "hidden-$_.png", mipmap => 1, wrap => 1
17 } 0, 1, 2;
14 18
15my $magicmap_tex = 19my $magicmap_tex =
16 new_from_resource DC::Texture "magicmap.png", 20 new_from_resource DC::Texture "magicmap.png",
17 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 21 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
18 22
209# push @items, [ 213# push @items, [
210# "Edit this map <span size='xx-small'>(" . (DC::asxml $::CONN->{map_info}[0]) . ")</span>", 214# "Edit this map <span size='xx-small'>(" . (DC::asxml $::CONN->{map_info}[0]) . ")</span>",
211# \&editor_invoke, 215# \&editor_invoke,
212# ]; 216# ];
213 217
214 for my $type (qw(test name)) { 218 for my $type (@{ $::CONN->{editor_support}{servertypes} }) {
215 $::CONN->{editor_support}{type} ne $type 219 $::CONN->{editor_support}{servertype} ne $type
216 or next; 220 or next;
217 my $server = $::CONN->{editor_support}{"${type}server"} 221 my $server = $::CONN->{editor_support}{"${type}server"}
218 or next; 222 or next;
219 223
220 push @items, [ 224 push @items, [
402 406
403 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement 407 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement
404 $self->{sdy} += $dy * $self->{tilesize}; 408 $self->{sdy} += $dy * $self->{tilesize};
405 409
406 # save old fow texture, if applicable 410 # save old fow texture, if applicable
407 $self->{last_fow_texture} = $self->{fow_texture} 411 $self->{prev_fow_texture} = $::CFG->{smooth_transitions} && $self->{fow_texture};
408 if $::CFG->{smooth_transitions};
409 $self->{lfdx} = $dx; 412 $self->{lfdx} = $dx;
410 $self->{lfdy} = $dy; 413 $self->{lfdy} = $dy;
411 $self->{lmdx} = $self->{dx}; 414 $self->{lmdx} = $self->{dx};
412 $self->{lmdy} = $self->{dy}; 415 $self->{lmdy} = $self->{dy};
413 416
490 493
491 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx; 494 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx;
492 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; 495 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy;
493 496
494 if ($::CFG->{fow_enable}) { 497 if ($::CFG->{fow_enable}) {
498 # draw_fow_texture REQUIRES the fow texture to stay the same size.
495 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh); 499 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
496 500
497 $self->{fow_texture} = new DC::Texture 501 $self->{fow_texture} = new DC::Texture
498 w => $w, 502 w => $w,
499 h => $h, 503 h => $h,
517 -$self->{sdx}, -$self->{sdy}); 521 -$self->{sdx}, -$self->{sdy});
518 522
519 glScale $self->{tilesize}, $self->{tilesize}; 523 glScale $self->{tilesize}, $self->{tilesize};
520 524
521 if (my $tex = $self->{fow_texture}) { 525 if (my $tex = $self->{fow_texture}) {
526 my @prev_fow_params;
527
522 if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d# 528 if ($DC::OpenGL::GL_MULTITEX && $self->{prev_fow_texture}) {
523 my $d1 = DC::distance $self->{sdx}, $self->{sdy}; 529 my $d1 = DC::distance $self->{sdx}, $self->{sdy};
524 my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize; 530 my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize;
525 531
526 if ($d1 * $d2) { 532 if ($d1 * $d2) {
527 DC::Texture::draw_fow_texture 533 @prev_fow_params = (
528 $::CFG->{fow_intensity},
529 @{$self->{fow_texture}}{qw(name s t w h)},
530 (min 1, $d1 / $d2), 534 (min 1, $d1 / $d2),
531 $self->{lmdx} - $dx - $self->{lfdx}, 535 $self->{lmdx} - $dx - $self->{lfdx},
532 $self->{lmdy} - $dy - $self->{lfdy}, 536 $self->{lmdy} - $dy - $self->{lfdy},
533 @{$self->{last_fow_texture}}{qw(name s t w h)}; 537 @{$self->{prev_fow_texture}}{qw(name data)}
534 } else { 538 );
535 delete $self->{last_fow_texture};
536 } 539 }
537 } 540 }
538 541
539 unless ($self->{last_fow_texture}) {
540 DC::Texture::draw_fow_texture 542 DC::Texture::draw_fow_texture
541 $::CFG->{fow_intensity}, 543 $::CFG->{fow_intensity},
544 $TEX_HIDDEN[$::CFG->{fow_texture}]{name},
542 @{$self->{fow_texture}}{qw(name s t w h)}; 545 @{$self->{fow_texture}}{qw(name data s t w h)},
543 } 546 @prev_fow_params;
544 } 547 }
545 548
546 if ($self->{magicmap}) { 549 if ($self->{magicmap}) {
547 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; 550 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
548 551
556 559
557 glPopMatrix; 560 glPopMatrix;
558 glEndList; 561 glEndList;
559 } 562 }
560 } else { 563 } else {
564 delete $self->{last_fow_texture};
565 delete $self->{fow_texture};
566
561 glDeleteList delete $self->{list} 567 glDeleteList delete $self->{list}
562 if $self->{list}; 568 if $self->{list};
563 } 569 }
564} 570}
565 571
601 $self->SUPER::DESTROY; 607 $self->SUPER::DESTROY;
602} 608}
603 609
604package DC::MapWidget::MapMap; 610package DC::MapWidget::MapMap;
605 611
606use strict; 612use common::sense;
607use utf8;
608 613
609our @ISA = DC::UI::Base::; 614our @ISA = DC::UI::Base::;
610 615
611use Time::HiRes qw(time); 616use Time::HiRes qw(time);
612use DC::OpenGL; 617use DC::OpenGL;
706 glDisable GL_BLEND; 711 glDisable GL_BLEND;
707} 712}
708 713
709package DC::MapWidget::Command; 714package DC::MapWidget::Command;
710 715
711use strict; 716use common::sense;
712 717
713use DC::OpenGL; 718use DC::OpenGL;
714 719
715our @ISA = DC::UI::Frame::; 720our @ISA = DC::UI::Frame::;
716 721

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines