… | |
… | |
638 | my ($class, $x, $y, $z, $height, $text) = @_; |
638 | my ($class, $x, $y, $z, $height, $text) = @_; |
639 | |
639 | |
640 | $height ||= $::FONTSIZE; |
640 | $height ||= $::FONTSIZE; |
641 | |
641 | |
642 | # TODO: color, and make height, xyz etc. optional |
642 | # TODO: color, and make height, xyz etc. optional |
643 | my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height); |
643 | my $self = $class->SUPER::new ( |
|
|
644 | x => $x, |
|
|
645 | y => $y, |
|
|
646 | z => $z, |
|
|
647 | height => $height, |
|
|
648 | layout => new Crossfire::Client::Layout, |
|
|
649 | ); |
644 | |
650 | |
645 | $self->set_text ($text); |
651 | $self->set_text ($text); |
646 | |
652 | |
647 | $self |
653 | $self |
648 | } |
654 | } |
649 | |
655 | |
650 | sub set_text { |
656 | sub set_text { |
651 | my ($self, $text) = @_; |
657 | my ($self, $text) = @_; |
652 | |
658 | |
653 | $self->{text} = $text; |
659 | $self->{text} = $text; |
654 | $self->{texture} = new_from_text Crossfire::Client::Texture $text, $self->{height}; |
660 | $self->{layout}->set_markup ($text); |
655 | |
661 | |
656 | $self->update; |
662 | delete $self->{texture}; |
657 | } |
663 | } |
658 | |
664 | |
659 | sub get_text { |
665 | sub get_text { |
660 | my ($self, $text) = @_; |
666 | my ($self, $text) = @_; |
661 | |
667 | |
… | |
… | |
663 | } |
669 | } |
664 | |
670 | |
665 | sub size_request { |
671 | sub size_request { |
666 | my ($self) = @_; |
672 | my ($self) = @_; |
667 | |
673 | |
|
|
674 | $self->{layout}->set_width; |
|
|
675 | $self->{layout}->size |
668 | if ($self->{texture}{width} > 1 && $self->{texture}{height} > 1) { #TODO: hack |
676 | # if ($self->{texture}{width} > 1 && $self->{texture}{height} > 1) { #TODO: hack |
669 | ( |
677 | # ( |
670 | $self->{texture}{width}, |
678 | # $self->{texture}{width}, |
671 | $self->{texture}{height}, |
679 | # $self->{texture}{height}, |
672 | ) |
680 | # ) |
673 | } else { |
681 | # } else { |
674 | my ($w, $h, $data) = Crossfire::Client::font_render "Yy", $self->{height}; |
682 | # my ($w, $h, $data) = Crossfire::Client::font_render "Yy", $self->{height}; |
675 | |
683 | # |
676 | ($w, $h) |
684 | # ($w, $h) |
677 | } |
685 | # } |
|
|
686 | } |
678 | |
687 | |
|
|
688 | sub size_allocate { |
|
|
689 | my ($self, $w, $h) = @_; |
|
|
690 | |
|
|
691 | $self->SUPER::size_allocate ($w, $h); |
|
|
692 | delete $self->{texture}; |
679 | } |
693 | } |
680 | |
694 | |
681 | sub _draw { |
695 | sub _draw { |
682 | my ($self) = @_; |
696 | my ($self) = @_; |
683 | |
697 | |
684 | my $tex = $self->{texture}; |
698 | my $tex = $self->{texture} ||= do { |
|
|
699 | $self->{layout}->set_width ($self->{w}); |
|
|
700 | new_from_layout Crossfire::Client::Texture $self->{layout}; |
|
|
701 | }; |
685 | |
702 | |
686 | glEnable GL_BLEND; |
703 | glEnable GL_BLEND; |
687 | glEnable GL_TEXTURE_2D; |
704 | glEnable GL_TEXTURE_2D; |
688 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
705 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
689 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
706 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |