… | |
… | |
1655 | } |
1655 | } |
1656 | |
1656 | |
1657 | sub key_up { |
1657 | sub key_up { |
1658 | } |
1658 | } |
1659 | |
1659 | |
|
|
1660 | sub button_down { |
|
|
1661 | my ($self, $ev, $x, $y) = @_; |
|
|
1662 | |
|
|
1663 | $self->focus_in; |
|
|
1664 | |
|
|
1665 | if ($ev->button == 2) { |
|
|
1666 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
|
|
1667 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
|
|
1668 | |
|
|
1669 | $self->{motion} = sub { |
|
|
1670 | my ($ev, $x, $y) = @_; |
|
|
1671 | |
|
|
1672 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
|
|
1673 | |
|
|
1674 | $::CFG->{map_shift_x} = $bw + $x - $ox; |
|
|
1675 | $::CFG->{map_shift_y} = $bh + $y - $oy; |
|
|
1676 | |
|
|
1677 | $self->update; |
|
|
1678 | }; |
|
|
1679 | } |
|
|
1680 | } |
|
|
1681 | |
|
|
1682 | sub button_up { |
|
|
1683 | my ($self, $ev, $x, $y) = @_; |
|
|
1684 | |
|
|
1685 | delete $self->{motion}; |
|
|
1686 | } |
|
|
1687 | |
|
|
1688 | sub mouse_motion { |
|
|
1689 | my ($self, $ev, $x, $y) = @_; |
|
|
1690 | |
|
|
1691 | $self->{motion}->($ev, $x, $y) if $self->{motion}; |
|
|
1692 | } |
|
|
1693 | |
1660 | sub size_request { |
1694 | sub size_request { |
1661 | ( |
1695 | ( |
1662 | 1 + 32 * int $::WIDTH / 32, |
1696 | 1 + 32 * int $::WIDTH / 32, |
1663 | 1 + 32 * int $::HEIGHT / 32, |
1697 | 1 + 32 * int $::HEIGHT / 32, |
1664 | ) |
1698 | ) |
… | |
… | |
1672 | } |
1706 | } |
1673 | |
1707 | |
1674 | sub draw { |
1708 | sub draw { |
1675 | my ($self) = @_; |
1709 | my ($self) = @_; |
1676 | |
1710 | |
1677 | $self->{need_update}++;#d# |
|
|
1678 | if (delete $self->{need_update}) { |
1711 | if (delete $self->{need_update}) { |
1679 | glNewList $self->{list}, GL_COMPILE; |
1712 | glNewList $self->{list}, GL_COMPILE; |
1680 | |
1713 | |
1681 | my $sw = int $::WIDTH / 32; |
1714 | my $sw = int $::WIDTH / 32; |
1682 | my $sh = int $::HEIGHT / 32; |
1715 | my $sh = int $::HEIGHT / 32; |
1683 | |
1716 | |
1684 | if ($::MAP) { |
1717 | if ($::MAP) { |
|
|
1718 | my $sx = $::CFG->{map_shift_x}; |
|
|
1719 | my $sy = $::CFG->{map_shift_y}; |
|
|
1720 | |
|
|
1721 | glTranslate +($sx & 31) - 32, ($sy & 31) - 32, 0; |
|
|
1722 | |
1685 | my ($w, $h, $data) = $::MAP->draw (0, 0, $sw, $sh); |
1723 | my ($w, $h, $data) = $::MAP->draw ($sx >> 5, $sy >> 5, 0, 0, $sw + 1, $sh + 1); |
1686 | |
1724 | |
1687 | if ($::CFG->{fow_enable}) { |
1725 | if ($::CFG->{fow_enable}) { |
1688 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1726 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1689 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1727 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1690 | glConvolutionFilter2D |
1728 | glConvolutionFilter2D |
… | |
… | |
1722 | } |
1760 | } |
1723 | |
1761 | |
1724 | glEndList; |
1762 | glEndList; |
1725 | } |
1763 | } |
1726 | |
1764 | |
|
|
1765 | glPushMatrix; |
1727 | glCallList $self->{list}; |
1766 | glCallList $self->{list}; |
|
|
1767 | glPopMatrix; |
1728 | |
1768 | |
1729 | if ($FOCUS != $self) { |
1769 | if ($FOCUS != $self) { |
1730 | glColor 64/255, 64/255, 64/255; |
1770 | glColor 64/255, 64/255, 64/255; |
1731 | glLogicOp GL_AND; |
1771 | glLogicOp GL_AND; |
1732 | glEnable GL_COLOR_LOGIC_OP; |
1772 | glEnable GL_COLOR_LOGIC_OP; |