… | |
… | |
74 | sub harmonize { |
74 | sub 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 | |
115 | sub move { |
115 | sub 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 | |
122 | sub needs_redraw { |
122 | sub 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 | |
575 | sub size_request { |
575 | sub size_request { |
… | |
… | |
704 | |
704 | |
705 | $child->set_parent ($self); |
705 | $child->set_parent ($self); |
706 | $self->{children}[$y][$x] = $child; |
706 | $self->{children}[$y][$x] = $child; |
707 | |
707 | |
708 | $self->{w} = $self->{h} = -1; |
708 | $self->{w} = $self->{h} = -1; |
|
|
709 | $self->update; |
|
|
710 | } |
|
|
711 | |
|
|
712 | # TODO: move to container class maybe? send childs a signal on removal? |
|
|
713 | sub clear { |
|
|
714 | my ($self) = @_; |
|
|
715 | |
|
|
716 | delete $self->{children}; |
709 | $self->update; |
717 | $self->update; |
710 | } |
718 | } |
711 | |
719 | |
712 | sub get_wh { |
720 | sub get_wh { |
713 | my ($self) = @_; |
721 | my ($self) = @_; |
… | |
… | |
942 | my $self = $class->SUPER::new ( |
950 | my $self = $class->SUPER::new ( |
943 | fg => [1, 1, 1], |
951 | fg => [1, 1, 1], |
944 | fontsize => $::FONTSIZE, |
952 | fontsize => $::FONTSIZE, |
945 | text => "", |
953 | text => "", |
946 | align => -1, |
954 | align => -1, |
|
|
955 | valign => -1, |
947 | padding => 2, |
956 | padding => 2, |
948 | layout => new CFClient::Layout, |
957 | layout => new CFClient::Layout, |
949 | %arg |
958 | %arg |
950 | ); |
959 | ); |
951 | |
960 | |
… | |
… | |
1028 | my $x = |
1037 | my $x = |
1029 | $self->{align} < 0 ? $self->{padding} |
1038 | $self->{align} < 0 ? $self->{padding} |
1030 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1039 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1031 | : ($self->{w} - $tex->{w}) * 0.5; |
1040 | : ($self->{w} - $tex->{w}) * 0.5; |
1032 | |
1041 | |
1033 | $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); |
1034 | |
1048 | |
1035 | glDisable GL_TEXTURE_2D; |
1049 | glDisable GL_TEXTURE_2D; |
1036 | glDisable GL_BLEND; |
1050 | glDisable GL_BLEND; |
1037 | } |
1051 | } |
1038 | |
1052 | |
… | |
… | |
1053 | bg => [0, 0, 0, 0.2], |
1067 | bg => [0, 0, 0, 0.2], |
1054 | active_bg => [1, 1, 1, 0.5], |
1068 | active_bg => [1, 1, 1, 0.5], |
1055 | active_fg => [0, 0, 0], |
1069 | active_fg => [0, 0, 0], |
1056 | can_hover => 1, |
1070 | can_hover => 1, |
1057 | can_focus => 1, |
1071 | can_focus => 1, |
|
|
1072 | valign => 0, |
1058 | @_ |
1073 | @_ |
1059 | ) |
1074 | ) |
1060 | } |
1075 | } |
1061 | |
1076 | |
1062 | sub _set_text { |
1077 | sub _set_text { |
… | |
… | |
1766 | 0.1, 0.1, 0.1, |
1781 | 0.1, 0.1, 0.1, |
1767 | ; |
1782 | ; |
1768 | glEnable GL_CONVOLUTION_2D; |
1783 | glEnable GL_CONVOLUTION_2D; |
1769 | } |
1784 | } |
1770 | |
1785 | |
1771 | my $tex = new CFClient::Texture |
1786 | $self->{fow_texture} = new CFClient::Texture |
1772 | w => $w, |
1787 | w => $w, |
1773 | h => $h, |
1788 | h => $h, |
1774 | data => $data, |
1789 | data => $data, |
1775 | internalformat => GL_ALPHA, |
1790 | internalformat => GL_ALPHA, |
1776 | format => GL_ALPHA; |
1791 | format => GL_ALPHA; |
… | |
… | |
1781 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1796 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1782 | glEnable GL_TEXTURE_2D; |
1797 | glEnable GL_TEXTURE_2D; |
1783 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
1798 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
1784 | |
1799 | |
1785 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
1800 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
1786 | $tex->draw_quad (0, 0, $w * 32, $h * 32); |
1801 | $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32); |
1787 | |
1802 | |
1788 | glDisable GL_TEXTURE_2D; |
1803 | glDisable GL_TEXTURE_2D; |
1789 | glDisable GL_BLEND; |
1804 | glDisable GL_BLEND; |
1790 | } |
1805 | } |
1791 | |
1806 | |
… | |
… | |
1797 | glEnable GL_BLEND; |
1812 | glEnable GL_BLEND; |
1798 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1813 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1799 | glEnable GL_TEXTURE_2D; |
1814 | glEnable GL_TEXTURE_2D; |
1800 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1815 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1801 | |
1816 | |
|
|
1817 | $self->{mapmap_texture} = |
1802 | CFClient::Texture->new ( |
1818 | new CFClient::Texture |
1803 | w => $w, |
1819 | w => $w, |
1804 | h => $h, |
1820 | h => $h, |
1805 | data => $::MAP->mapmap ($w, $h), |
1821 | data => $::MAP->mapmap ($w, $h), |
1806 | type => GL_UNSIGNED_INT_8_8_8_8_REV |
1822 | type => GL_UNSIGNED_INT_8_8_8_8_REV; |
1807 | )->draw_quad (100, 100); |
1823 | |
|
|
1824 | $self->{mapmap_texture}->draw_quad (100, 100); |
1808 | |
1825 | |
1809 | glDisable GL_TEXTURE_2D; |
1826 | glDisable GL_TEXTURE_2D; |
1810 | glDisable GL_BLEND; |
1827 | glDisable GL_BLEND; |
1811 | } |
1828 | } |
1812 | # HACK END |
1829 | # HACK END |
… | |
… | |
2008 | sub add { |
2025 | sub add { |
2009 | my ($self, $widget) = @_; |
2026 | my ($self, $widget) = @_; |
2010 | |
2027 | |
2011 | $self->SUPER::add ($widget); |
2028 | $self->SUPER::add ($widget); |
2012 | |
2029 | |
2013 | $widget->size_allocate ($widget->{x}, $widget->{y}, $widget->size_request); |
2030 | $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request); |
2014 | } |
2031 | } |
2015 | |
2032 | |
2016 | sub on_refresh { |
2033 | sub on_refresh { |
2017 | my ($self, $id, $cb) = @_; |
2034 | my ($self, $id, $cb) = @_; |
2018 | |
2035 | |