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.113 by elmex, Sat Jul 21 20:30:41 2007 UTC vs.
Revision 1.114 by root, Mon Jul 23 23:52:41 2007 UTC

20 my $class = shift; 20 my $class = shift;
21 21
22 my $self = $class->SUPER::new ( 22 my $self = $class->SUPER::new (
23 z => -1, 23 z => -1,
24 can_focus => 1, 24 can_focus => 1,
25 list => glGenList,
26 tilesize => 32, 25 tilesize => 32,
27 @_ 26 @_
28 ); 27 );
29 28
30 $self->{completer} = new CFPlus::MapWidget::Command:: 29 $self->{completer} = new CFPlus::MapWidget::Command::
449} 448}
450 449
451sub refresh_hook { 450sub refresh_hook {
452 my ($self) = @_; 451 my ($self) = @_;
453 452
454 return unless $::MAP; 453 if ($::MAP) {
455
456 if (delete $self->{need_update}) { 454 if (delete $self->{need_update}) {
457 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1; 455 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1;
458 456
459 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 457 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
460 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 458 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
461 459
462 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize; 460 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
463 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize; 461 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
464 462
465 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 463 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
466 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 464 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
467 465
468 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx; 466 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx;
469 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy; 467 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy;
470 468
471 if ($::CFG->{fow_enable}) { 469 if ($::CFG->{fow_enable}) {
472 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh); 470 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
473 471
474 $self->{fow_texture} = new CFPlus::Texture 472 $self->{fow_texture} = new CFPlus::Texture
475 w => $w, 473 w => $w,
476 h => $h, 474 h => $h,
477 data => $data, 475 data => $data,
478 internalformat => GL_ALPHA, 476 internalformat => GL_ALPHA,
479 format => GL_ALPHA; 477 format => GL_ALPHA;
480 } else { 478 } else {
481 delete $self->{fow_texture}; 479 delete $self->{fow_texture};
482 } 480 }
483 481
484 glNewList $self->{list}; 482 glNewList ($self->{list} ||= glGenList);
485 483
486 glPushMatrix;
487 glTranslate $sx0, $sy0;
488 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
489
490 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
491
492 glScale $self->{tilesize}, $self->{tilesize};
493
494 if (my $tex = $self->{fow_texture}) {
495 glPushMatrix; 484 glPushMatrix;
485 glTranslate $sx0, $sy0;
486 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
487
488 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
489
490 glScale $self->{tilesize}, $self->{tilesize};
491
492 if (my $tex = $self->{fow_texture}) {
493 glPushMatrix;
496 glScale 1/3, 1/3; 494 glScale 1/3, 1/3;
497 glEnable GL_TEXTURE_2D; 495 glEnable GL_TEXTURE_2D;
498 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 496 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
499 497
500 glColor +($::CFG->{fow_intensity}) x 3, 0.9; 498 glColor +($::CFG->{fow_intensity}) x 3, 0.9;
501 $self->{fow_texture}->draw_quad_alpha (0, 0); 499 $self->{fow_texture}->draw_quad_alpha (0, 0);
502 500
503 glDisable GL_TEXTURE_2D; 501 glDisable GL_TEXTURE_2D;
502 glPopMatrix;
503 }
504
505 if ($self->{magicmap}) {
506 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
507
508 $x += $::MAP->ox + $self->{dx};
509 $y += $::MAP->oy + $self->{dy};
510
511 glTranslate - $x - 1, - $y - 1;
512 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
513 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
514 }
515
504 glPopMatrix; 516 glPopMatrix;
505 }
506
507 if ($self->{magicmap}) {
508 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
509
510 $x += $::MAP->ox + $self->{dx};
511 $y += $::MAP->oy + $self->{dy};
512
513 glTranslate - $x - 1, - $y - 1;
514 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
515 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
516 }
517
518 glPopMatrix;
519 glEndList; 517 glEndList;
518 }
519 } else {
520 glDeleteList delete $self->{list}
521 if $self->{list};
520 } 522 }
521
522} 523}
523 524
524sub draw { 525sub draw {
525 my ($self) = @_; 526 my ($self) = @_;
526 527

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines