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.143 by root, Thu Apr 20 21:28:51 2006 UTC vs.
Revision 1.145 by elmex, Fri Apr 21 12:27:20 2006 UTC

625our @ISA = CFClient::UI::Bin::; 625our @ISA = CFClient::UI::Bin::;
626 626
627use CFClient::OpenGL; 627use CFClient::OpenGL;
628 628
629my @tex = 629my @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
633sub new { 633sub new {
634 my $class = shift; 634 my $class = shift;
635 635
1344our @ISA = CFClient::UI::Label::; 1344our @ISA = CFClient::UI::Label::;
1345 1345
1346use CFClient::OpenGL; 1346use CFClient::OpenGL;
1347 1347
1348my @tex = 1348my @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
1352sub new { 1352sub new {
1353 my $class = shift; 1353 my $class = shift;
1354 1354
1401package CFClient::UI::CheckBox; 1401package CFClient::UI::CheckBox;
1402 1402
1403our @ISA = CFClient::UI::DrawBG::; 1403our @ISA = CFClient::UI::DrawBG::;
1404 1404
1405my @tex = 1405my @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
1409use CFClient::OpenGL; 1409use CFClient::OpenGL;
1410 1410
1411sub new { 1411sub new {
1460 glDisable GL_BLEND; 1460 glDisable GL_BLEND;
1461} 1461}
1462 1462
1463############################################################################# 1463#############################################################################
1464 1464
1465package CFClient::UI::Image;
1466
1467our @ISA = CFClient::UI::Base::;
1468
1469use CFClient::OpenGL;
1470use Carp qw/confess/;
1471
1472our %loaded_images;
1473
1474sub 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
1491sub size_request {
1492 my ($self) = @_;
1493
1494 ($self->{tex}->{w}, $self->{tex}->{h})
1495}
1496
1497sub _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
1465package CFClient::UI::VGauge; 1524package CFClient::UI::VGauge;
1466 1525
1467our @ISA = CFClient::UI::Base::; 1526our @ISA = CFClient::UI::Base::;
1468 1527
1469use CFClient::OpenGL; 1528use CFClient::OpenGL;
1470 1529
1471my %tex = ( 1530my %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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines