… | |
… | |
225 | glPopMatrix; |
225 | glPopMatrix; |
226 | |
226 | |
227 | if ($self == $HOVER && $self->{can_hover}) { |
227 | if ($self == $HOVER && $self->{can_hover}) { |
228 | my ($x, $y) = @$self{qw(x y)}; |
228 | my ($x, $y) = @$self{qw(x y)}; |
229 | |
229 | |
230 | glColor 0, 0, 1, 0.2; |
230 | glColor 1, 0.8, 0.5, 0.2; |
231 | glEnable GL_BLEND; |
231 | glEnable GL_BLEND; |
232 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
232 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
233 | glBegin GL_QUADS; |
233 | glBegin GL_QUADS; |
234 | glVertex $x , $y; |
234 | glVertex $x , $y; |
235 | glVertex $x + $self->{w}, $y; |
235 | glVertex $x + $self->{w}, $y; |
… | |
… | |
1043 | glEnable GL_TEXTURE_2D; |
1043 | glEnable GL_TEXTURE_2D; |
1044 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1044 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1045 | |
1045 | |
1046 | glColor @{$self->{fg}}; |
1046 | glColor @{$self->{fg}}; |
1047 | |
1047 | |
1048 | my $x = |
1048 | $self->{ox} = int ( |
1049 | $self->{align} < 0 ? $self->{padding} |
1049 | $self->{align} < 0 ? $self->{padding} |
1050 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1050 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1051 | : ($self->{w} - $tex->{w}) * 0.5; |
1051 | : ($self->{w} - $tex->{w}) * 0.5 |
|
|
1052 | ); |
1052 | |
1053 | |
1053 | my $y = |
1054 | $self->{oy} = int ( |
1054 | $self->{valign} < 0 ? $self->{padding} |
1055 | $self->{valign} < 0 ? $self->{padding} |
1055 | : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} |
1056 | : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} |
1056 | : ($self->{h} - $tex->{h}) * 0.5; |
1057 | : ($self->{h} - $tex->{h}) * 0.5 |
|
|
1058 | ); |
1057 | |
1059 | |
1058 | $tex->draw_quad (int $x, int $y); |
1060 | $tex->draw_quad ($self->{ox}, $self->{oy}); |
1059 | |
1061 | |
1060 | glDisable GL_TEXTURE_2D; |
1062 | glDisable GL_TEXTURE_2D; |
1061 | glDisable GL_BLEND; |
1063 | glDisable GL_BLEND; |
1062 | } |
1064 | } |
1063 | |
1065 | |
… | |
… | |
1224 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) |
1226 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) |
1225 | } |
1227 | } |
1226 | |
1228 | |
1227 | glColor @{$self->{fg}}; |
1229 | glColor @{$self->{fg}}; |
1228 | glBegin GL_LINES; |
1230 | glBegin GL_LINES; |
1229 | glVertex $self->{cur_x}, $self->{cur_y}; |
|
|
1230 | glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; |
1231 | glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; |
|
|
1232 | glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
1231 | glEnd; |
1233 | glEnd; |
1232 | } |
1234 | } |
1233 | } |
1235 | } |
1234 | |
1236 | |
1235 | package CFClient::UI::Entry; |
1237 | package CFClient::UI::Entry; |
… | |
… | |
1272 | |
1274 | |
1273 | $class->SUPER::new ( |
1275 | $class->SUPER::new ( |
1274 | padding => 4, |
1276 | padding => 4, |
1275 | fg => [1, 1, 1], |
1277 | fg => [1, 1, 1], |
1276 | bg => [1, 1, 1, 0.2], |
1278 | bg => [1, 1, 1, 0.2], |
1277 | active_fg => [1, 1, 0], |
1279 | active_fg => [0, 0, 1], |
1278 | can_hover => 1, |
1280 | can_hover => 1, |
1279 | @_ |
1281 | @_ |
1280 | ) |
1282 | ) |
1281 | } |
1283 | } |
1282 | |
1284 | |
… | |
… | |
1379 | |
1381 | |
1380 | $tex->draw_quad (0, 0, $s, $s); |
1382 | $tex->draw_quad (0, 0, $s, $s); |
1381 | |
1383 | |
1382 | glDisable GL_TEXTURE_2D; |
1384 | glDisable GL_TEXTURE_2D; |
1383 | glDisable GL_BLEND; |
1385 | glDisable GL_BLEND; |
|
|
1386 | } |
|
|
1387 | |
|
|
1388 | ############################################################################# |
|
|
1389 | |
|
|
1390 | package CFClient::UI::VGauge; |
|
|
1391 | |
|
|
1392 | our @ISA = CFClient::UI::Base::; |
|
|
1393 | |
|
|
1394 | use SDL::OpenGL; |
|
|
1395 | |
|
|
1396 | my %tex = ( |
|
|
1397 | food => [ |
|
|
1398 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1399 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
|
|
1400 | ], |
|
|
1401 | grace => [ |
|
|
1402 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1403 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
|
|
1404 | ], |
|
|
1405 | hp => [ |
|
|
1406 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1407 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
|
|
1408 | ], |
|
|
1409 | mana => [ |
|
|
1410 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1411 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
|
|
1412 | ], |
|
|
1413 | ); |
|
|
1414 | |
|
|
1415 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
|
|
1416 | sub new { |
|
|
1417 | my $class = shift; |
|
|
1418 | |
|
|
1419 | my $self = $class->SUPER::new (gauge => 'food', @_); |
|
|
1420 | |
|
|
1421 | $self |
|
|
1422 | } |
|
|
1423 | |
|
|
1424 | sub size_request { |
|
|
1425 | my ($self) = @_; |
|
|
1426 | |
|
|
1427 | ($self->{w}, $self->{h}) |
|
|
1428 | } |
|
|
1429 | |
|
|
1430 | sub set_max { |
|
|
1431 | my ($self, $max) = @_; |
|
|
1432 | $self->{max_val} = $max; |
|
|
1433 | } |
|
|
1434 | |
|
|
1435 | sub set_value { |
|
|
1436 | my ($self, $val, $max) = @_; |
|
|
1437 | |
|
|
1438 | $self->set_max ($max) |
|
|
1439 | if defined $max; |
|
|
1440 | |
|
|
1441 | $max = $self->{max_val}; |
|
|
1442 | $self->{val} = $val; |
|
|
1443 | |
|
|
1444 | $self->update; |
|
|
1445 | } |
|
|
1446 | |
|
|
1447 | sub _draw { |
|
|
1448 | my ($self) = @_; |
|
|
1449 | |
|
|
1450 | my $tex = $tex{$self->{gauge}}; |
|
|
1451 | |
|
|
1452 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1453 | |
|
|
1454 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
|
|
1455 | $ycut = 1 if $self->{val} > $self->{max_val}; |
|
|
1456 | |
|
|
1457 | my $t1 = $tex->[0]; |
|
|
1458 | my $t2 = $tex->[1]; |
|
|
1459 | |
|
|
1460 | glEnable GL_BLEND; |
|
|
1461 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1462 | glEnable GL_TEXTURE_2D; |
|
|
1463 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1464 | |
|
|
1465 | my $h1 = $self->{h} - $ycut * $self->{h}; |
|
|
1466 | my $h2 = $ycut * $self->{h}; |
|
|
1467 | |
|
|
1468 | my $yp = 0; |
|
|
1469 | |
|
|
1470 | glBindTexture (GL_TEXTURE_2D, $t1->{name}); |
|
|
1471 | glBegin (GL_QUADS); |
|
|
1472 | glTexCoord (0, 0); glVertex (0 , $yp); |
|
|
1473 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp + $h1); |
|
|
1474 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp + $h1); |
|
|
1475 | glTexCoord (1, 0); glVertex (0 + $w, $yp); |
|
|
1476 | glEnd (); |
|
|
1477 | |
|
|
1478 | $yp += $h1; |
|
|
1479 | |
|
|
1480 | glBindTexture (GL_TEXTURE_2D, $t2->{name}); |
|
|
1481 | glBegin (GL_QUADS); |
|
|
1482 | glTexCoord (0, (1 - $ycut)); glVertex (0 , $yp); |
|
|
1483 | glTexCoord (0, 1); glVertex (0 , $yp + $h2); |
|
|
1484 | glTexCoord (1, 1); glVertex (0 + $w, $yp + $h2); |
|
|
1485 | glTexCoord (1, (1 - $ycut)); glVertex (0 + $w, $yp); |
|
|
1486 | glEnd (); |
|
|
1487 | |
|
|
1488 | glDisable GL_BLEND; |
|
|
1489 | glDisable GL_TEXTURE_2D; |
1384 | } |
1490 | } |
1385 | |
1491 | |
1386 | ############################################################################# |
1492 | ############################################################################# |
1387 | |
1493 | |
1388 | package CFClient::UI::Slider; |
1494 | package CFClient::UI::Slider; |
… | |
… | |
1884 | |
1990 | |
1885 | my $mod = $ev->key_mod; |
1991 | my $mod = $ev->key_mod; |
1886 | my $sym = $ev->key_sym; |
1992 | my $sym = $ev->key_sym; |
1887 | |
1993 | |
1888 | if ($sym == SDLK_KP5) { |
1994 | if ($sym == SDLK_KP5) { |
1889 | $::CONN->user_send ("command stay fire"); |
1995 | $::CONN->user_send ("stay fire"); |
1890 | } elsif ($sym == SDLK_a) { |
1996 | } elsif ($sym == SDLK_a) { |
1891 | $::CONN->user_send ("command apply"); |
1997 | $::CONN->user_send ("apply"); |
1892 | } elsif ($sym == SDLK_QUOTE) { |
1998 | } elsif ($sym == SDLK_QUOTE) { |
1893 | $self->emit ('activate_console'); |
1999 | $self->emit ('activate_console'); |
1894 | } elsif ($sym == SDLK_SLASH) { |
2000 | } elsif ($sym == SDLK_SLASH) { |
1895 | $self->emit ('activate_console' => '/'); |
2001 | $self->emit ('activate_console' => '/'); |
1896 | } elsif (exists $DIR{$sym}) { |
2002 | } elsif (exists $DIR{$sym}) { |
1897 | if ($mod & KMOD_SHIFT) { |
2003 | if ($mod & KMOD_SHIFT) { |
1898 | $self->{shft}++; |
2004 | $self->{shft}++; |
1899 | $::CONN->user_send ("command fire $DIR{$sym}[0]"); |
2005 | $::CONN->user_send ("fire $DIR{$sym}[0]"); |
1900 | } elsif ($mod & KMOD_CTRL) { |
2006 | } elsif ($mod & KMOD_CTRL) { |
1901 | $self->{ctrl}++; |
2007 | $self->{ctrl}++; |
1902 | $::CONN->user_send ("command run $DIR{$sym}[0]"); |
2008 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
1903 | } else { |
2009 | } else { |
1904 | $::CONN->user_send ("command $DIR{$sym}[1]"); |
2010 | $::CONN->user_send ("$DIR{$sym}[1]"); |
1905 | } |
2011 | } |
1906 | } |
2012 | } |
1907 | } |
2013 | } |
1908 | |
2014 | |
1909 | sub key_up { |
2015 | sub key_up { |
… | |
… | |
1911 | |
2017 | |
1912 | my $mod = $ev->key_mod; |
2018 | my $mod = $ev->key_mod; |
1913 | my $sym = $ev->key_sym; |
2019 | my $sym = $ev->key_sym; |
1914 | |
2020 | |
1915 | if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { |
2021 | if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { |
1916 | $::CONN->user_send ("command fire_stop"); |
2022 | $::CONN->user_send ("fire_stop"); |
1917 | } |
2023 | } |
1918 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
2024 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
1919 | $::CONN->user_send ("command run_stop"); |
2025 | $::CONN->user_send ("run_stop"); |
1920 | } |
2026 | } |
1921 | } |
2027 | } |
1922 | |
2028 | |
1923 | ############################################################################# |
2029 | ############################################################################# |
1924 | |
2030 | |