… | |
… | |
66 | $hover->update if $hover && $hover->{can_hover}; |
66 | $hover->update if $hover && $hover->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
68 | } |
68 | } |
69 | |
69 | |
70 | $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; |
70 | $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; |
|
|
71 | } |
|
|
72 | |
|
|
73 | # convert position array to integers |
|
|
74 | sub harmonize { |
|
|
75 | my ($vals) = @_; |
|
|
76 | |
|
|
77 | my $rem = 0; |
|
|
78 | |
|
|
79 | for ($vals) { |
|
|
80 | my $i = int $_ + $rem; |
|
|
81 | $rem += $_ - $i; |
|
|
82 | $_ = $i; |
|
|
83 | } |
71 | } |
84 | } |
72 | |
85 | |
73 | ############################################################################# |
86 | ############################################################################# |
74 | |
87 | |
75 | package CFClient::UI::Base; |
88 | package CFClient::UI::Base; |
… | |
… | |
733 | |
746 | |
734 | # linearly scale sizes |
747 | # linearly scale sizes |
735 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
748 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
736 | $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; |
749 | $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; |
737 | |
750 | |
738 | $_ = int $_ for @$ws; #TODO: avoid rounding problems |
751 | CFClient::UI::harmonize $ws; |
739 | $_ = int $_ for @$hs; #TODO: avoid rounding problems |
752 | CFClient::UI::harmonize $hs; |
740 | |
753 | |
741 | my $y; |
754 | my $y; |
742 | |
755 | |
743 | for my $r (0 .. $#{$self->{children}}) { |
756 | for my $r (0 .. $#{$self->{children}}) { |
744 | my $row = $self->{children}[$r] |
757 | my $row = $self->{children}[$r] |
… | |
… | |
832 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
845 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
833 | $h[$_] = $alloc_h; |
846 | $h[$_] = $alloc_h; |
834 | } |
847 | } |
835 | } |
848 | } |
836 | |
849 | |
|
|
850 | CFClient::UI::harmonize \@h; |
|
|
851 | |
837 | my $y = 0; |
852 | my $y = 0; |
838 | for (0 .. $#$children) { |
853 | for (0 .. $#$children) { |
839 | my $child = $children->[$_]; |
854 | my $child = $children->[$_]; |
840 | my $h = int $h[$_]; |
855 | my $h = $h[$_]; |
841 | $child->size_allocate ($y, 0, $h, $w); |
856 | $child->size_allocate ($y, 0, $h, $w); |
842 | |
857 | |
843 | $y += $h; |
858 | $y += $h; |
844 | } |
859 | } |
845 | } |
860 | } |
… | |
… | |
886 | |
901 | |
887 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
902 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
888 | } |
903 | } |
889 | } |
904 | } |
890 | |
905 | |
|
|
906 | CFClient::UI::harmonize \@h; |
|
|
907 | |
891 | my $y = 0; |
908 | my $y = 0; |
892 | for (0 .. $#$children) { |
909 | for (0 .. $#$children) { |
893 | my $child = $children->[$_]; |
910 | my $child = $children->[$_]; |
894 | my $h = int $h[$_]; |
911 | my $h = $h[$_]; |
895 | $child->size_allocate (0, $y, $w, $h); |
912 | $child->size_allocate (0, $y, $w, $h); |
896 | |
913 | |
897 | $y += $h; |
914 | $y += $h; |
898 | } |
915 | } |
899 | } |
916 | } |
… | |
… | |
1713 | |
1730 | |
1714 | if ($::MAP) { |
1731 | if ($::MAP) { |
1715 | my $sw = int $::WIDTH / 32; |
1732 | my $sw = int $::WIDTH / 32; |
1716 | my $sh = int $::HEIGHT / 32; |
1733 | my $sh = int $::HEIGHT / 32; |
1717 | |
1734 | |
1718 | my $sx = $::CFG->{map_shift_x}; |
1735 | my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; |
1719 | my $sy = $::CFG->{map_shift_y}; |
1736 | my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; |
1720 | |
1737 | |
1721 | glTranslate +($sx & 31) - 32, ($sy & 31) - 32, 0; |
1738 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
1722 | |
1739 | |
1723 | my ($w, $h, $data) = $::MAP->draw ($sx >> 5, $sy >> 5, 0, 0, $sw + 1, $sh + 1); |
1740 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
1724 | |
1741 | |
1725 | if ($::CFG->{fow_enable}) { |
1742 | if ($::CFG->{fow_enable}) { |
1726 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1743 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
1727 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1744 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
1728 | glConvolutionFilter2D |
1745 | glConvolutionFilter2D |
… | |
… | |
1759 | glDisable GL_BLEND; |
1776 | glDisable GL_BLEND; |
1760 | } |
1777 | } |
1761 | |
1778 | |
1762 | # HACK BEGIN |
1779 | # HACK BEGIN |
1763 | { |
1780 | { |
1764 | glTranslate -(($sx & 31) - 32), -(($sy & 31) - 32), 0;#remove |
1781 | glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove |
1765 | my ($w, $h) = (250, 250); |
1782 | my ($w, $h) = (250, 250); |
1766 | |
1783 | |
1767 | glEnable GL_BLEND; |
1784 | glEnable GL_BLEND; |
1768 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1785 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1769 | glEnable GL_TEXTURE_2D; |
1786 | glEnable GL_TEXTURE_2D; |