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.98 by root, Fri Apr 14 02:06:22 2006 UTC vs.
Revision 1.105 by root, Fri Apr 14 14:55:28 2006 UTC

61 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); 61 my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y);
62 62
63 if ($widget != $HOVER) { 63 if ($widget != $HOVER) {
64 my $hover = $HOVER; $HOVER = $widget; 64 my $hover = $HOVER; $HOVER = $widget;
65 65
66 $hover->update if $hover; 66 $hover->update if $hover && $hover->{can_hover};
67 $HOVER->update if $HOVER; 67 $HOVER->update if $HOVER && $HOVER->{can_hover};
68 } 68 }
69 69
70 $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER; 70 $HOVER->mouse_motion ($ev, $HOVER->translate ($x, $y)) if $HOVER;
71} 71}
72 72
439} 439}
440 440
441sub render_chld { 441sub render_chld {
442 my ($self) = @_; 442 my ($self) = @_;
443 443
444 $self->{texture} = 444 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub {
445 CFClient::Texture->new_from_opengl ( 445 glClearColor 0, 0, 0, 1;
446 $self->{w}, $self->{h}, sub { $self->child->draw } 446 glClear GL_COLOR_BUFFER_BIT;
447 ); 447 $self->child->draw;
448 };
448} 449}
449 450
450sub size_allocate { 451sub size_allocate {
451 my ($self, $x, $y, $w, $h) = @_; 452 my ($self, $x, $y, $w, $h) = @_;
452 453
639 # TODO: repeat texture not scale 640 # TODO: repeat texture not scale
640 my $rep_x = $cw / $bg->{w}; 641 my $rep_x = $cw / $bg->{w};
641 my $rep_y = $ch / $bg->{h}; 642 my $rep_y = $ch / $bg->{h};
642 643
643 glColor @{ $self->{bg} }; 644 glColor @{ $self->{bg} };
645
646 $bg->{s} = $rep_x;
647 $bg->{t} = $rep_y;
648 $bg->{wrap_mode} = 1;
644 $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); 649 $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch);
645 650
646 glDisable GL_TEXTURE_2D; 651 glDisable GL_TEXTURE_2D;
647 glDisable GL_BLEND; 652 glDisable GL_BLEND;
648 653
827 } 832 }
828 833
829 my $y = 0; 834 my $y = 0;
830 for (0 .. $#$children) { 835 for (0 .. $#$children) {
831 my $child = $children->[$_]; 836 my $child = $children->[$_];
832 my $h = $h[$_]; 837 my $h = int $h[$_];
833 $child->size_allocate ($y, 0, $h, $w); 838 $child->size_allocate ($y, 0, $h, $w);
834 839
835 $y += $h; 840 $y += $h;
836 } 841 }
837} 842}
881 } 886 }
882 887
883 my $y = 0; 888 my $y = 0;
884 for (0 .. $#$children) { 889 for (0 .. $#$children) {
885 my $child = $children->[$_]; 890 my $child = $children->[$_];
886 my $h = $h[$_]; 891 my $h = int $h[$_];
887 $child->size_allocate (0, $y, $w, $h); 892 $child->size_allocate (0, $y, $w, $h);
888 893
889 $y += $h; 894 $y += $h;
890 } 895 }
891} 896}
900 905
901sub new { 906sub new {
902 my ($class, %arg) = @_; 907 my ($class, %arg) = @_;
903 908
904 my $self = $class->SUPER::new ( 909 my $self = $class->SUPER::new (
905 fg => [1, 1, 1], 910 fg => [1, 1, 1],
906 height => $::FONTSIZE, 911 fontsize => $::FONTSIZE,
907 text => "", 912 text => "",
908 align => -1, 913 align => -1,
909 padding => 2, 914 padding => 2,
910 layout => new CFClient::Layout, 915 layout => new CFClient::Layout,
911 %arg 916 %arg
912 ); 917 );
913 918
914 $self->set_text ($self->{text}); 919 $self->set_text ($self->{text});
915 920
945 950
946sub size_request { 951sub size_request {
947 my ($self) = @_; 952 my ($self) = @_;
948 953
949 $self->{layout}->set_width; 954 $self->{layout}->set_width;
950 $self->{layout}->set_height ($self->{height}); 955 $self->{layout}->set_height ($self->{fontsize});
951 my ($w, $h) = $self->{layout}->size; 956 my ($w, $h) = $self->{layout}->size;
952 957
953 ( 958 (
954 $w + $self->{padding} * 2, 959 $w + $self->{padding} * 2,
955 $h + $self->{padding} * 2, 960 $h + $self->{padding} * 2,
974sub _draw { 979sub _draw {
975 my ($self) = @_; 980 my ($self) = @_;
976 981
977 my $tex = $self->{texture} ||= do { 982 my $tex = $self->{texture} ||= do {
978 $self->{layout}->set_width ($self->{w}); 983 $self->{layout}->set_width ($self->{w});
979 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); 984 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize});
980 new_from_layout CFClient::Texture $self->{layout} 985 new_from_layout CFClient::Texture $self->{layout}
981 }; 986 };
982 987
983 glEnable GL_BLEND; 988 glEnable GL_BLEND;
984 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 989 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
985 glEnable GL_TEXTURE_2D; 990 glEnable GL_TEXTURE_2D;
986 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 991 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
987 992
988 glColor @{$self->{fg}}; 993 glColor @{$self->{fg}};
989 994
990 my $x = 995 my $x =
991 $self->{align} < 0 ? $self->{padding} 996 $self->{align} < 0 ? $self->{padding}
992 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 997 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
993 : ($self->{w} - $tex->{w}) * 0.5; 998 : ($self->{w} - $tex->{w}) * 0.5;
994 999
995 glTranslate int $x, int +($self->{h} - $tex->{h}) * 0.5, 0; 1000 $tex->draw_quad (int $x, int +($self->{h} - $tex->{h}) * 0.5);
996 $tex->draw_quad (0, 0);
997 1001
998 glDisable GL_TEXTURE_2D; 1002 glDisable GL_TEXTURE_2D;
999 glDisable GL_BLEND; 1003 glDisable GL_BLEND;
1000} 1004}
1001 1005
1023} 1027}
1024 1028
1025sub _set_text { 1029sub _set_text {
1026 my ($self, $text) = @_; 1030 my ($self, $text) = @_;
1027 1031
1032 my $old_text = $self->{text};
1033
1028 $self->{last_activity} = $::NOW; 1034 $self->{last_activity} = $::NOW;
1029 1035
1030 $self->{text} = $text; 1036 $self->{text} = $text;
1031 $self->{layout}->set_width ($self->{w}); 1037 $self->{layout}->set_width ($self->{w});
1032 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); 1038 $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize});
1033 1039
1034 $text =~ s/./*/g if $self->{hidden}; 1040 $text =~ s/./*/g if $self->{hidden};
1035 1041
1036 $self->{layout}->set_markup ($self->escape_text ($text) . " "); 1042 $self->{layout}->set_markup ($self->escape_text ($text) . " ");
1037 1043
1038 $text = substr $text, 0, $self->{cursor}; 1044 $text = substr $text, 0, $self->{cursor};
1039 utf8::encode $text; 1045 utf8::encode $text;
1040 1046
1041 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); 1047 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
1048
1049 $self->emit (changed => $self->{text}) # XXX: is this the right place to do this?
1050 if $old_text ne $self->{text};
1042} 1051}
1043 1052
1044sub size_request { 1053sub size_request {
1045 my ($self) = @_; 1054 my ($self) = @_;
1046 1055
1085 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1094 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1086 } elsif ($sym == SDLK_HOME) { 1095 } elsif ($sym == SDLK_HOME) {
1087 $self->{cursor} = 0; 1096 $self->{cursor} = 0;
1088 } elsif ($sym == SDLK_END) { 1097 } elsif ($sym == SDLK_END) {
1089 $self->{cursor} = length $text; 1098 $self->{cursor} = length $text;
1099 } elsif ($sym == SDLK_ESCAPE) {
1100 $self->emit ('escape');
1090 } elsif ($uni) { 1101 } elsif ($uni) {
1091 substr $text, $self->{cursor}++, 0, chr $uni; 1102 substr $text, $self->{cursor}++, 0, chr $uni;
1092 } 1103 }
1093 1104
1094 $self->_set_text ($text); 1105 $self->_set_text ($text);
1156 glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; 1167 glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h};
1157 glEnd; 1168 glEnd;
1158 } 1169 }
1159} 1170}
1160 1171
1172package CFClient::UI::LineEntry;
1173
1174our @ISA = CFClient::UI::Entry::;
1175
1176use SDL;
1177use SDL::OpenGL;
1178
1179sub key_down {
1180 my ($self, $ev) = @_;
1181
1182 my $sym = $ev->key_sym;
1183
1184 if ($sym == SDLK_RETURN) {
1185 $self->emit (activate => $self->get_text);
1186 $self->update;
1187
1188 } else {
1189 $self->SUPER::key_down ($ev);
1190 }
1191
1192}
1193
1161############################################################################# 1194#############################################################################
1162 1195
1163package CFClient::UI::Button; 1196package CFClient::UI::Button;
1164 1197
1165our @ISA = CFClient::UI::Label::; 1198our @ISA = CFClient::UI::Label::;
1222 1255
1223package CFClient::UI::CheckBox; 1256package CFClient::UI::CheckBox;
1224 1257
1225our @ISA = CFClient::UI::DrawBG::; 1258our @ISA = CFClient::UI::DrawBG::;
1226 1259
1260my @tex =
1261 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1262 qw(c1_checkbox_bg.png c1_checkbox_active.png);
1263
1227use SDL; 1264use SDL;
1228use SDL::OpenGL; 1265use SDL::OpenGL;
1229 1266
1230sub new { 1267sub new {
1231 my $class = shift; 1268 my $class = shift;
1268 $self->SUPER::_draw; 1305 $self->SUPER::_draw;
1269 1306
1270 glTranslate $self->{padding} + 0.375, $self->{padding} + 0.375, 0; 1307 glTranslate $self->{padding} + 0.375, $self->{padding} + 0.375, 0;
1271 1308
1272 my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2; 1309 my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2;
1273 1310
1274 glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} }; 1311 glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} };
1275 1312
1276 glBegin GL_LINE_LOOP; 1313 glEnable GL_BLEND;
1277 glVertex 0 , 0; 1314 glEnable GL_TEXTURE_2D;
1278 glVertex 0 , $s; 1315 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1279 glVertex $s, $s;
1280 glVertex $s, 0;
1281 glEnd;
1282 1316
1283 if ($self->{state}) { 1317 my $tex = $self->{state} ? $tex[1] : $tex[0];
1284 glBegin GL_LINES; 1318
1285 glVertex 0 , 0; 1319 $tex->draw_quad (0, 0, $s, $s);
1286 glVertex $s, $s; 1320
1287 glVertex $s, 0; 1321 glDisable GL_TEXTURE_2D;
1288 glVertex 0 , $s; 1322 glDisable GL_BLEND;
1289 glEnd;
1290 }
1291} 1323}
1292 1324
1293############################################################################# 1325#############################################################################
1294 1326
1295package CFClient::UI::Slider; 1327package CFClient::UI::Slider;
1297use strict; 1329use strict;
1298 1330
1299use SDL::OpenGL; 1331use SDL::OpenGL;
1300 1332
1301our @ISA = CFClient::UI::DrawBG::; 1333our @ISA = CFClient::UI::DrawBG::;
1334
1335my @tex =
1336 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1337 qw(s1_slider.png s1_slider_bg.png);
1302 1338
1303sub new { 1339sub new {
1304 my $class = shift; 1340 my $class = shift;
1305 1341
1306 # range [value, low, high, page] 1342 # range [value, low, high, page]
1314 range => [0, 0, 100, 10], 1350 range => [0, 0, 100, 10],
1315 req_w => 40, 1351 req_w => 40,
1316 req_h => 13, 1352 req_h => 13,
1317 vertical => 0, 1353 vertical => 0,
1318 can_hover => 1, 1354 can_hover => 1,
1355 inner_pad => 5,
1319 @_ 1356 @_
1320 ); 1357 );
1321 1358
1322 $self 1359 $self
1323} 1360}
1344 if ($GRAB == $self) { 1381 if ($GRAB == $self) {
1345 my ($value, $lo, $hi, $page) = @{$self->{range}}; 1382 my ($value, $lo, $hi, $page) = @{$self->{range}};
1346 1383
1347 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); 1384 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w});
1348 1385
1386 my $inner_pad_px = $self->_calc_inner_pad_px ($w);
1387 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
1388
1389 $x -= $inner_pad_px; # substract the padding
1349 $x = $x * ($hi - $lo) / $w + $lo; 1390 $x = $x * ($hi - $lo) / $inner_w + $lo;
1350 $x = $lo if $x < $lo; 1391 $x = $lo if $x < $lo;
1351 $x = $hi - $page if $x > $hi - $page; 1392 $x = $hi - $page if $x > $hi - $page;
1352 $self->{range}[0] = $x; 1393 $self->{range}[0] = $x;
1353 1394
1354 $self->emit (changed => $x); 1395 $self->emit (changed => $x);
1355 $self->update; 1396 $self->update;
1356 } 1397 }
1398}
1399
1400# the inner_* stuff is for generating a padding for the slider handle,
1401# so that the handle doesn't leave the texture. This calculation isn't 100%
1402# correct propably, but it does the job for now
1403sub _calc_inner_pad_px {
1404 my ($self, $w) = @_;
1405 ($w / 100) * $self->{inner_pad} # % to pixels
1357} 1406}
1358 1407
1359sub _draw { 1408sub _draw {
1360 my ($self) = @_; 1409 my ($self) = @_;
1361 1410
1375 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg}; 1424 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg};
1376 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg}; 1425 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg};
1377 1426
1378 my ($value, $lo, $hi, $page) = @{$self->{range}}; 1427 my ($value, $lo, $hi, $page) = @{$self->{range}};
1379 1428
1429 my $inner_pad_px = $self->_calc_inner_pad_px ($w);
1430 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
1431
1380 $page = int $page * $w / ($hi - $lo); 1432 $page = int $page * $inner_w / ($hi - $lo);
1381 $value = int +($value - $lo) * $w / ($hi - $lo); 1433 $value = int +($value - $lo) * $inner_w / ($hi - $lo);
1382 1434
1383 $w -= $page; 1435 $w -= $page;
1384 $page &= ~1; 1436 $page &= ~1;
1385 glTranslate $page * 0.5, 0, 0; 1437 glTranslate $page * 0.5, 0, 0;
1386 $page ||= 2; 1438 $page ||= 2;
1387 1439
1388 glColor @$fg;
1389 glBegin GL_LINES;
1390 glVertex 0, 0; glVertex 0, $h;
1391 glVertex $w - 1, 0; glVertex $w - 1, $h;
1392 glVertex 0, $h * 0.5; glVertex $w, $h * 0.5;
1393 glEnd;
1394
1395 my $knob_a = $value - $page * 0.5; 1440 my $knob_a = $inner_pad_px + ($value - $page * 0.5);
1396 my $knob_b = $value + $page * 0.5; 1441 my $knob_b = $inner_pad_px + ($value + $page * 0.5);
1397 1442
1398 glBegin GL_QUADS; 1443 glEnable GL_BLEND;
1399 glColor @$fg; 1444 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1400 glVertex $knob_a, 0; 1445 glEnable GL_TEXTURE_2D;
1401 glVertex $knob_a, $h; 1446 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1402 glVertex $knob_b, $h;
1403 glVertex $knob_b, 0;
1404 1447
1405 if ($knob_a < $knob_b - 2) { 1448 # draw background
1406 glColor @$bg; 1449 $tex[1]->draw_quad (0, 0, $w, $h);
1407 glVertex $knob_a + 1, 1; 1450
1408 glVertex $knob_a + 1, $h - 1; 1451 # draw handle
1409 glVertex $knob_b - 1, $h - 1; 1452 $tex[0]->draw_quad ($knob_a, 0, $knob_b - $knob_a, $h);
1410 glVertex $knob_b - 1, 1; 1453
1411 } 1454 glDisable GL_BLEND;
1412 glEnd; 1455 glDisable GL_TEXTURE_2D;
1413} 1456}
1414 1457
1415############################################################################# 1458#############################################################################
1416 1459
1417package CFClient::UI::TextView; 1460package CFClient::UI::TextView;
1422 1465
1423sub new { 1466sub new {
1424 my $class = shift; 1467 my $class = shift;
1425 1468
1426 my $self = $class->SUPER::new ( 1469 my $self = $class->SUPER::new (
1470 req_w => $::WIDTH / 6,
1471 req_h => $::HEIGHT / 6,
1472 fontsize => $::FONTSIZE,
1473 @_,
1474
1475 layout => (new CFClient::Layout),
1427 par => [], 1476 par => [],
1428 @_, 1477 height => 0,
1429 children => [ 1478 children => [
1430 (new CFClient::UI::Empty expand => 1), 1479 (new CFClient::UI::Empty expand => 1),
1431 (new CFClient::UI::Slider vertical => 1), 1480 (new CFClient::UI::Slider vertical => 1),
1432 ], 1481 ],
1433 ); 1482 );
1434 1483
1435 $self 1484 $self
1436} 1485}
1437 1486
1487sub text_height {
1488 my ($self, $text) = @_;
1489
1490 my $layout = $self->{layout};
1491
1492 $layout->set_height ($self->{fontsize});
1493 $layout->set_width ($self->{w});
1494 $layout->set_text ($text);
1495
1496 ($layout->size)[1]
1497}
1498
1499sub reflow {
1500 my ($self) = @_;
1501
1502 my $height = 0;
1503
1504 for (@{$self->{par}}) {
1505 $height += $_->[0] = $self->text_height ($_->[2]);
1506 }
1507
1508 $self->{height} = $height;
1509
1510 $self->{range} = [$height - $self->{h}, 0, $height, $self->{h}];
1511}
1512
1513sub size_request {
1514 my ($self) = @_;
1515
1516 ($self->{req_w}, $self->{req_h})
1517}
1518
1519sub size_allocate {
1520 my ($self, $x, $y, $w, $h) = @_;
1521
1522 $self->SUPER::size_allocate ($x, $y, $w, $h);
1523
1524 $self->{layout}->set_height ($self->{fontsize});
1525 $self->{layout}->set_width ($self->{w});
1526
1527 $self->reflow;
1528 $self->update;
1529}
1530
1438sub add_paragraph { 1531sub add_paragraph {
1439 my ($self, $color, $text) = @_; 1532 my ($self, $color, $text) = @_;
1440 1533
1534 #TODO: intelligently "reformat" paragraph
1535
1536 my $height = $self->text_height ($text);
1537
1538 $self->{height} += $height;
1539
1441 push @{$self->{par}}, [$color, $text]; 1540 push @{$self->{par}}, [$height, $color, $text];
1442 my $count = scalar @{$self->{par}}; 1541
1443 $self->{children}[1]{range} = [$count - 1, 0, $count, 1]; 1542 $self->{children}[1]{range} = [$self->{height} - $self->{h}, 0, $self->{height}, $self->{h}];
1444 $self->{children}[1]->update; 1543 $self->{children}[1]->update;
1445} 1544}
1446 1545
1546sub update {
1547 my ($self) = @_;
1548
1549 $self->SUPER::update;
1550
1551 return unless $self->{h} > 0;
1552
1553 $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub {
1554 glClearColor 0, 0, 0, 1;
1555 glClear GL_COLOR_BUFFER_BIT;
1556
1557 my $y0 = $self->{height} - $self->{h};
1558 my $y1 = $self->{height};
1559
1560 glEnable GL_BLEND;
1561 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1562 glEnable GL_TEXTURE_2D;
1563 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1564
1565 my $y = 0;
1566
1567 my $layout = $self->{layout};
1568
1569 for my $par (@{$self->{par}}) {
1570 my $h = $par->[0];
1571
1572 if ($y0 < $y + $h && $y < $y1) {
1573 $layout->set_text ($par->[2]);
1574
1575 glColor @{ $par->[1] };
1576 my ($W, $H) = $layout->size;
1577 CFClient::Texture->new_from_layout ($layout)->draw_quad (0, $y - $y0);
1578 }
1579
1580 $y += $h;
1581 }
1582
1583 glDisable GL_TEXTURE_2D;
1584 glDisable GL_BLEND;
1585 };
1586}
1587
1447sub _draw { 1588sub _draw {
1448 my ($self) = @_; 1589 my ($self) = @_;
1449 1590
1450 my $par = $self->{par}; 1591 if ($self->{texture}) {
1451
1452 my $bottom = (scalar @$par) - 1;
1453
1454 my $w = $self->{children}[0]{w};
1455 my $y = $self->{h};
1456
1457 glEnable GL_BLEND;
1458 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
1459 glEnable GL_TEXTURE_2D; 1592 glEnable GL_TEXTURE_2D;
1460 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 1593 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1461 1594 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
1462 # TODO: everything!
1463 while ($y > 0 && $bottom >= 0) {
1464 my $par = $par->[$bottom--];
1465
1466 my $layout = new CFClient::Layout;
1467
1468 $layout->set_height ($::FONTSIZE);
1469 $layout->set_width ($w);
1470 $layout->set_text ($par->[1]);
1471 my $tex = new_from_layout CFClient::Texture $layout;
1472 $y -= $tex->{h};
1473
1474 glColor @{ $par->[0] };
1475 $tex->draw_quad (0, $y);
1476 }
1477
1478 glDisable GL_TEXTURE_2D; 1595 glDisable GL_TEXTURE_2D;
1479 glDisable GL_BLEND; 1596 }
1597
1480} 1598}
1481 1599
1482############################################################################# 1600#############################################################################
1483 1601
1484package CFClient::UI::MapWidget; 1602package CFClient::UI::MapWidget;
1617 1735
1618 if ($sym == SDLK_KP5) { 1736 if ($sym == SDLK_KP5) {
1619 $::CONN->user_send ("command stay fire"); 1737 $::CONN->user_send ("command stay fire");
1620 } elsif ($sym == SDLK_a) { 1738 } elsif ($sym == SDLK_a) {
1621 $::CONN->user_send ("command apply"); 1739 $::CONN->user_send ("command apply");
1740 } elsif ($sym == SDLK_QUOTE) {
1741 $self->emit ('activate_console');
1742 } elsif ($sym == SDLK_SLASH) {
1743 $self->emit ('activate_console' => '/');
1622 } elsif (exists $DIR{$sym}) { 1744 } elsif (exists $DIR{$sym}) {
1623 if ($mod & KMOD_SHIFT) { 1745 if ($mod & KMOD_SHIFT) {
1624 $self->{shft}++; 1746 $self->{shft}++;
1625 $::CONN->user_send ("command fire $DIR{$sym}[0]"); 1747 $::CONN->user_send ("command fire $DIR{$sym}[0]");
1626 } elsif ($mod & KMOD_CTRL) { 1748 } elsif ($mod & KMOD_CTRL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines