1 | package DC::MapWidget; |
1 | package DC::MapWidget; |
2 | |
2 | |
3 | use strict; |
3 | use common::sense; |
4 | use utf8; |
|
|
5 | |
4 | |
6 | use List::Util qw(min max); |
5 | use List::Util qw(min max); |
7 | |
6 | |
8 | use DC; |
7 | use DC; |
9 | use DC::OpenGL; |
8 | use DC::OpenGL; |
… | |
… | |
515 | glTranslate $sx0, $sy0; |
514 | glTranslate $sx0, $sy0; |
516 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
515 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
517 | glTranslate DC::ceil $self->{sdx}, DC::ceil $self->{sdy}; |
516 | glTranslate DC::ceil $self->{sdx}, DC::ceil $self->{sdy}; |
518 | |
517 | |
519 | $::MAP->draw ($dx, $dy, $sw, $sh, |
518 | $::MAP->draw ($dx, $dy, $sw, $sh, |
520 | $self->{tilesize}, |
519 | ($self->{tilesize}) x 2, |
521 | $::CONN->{player}{tag}, |
520 | $::CONN->{player}{tag}, |
522 | -$self->{sdx}, -$self->{sdy}); |
521 | -$self->{sdx}, -$self->{sdy}); |
523 | |
522 | |
524 | glScale $self->{tilesize}, $self->{tilesize}; |
523 | glScale $self->{tilesize}, $self->{tilesize}; |
525 | |
524 | |
… | |
… | |
608 | $self->SUPER::DESTROY; |
607 | $self->SUPER::DESTROY; |
609 | } |
608 | } |
610 | |
609 | |
611 | package DC::MapWidget::MapMap; |
610 | package DC::MapWidget::MapMap; |
612 | |
611 | |
613 | use strict; |
612 | use common::sense; |
614 | use utf8; |
|
|
615 | |
613 | |
616 | our @ISA = DC::UI::Base::; |
614 | our @ISA = DC::UI::Base::; |
617 | |
615 | |
618 | use Time::HiRes qw(time); |
|
|
619 | use DC::OpenGL; |
616 | use DC::OpenGL; |
620 | |
617 | |
621 | sub size_request { |
618 | sub size_request { |
622 | ($::HEIGHT * 0.2, $::HEIGHT * 0.2) |
619 | ($::HEIGHT * 0.2, $::HEIGHT * 0.2) |
623 | } |
620 | } |
624 | |
621 | |
625 | sub refresh_hook { |
622 | sub refresh_hook { |
626 | my ($self) = @_; |
623 | my ($self) = @_; |
627 | |
624 | |
628 | if ($::MAP && $self->{texture_atime} < time) { |
625 | if ($::MAP && $self->{texture_atime} < EV::now) { |
629 | my ($w, $h) = @$self{qw(w h)}; |
626 | my ($w, $h) = @$self{qw(w h)}; |
630 | |
627 | |
631 | return unless $w && $h; |
628 | return unless $w && $h; |
632 | |
629 | |
633 | my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; |
630 | my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; |
… | |
… | |
648 | $self->{sh} = $sh; |
645 | $self->{sh} = $sh; |
649 | |
646 | |
650 | $self->{x0} = $x0; |
647 | $self->{x0} = $x0; |
651 | $self->{y0} = $y0; |
648 | $self->{y0} = $y0; |
652 | |
649 | |
653 | $self->{texture_atime} = time + 1/3; |
650 | $self->{texture_atime} = EV::now + 1/2; |
654 | |
651 | |
655 | $self->{texture} = |
652 | $self->{texture} = |
656 | new DC::Texture |
653 | new DC::Texture |
657 | w => $w, |
654 | w => $w, |
658 | h => $h, |
655 | h => $h, |
… | |
… | |
713 | glDisable GL_BLEND; |
710 | glDisable GL_BLEND; |
714 | } |
711 | } |
715 | |
712 | |
716 | package DC::MapWidget::Command; |
713 | package DC::MapWidget::Command; |
717 | |
714 | |
718 | use strict; |
715 | use common::sense; |
719 | |
716 | |
720 | use DC::OpenGL; |
717 | use DC::OpenGL; |
721 | |
718 | |
722 | our @ISA = DC::UI::Frame::; |
719 | our @ISA = DC::UI::Frame::; |
723 | |
720 | |