… | |
… | |
79 | use SDL::OpenGL; |
79 | use SDL::OpenGL; |
80 | |
80 | |
81 | sub new { |
81 | sub new { |
82 | my $class = shift; |
82 | my $class = shift; |
83 | |
83 | |
84 | bless { |
84 | my $self = bless { |
85 | x => 0, |
85 | x => 0, |
86 | y => 0, |
86 | y => 0, |
87 | z => 0, |
87 | z => 0, |
88 | w => -1, |
88 | w => -1, |
89 | h => -1, |
89 | h => -1, |
90 | @_ |
90 | @_ |
91 | }, $class |
91 | }, $class; |
|
|
92 | |
|
|
93 | for (keys %$self) { |
|
|
94 | if (/^connect_(.*)$/) { |
|
|
95 | $self->connect ($1 => delete $self->{$_}); |
|
|
96 | } |
|
|
97 | } |
|
|
98 | |
|
|
99 | $self |
92 | } |
100 | } |
93 | |
101 | |
94 | sub move { |
102 | sub move { |
95 | my ($self, $x, $y, $z) = @_; |
103 | my ($self, $x, $y, $z) = @_; |
96 | $self->{x} = $x; |
104 | $self->{x} = $x; |
… | |
… | |
125 | my ($self, $x, $y, $w, $h) = @_; |
133 | my ($self, $x, $y, $w, $h) = @_; |
126 | |
134 | |
127 | $self->_size_allocate ($x, $y, $w, $h); |
135 | $self->_size_allocate ($x, $y, $w, $h); |
128 | } |
136 | } |
129 | |
137 | |
130 | # translate global koordinates to local coordinate system |
138 | # translate global coordinates to local coordinate system |
131 | sub translate { |
139 | sub translate { |
132 | my ($self, $x, $y) = @_; |
140 | my ($self, $x, $y) = @_; |
133 | |
141 | |
134 | $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); |
142 | $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); |
135 | } |
143 | } |
… | |
… | |
263 | |
271 | |
264 | # range [value, low, high, page] |
272 | # range [value, low, high, page] |
265 | |
273 | |
266 | $class->SUPER::new ( |
274 | $class->SUPER::new ( |
267 | bg => [0, 0, 0, 0.2], |
275 | bg => [0, 0, 0, 0.2], |
268 | active_bg => [1, 1, 1], |
276 | active_bg => [1, 1, 1, 0.5], |
269 | @_ |
277 | @_ |
270 | ) |
278 | ) |
271 | } |
279 | } |
272 | |
280 | |
273 | sub _draw { |
281 | sub _draw { |
… | |
… | |
629 | |
637 | |
630 | my $bg = $tex[0]; |
638 | my $bg = $tex[0]; |
631 | |
639 | |
632 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
640 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
633 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
641 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
634 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; |
|
|
635 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; |
|
|
636 | |
642 | |
637 | my $rep_x = $cw / $bg->{w}; |
643 | my $rep_x = $cw / $bg->{w}; |
638 | my $rep_y = $ch / $bg->{h}; |
644 | my $rep_y = $ch / $bg->{h}; |
639 | |
645 | |
640 | $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch); |
646 | $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch); |
… | |
… | |
735 | |
741 | |
736 | my $x = 0; |
742 | my $x = 0; |
737 | my $row_h = $hs->[$r]; |
743 | my $row_h = $hs->[$r]; |
738 | |
744 | |
739 | for my $c (0 .. $#$row) { |
745 | for my $c (0 .. $#$row) { |
740 | my $widget = $row->[$c] |
|
|
741 | or next; |
|
|
742 | |
|
|
743 | my $col_w = $ws->[$c]; |
746 | my $col_w = $ws->[$c]; |
744 | |
747 | |
|
|
748 | if (my $widget = $row->[$c]) { |
745 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
749 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
|
|
750 | } |
746 | |
751 | |
747 | $x += $col_w; |
752 | $x += $col_w; |
748 | } |
753 | } |
749 | |
754 | |
750 | $y += $row_h; |
755 | $y += $row_h; |
… | |
… | |
796 | } |
801 | } |
797 | |
802 | |
798 | sub size_allocate { |
803 | sub size_allocate { |
799 | my ($self, $x, $y, $w, $h) = @_; |
804 | my ($self, $x, $y, $w, $h) = @_; |
800 | |
805 | |
801 | $self->_size_allocate ($x, $y, $w, $h) or return; |
806 | $self->_size_allocate ($x, $y, $w, $h); |
802 | |
|
|
803 | return unless $self->{w}; |
|
|
804 | |
807 | |
805 | ($h, $w) = ($w, $h); |
808 | ($h, $w) = ($w, $h); |
806 | |
809 | |
807 | my $children = $self->{children}; |
810 | my $children = $self->{children}; |
808 | |
811 | |
… | |
… | |
856 | } |
859 | } |
857 | |
860 | |
858 | sub size_allocate { |
861 | sub size_allocate { |
859 | my ($self, $x, $y, $w, $h) = @_; |
862 | my ($self, $x, $y, $w, $h) = @_; |
860 | |
863 | |
861 | $self->_size_allocate ($x, $y, $w, $h) or return; |
864 | $self->_size_allocate ($x, $y, $w, $h); |
862 | |
|
|
863 | return unless $self->{h}; |
|
|
864 | |
865 | |
865 | my $children = $self->{children}; |
866 | my $children = $self->{children}; |
866 | |
867 | |
867 | my @h = map +($_->size_request)[1], @$children; |
868 | my @h = map +($_->size_request)[1], @$children; |
868 | |
869 | |
… | |
… | |
933 | |
934 | |
934 | $self->{text} = $text; |
935 | $self->{text} = $text; |
935 | $self->{layout}->set_markup ($text); |
936 | $self->{layout}->set_markup ($text); |
936 | |
937 | |
937 | delete $self->{texture}; |
938 | delete $self->{texture}; |
|
|
939 | # $self->{w} = $self->{h} = -1; |
938 | $self->update; |
940 | $self->update; |
939 | } |
941 | } |
940 | |
942 | |
941 | sub get_text { |
943 | sub get_text { |
942 | my ($self, $text) = @_; |
944 | my ($self, $text) = @_; |
… | |
… | |
975 | sub _draw { |
977 | sub _draw { |
976 | my ($self) = @_; |
978 | my ($self) = @_; |
977 | |
979 | |
978 | my $tex = $self->{texture} ||= do { |
980 | my $tex = $self->{texture} ||= do { |
979 | $self->{layout}->set_width ($self->{w}); |
981 | $self->{layout}->set_width ($self->{w}); |
980 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{height}); |
982 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
981 | new_from_layout CFClient::Texture $self->{layout} |
983 | new_from_layout CFClient::Texture $self->{layout} |
982 | }; |
984 | }; |
983 | |
985 | |
984 | glEnable GL_BLEND; |
986 | glEnable GL_BLEND; |
985 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
987 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
… | |
… | |
991 | my $x = |
993 | my $x = |
992 | $self->{align} < 0 ? $self->{padding} |
994 | $self->{align} < 0 ? $self->{padding} |
993 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
995 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
994 | : ($self->{w} - $tex->{w}) * 0.5; |
996 | : ($self->{w} - $tex->{w}) * 0.5; |
995 | |
997 | |
996 | $tex->draw_quad ($x, $self->{padding}); |
998 | glTranslate $x, ($self->{h} - $tex->{h}) * 0.5, 0; |
|
|
999 | $tex->draw_quad (0, 0); |
997 | |
1000 | |
998 | glDisable GL_TEXTURE_2D; |
1001 | glDisable GL_TEXTURE_2D; |
999 | glDisable GL_BLEND; |
1002 | glDisable GL_BLEND; |
1000 | } |
1003 | } |
1001 | |
1004 | |
… | |
… | |
1012 | my $class = shift; |
1015 | my $class = shift; |
1013 | |
1016 | |
1014 | $class->SUPER::new ( |
1017 | $class->SUPER::new ( |
1015 | fg => [1, 1, 1], |
1018 | fg => [1, 1, 1], |
1016 | bg => [0, 0, 0, 0.2], |
1019 | bg => [0, 0, 0, 0.2], |
1017 | active_bg => [1, 1, 1], |
1020 | active_bg => [1, 1, 1, 0.5], |
1018 | active_fg => [0, 0, 0], |
1021 | active_fg => [0, 0, 0], |
1019 | @_ |
1022 | @_ |
1020 | ) |
1023 | ) |
1021 | } |
1024 | } |
1022 | |
1025 | |
… | |
… | |
1025 | |
1028 | |
1026 | $self->{last_activity} = $::NOW; |
1029 | $self->{last_activity} = $::NOW; |
1027 | |
1030 | |
1028 | $self->{text} = $text; |
1031 | $self->{text} = $text; |
1029 | $self->{layout}->set_width ($self->{w}); |
1032 | $self->{layout}->set_width ($self->{w}); |
|
|
1033 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
1030 | |
1034 | |
1031 | $text =~ s/./*/g if $self->{hidden}; |
1035 | $text =~ s/./*/g if $self->{hidden}; |
1032 | |
1036 | |
1033 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1037 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1034 | |
1038 | |
… | |
… | |
1155 | } |
1159 | } |
1156 | } |
1160 | } |
1157 | |
1161 | |
1158 | ############################################################################# |
1162 | ############################################################################# |
1159 | |
1163 | |
|
|
1164 | package CFClient::UI::Button; |
|
|
1165 | |
|
|
1166 | our @ISA = CFClient::UI::Label::; |
|
|
1167 | |
|
|
1168 | use SDL; |
|
|
1169 | use SDL::OpenGL; |
|
|
1170 | |
|
|
1171 | my @tex = |
|
|
1172 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1173 | qw(b1_button_active.png); |
|
|
1174 | |
|
|
1175 | sub new { |
|
|
1176 | my $class = shift; |
|
|
1177 | |
|
|
1178 | $class->SUPER::new ( |
|
|
1179 | padding => 4, |
|
|
1180 | fg => [1, 1, 1], |
|
|
1181 | bg => [1, 1, 1, 0.2], |
|
|
1182 | active_fg => [1, 1, 0], |
|
|
1183 | # active_bg => [0, 0, 0, 0.5], |
|
|
1184 | # border_fg => [1, 1, 0], |
|
|
1185 | @_ |
|
|
1186 | ) |
|
|
1187 | } |
|
|
1188 | |
|
|
1189 | sub button_up { |
|
|
1190 | my ($self, $ev, $x, $y) = @_; |
|
|
1191 | |
|
|
1192 | if ($x >= 0 && $x < $self->{w} |
|
|
1193 | && $y >= 0 && $y < $self->{h}) { |
|
|
1194 | $self->emit ("activate"); |
|
|
1195 | } |
|
|
1196 | } |
|
|
1197 | |
|
|
1198 | sub _draw { |
|
|
1199 | my ($self) = @_; |
|
|
1200 | |
|
|
1201 | local $self->{fg} = $self->{fg}; |
|
|
1202 | my $tex = $tex[0]; |
|
|
1203 | |
|
|
1204 | glEnable GL_BLEND; |
|
|
1205 | glEnable GL_TEXTURE_2D; |
|
|
1206 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1207 | |
|
|
1208 | if ($GRAB == $self) { |
|
|
1209 | $self->{fg} = $self->{active_fg}; |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
|
|
1213 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1214 | |
|
|
1215 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
|
|
1216 | |
|
|
1217 | glDisable GL_TEXTURE_2D; |
|
|
1218 | glDisable GL_BLEND; |
|
|
1219 | |
|
|
1220 | $self->SUPER::_draw; |
|
|
1221 | } |
|
|
1222 | |
|
|
1223 | ############################################################################# |
|
|
1224 | |
|
|
1225 | package CFClient::UI::CheckBox; |
|
|
1226 | |
|
|
1227 | our @ISA = CFClient::UI::DrawBG::; |
|
|
1228 | |
|
|
1229 | use SDL; |
|
|
1230 | use SDL::OpenGL; |
|
|
1231 | |
|
|
1232 | sub new { |
|
|
1233 | my $class = shift; |
|
|
1234 | |
|
|
1235 | $class->SUPER::new ( |
|
|
1236 | padding => 2, |
|
|
1237 | fg => [1, 1, 1], |
|
|
1238 | active_fg => [1, 1, 0], |
|
|
1239 | state => 0, |
|
|
1240 | @_ |
|
|
1241 | ) |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | sub size_request { |
|
|
1245 | my ($self) = @_; |
|
|
1246 | |
|
|
1247 | ($self->{padding} * 2 + 6) x 2 |
|
|
1248 | } |
|
|
1249 | |
|
|
1250 | sub size_allocate { |
|
|
1251 | my ($self, $x, $y, $w, $h) = @_; |
|
|
1252 | |
|
|
1253 | $self->_size_allocate ($x, $y, $w, $h); |
|
|
1254 | } |
|
|
1255 | |
|
|
1256 | sub button_down { |
|
|
1257 | my ($self, $ev, $x, $y) = @_; |
|
|
1258 | |
|
|
1259 | if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} |
|
|
1260 | && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { |
|
|
1261 | $self->{state} = !$self->{state}; |
|
|
1262 | $self->emit (changed => $self->{state}); |
|
|
1263 | } |
|
|
1264 | } |
|
|
1265 | |
|
|
1266 | sub _draw { |
|
|
1267 | my ($self) = @_; |
|
|
1268 | |
|
|
1269 | $self->SUPER::_draw; |
|
|
1270 | |
|
|
1271 | glTranslate $self->{padding} + 0.375, $self->{padding} + 0.375, 0; |
|
|
1272 | |
|
|
1273 | my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2; |
|
|
1274 | |
|
|
1275 | glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} }; |
|
|
1276 | |
|
|
1277 | glBegin GL_LINE_LOOP; |
|
|
1278 | glVertex 0 , 0; |
|
|
1279 | glVertex 0 , $s; |
|
|
1280 | glVertex $s, $s; |
|
|
1281 | glVertex $s, 0; |
|
|
1282 | glEnd; |
|
|
1283 | |
|
|
1284 | if ($self->{state}) { |
|
|
1285 | glBegin GL_LINES; |
|
|
1286 | glVertex 0 , 0; |
|
|
1287 | glVertex $s, $s; |
|
|
1288 | glVertex $s, 0; |
|
|
1289 | glVertex 0 , $s; |
|
|
1290 | glEnd; |
|
|
1291 | } |
|
|
1292 | } |
|
|
1293 | |
|
|
1294 | ############################################################################# |
|
|
1295 | |
1160 | package CFClient::UI::Slider; |
1296 | package CFClient::UI::Slider; |
1161 | |
1297 | |
1162 | use strict; |
1298 | use strict; |
1163 | |
1299 | |
1164 | use SDL::OpenGL; |
1300 | use SDL::OpenGL; |
… | |
… | |
1242 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1378 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1243 | |
1379 | |
1244 | $w -= $page; |
1380 | $w -= $page; |
1245 | $page &= ~1; |
1381 | $page &= ~1; |
1246 | glTranslate $page * 0.5, 0, 0; |
1382 | glTranslate $page * 0.5, 0, 0; |
|
|
1383 | $page ||= 2; |
1247 | |
1384 | |
1248 | glColor @$fg; |
1385 | glColor @$fg; |
1249 | glBegin GL_LINES; |
1386 | glBegin GL_LINES; |
1250 | glVertex 0, 0; glVertex 0, $h; |
1387 | glVertex 0, 0; glVertex 0, $h; |
1251 | glVertex $w - 1, 0; glVertex $w - 1, $h; |
1388 | glVertex $w - 1, 0; glVertex $w - 1, $h; |
… | |
… | |
1346 | |
1483 | |
1347 | glEnable GL_TEXTURE_2D; |
1484 | glEnable GL_TEXTURE_2D; |
1348 | glEnable GL_BLEND; |
1485 | glEnable GL_BLEND; |
1349 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1486 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1350 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1487 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1488 | glColor 1, 1, 1, 1; |
1351 | |
1489 | |
1352 | my $sw4 = ($sw + 3) & ~3; |
1490 | my $sw4 = ($sw + 3) & ~3; |
1353 | my $darkness = "\x00" x ($sw4 * $sh); |
1491 | my $darkness = "\x00" x ($sw4 * $sh); |
1354 | |
1492 | |
1355 | for my $x (0 .. $sw - 1) { |
1493 | for my $x (0 .. $sw - 1) { |
… | |
… | |
1374 | $tex->draw_quad (($x + 1) * 32 - $w, ($y + 1) * 32 - $h, $w, $h); |
1512 | $tex->draw_quad (($x + 1) * 32 - $w, ($y + 1) * 32 - $h, $w, $h); |
1375 | } |
1513 | } |
1376 | } |
1514 | } |
1377 | } |
1515 | } |
1378 | |
1516 | |
1379 | # if (1) { # higher quality darkness |
|
|
1380 | # $lighting =~ s/(.)/$1$1$1/gs; |
|
|
1381 | # my $pb = new_from_data Gtk2::Gdk::Pixbuf $lighting, "rgb", 0, 8, $sw4, $sh, $sw4 * 3; |
|
|
1382 | # |
|
|
1383 | # $pb = $pb->scale_simple ($sw4 * 0.5, $sh * 0.5, "bilinear"); |
|
|
1384 | # |
|
|
1385 | # $lighting = $pb->get_pixels; |
|
|
1386 | # $lighting =~ s/(.)../$1/gs; |
|
|
1387 | # } |
|
|
1388 | |
|
|
1389 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
1517 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
|
|
1518 | |
|
|
1519 | if ($::CFG->{fow_smooth}) { # smooth fog of war |
|
|
1520 | my @conv = ( |
|
|
1521 | 0.1, 0.1, 0.1, |
|
|
1522 | 0.1, 0.2, 0.1, |
|
|
1523 | 0.1, 0.1, 0.1, |
|
|
1524 | ); |
|
|
1525 | glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; |
|
|
1526 | glConvolutionFilter2D GL_CONVOLUTION_2D, |
|
|
1527 | GL_ALPHA, 3, 3, GL_ALPHA, GL_FLOAT, |
|
|
1528 | pack "f*", @conv; |
|
|
1529 | glEnable GL_CONVOLUTION_2D; |
|
|
1530 | } |
1390 | |
1531 | |
1391 | $darkness = new CFClient::Texture |
1532 | $darkness = new CFClient::Texture |
1392 | w => $sw4, |
1533 | w => $sw4, |
1393 | h => $sh, |
1534 | h => $sh, |
1394 | data => $darkness, |
1535 | data => $darkness, |
1395 | internalformat => GL_ALPHA, |
1536 | internalformat => GL_ALPHA, |
1396 | format => GL_ALPHA; |
1537 | format => GL_ALPHA; |
1397 | |
1538 | |
1398 | glColor 0.45, 0.45, 0.45, 1; |
1539 | glColor +($::CFG->{fow_intensity}) x 3, 1; |
1399 | $darkness->draw_quad (0, 0, $sw4 * 32, $sh * 32); |
1540 | $darkness->draw_quad (0, 0, $sw4 * 32, $sh * 32); |
|
|
1541 | |
|
|
1542 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
1400 | |
1543 | |
1401 | glDisable GL_TEXTURE_2D; |
1544 | glDisable GL_TEXTURE_2D; |
1402 | glDisable GL_BLEND; |
1545 | glDisable GL_BLEND; |
1403 | |
1546 | |
1404 | glEndList; |
1547 | glEndList; |
1405 | } |
1548 | } |
1406 | |
1549 | |
1407 | glCallList $self->{list}; |
1550 | glCallList $self->{list}; |
|
|
1551 | |
|
|
1552 | if ($FOCUS != $self) { |
|
|
1553 | glEnable GL_BLEND; |
|
|
1554 | glColor 0, 0, 1, 0.4; |
|
|
1555 | glBegin GL_QUADS; |
|
|
1556 | glVertex 0, 0; |
|
|
1557 | glVertex 0, $::HEIGHT; |
|
|
1558 | glVertex $::WIDTH, $::HEIGHT; |
|
|
1559 | glVertex $::WIDTH, 0; |
|
|
1560 | glEnd; |
|
|
1561 | glDisable GL_BLEND; |
|
|
1562 | } |
1408 | } |
1563 | } |
1409 | |
1564 | |
1410 | my %DIR = ( |
1565 | my %DIR = ( |
1411 | SDLK_KP8, [1, "north"], |
1566 | SDLK_KP8, [1, "north"], |
1412 | SDLK_KP9, [2, "northeast"], |
1567 | SDLK_KP9, [2, "northeast"], |
… | |
… | |
1428 | |
1583 | |
1429 | my $mod = $ev->key_mod; |
1584 | my $mod = $ev->key_mod; |
1430 | my $sym = $ev->key_sym; |
1585 | my $sym = $ev->key_sym; |
1431 | |
1586 | |
1432 | if ($sym == SDLK_KP5) { |
1587 | if ($sym == SDLK_KP5) { |
1433 | $::CONN->send ("command stay fire"); |
1588 | $::CONN->user_send ("command stay fire"); |
|
|
1589 | } elsif ($sym == SDLK_a) { |
|
|
1590 | $::CONN->user_send ("command apply"); |
1434 | } elsif (exists $DIR{$sym}) { |
1591 | } elsif (exists $DIR{$sym}) { |
1435 | if ($mod & KMOD_SHIFT) { |
1592 | if ($mod & KMOD_SHIFT) { |
1436 | $self->{shft}++; |
1593 | $self->{shft}++; |
1437 | $::CONN->send ("command fire $DIR{$sym}[0]"); |
1594 | $::CONN->user_send ("command fire $DIR{$sym}[0]"); |
1438 | } elsif ($mod & KMOD_CTRL) { |
1595 | } elsif ($mod & KMOD_CTRL) { |
1439 | $self->{ctrl}++; |
1596 | $self->{ctrl}++; |
1440 | $::CONN->send ("command run $DIR{$sym}[0]"); |
1597 | $::CONN->user_send ("command run $DIR{$sym}[0]"); |
1441 | } else { |
1598 | } else { |
1442 | $::CONN->send ("command $DIR{$sym}[1]"); |
1599 | $::CONN->user_send ("command $DIR{$sym}[1]"); |
1443 | } |
1600 | } |
1444 | } |
1601 | } |
1445 | } |
1602 | } |
1446 | |
1603 | |
1447 | sub key_up { |
1604 | sub key_up { |
… | |
… | |
1449 | |
1606 | |
1450 | my $mod = $ev->key_mod; |
1607 | my $mod = $ev->key_mod; |
1451 | my $sym = $ev->key_sym; |
1608 | my $sym = $ev->key_sym; |
1452 | |
1609 | |
1453 | if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { |
1610 | if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { |
1454 | $::CONN->send ("command fire_stop"); |
1611 | $::CONN->user_send ("command fire_stop"); |
1455 | } |
1612 | } |
1456 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
1613 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
1457 | $::CONN->send ("command run_stop"); |
1614 | $::CONN->user_send ("command run_stop"); |
1458 | } |
1615 | } |
1459 | } |
1616 | } |
1460 | |
1617 | |
1461 | ############################################################################# |
1618 | ############################################################################# |
1462 | |
1619 | |