… | |
… | |
1170 | our @ISA = CFClient::UI::Label::; |
1170 | our @ISA = CFClient::UI::Label::; |
1171 | |
1171 | |
1172 | use SDL; |
1172 | use SDL; |
1173 | use SDL::OpenGL; |
1173 | use SDL::OpenGL; |
1174 | |
1174 | |
|
|
1175 | my @tex = |
|
|
1176 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1177 | qw(b1_button_active.png); |
|
|
1178 | |
1175 | sub new { |
1179 | sub new { |
1176 | my $class = shift; |
1180 | my $class = shift; |
1177 | |
1181 | |
1178 | $class->SUPER::new ( |
1182 | $class->SUPER::new ( |
1179 | padding => 4, |
1183 | padding => 4, |
1180 | fg => [1, 1, 1], |
1184 | fg => [1, 1, 1], |
1181 | bg => [1, 1, 1, 0.2], |
1185 | bg => [1, 1, 1, 0.2], |
1182 | active_bg => [0, 0, 0, 0.5], |
|
|
1183 | active_fg => [1, 1, 0], |
1186 | active_fg => [1, 1, 0], |
|
|
1187 | # active_bg => [0, 0, 0, 0.5], |
1184 | border_fg => [1, 1, 0], |
1188 | # border_fg => [1, 1, 0], |
1185 | @_ |
1189 | @_ |
1186 | ) |
1190 | ) |
1187 | } |
1191 | } |
1188 | |
1192 | |
1189 | sub button_up { |
1193 | sub button_up { |
… | |
… | |
1197 | |
1201 | |
1198 | sub _draw { |
1202 | sub _draw { |
1199 | my ($self) = @_; |
1203 | my ($self) = @_; |
1200 | |
1204 | |
1201 | local $self->{fg} = $self->{fg}; |
1205 | local $self->{fg} = $self->{fg}; |
|
|
1206 | my $tex = $tex[0]; |
1202 | |
1207 | |
1203 | glEnable GL_BLEND; |
1208 | glEnable GL_BLEND; |
|
|
1209 | glEnable GL_TEXTURE_2D; |
1204 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1210 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1205 | |
1211 | |
1206 | glTranslate 0.375, 0.375, 0; # make line and polyogon coordinates behave similarly |
|
|
1207 | |
|
|
1208 | glBegin GL_LINE_LOOP; |
|
|
1209 | glColor @{$self->{border_fg}}; |
|
|
1210 | glVertex 1 , 1; |
|
|
1211 | glVertex 1 , $self->{h} - 2; |
|
|
1212 | glVertex $self->{w} - 2, $self->{h} - 2; |
|
|
1213 | glVertex $self->{w} - 2, 1; |
|
|
1214 | glEnd; |
|
|
1215 | |
|
|
1216 | if ($GRAB == $self) { |
1212 | if ($GRAB == $self) { |
1217 | glColor @{$self->{active_bg}}; |
|
|
1218 | $self->{fg} = $self->{active_fg}; |
1213 | $self->{fg} = $self->{active_fg}; |
1219 | } else { |
|
|
1220 | glColor @{$self->{bg}}; |
|
|
1221 | } |
1214 | } |
1222 | |
1215 | |
1223 | glBegin GL_QUADS; |
1216 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
1224 | glVertex 2 , 2; |
1217 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1225 | glVertex 2 , $self->{h} - 2; |
1218 | |
1226 | glVertex $self->{w} - 2, $self->{h} - 2; |
1219 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
1227 | glVertex $self->{w} - 2, 2; |
1220 | |
1228 | glEnd; |
1221 | glDisable GL_TEXTURE_2D; |
1229 | glDisable GL_BLEND; |
1222 | glDisable GL_BLEND; |
1230 | |
1223 | |
1231 | $self->SUPER::_draw; |
1224 | $self->SUPER::_draw; |
1232 | } |
1225 | } |
1233 | |
1226 | |
… | |
… | |
1506 | my $mod = $ev->key_mod; |
1499 | my $mod = $ev->key_mod; |
1507 | my $sym = $ev->key_sym; |
1500 | my $sym = $ev->key_sym; |
1508 | |
1501 | |
1509 | if ($sym == SDLK_KP5) { |
1502 | if ($sym == SDLK_KP5) { |
1510 | $::CONN->send ("command stay fire"); |
1503 | $::CONN->send ("command stay fire"); |
|
|
1504 | } elsif ($sym == SDLK_a) { |
|
|
1505 | $::CONN->send ("command apply"); |
1511 | } elsif (exists $DIR{$sym}) { |
1506 | } elsif (exists $DIR{$sym}) { |
1512 | if ($mod & KMOD_SHIFT) { |
1507 | if ($mod & KMOD_SHIFT) { |
1513 | $self->{shft}++; |
1508 | $self->{shft}++; |
1514 | $::CONN->send ("command fire $DIR{$sym}[0]"); |
1509 | $::CONN->send ("command fire $DIR{$sym}[0]"); |
1515 | } elsif ($mod & KMOD_CTRL) { |
1510 | } elsif ($mod & KMOD_CTRL) { |