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.30 by root, Sun Apr 9 00:18:45 2006 UTC vs.
Revision 1.31 by elmex, Sun Apr 9 00:43:11 2006 UTC

158 glEnable GL_BLEND; 158 glEnable GL_BLEND;
159 glEnable GL_TEXTURE_2D; 159 glEnable GL_TEXTURE_2D;
160 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 160 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
161 glBindTexture GL_TEXTURE_2D, $tex->{name}; 161 glBindTexture GL_TEXTURE_2D, $tex->{name};
162 162
163 glColor 1, 1, 1; 163 glColor 1, 0, 1;
164 164
165 glBegin GL_QUADS; 165 glBegin GL_QUADS;
166 glTexCoord 0, 0; glVertex 0, 0; 166 glTexCoord 0, 0; glVertex 0, 0;
167 glTexCoord 0, 1; glVertex 0, $h; 167 glTexCoord 0, 1; glVertex 0, $h;
168 glTexCoord 1, 1; glVertex $w, $h; 168 glTexCoord 1, 1; glVertex $w, $h;
205 glEnd; 205 glEnd;
206 206
207 $chld->draw; 207 $chld->draw;
208} 208}
209 209
210package Crossfire::Client::Widget::FancyFrame;
211
212our @ISA = Crossfire::Client::Widget::Frame::;
213
214use SDL::OpenGL;
215
216#TODO: implement themed frame
217
210package Crossfire::Client::Widget::Table; 218package Crossfire::Client::Widget::Table;
211 219
212our @ISA = Crossfire::Client::Widget::Container::; 220our @ISA = Crossfire::Client::Widget::Container::;
213 221
214use SDL::OpenGL; 222use SDL::OpenGL;
385 393
386 glDisable GL_BLEND; 394 glDisable GL_BLEND;
387 glDisable GL_TEXTURE_2D; 395 glDisable GL_TEXTURE_2D;
388} 396}
389 397
398package Crossfire::Client::Widget::TextEntry;
399
400our @ISA = Crossfire::Client::Widget::Label::;
401
402use SDL;
403use SDL::OpenGL;
404
405sub key_down {
406 my ($self, $ev) = @_;
407
408 my $mod = $ev->key_mod;
409 my $sym = $ev->key_sym;
410
411 $ev->set_unicode (1);
412 my $uni = $ev->key_unicode;
413
414 my $text = $self->get_text;
415
416 if ($sym == SDLK_BACKSPACE) {
417 substr $text, -1, 1, '';
418
419 } elsif ($uni) {
420 $text .= chr $uni;
421 }
422 $self->set_text ($text);
423}
424
425
426# XXX: TextView isn't neccessary with pango multiline text rendering
390package Crossfire::Client::Widget::TextView; 427package Crossfire::Client::Widget::TextView;
391 428
392use strict; 429use strict;
393 430
394our @ISA = qw/Crossfire::Client::Widget/; 431our @ISA = qw/Crossfire::Client::Widget/;
395 432
396use SDL::OpenGL; 433use SDL::OpenGL;
397use SDL::OpenGL::Constants; 434use SDL::OpenGL::Constants;
435
436sub new {
437 my ($class, $text, $h) = @_;
438 my $self = $class->SUPER::new ();
439
440 $self->{txt_height} = $h;
441 @{$self->{lines}} = split /\r?\n/, $text;
442
443 for (split /\r?\n/, $text) {
444 $self->add_line ($_);
445 }
446 $self
447}
448
449#sub render_lines {
450# my ($self) = @_;
451#
452# $self->{txt_lines} = [];
453#
454# for (@{$self->{lines}}) {
455# push @{$self->{txt_lines}},
456# new_from_ttf Crossfire::Client::Texture $self->{ttf}, $_;
457# }
458#}
398 459
399sub add_line { 460sub add_line {
400 my ($self, $line) = @_; 461 my ($self, $line) = @_;
401 push @{$self->{lines}}, $line; 462 push @{$self->{lines}}, $line;
402}
403 463
464 push @{$self->{txt_lines}},
465 new_from_text Crossfire::Client::Texture $line, $self->{txt_height};
466}
467
468sub size_request {
469 my ($self) = @_;
470
471 my $w = 0;
472 my $h = 0;
473
474 for (@{$self->{txt_lines}}) {
475 if ($w < $_->{width}) { $w = $_->{width} }
476 $h += $_->{height};
477 }
478
479 return ($w, $h);
480}
481
404sub _draw { 482sub draw_line {
405 my ($self) = @_; 483 my ($self, $tex, $y) = @_;
406 484
485 glBindTexture GL_TEXTURE_2D, $tex->{name};
486
487 glColor 1, 0, 1;
488
489 glBegin GL_QUADS;
490 glTexCoord 0, 0; glVertex 0 , $y;
491 glTexCoord 0, 1; glVertex 0 , $y + $tex->{height};
492 glTexCoord 1, 1; glVertex $tex->{width}, $y + $tex->{height};
493 glTexCoord 1, 0; glVertex $tex->{width}, $y;
494 glEnd;
495}
496
497sub _draw {
498 my ($self) = @_;
499
500 glEnable GL_BLEND;
501 glEnable GL_TEXTURE_2D;
502 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;#DECAL;
503
504 my $l = 0;
505 for (@{$self->{txt_lines}}) {
506 $self->draw_line ($_, $l);
507 $l += $_->{height};
508 }
509
510 glDisable GL_BLEND;
511 glDisable GL_TEXTURE_2D;
407} 512}
408 513
409package Crossfire::Client::Widget::MapWidget; 514package Crossfire::Client::Widget::MapWidget;
410 515
411use strict; 516use strict;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines