… | |
… | |
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; |
|
|
1682 | my $sh = int $::HEIGHT / 32; |
|
|
1683 | |
|
|
1684 | if ($::MAP) { |
1714 | if ($::MAP) { |
|
|
1715 | my $sw = int $::WIDTH / 32; |
|
|
1716 | my $sh = int $::HEIGHT / 32; |
|
|
1717 | |
|
|
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 |
… | |
… | |
1708 | format => GL_ALPHA; |
1746 | format => GL_ALPHA; |
1709 | |
1747 | |
1710 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
1748 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
1711 | |
1749 | |
1712 | glEnable GL_BLEND; |
1750 | glEnable GL_BLEND; |
|
|
1751 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1713 | glEnable GL_TEXTURE_2D; |
1752 | glEnable GL_TEXTURE_2D; |
1714 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
1753 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
1715 | |
1754 | |
1716 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
1755 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
1717 | $tex->draw_quad (0, 0, $w * 32, $h * 32); |
1756 | $tex->draw_quad (0, 0, $w * 32, $h * 32); |
1718 | |
1757 | |
1719 | glDisable GL_TEXTURE_2D; |
1758 | glDisable GL_TEXTURE_2D; |
1720 | glDisable GL_BLEND; |
1759 | glDisable GL_BLEND; |
1721 | } |
1760 | } |
|
|
1761 | |
|
|
1762 | # HACK BEGIN |
|
|
1763 | { |
|
|
1764 | my ($w, $h) = (250, 250); |
|
|
1765 | |
|
|
1766 | glEnable GL_BLEND; |
|
|
1767 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1768 | glEnable GL_TEXTURE_2D; |
|
|
1769 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1770 | |
|
|
1771 | CFClient::Texture->new ( |
|
|
1772 | w => $w, |
|
|
1773 | h => $h, |
|
|
1774 | data => $::MAP->mapmap ($w, $h), |
|
|
1775 | type => GL_UNSIGNED_INT_8_8_8_8_REV |
|
|
1776 | )->draw_quad (100, 100); |
|
|
1777 | |
|
|
1778 | glDisable GL_TEXTURE_2D; |
|
|
1779 | glDisable GL_BLEND; |
|
|
1780 | } |
|
|
1781 | # HACK END |
1722 | } |
1782 | } |
1723 | |
1783 | |
1724 | glEndList; |
1784 | glEndList; |
1725 | } |
1785 | } |
1726 | |
1786 | |
|
|
1787 | glPushMatrix; |
1727 | glCallList $self->{list}; |
1788 | glCallList $self->{list}; |
|
|
1789 | glPopMatrix; |
1728 | |
1790 | |
1729 | if ($FOCUS != $self) { |
1791 | if ($FOCUS != $self) { |
1730 | glColor 64/255, 64/255, 64/255; |
1792 | glColor 64/255, 64/255, 64/255; |
1731 | glLogicOp GL_AND; |
1793 | glLogicOp GL_AND; |
1732 | glEnable GL_COLOR_LOGIC_OP; |
1794 | glEnable GL_COLOR_LOGIC_OP; |