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.103 by root, Sun Apr 1 15:09:45 2007 UTC vs.
Revision 1.104 by root, Wed Apr 4 02:43:29 2007 UTC

10use CFPlus::UI; 10use CFPlus::UI;
11use CFPlus::Macro; 11use CFPlus::Macro;
12 12
13our @ISA = CFPlus::UI::Base::; 13our @ISA = CFPlus::UI::Base::;
14 14
15sub ::T() { 32 }
16
17my $magicmap_tex = 15my $magicmap_tex =
18 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png", 16 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png",
19 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 17 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
20 18
21sub new { 19sub new {
23 21
24 my $self = $class->SUPER::new ( 22 my $self = $class->SUPER::new (
25 z => -1, 23 z => -1,
26 can_focus => 1, 24 can_focus => 1,
27 list => glGenList, 25 list => glGenList,
26 tilesize => 32,
28 27
29 smooth_matrix => [ 28 smooth_matrix => [
30 0.05, 0.13, 0.05, 29 0.05, 0.13, 0.05,
31 0.13, 0.30, 0.13, 30 0.13, 0.30, 0.13,
32 0.05, 0.13, 0.05, 31 0.05, 0.13, 0.05,
39 command => $self->{command}, 38 command => $self->{command},
40 tooltip => "#completer_help", 39 tooltip => "#completer_help",
41 ; 40 ;
42 41
43 $self 42 $self
43}
44
45sub set_tilesize {
46 my ($self, $tilesize) = @_;
47
48 $self->{tilesize} = $tilesize;
44} 49}
45 50
46sub add_command { 51sub add_command {
47 my ($self, $command, $tooltip, $widget, $cb) = @_; 52 my ($self, $command, $tooltip, $widget, $cb) = @_;
48 53
287 292
288 1 293 1
289} 294}
290 295
291sub size_request { 296sub size_request {
297 my ($self) = @_;
298
292 ( 299 (
293 ::T * CFPlus::ceil $::WIDTH / ::T, 300 $self->{tilesize} * CFPlus::ceil $::WIDTH / $self->{tilesize},
294 ::T * CFPlus::ceil $::HEIGHT / ::T, 301 $self->{tilesize} * CFPlus::ceil $::HEIGHT / $self->{tilesize},
295 ) 302 )
296} 303}
297 304
298sub update { 305sub update {
299 my ($self) = @_; 306 my ($self) = @_;
447 454
448 return 455 return
449 unless $focused || !$::FAST; 456 unless $focused || !$::FAST;
450 457
451 if (delete $self->{need_update}) { 458 if (delete $self->{need_update}) {
452 my $tilesize = $self->{tilesize} = int ::T * $::CFG->{map_scale}; 459 my $tilesize = $self->{tilesize} = int $self->{tilesize} * $::CFG->{map_scale};
453 460
454 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 461 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
455 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 462 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
456 463
457 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize; 464 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
494 501
495 glPushMatrix; 502 glPushMatrix;
496 glTranslate $sx0, $sy0; 503 glTranslate $sx0, $sy0;
497 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 504 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
498 505
499 $::MAP->draw ($dx, $dy, $sw, $sh, ::T); 506 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
500 507
501 glScale ::T, ::T; 508 glScale $self->{tilesize}, $self->{tilesize};
502 509
503 if (my $tex = $self->{fow_texture}) { 510 if (my $tex = $self->{fow_texture}) {
504 glEnable GL_TEXTURE_2D; 511 glEnable GL_TEXTURE_2D;
505 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 512 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
506 513
581 588
582 $::MAP or return; 589 $::MAP or return;
583 590
584 my ($w, $h) = @$self{qw(w h)}; 591 my ($w, $h) = @$self{qw(w h)};
585 592
586 my $sw = int $::WIDTH / (::T * $::CFG->{map_scale}) + 0.99; 593 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
587 my $sh = int $::HEIGHT / (::T * $::CFG->{map_scale}) + 0.99; 594 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
588 595
589 my $sx = int $::CFG->{map_shift_x} / ::T; 596 my $sx = int $::CFG->{map_shift_x} / $::MAPWIDGET->{tilesize};
590 my $sy = int $::CFG->{map_shift_y} / ::T; 597 my $sy = int $::CFG->{map_shift_y} / $::MAPWIDGET->{tilesize};
591 598
592 my $ox = 0.5 * ($w - $sw); 599 my $ox = 0.5 * ($w - $sw);
593 my $oy = 0.5 * ($h - $sh); 600 my $oy = 0.5 * ($h - $sh);
594 601
595 glEnable GL_BLEND; 602 glEnable GL_BLEND;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines