--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/07 20:09:52 1.9 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/07 20:34:44 1.10 @@ -13,9 +13,8 @@ sub new { my $class = shift; - my $self = { @_ }; - bless $self, $class; - return $self; + + bless { @_ }, $class } sub activate { @@ -59,9 +58,42 @@ my ($widget) = @_; } +package Crossfire::Client::Widget::Label; + +use SDL::OpenGL; + +sub new { + my ($class, $ttf, $text) = @_; + + my $self = $class->SUPER::new; + + $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text; + + $self +} + +sub draw { + my ($self) = @_; + + my $tex = $self->{texture}; + + glEnable GL_TEXTURE_2D; + glBindTexture GL_TEXTURE_2D, $tex->{name}; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex 0 , 0; + glTexCoord 0, 1; glVertex 0 , $tex->{height}; + glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height}; + glTexCoord 1, 0; glVertex $tex->{width}, 0; + glEnd; + + glDisable GL_TEXTURE_2D; +} + package Crossfire::Client::Widget::TextView; use strict; + our @ISA = qw/Crossfire::Client::Widget/; use SDL::OpenGL; @@ -114,10 +146,10 @@ glBindTexture GL_TEXTURE_2D, $tex->{name}; glBegin GL_QUADS; - glTexCoord 0, 0; glVertex $x, $y; - glTexCoord 0, 1; glVertex $x, $y + 1; - glTexCoord 1, 1; glVertex $x + 1, $y + 1; - glTexCoord 1, 0; glVertex $x + 1, $y; + glTexCoord 0, 0; glVertex $x * 32 , $y * 32; + glTexCoord 0, 1; glVertex $x * 32 , $y * 32 + 32; + glTexCoord 1, 1; glVertex $x * 32 + 32, $y * 32 + 32; + glTexCoord 1, 0; glVertex $x * 32 + 32, $y * 32; glEnd; } }