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.115 by root, Sat Apr 15 19:35:20 2006 UTC vs.
Revision 1.119 by root, Sun Apr 16 07:25:30 2006 UTC

74sub harmonize { 74sub harmonize {
75 my ($vals) = @_; 75 my ($vals) = @_;
76 76
77 my $rem = 0; 77 my $rem = 0;
78 78
79 for ($vals) { 79 for (@$vals) {
80 my $i = int $_ + $rem; 80 my $i = int $_ + $rem;
81 $rem += $_ - $i; 81 $rem += $_ - $i;
82 $_ = $i; 82 $_ = $i;
83 } 83 }
84} 84}
112 $self 112 $self
113} 113}
114 114
115sub move { 115sub move {
116 my ($self, $x, $y, $z) = @_; 116 my ($self, $x, $y, $z) = @_;
117 $self->{x} = $x; 117 $self->{x} = int $x;
118 $self->{y} = $y; 118 $self->{y} = int $y;
119 $self->{z} = $z if defined $z; 119 $self->{z} = $z if defined $z;
120} 120}
121 121
122sub needs_redraw { 122sub needs_redraw {
123 0 123 0
565 # TODO: user_x, user_y, overwrite moveto? 565 # TODO: user_x, user_y, overwrite moveto?
566 566
567 $class->SUPER::new ( 567 $class->SUPER::new (
568 bg => [1, 1, 1, 1], 568 bg => [1, 1, 1, 1],
569 border_bg => [1, 1, 1, 1], 569 border_bg => [1, 1, 1, 1],
570 border => $::FONTSIZE * 0.8, 570 border => int $::FONTSIZE * 0.8,
571 @_ 571 @_
572 ) 572 )
573} 573}
574 574
575sub size_request { 575sub size_request {
950 my $self = $class->SUPER::new ( 950 my $self = $class->SUPER::new (
951 fg => [1, 1, 1], 951 fg => [1, 1, 1],
952 fontsize => $::FONTSIZE, 952 fontsize => $::FONTSIZE,
953 text => "", 953 text => "",
954 align => -1, 954 align => -1,
955 valign => -1,
955 padding => 2, 956 padding => 2,
956 layout => new CFClient::Layout, 957 layout => new CFClient::Layout,
957 %arg 958 %arg
958 ); 959 );
959 960
1036 my $x = 1037 my $x =
1037 $self->{align} < 0 ? $self->{padding} 1038 $self->{align} < 0 ? $self->{padding}
1038 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 1039 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1039 : ($self->{w} - $tex->{w}) * 0.5; 1040 : ($self->{w} - $tex->{w}) * 0.5;
1040 1041
1041 $tex->draw_quad (int $x, int +($self->{h} - $tex->{h}) * 0.5); 1042 my $y =
1043 $self->{valign} < 0 ? $self->{padding}
1044 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
1045 : ($self->{h} - $tex->{h}) * 0.5;
1046
1047 $tex->draw_quad (int $x, int $y);
1042 1048
1043 glDisable GL_TEXTURE_2D; 1049 glDisable GL_TEXTURE_2D;
1044 glDisable GL_BLEND; 1050 glDisable GL_BLEND;
1045} 1051}
1046 1052
1061 bg => [0, 0, 0, 0.2], 1067 bg => [0, 0, 0, 0.2],
1062 active_bg => [1, 1, 1, 0.5], 1068 active_bg => [1, 1, 1, 0.5],
1063 active_fg => [0, 0, 0], 1069 active_fg => [0, 0, 0],
1064 can_hover => 1, 1070 can_hover => 1,
1065 can_focus => 1, 1071 can_focus => 1,
1072 valign => 0,
1066 @_ 1073 @_
1067 ) 1074 )
1068} 1075}
1069 1076
1070sub _set_text { 1077sub _set_text {
1269 1276
1270sub _draw { 1277sub _draw {
1271 my ($self) = @_; 1278 my ($self) = @_;
1272 1279
1273 local $self->{fg} = $self->{fg}; 1280 local $self->{fg} = $self->{fg};
1274 my $tex = $tex[0];
1275
1276 glEnable GL_BLEND;
1277 glEnable GL_TEXTURE_2D;
1278 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1279 1281
1280 if ($GRAB == $self) { 1282 if ($GRAB == $self) {
1281 $self->{fg} = $self->{active_fg}; 1283 $self->{fg} = $self->{active_fg};
1282 } 1284 }
1283 1285
1284 glBindTexture GL_TEXTURE_2D, $tex->{name}; 1286 glEnable GL_BLEND;
1287 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1288 glEnable GL_TEXTURE_2D;
1285 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1289 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1290 glColor 0, 0, 0, 1;
1286 1291
1287 $tex->draw_quad (0, 0, $self->{w}, $self->{h}); 1292 $tex[0]->draw_quad (0, 0, $self->{w}, $self->{h});
1288 1293
1289 glDisable GL_TEXTURE_2D; 1294 glDisable GL_TEXTURE_2D;
1290 glDisable GL_BLEND; 1295 glDisable GL_BLEND;
1291 1296
1292 $self->SUPER::_draw; 1297 $self->SUPER::_draw;
1774 0.1, 0.1, 0.1, 1779 0.1, 0.1, 0.1,
1775 ; 1780 ;
1776 glEnable GL_CONVOLUTION_2D; 1781 glEnable GL_CONVOLUTION_2D;
1777 } 1782 }
1778 1783
1779 my $tex = new CFClient::Texture 1784 $self->{fow_texture} = new CFClient::Texture
1780 w => $w, 1785 w => $w,
1781 h => $h, 1786 h => $h,
1782 data => $data, 1787 data => $data,
1783 internalformat => GL_ALPHA, 1788 internalformat => GL_ALPHA,
1784 format => GL_ALPHA; 1789 format => GL_ALPHA;
1789 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1794 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1790 glEnable GL_TEXTURE_2D; 1795 glEnable GL_TEXTURE_2D;
1791 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1796 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1792 1797
1793 glColor +($::CFG->{fow_intensity}) x 3, 1; 1798 glColor +($::CFG->{fow_intensity}) x 3, 1;
1794 $tex->draw_quad (0, 0, $w * 32, $h * 32); 1799 $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32);
1795 1800
1796 glDisable GL_TEXTURE_2D; 1801 glDisable GL_TEXTURE_2D;
1797 glDisable GL_BLEND; 1802 glDisable GL_BLEND;
1798 } 1803 }
1799 1804
1805 glEnable GL_BLEND; 1810 glEnable GL_BLEND;
1806 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1811 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1807 glEnable GL_TEXTURE_2D; 1812 glEnable GL_TEXTURE_2D;
1808 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1813 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1809 1814
1815 $self->{mapmap_texture} =
1810 CFClient::Texture->new ( 1816 new CFClient::Texture
1811 w => $w, 1817 w => $w,
1812 h => $h, 1818 h => $h,
1813 data => $::MAP->mapmap ($w, $h), 1819 data => $::MAP->mapmap ($w, $h),
1814 type => GL_UNSIGNED_INT_8_8_8_8_REV 1820 type => GL_UNSIGNED_INT_8_8_8_8_REV;
1815 )->draw_quad (100, 100); 1821
1822 $self->{mapmap_texture}->draw_quad (100, 100);
1816 1823
1817 glDisable GL_TEXTURE_2D; 1824 glDisable GL_TEXTURE_2D;
1818 glDisable GL_BLEND; 1825 glDisable GL_BLEND;
1819 } 1826 }
1820 # HACK END 1827 # HACK END
2016sub add { 2023sub add {
2017 my ($self, $widget) = @_; 2024 my ($self, $widget) = @_;
2018 2025
2019 $self->SUPER::add ($widget); 2026 $self->SUPER::add ($widget);
2020 2027
2021 $widget->size_allocate ($widget->{x}, $widget->{y}, $widget->size_request); 2028 $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request);
2022} 2029}
2023 2030
2024sub on_refresh { 2031sub on_refresh {
2025 my ($self, $id, $cb) = @_; 2032 my ($self, $id, $cb) = @_;
2026 2033

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines