… | |
… | |
625 | our @ISA = CFClient::UI::Bin::; |
625 | our @ISA = CFClient::UI::Bin::; |
626 | |
626 | |
627 | use CFClient::OpenGL; |
627 | use CFClient::OpenGL; |
628 | |
628 | |
629 | my @tex = |
629 | my @tex = |
630 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
630 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
631 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
631 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
632 | |
632 | |
633 | sub new { |
633 | sub new { |
634 | my $class = shift; |
634 | my $class = shift; |
635 | |
635 | |
… | |
… | |
1344 | our @ISA = CFClient::UI::Label::; |
1344 | our @ISA = CFClient::UI::Label::; |
1345 | |
1345 | |
1346 | use CFClient::OpenGL; |
1346 | use CFClient::OpenGL; |
1347 | |
1347 | |
1348 | my @tex = |
1348 | my @tex = |
1349 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1349 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1350 | qw(b1_button_active.png); |
1350 | qw(b1_button_active.png); |
1351 | |
1351 | |
1352 | sub new { |
1352 | sub new { |
1353 | my $class = shift; |
1353 | my $class = shift; |
1354 | |
1354 | |
… | |
… | |
1401 | package CFClient::UI::CheckBox; |
1401 | package CFClient::UI::CheckBox; |
1402 | |
1402 | |
1403 | our @ISA = CFClient::UI::DrawBG::; |
1403 | our @ISA = CFClient::UI::DrawBG::; |
1404 | |
1404 | |
1405 | my @tex = |
1405 | my @tex = |
1406 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1406 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1407 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1407 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1408 | |
1408 | |
1409 | use CFClient::OpenGL; |
1409 | use CFClient::OpenGL; |
1410 | |
1410 | |
1411 | sub new { |
1411 | sub new { |
… | |
… | |
1460 | glDisable GL_BLEND; |
1460 | glDisable GL_BLEND; |
1461 | } |
1461 | } |
1462 | |
1462 | |
1463 | ############################################################################# |
1463 | ############################################################################# |
1464 | |
1464 | |
|
|
1465 | package CFClient::UI::Image; |
|
|
1466 | |
|
|
1467 | our @ISA = CFClient::UI::Base::; |
|
|
1468 | |
|
|
1469 | use CFClient::OpenGL; |
|
|
1470 | use Carp qw/confess/; |
|
|
1471 | |
|
|
1472 | our %loaded_images; |
|
|
1473 | |
|
|
1474 | sub new { |
|
|
1475 | my $class = shift; |
|
|
1476 | |
|
|
1477 | my $self = $class->SUPER::new (@_); |
|
|
1478 | |
|
|
1479 | $self->{image} or confess "Image has 'image' not set. This is a fatal error!"; |
|
|
1480 | |
|
|
1481 | $loaded_images{$self->{image}} ||= |
|
|
1482 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
|
|
1483 | |
|
|
1484 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
|
|
1485 | |
|
|
1486 | $self->{aspect} = $tex->{w} / $tex->{h}; |
|
|
1487 | |
|
|
1488 | $self |
|
|
1489 | } |
|
|
1490 | |
|
|
1491 | sub size_request { |
|
|
1492 | my ($self) = @_; |
|
|
1493 | |
|
|
1494 | ($self->{tex}->{w}, $self->{tex}->{h}) |
|
|
1495 | } |
|
|
1496 | |
|
|
1497 | sub _draw { |
|
|
1498 | my ($self) = @_; |
|
|
1499 | |
|
|
1500 | my $tex = $self->{tex}; |
|
|
1501 | |
|
|
1502 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1503 | |
|
|
1504 | if ($self->{rot90}) { |
|
|
1505 | glRotate 90, 0, 0, 1; |
|
|
1506 | glTranslate 0, -$self->{w}, 0; |
|
|
1507 | |
|
|
1508 | ($w, $h) = ($h, $w); |
|
|
1509 | } |
|
|
1510 | |
|
|
1511 | glEnable GL_BLEND; |
|
|
1512 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1513 | glEnable GL_TEXTURE_2D; |
|
|
1514 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1515 | |
|
|
1516 | $tex->draw_quad (0, 0, $w, $h); |
|
|
1517 | |
|
|
1518 | glDisable GL_BLEND; |
|
|
1519 | glDisable GL_TEXTURE_2D; |
|
|
1520 | } |
|
|
1521 | |
|
|
1522 | ############################################################################# |
|
|
1523 | |
1465 | package CFClient::UI::VGauge; |
1524 | package CFClient::UI::VGauge; |
1466 | |
1525 | |
1467 | our @ISA = CFClient::UI::Base::; |
1526 | our @ISA = CFClient::UI::Base::; |
1468 | |
1527 | |
1469 | use CFClient::OpenGL; |
1528 | use CFClient::OpenGL; |
1470 | |
1529 | |
1471 | my %tex = ( |
1530 | my %tex = ( |
1472 | food => [ |
1531 | food => [ |
1473 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1532 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1474 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
1533 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
1475 | ], |
1534 | ], |
1476 | grace => [ |
1535 | grace => [ |
1477 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1536 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1478 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
1537 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
1479 | ], |
1538 | ], |
1480 | hp => [ |
1539 | hp => [ |
1481 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1540 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1482 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
1541 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
1483 | ], |
1542 | ], |
1484 | mana => [ |
1543 | mana => [ |
1485 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1544 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1486 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
1545 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
1487 | ], |
1546 | ], |
1488 | ); |
1547 | ); |
1489 | |
1548 | |
1490 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
1549 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
1491 | sub new { |
1550 | sub new { |
1492 | my $class = shift; |
1551 | my $class = shift; |
1493 | |
1552 | |
1494 | my $self = $class->SUPER::new ( |
1553 | my $self = $class->SUPER::new ( |
1495 | type => 'food', |
1554 | type => 'food', |
1496 | scale => 1, |
|
|
1497 | @_ |
1555 | @_ |
1498 | ); |
1556 | ); |
1499 | |
1557 | |
1500 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
1558 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
1501 | |
1559 | |
… | |
… | |
1503 | } |
1561 | } |
1504 | |
1562 | |
1505 | sub size_request { |
1563 | sub size_request { |
1506 | my ($self) = @_; |
1564 | my ($self) = @_; |
1507 | |
1565 | |
1508 | my $tex = $tex{$self->{type}}[0]; |
1566 | #my $tex = $tex{$self->{type}}[0]; |
1509 | |
1567 | #@$tex{qw(w h)} |
1510 | my ($w, $h) = map { $_ * $self->{scale} } @$tex{qw(w h)}; |
1568 | (0, 0) |
1511 | ($self->{vertical}) ? ($h, $w) : ($w, $h) |
|
|
1512 | } |
1569 | } |
1513 | |
1570 | |
1514 | sub set_max { |
1571 | sub set_max { |
1515 | my ($self, $max) = @_; |
1572 | my ($self, $max) = @_; |
1516 | |
1573 | |
… | |
… | |
1589 | my $self = $class->SUPER::new ( |
1646 | my $self = $class->SUPER::new ( |
1590 | @_, |
1647 | @_, |
1591 | ); |
1648 | ); |
1592 | |
1649 | |
1593 | $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1650 | $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1594 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, scale => ($self->{scale} || 0.5)); |
1651 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); |
1595 | $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1652 | $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1596 | |
1653 | |
1597 | $self |
1654 | $self |
1598 | } |
1655 | } |
1599 | |
1656 | |