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.100 by pippijn, Tue Jan 2 14:45:22 2007 UTC vs.
Revision 1.106 by root, Wed Apr 4 02:59:57 2007 UTC

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, 25 list => glGenList,
26 tilesize => 32,
26 27
27 smooth_matrix => [ 28 smooth_matrix => [
28 0.05, 0.13, 0.05, 29 0.05, 0.13, 0.05,
29 0.13, 0.30, 0.13, 30 0.13, 0.30, 0.13,
30 0.05, 0.13, 0.05, 31 0.05, 0.13, 0.05,
37 command => $self->{command}, 38 command => $self->{command},
38 tooltip => "#completer_help", 39 tooltip => "#completer_help",
39 ; 40 ;
40 41
41 $self 42 $self
43}
44
45sub set_tilesize {
46 my ($self, $tilesize) = @_;
47
48 $self->{tilesize} = $tilesize;
42} 49}
43 50
44sub add_command { 51sub add_command {
45 my ($self, $command, $tooltip, $widget, $cb) = @_; 52 my ($self, $command, $tooltip, $widget, $cb) = @_;
46 53
177 184
178 if ($ev->{button} == 1) { 185 if ($ev->{button} == 1) {
179 $self->grab_focus; 186 $self->grab_focus;
180 return unless $::CONN; 187 return unless $::CONN;
181 188
182 my $x = $self->{dx} + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize}; 189 my $x = $self->{dx} + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{ctilesize};
183 my $y = $self->{dy} + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize}; 190 my $y = $self->{dy} + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{ctilesize};
184 191
185 $x -= CFPlus::floor $::MAP->w * 0.5; 192 $x -= CFPlus::floor $::MAP->w * 0.5;
186 $y -= CFPlus::floor $::MAP->h * 0.5; 193 $y -= CFPlus::floor $::MAP->h * 0.5;
187 194
188 if ($::CONN) { 195 if ($::CONN) {
285 292
286 1 293 1
287} 294}
288 295
289sub size_request { 296sub size_request {
297 my ($self) = @_;
298
290 ( 299 (
291 32 * CFPlus::ceil $::WIDTH / 32, 300 $self->{tilesize} * CFPlus::ceil $::WIDTH / $self->{tilesize},
292 32 * CFPlus::ceil $::HEIGHT / 32, 301 $self->{tilesize} * CFPlus::ceil $::HEIGHT / $self->{tilesize},
293 ) 302 )
294} 303}
295 304
296sub update { 305sub update {
297 my ($self) = @_; 306 my ($self) = @_;
445 454
446 return 455 return
447 unless $focused || !$::FAST; 456 unless $focused || !$::FAST;
448 457
449 if (delete $self->{need_update}) { 458 if (delete $self->{need_update}) {
450 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 459 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1;
451 460
452 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 461 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
453 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 462 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
454 463
455 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize; 464 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
492 501
493 glPushMatrix; 502 glPushMatrix;
494 glTranslate $sx0, $sy0; 503 glTranslate $sx0, $sy0;
495 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 504 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
496 505
497 $::MAP->draw ($dx, $dy, $sw, $sh); 506 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
498 507
499 glScale 32, 32; 508 glScale $self->{tilesize}, $self->{tilesize};
500 509
501 if (my $tex = $self->{fow_texture}) { 510 if (my $tex = $self->{fow_texture}) {
502 glEnable GL_TEXTURE_2D; 511 glEnable GL_TEXTURE_2D;
503 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 512 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
504 513
548 $self->SUPER::DESTROY; 557 $self->SUPER::DESTROY;
549} 558}
550 559
551package CFPlus::MapWidget::MapMap; 560package CFPlus::MapWidget::MapMap;
552 561
562use strict;
563use utf8;
564
553our @ISA = CFPlus::UI::Base::; 565our @ISA = CFPlus::UI::Base::;
554 566
555use Time::HiRes qw(time); 567use Time::HiRes qw(time);
556use CFPlus::OpenGL; 568use CFPlus::OpenGL;
557 569
579 591
580 $::MAP or return; 592 $::MAP or return;
581 593
582 my ($w, $h) = @$self{qw(w h)}; 594 my ($w, $h) = @$self{qw(w h)};
583 595
584 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale}) + 0.99; 596 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
585 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale}) + 0.99; 597 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
586 598
587 my $sx = int $::CFG->{map_shift_x} / 32; 599 my $sx = int $::CFG->{map_shift_x} / $::MAPWIDGET->{tilesize};
588 my $sy = int $::CFG->{map_shift_y} / 32; 600 my $sy = int $::CFG->{map_shift_y} / $::MAPWIDGET->{tilesize};
589 601
590 my $ox = 0.5 * ($w - $sw); 602 my $ox = 0.5 * ($w - $sw);
591 my $oy = 0.5 * ($h - $sh); 603 my $oy = 0.5 * ($h - $sh);
592 604
593 glEnable GL_BLEND; 605 glEnable GL_BLEND;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines