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.119 by root, Sun Apr 16 07:25:30 2006 UTC vs.
Revision 1.127 by root, Mon Apr 17 21:03:31 2006 UTC

176 176
177 return if $FOCUS == $self; 177 return if $FOCUS == $self;
178 return unless $self->{can_focus}; 178 return unless $self->{can_focus};
179 179
180 my $focus = $FOCUS; $FOCUS = $self; 180 my $focus = $FOCUS; $FOCUS = $self;
181
182 $self->emit (focus_in => $focus);
183
181 $focus->update if $focus; 184 $focus->update if $focus;
182 $FOCUS->update; 185 $FOCUS->update;
183} 186}
184 187
185sub focus_out { 188sub focus_out {
186 my ($self) = @_; 189 my ($self) = @_;
187 190
188 return unless $FOCUS == $self; 191 return unless $FOCUS == $self;
189 192
190 my $focus = $FOCUS; undef $FOCUS; 193 my $focus = $FOCUS; undef $FOCUS;
194
195 $self->emit (focus_out => $focus);
196
191 $focus->update if $focus; #? 197 $focus->update if $focus; #?
192} 198}
193 199
194sub mouse_motion { } 200sub mouse_motion { }
195sub button_up { } 201sub button_up { }
219 glPopMatrix; 225 glPopMatrix;
220 226
221 if ($self == $HOVER && $self->{can_hover}) { 227 if ($self == $HOVER && $self->{can_hover}) {
222 my ($x, $y) = @$self{qw(x y)}; 228 my ($x, $y) = @$self{qw(x y)};
223 229
224 glColor 0, 0, 1, 0.2; 230 glColor 1, 0.8, 0.5, 0.2;
225 glEnable GL_BLEND; 231 glEnable GL_BLEND;
226 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 232 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
227 glBegin GL_QUADS; 233 glBegin GL_QUADS;
228 glVertex $x , $y; 234 glVertex $x , $y;
229 glVertex $x + $self->{w}, $y; 235 glVertex $x + $self->{w}, $y;
254 my ($self, $parent) = @_; 260 my ($self, $parent) = @_;
255 261
256 Scalar::Util::weaken ($self->{parent} = $parent); 262 Scalar::Util::weaken ($self->{parent} = $parent);
257} 263}
258 264
265sub check_size {
266 my ($self) = @_;
267
268 my ($w, $h) = $self->size_request;
269
270 if ($w != $self->{req_w} || $h != $self->{req_h}) {
271 $self->{req_w} = $w;
272 $self->{req_h} = $h;
273
274 $self->{parent}->check_size
275 if $self->{parent};
276 }
277}
278
259sub update { 279sub update {
260 my ($self) = @_; 280 my ($self) = @_;
261 281
262 $self->{parent}->update 282 $self->{parent}->update
263 if $self->{parent}; 283 if $self->{parent};
362 sort { $a->{z} <=> $b->{z} } 382 sort { $a->{z} <=> $b->{z} }
363 @{$self->{children}}, $child 383 @{$self->{children}}, $child
364 ]; 384 ];
365 385
366 $self->{w} = $self->{h} = -1; 386 $self->{w} = $self->{h} = -1;
367 $self->update; 387
388 $child->check_size;
368} 389}
369 390
370sub remove { 391sub remove {
371 my ($self, $widget) = @_; 392 my ($self, $widget) = @_;
372 393
373 $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; 394 $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ];
374 395
375 $self->size_allocate (0, 0, $self->{w}, $self->{h}); 396 $self->check_size;
376} 397}
377 398
378sub find_widget { 399sub find_widget {
379 my ($self, $x, $y) = @_; 400 my ($self, $x, $y) = @_;
380 401
500 $tex->draw_quad (0, 0, $w, $h); 521 $tex->draw_quad (0, 0, $w, $h);
501 522
502 glDisable GL_BLEND; 523 glDisable GL_BLEND;
503 glDisable GL_TEXTURE_2D; 524 glDisable GL_TEXTURE_2D;
504} 525}
526
527#############################################################################
528
529package CFClient::UI::ViewPort;
530
531our @ISA = CFClient::UI::Window::;
532
533sub new { die }
534
535sub size_request {
536 my ($self) = @_;
537
538 @$self{qw(child_w child_h)} = $self->child->size_request;
539 $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)});
540
541 @$self{qw(child_w child_h)}
542}
543
544sub size_allocate {
545 my ($self, $x, $y, $w, $h) = @_;
546
547 $self->_size_allocate ($x, $y, $w, $h) or return;
548}
549
550sub _draw {
551 my ($self) = @_;
552
553 $self->{children}[1]->draw;
554}
555
505 556
506############################################################################# 557#############################################################################
507 558
508package CFClient::UI::Frame; 559package CFClient::UI::Frame;
509 560
704 755
705 $child->set_parent ($self); 756 $child->set_parent ($self);
706 $self->{children}[$y][$x] = $child; 757 $self->{children}[$y][$x] = $child;
707 758
708 $self->{w} = $self->{h} = -1; 759 $self->{w} = $self->{h} = -1;
709 $self->update; 760
761 $child->check_size;
710} 762}
711 763
712# TODO: move to container class maybe? send childs a signal on removal? 764# TODO: move to container class maybe? send childs a signal on removal?
713sub clear { 765sub clear {
714 my ($self) = @_; 766 my ($self) = @_;
840} 892}
841 893
842sub size_allocate { 894sub size_allocate {
843 my ($self, $x, $y, $w, $h) = @_; 895 my ($self, $x, $y, $w, $h) = @_;
844 896
845 $self->_size_allocate ($x, $y, $w, $h); 897 $self->_size_allocate ($x, $y, $w, $h) or return;
846 898
847 ($h, $w) = ($w, $h); 899 ($h, $w) = ($w, $h);
848 900
849 my $children = $self->{children}; 901 my $children = $self->{children};
850 902
876 my $h = $h[$_]; 928 my $h = $h[$_];
877 $child->size_allocate ($y, 0, $h, $w); 929 $child->size_allocate ($y, 0, $h, $w);
878 930
879 $y += $h; 931 $y += $h;
880 } 932 }
933
934 1
881} 935}
882 936
883############################################################################# 937#############################################################################
884 938
885package CFClient::UI::VBox; 939package CFClient::UI::VBox;
900} 954}
901 955
902sub size_allocate { 956sub size_allocate {
903 my ($self, $x, $y, $w, $h) = @_; 957 my ($self, $x, $y, $w, $h) = @_;
904 958
905 $self->_size_allocate ($x, $y, $w, $h); 959 $self->_size_allocate ($x, $y, $w, $h) or return;
906 960
907 my $children = $self->{children}; 961 my $children = $self->{children};
908 962
909 my @h = map +($_->size_request)[1], @$children; 963 my @h = map +($_->size_request)[1], @$children;
910 964
932 my $h = $h[$_]; 986 my $h = $h[$_];
933 $child->size_allocate (0, $y, $w, $h); 987 $child->size_allocate (0, $y, $w, $h);
934 988
935 $y += $h; 989 $y += $h;
936 } 990 }
991
992 1
937} 993}
938 994
939############################################################################# 995#############################################################################
940 996
941package CFClient::UI::Label; 997package CFClient::UI::Label;
956 padding => 2, 1012 padding => 2,
957 layout => new CFClient::Layout, 1013 layout => new CFClient::Layout,
958 %arg 1014 %arg
959 ); 1015 );
960 1016
961 $self->set_text ($self->{text}); 1017 $self->{xxx}++ if $self->{text} eq "Client Setup" && $self->{align};#d#
1018
1019 $self->set_text (delete $self->{text}) if exists $self->{text};
1020 $self->set_markup (delete $self->{markup}) if exists $self->{markup};
962 1021
963 $self 1022 $self
964} 1023}
965 1024
966sub escape_text { 1025sub escape_text {
974} 1033}
975 1034
976sub set_text { 1035sub set_text {
977 my ($self, $text) = @_; 1036 my ($self, $text) = @_;
978 1037
979 $self->{text} = $text;
980 $self->{layout}->set_markup ($text); 1038 $self->{layout}->set_text ($text);
981 1039
982 delete $self->{texture}; 1040 delete $self->{texture};
983# $self->{w} = $self->{h} = -1;
984 $self->update; 1041 $self->update;
985} 1042}
986 1043
987sub get_text { 1044sub set_markup {
988 my ($self, $text) = @_; 1045 my ($self, $markup) = @_;
989 1046
990 $self->{text} 1047 $self->{layout}->set_markup ($markup);
1048
1049 delete $self->{texture};
1050 $self->update;
991} 1051}
992 1052
993sub size_request { 1053sub size_request {
994 my ($self) = @_; 1054 my ($self) = @_;
995 1055
996 $self->{layout}->set_width; 1056 $self->{layout}->set_width;
997 $self->{layout}->set_height ($self->{fontsize}); 1057 $self->{layout}->set_height ($self->{fontsize});
1058
998 my ($w, $h) = $self->{layout}->size; 1059 my ($w, $h) = $self->{layout}->size;
999 1060
1000 ( 1061 (
1001 $w + $self->{padding} * 2, 1062 $w + $self->{padding} * 2,
1002 $h + $self->{padding} * 2, 1063 $h + $self->{padding} * 2,
1021sub _draw { 1082sub _draw {
1022 my ($self) = @_; 1083 my ($self) = @_;
1023 1084
1024 my $tex = $self->{texture} ||= do { 1085 my $tex = $self->{texture} ||= do {
1025 $self->{layout}->set_width ($self->{w}); 1086 $self->{layout}->set_width ($self->{w});
1026 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); 1087 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize});
1027 new_from_layout CFClient::Texture $self->{layout} 1088 new_from_layout CFClient::Texture $self->{layout}
1028 }; 1089 };
1029 1090
1030 glEnable GL_BLEND; 1091 glEnable GL_BLEND;
1031 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 1092 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1032 glEnable GL_TEXTURE_2D; 1093 glEnable GL_TEXTURE_2D;
1033 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1094 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1034 1095
1035 glColor @{$self->{fg}}; 1096 glColor @{$self->{fg}};
1036 1097
1037 my $x = 1098 $self->{ox} = int (
1038 $self->{align} < 0 ? $self->{padding} 1099 $self->{align} < 0 ? $self->{padding}
1039 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 1100 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1040 : ($self->{w} - $tex->{w}) * 0.5; 1101 : ($self->{w} - $tex->{w}) * 0.5
1102 );
1041 1103
1042 my $y = 1104 $self->{oy} = int (
1043 $self->{valign} < 0 ? $self->{padding} 1105 $self->{valign} < 0 ? $self->{padding}
1044 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} 1106 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
1045 : ($self->{h} - $tex->{h}) * 0.5; 1107 : ($self->{h} - $tex->{h}) * 0.5
1108 );
1046 1109
1047 $tex->draw_quad (int $x, int $y); 1110 $tex->draw_quad ($self->{ox}, $self->{oy});
1048 1111
1049 glDisable GL_TEXTURE_2D; 1112 glDisable GL_TEXTURE_2D;
1050 glDisable GL_BLEND; 1113 glDisable GL_BLEND;
1051} 1114}
1052 1115
1053############################################################################# 1116#############################################################################
1054 1117
1055package CFClient::UI::Entry; 1118package CFClient::UI::EntryBase;
1056 1119
1057our @ISA = CFClient::UI::Label::; 1120our @ISA = CFClient::UI::Label::;
1058 1121
1059use SDL; 1122use SDL;
1060use SDL::OpenGL; 1123use SDL::OpenGL;
1075} 1138}
1076 1139
1077sub _set_text { 1140sub _set_text {
1078 my ($self, $text) = @_; 1141 my ($self, $text) = @_;
1079 1142
1080 my $old_text = $self->{text}; 1143 delete $self->{cur_h};
1144
1145 return if $self->{text} eq $text;
1081 1146
1082 $self->{last_activity} = $::NOW; 1147 $self->{last_activity} = $::NOW;
1083
1084 $self->{text} = $text; 1148 $self->{text} = $text;
1085 $self->{layout}->set_width ($self->{w});
1086 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize});
1087 1149
1088 $text =~ s/./*/g if $self->{hidden}; 1150 $text =~ s/./*/g if $self->{hidden};
1151 $self->{layout}->set_text ("$text ");
1089 1152
1090 $self->{layout}->set_markup ($self->escape_text ($text) . " "); 1153 $self->emit (changed => $self->{text});
1154}
1091 1155
1092 $text = substr $text, 0, $self->{cursor}; 1156sub get_text {
1093 utf8::encode $text; 1157 $_[0]{text}
1094
1095 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
1096
1097 $self->emit (changed => $self->{text}) # XXX: is this the right place to do this?
1098 if $old_text ne $self->{text};
1099} 1158}
1100 1159
1101sub size_request { 1160sub size_request {
1102 my ($self) = @_; 1161 my ($self) = @_;
1103 1162
1107} 1166}
1108 1167
1109sub size_allocate { 1168sub size_allocate {
1110 my ($self, $x, $y, $w, $h) = @_; 1169 my ($self, $x, $y, $w, $h) = @_;
1111 1170
1112 $self->SUPER::size_allocate ($x, $y, $w, $h); 1171 $self->SUPER::size_allocate ($x, $y, $w, $h) or return;
1113 1172
1114 $self->_set_text ($self->{text}); 1173 $self->_set_text ($self->{text});
1115} 1174}
1116 1175
1117sub set_text { 1176sub set_text {
1207 1266
1208 $self->SUPER::_draw; 1267 $self->SUPER::_draw;
1209 1268
1210 #TODO: force update every cursor change :( 1269 #TODO: force update every cursor change :(
1211 if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) { 1270 if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) {
1271
1272 unless (exists $self->{cur_h}) {
1273 my $text = substr $self->{text}, 0, $self->{cursor};
1274 utf8::encode $text;
1275
1276 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text)
1277 }
1278
1212 glColor @{$self->{fg}}; 1279 glColor @{$self->{fg}};
1213 glBegin GL_LINES; 1280 glBegin GL_LINES;
1214 glVertex $self->{cur_x}, $self->{cur_y};
1215 glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; 1281 glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy};
1282 glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h};
1216 glEnd; 1283 glEnd;
1217 } 1284 }
1218} 1285}
1219 1286
1220package CFClient::UI::LineEntry; 1287package CFClient::UI::Entry;
1221 1288
1222our @ISA = CFClient::UI::Entry::; 1289our @ISA = CFClient::UI::EntryBase::;
1223 1290
1224use SDL; 1291use SDL;
1225use SDL::OpenGL; 1292use SDL::OpenGL;
1226 1293
1227sub key_down { 1294sub key_down {
1257 1324
1258 $class->SUPER::new ( 1325 $class->SUPER::new (
1259 padding => 4, 1326 padding => 4,
1260 fg => [1, 1, 1], 1327 fg => [1, 1, 1],
1261 bg => [1, 1, 1, 0.2], 1328 bg => [1, 1, 1, 0.2],
1262 active_fg => [1, 1, 0], 1329 active_fg => [0, 0, 1],
1263 can_hover => 1, 1330 can_hover => 1,
1331 align => 0,
1332 valign => 0,
1264 @_ 1333 @_
1265 ) 1334 )
1266} 1335}
1267 1336
1268sub button_up { 1337sub button_up {
1330} 1399}
1331 1400
1332sub size_allocate { 1401sub size_allocate {
1333 my ($self, $x, $y, $w, $h) = @_; 1402 my ($self, $x, $y, $w, $h) = @_;
1334 1403
1335 $self->_size_allocate ($x, $y, $w, $h); 1404 $self->_size_allocate ($x, $y, $w, $h) or return;
1336} 1405}
1337 1406
1338sub button_down { 1407sub button_down {
1339 my ($self, $ev, $x, $y) = @_; 1408 my ($self, $ev, $x, $y) = @_;
1340 1409
1364 1433
1365 $tex->draw_quad (0, 0, $s, $s); 1434 $tex->draw_quad (0, 0, $s, $s);
1366 1435
1367 glDisable GL_TEXTURE_2D; 1436 glDisable GL_TEXTURE_2D;
1368 glDisable GL_BLEND; 1437 glDisable GL_BLEND;
1438}
1439
1440#############################################################################
1441
1442package CFClient::UI::VGauge;
1443
1444our @ISA = CFClient::UI::Base::;
1445
1446use SDL::OpenGL;
1447
1448my %tex = (
1449 food => [
1450 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1451 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/
1452 ],
1453 grace => [
1454 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1455 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/
1456 ],
1457 hp => [
1458 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1459 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/
1460 ],
1461 mana => [
1462 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1463 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/
1464 ],
1465);
1466
1467# eg. VGauge->new (gauge => 'food'), default gauge: food
1468sub new {
1469 my $class = shift;
1470
1471 my $self = $class->SUPER::new (gauge => 'food', @_);
1472
1473 $self
1474}
1475
1476sub size_request {
1477 my ($self) = @_;
1478
1479 my $tex = $tex{$self->{gauge}}[0];
1480
1481 @$tex{qw(w h)}
1482}
1483
1484sub set_max {
1485 my ($self, $max) = @_;
1486
1487 $self->{max_val} = $max;
1488}
1489
1490sub set_value {
1491 my ($self, $val, $max) = @_;
1492
1493 $self->set_max ($max)
1494 if defined $max;
1495
1496 $max = $self->{max_val};
1497 $self->{val} = $val;
1498
1499 $self->update;
1500}
1501
1502sub _draw {
1503 my ($self) = @_;
1504
1505 my $tex = $tex{$self->{gauge}};
1506
1507 my ($w, $h) = ($self->{w}, $self->{h});
1508
1509 my $ycut = $self->{val} / ($self->{max_val} || 1);
1510 $ycut = 1 if $self->{val} > $self->{max_val};
1511
1512 my $t1 = $tex->[0];
1513 my $t2 = $tex->[1];
1514
1515 glEnable GL_BLEND;
1516 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1517 glEnable GL_TEXTURE_2D;
1518 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1519
1520 my $h1 = $self->{h} - $ycut * $self->{h};
1521 my $h2 = $ycut * $self->{h};
1522
1523 my $yp = 0;
1524
1525 glBindTexture (GL_TEXTURE_2D, $t1->{name});
1526 glBegin (GL_QUADS);
1527 glTexCoord (0, 0); glVertex (0 , $yp);
1528 glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp + $h1);
1529 glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp + $h1);
1530 glTexCoord (1, 0); glVertex (0 + $w, $yp);
1531 glEnd ();
1532
1533 $yp += $h1;
1534
1535 glBindTexture (GL_TEXTURE_2D, $t2->{name});
1536 glBegin (GL_QUADS);
1537 glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp);
1538 glTexCoord (0, 1); glVertex (0 , $yp + $h2);
1539 glTexCoord (1, 1); glVertex (0 + $w, $yp + $h2);
1540 glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp);
1541 glEnd ();
1542
1543 glDisable GL_BLEND;
1544 glDisable GL_TEXTURE_2D;
1369} 1545}
1370 1546
1371############################################################################# 1547#############################################################################
1372 1548
1373package CFClient::UI::Slider; 1549package CFClient::UI::Slider;
1569} 1745}
1570 1746
1571sub size_allocate { 1747sub size_allocate {
1572 my ($self, $x, $y, $w, $h) = @_; 1748 my ($self, $x, $y, $w, $h) = @_;
1573 1749
1574 $self->SUPER::size_allocate ($x, $y, $w, $h); 1750 $self->SUPER::size_allocate ($x, $y, $w, $h) or return;
1575 1751
1576 $self->{layout}->set_height ($self->{fontsize}); 1752 $self->{layout}->set_height ($self->{fontsize});
1577 $self->{layout}->set_width ($self->{w}); 1753 $self->{layout}->set_width ($self->{w});
1578 1754
1579 $self->reflow; 1755 $self->reflow;
1756 $self->update;
1580} 1757}
1581 1758
1582sub add_paragraph { 1759sub add_paragraph {
1583 my ($self, $color, $text) = @_; 1760 my ($self, $color, $text) = @_;
1584 1761
1869 2046
1870 my $mod = $ev->key_mod; 2047 my $mod = $ev->key_mod;
1871 my $sym = $ev->key_sym; 2048 my $sym = $ev->key_sym;
1872 2049
1873 if ($sym == SDLK_KP5) { 2050 if ($sym == SDLK_KP5) {
1874 $::CONN->user_send ("command stay fire"); 2051 $::CONN->user_send ("stay fire");
1875 } elsif ($sym == SDLK_a) { 2052 } elsif ($sym == SDLK_a) {
1876 $::CONN->user_send ("command apply"); 2053 $::CONN->user_send ("apply");
1877 } elsif ($sym == SDLK_QUOTE) { 2054 } elsif ($sym == SDLK_QUOTE) {
1878 $self->emit ('activate_console'); 2055 $self->emit ('activate_console');
1879 } elsif ($sym == SDLK_SLASH) { 2056 } elsif ($sym == SDLK_SLASH) {
1880 $self->emit ('activate_console' => '/'); 2057 $self->emit ('activate_console' => '/');
1881 } elsif (exists $DIR{$sym}) { 2058 } elsif (exists $DIR{$sym}) {
1882 if ($mod & KMOD_SHIFT) { 2059 if ($mod & KMOD_SHIFT) {
1883 $self->{shft}++; 2060 $self->{shft}++;
1884 $::CONN->user_send ("command fire $DIR{$sym}[0]"); 2061 $::CONN->user_send ("fire $DIR{$sym}[0]");
1885 } elsif ($mod & KMOD_CTRL) { 2062 } elsif ($mod & KMOD_CTRL) {
1886 $self->{ctrl}++; 2063 $self->{ctrl}++;
1887 $::CONN->user_send ("command run $DIR{$sym}[0]"); 2064 $::CONN->user_send ("run $DIR{$sym}[0]");
1888 } else { 2065 } else {
1889 $::CONN->user_send ("command $DIR{$sym}[1]"); 2066 $::CONN->user_send ("$DIR{$sym}[1]");
1890 } 2067 }
1891 } 2068 }
1892} 2069}
1893 2070
1894sub key_up { 2071sub key_up {
1896 2073
1897 my $mod = $ev->key_mod; 2074 my $mod = $ev->key_mod;
1898 my $sym = $ev->key_sym; 2075 my $sym = $ev->key_sym;
1899 2076
1900 if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { 2077 if (!($mod & KMOD_SHIFT) && delete $self->{shft}) {
1901 $::CONN->user_send ("command fire_stop"); 2078 $::CONN->user_send ("fire_stop");
1902 } 2079 }
1903 if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { 2080 if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) {
1904 $::CONN->user_send ("command run_stop"); 2081 $::CONN->user_send ("run_stop");
1905 } 2082 }
1906} 2083}
1907 2084
1908############################################################################# 2085#############################################################################
1909 2086
1992 2169
1993our @ISA = CFClient::UI::Container::; 2170our @ISA = CFClient::UI::Container::;
1994 2171
1995use SDL::OpenGL; 2172use SDL::OpenGL;
1996 2173
2174sub check_size {
2175 my ($self) = @_;
2176
2177 $self->size_allocate (0, 0, $::WITH, $::HEIGHT);
2178}
2179
1997sub size_request { 2180sub size_request {
1998 ($::WIDTH, $::HEIGHT) 2181 ($::WIDTH, $::HEIGHT)
1999} 2182}
2000 2183
2001sub size_allocate { 2184sub size_allocate {
2014} 2197}
2015 2198
2016sub update { 2199sub update {
2017 my ($self) = @_; 2200 my ($self) = @_;
2018 2201
2019 $self->size_allocate (0, 0, $::WIDTH, $::HEIGHT); 2202 $self->check_size;
2020 ::refresh (); 2203 ::refresh ();
2021} 2204}
2022 2205
2023sub add { 2206sub add {
2024 my ($self, $widget) = @_; 2207 my ($self, $widget) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines