ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.108 by root, Fri Apr 14 23:32:29 2006 UTC vs.
Revision 1.112 by root, Sat Apr 15 12:29:46 2006 UTC

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
74sub 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
75package CFClient::UI::Base; 88package 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}
1709 my ($self) = @_; 1726 my ($self) = @_;
1710 1727
1711 if (delete $self->{need_update}) { 1728 if (delete $self->{need_update}) {
1712 glNewList $self->{list}, GL_COMPILE; 1729 glNewList $self->{list}, GL_COMPILE;
1713 1730
1714 my $sw = int $::WIDTH / 32;
1715 my $sh = int $::HEIGHT / 32;
1716
1717 if ($::MAP) { 1731 if ($::MAP) {
1718 my $sx = $::CFG->{map_shift_x}; 1732 my $sw = int $::WIDTH / 32;
1719 my $sy = $::CFG->{map_shift_y}; 1733 my $sh = int $::HEIGHT / 32;
1720 1734
1735 my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32;
1736 my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32;
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
1746 format => GL_ALPHA; 1763 format => GL_ALPHA;
1747 1764
1748 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; 1765 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
1749 1766
1750 glEnable GL_BLEND; 1767 glEnable GL_BLEND;
1768 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1751 glEnable GL_TEXTURE_2D; 1769 glEnable GL_TEXTURE_2D;
1752 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1770 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1753 1771
1754 glColor +($::CFG->{fow_intensity}) x 3, 1; 1772 glColor +($::CFG->{fow_intensity}) x 3, 1;
1755 $tex->draw_quad (0, 0, $w * 32, $h * 32); 1773 $tex->draw_quad (0, 0, $w * 32, $h * 32);
1756 1774
1757 glDisable GL_TEXTURE_2D; 1775 glDisable GL_TEXTURE_2D;
1758 glDisable GL_BLEND; 1776 glDisable GL_BLEND;
1759 } 1777 }
1778
1779 # HACK BEGIN
1780 {
1781 glTranslate -($sx0 - 32), -($sy0 - 32), 0;#remove
1782 my ($w, $h) = (250, 250);
1783
1784 glEnable GL_BLEND;
1785 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1786 glEnable GL_TEXTURE_2D;
1787 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1788
1789 CFClient::Texture->new (
1790 w => $w,
1791 h => $h,
1792 data => $::MAP->mapmap ($w, $h),
1793 type => GL_UNSIGNED_INT_8_8_8_8_REV
1794 )->draw_quad (100, 100);
1795
1796 glDisable GL_TEXTURE_2D;
1797 glDisable GL_BLEND;
1798 }
1799 # HACK END
1760 } 1800 }
1761 1801
1762 glEndList; 1802 glEndList;
1763 } 1803 }
1764 1804

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines