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.27 by root, Sat Apr 8 22:25:37 2006 UTC vs.
Revision 1.30 by root, Sun Apr 9 00:18:45 2006 UTC

148} 148}
149 149
150sub _draw { 150sub _draw {
151 my ($self) = @_; 151 my ($self) = @_;
152 152
153 my ($w, $h) = $self->size_request;#TODO# use widht/height of texture 153 my ($w, $h) = $self->size_request;#TODO# use width/height of texture
154
154 my $tex = $self->{texture} 155 my $tex = $self->{texture}
155 or return; 156 or return;
156 157
157 glEnable GL_BLEND; 158 glEnable GL_BLEND;
158 glEnable GL_TEXTURE_2D; 159 glEnable GL_TEXTURE_2D;
180 181
181sub size_request { 182sub size_request {
182 my ($self) = @_; 183 my ($self) = @_;
183 my $chld = $self->get 184 my $chld = $self->get
184 or return (0, 0); 185 or return (0, 0);
186
187 $chld->move (2, 2);
188
185 map { $_ + 4 } $chld->size_request; 189 map { $_ + 4 } $chld->size_request;
186} 190}
187 191
188sub _draw { 192sub _draw {
189 my ($self) = @_; 193 my ($self) = @_;
190 194
191 my $chld = $self->get; 195 my $chld = $self->get;
192 196
193 $chld->move (2, 2, 0); #TODO:move to size_request
194
195 my ($w, $h) = $chld->size_request; 197 my ($w, $h) = $chld->size_request;
196 198
197 glColor 1, 0, 0;
198 glBegin GL_QUADS; 199 glBegin GL_QUADS;
200 glColor 0, 0, 0;
199 glTexCoord 0, 0; glVertex 0 , 0; 201 glTexCoord 0, 0; glVertex 0 , 0;
200 glTexCoord 0, 1; glVertex 0 , $h + 4; 202 glTexCoord 0, 1; glVertex 0 , $h + 4;
201 glTexCoord 1, 1; glVertex $w + 4 , $h + 4; 203 glTexCoord 1, 1; glVertex $w + 4 , $h + 4;
202 glTexCoord 1, 0; glVertex $w + 4 , 0; 204 glTexCoord 1, 0; glVertex $w + 4 , 0;
203 glEnd; 205 glEnd;
327our @ISA = Crossfire::Client::Widget::; 329our @ISA = Crossfire::Client::Widget::;
328 330
329use SDL::OpenGL; 331use SDL::OpenGL;
330 332
331sub new { 333sub new {
332 my ($class, $x, $y, $z, $ttf, $text) = @_; 334 my ($class, $x, $y, $z, $height, $text) = @_;
333 335
334 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, ttf => $ttf); 336 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height);
335 337
336 $self->set_text ($text); 338 $self->set_text ($text);
337 339
338 $self 340 $self
339} 341}
340 342
341sub set_text { 343sub set_text {
342 my ($self, $text) = @_; 344 my ($self, $text) = @_;
345
346 $self->{text} = $text;
347
343 $self->{texture} = new_from_ttf Crossfire::Client::Texture $self->{ttf}, $self->{text} = $text; 348 $self->{texture} = new_from_text Crossfire::Client::Texture $text, $self->{height};
344} 349}
345 350
346sub get_text { 351sub get_text {
347 my ($self, $text) = @_; 352 my ($self, $text) = @_;
353
348 $self->{text} 354 $self->{text}
349} 355}
350 356
351sub size_request { 357sub size_request {
352 my ($self) = @_; 358 my ($self) = @_;
362 368
363 my $tex = $self->{texture}; 369 my $tex = $self->{texture};
364 370
365 glEnable GL_BLEND; 371 glEnable GL_BLEND;
366 glEnable GL_TEXTURE_2D; 372 glEnable GL_TEXTURE_2D;
373 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
367 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;#DECAL; 374 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
368 glBindTexture GL_TEXTURE_2D, $tex->{name}; 375 glBindTexture GL_TEXTURE_2D, $tex->{name};
369 376
370 glColor 1, 0, 1; 377 glColor 1, 1, 1, 0.8;
371 378
372 glBegin GL_QUADS; 379 glBegin GL_QUADS;
373 glTexCoord 0, 0; glVertex 0 , 0; 380 glTexCoord 0, 0; glVertex 0 , 0;
374 glTexCoord 0, 1; glVertex 0 , $tex->{height}; 381 glTexCoord 0, 1; glVertex 0 , $tex->{height};
375 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height}; 382 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines