… | |
… | |
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 | |
|
|
210 | package Crossfire::Client::Widget::FancyFrame; |
|
|
211 | |
|
|
212 | our @ISA = Crossfire::Client::Widget::Frame::; |
|
|
213 | |
|
|
214 | use SDL::OpenGL; |
|
|
215 | |
|
|
216 | #TODO: implement themed frame |
|
|
217 | |
210 | package Crossfire::Client::Widget::Table; |
218 | package Crossfire::Client::Widget::Table; |
211 | |
219 | |
212 | our @ISA = Crossfire::Client::Widget::Container::; |
220 | our @ISA = Crossfire::Client::Widget::Container::; |
213 | |
221 | |
214 | use SDL::OpenGL; |
222 | use 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 | |
|
|
398 | package Crossfire::Client::Widget::TextEntry; |
|
|
399 | |
|
|
400 | our @ISA = Crossfire::Client::Widget::Label::; |
|
|
401 | |
|
|
402 | use SDL; |
|
|
403 | use SDL::OpenGL; |
|
|
404 | |
|
|
405 | sub 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 |
390 | package Crossfire::Client::Widget::TextView; |
427 | package Crossfire::Client::Widget::TextView; |
391 | |
428 | |
392 | use strict; |
429 | use strict; |
393 | |
430 | |
394 | our @ISA = qw/Crossfire::Client::Widget/; |
431 | our @ISA = qw/Crossfire::Client::Widget/; |
395 | |
432 | |
396 | use SDL::OpenGL; |
433 | use SDL::OpenGL; |
397 | use SDL::OpenGL::Constants; |
434 | use SDL::OpenGL::Constants; |
|
|
435 | |
|
|
436 | sub 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 | |
399 | sub add_line { |
460 | sub 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 | |
|
|
468 | sub 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 | |
404 | sub _draw { |
482 | sub 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 | |
|
|
497 | sub _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 | |
409 | package Crossfire::Client::Widget::MapWidget; |
514 | package Crossfire::Client::Widget::MapWidget; |
410 | |
515 | |
411 | use strict; |
516 | use strict; |