… | |
… | |
1491 | sub new { |
1491 | sub new { |
1492 | my $class = shift; |
1492 | my $class = shift; |
1493 | |
1493 | |
1494 | my $self = $class->SUPER::new ( |
1494 | my $self = $class->SUPER::new ( |
1495 | type => 'food', |
1495 | type => 'food', |
|
|
1496 | scale => 1, |
1496 | @_ |
1497 | @_ |
1497 | ); |
1498 | ); |
1498 | |
1499 | |
1499 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
1500 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
1500 | |
1501 | |
… | |
… | |
1503 | |
1504 | |
1504 | sub size_request { |
1505 | sub size_request { |
1505 | my ($self) = @_; |
1506 | my ($self) = @_; |
1506 | |
1507 | |
1507 | my $tex = $tex{$self->{type}}[0]; |
1508 | my $tex = $tex{$self->{type}}[0]; |
1508 | |
1509 | |
1509 | @$tex{qw(w h)} |
1510 | my ($w, $h) = map { $_ * $self->{scale} } @$tex{qw(w h)}; |
|
|
1511 | ($self->{vertical}) ? ($h, $w) : ($w, $h) |
1510 | } |
1512 | } |
1511 | |
1513 | |
1512 | sub set_max { |
1514 | sub set_max { |
1513 | my ($self, $max) = @_; |
1515 | my ($self, $max) = @_; |
1514 | |
1516 | |
… | |
… | |
1531 | my ($self) = @_; |
1533 | my ($self) = @_; |
1532 | |
1534 | |
1533 | my $tex = $tex{$self->{type}}; |
1535 | my $tex = $tex{$self->{type}}; |
1534 | |
1536 | |
1535 | my ($w, $h) = ($self->{w}, $self->{h}); |
1537 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1538 | |
|
|
1539 | if ($self->{vertical}) { |
|
|
1540 | glRotate 90, 0, 0, 1; |
|
|
1541 | glTranslate 0, -$self->{w}, 0; |
|
|
1542 | |
|
|
1543 | ($w, $h) = ($h, $w); |
|
|
1544 | } |
1536 | |
1545 | |
1537 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
1546 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
1538 | $ycut = 1 if $self->{val} > $self->{max_val}; |
1547 | $ycut = 1 if $self->{val} > $self->{max_val}; |
1539 | |
1548 | |
1540 | my $t1 = $tex->[0]; |
1549 | my $t1 = $tex->[0]; |
… | |
… | |
1580 | my $self = $class->SUPER::new ( |
1589 | my $self = $class->SUPER::new ( |
1581 | @_, |
1590 | @_, |
1582 | ); |
1591 | ); |
1583 | |
1592 | |
1584 | $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1593 | $self->add ($self->{value} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1585 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); |
1594 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, scale => ($self->{scale} || 0.5)); |
1586 | $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1595 | $self->add ($self->{max} = new CFClient::UI::Label valign => 1, align => 0, template => "999"); |
1587 | |
1596 | |
1588 | $self |
1597 | $self |
1589 | } |
1598 | } |
1590 | |
1599 | |