--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/07 20:34:44 1.10 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/07 20:55:32 1.12 @@ -1,6 +1,8 @@ package Crossfire::Client::Widget; use strict; +use SDL::OpenGL; +use SDL::OpenGL::Constants; our $FOCUS; # the widget with current focus our %ACTIVE_WIDGETS; @@ -50,7 +52,19 @@ my ($widget, $sdlev) = @_; } +sub x { $_[0]->{x} = $_[1] if $_[1]; $_[0]->{x} } +sub y { $_[0]->{y} = $_[1] if $_[1]; $_[0]->{y} } + sub draw { + my ($self) = @_; + + glPushMatrix; + glTranslate $self->{x}, $self->{y}, 0; + $self->_draw; + glPopMatrix; +} + +sub _draw { my ($widget) = @_; } @@ -60,26 +74,34 @@ package Crossfire::Client::Widget::Label; +our @ISA = Crossfire::Client::Widget::; + use SDL::OpenGL; sub new { - my ($class, $ttf, $text) = @_; + my ($class, $x, $y, $z, $ttf, $text) = @_; - my $self = $class->SUPER::new; + my $self = $class->SUPER::new (x => $x, y => $y, z => $z); $self->{texture} = new_from_ttf Crossfire::Client::Texture $ttf, $text; $self } -sub draw { +sub _draw { my ($self) = @_; my $tex = $self->{texture}; + $self->{x}--; + + glEnable GL_BLEND; glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; glBindTexture GL_TEXTURE_2D, $tex->{name}; + glColor 1, 1, 1; + glBegin GL_QUADS; glTexCoord 0, 0; glVertex 0 , 0; glTexCoord 0, 1; glVertex 0 , $tex->{height}; @@ -87,6 +109,7 @@ glTexCoord 1, 0; glVertex $tex->{width}, 0; glEnd; + glDisable GL_BLEND; glDisable GL_TEXTURE_2D; } @@ -104,7 +127,7 @@ push @{$self->{lines}}, $line; } -sub draw { +sub _draw { my ($self) = @_; } @@ -125,9 +148,10 @@ sub key_up { } -sub draw { +sub _draw { glEnable GL_TEXTURE_2D; glEnable GL_BLEND; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; my $map = $::CONN->{map};