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.26 by elmex, Sat Apr 8 22:23:57 2006 UTC vs.
Revision 1.29 by root, Sun Apr 9 00:09:50 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;
327our @ISA = Crossfire::Client::Widget::; 328our @ISA = Crossfire::Client::Widget::;
328 329
329use SDL::OpenGL; 330use SDL::OpenGL;
330 331
331sub new { 332sub new {
332 my ($class, $x, $y, $z, $ttf, $text) = @_; 333 my ($class, $x, $y, $z, $height, $text) = @_;
333 334
334 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, ttf => $ttf); 335 my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height);
335 336
336 $self->set_text ($text); 337 $self->set_text ($text);
337 338
338 $self 339 $self
339} 340}
340 341
341sub set_text { 342sub set_text {
342 my ($self, $text) = @_; 343 my ($self, $text) = @_;
344
345 $self->{text} = $text;
346
343 $self->{texture} = new_from_ttf Crossfire::Client::Texture $self->{ttf}, $self->{text} = $text; 347 $self->{texture} = new_from_text Crossfire::Client::Texture $text, $self->{height};
344} 348}
345 349
346sub get_text { 350sub get_text {
347 my ($self, $text) = @_; 351 my ($self, $text) = @_;
352
348 $self->{text} 353 $self->{text}
349} 354}
350 355
351sub size_request { 356sub size_request {
352 my ($self) = @_; 357 my ($self) = @_;
362 367
363 my $tex = $self->{texture}; 368 my $tex = $self->{texture};
364 369
365 glEnable GL_BLEND; 370 glEnable GL_BLEND;
366 glEnable GL_TEXTURE_2D; 371 glEnable GL_TEXTURE_2D;
367 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;#DECAL; 372 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
368 glBindTexture GL_TEXTURE_2D, $tex->{name}; 373 glBindTexture GL_TEXTURE_2D, $tex->{name};
369 374
370 glColor 1, 0, 1; 375 glColor 1, 1, 1, 0.8;
371 376
372 glBegin GL_QUADS; 377 glBegin GL_QUADS;
373 glTexCoord 0, 0; glVertex 0 , 0; 378 glTexCoord 0, 0; glVertex 0 , 0;
374 glTexCoord 0, 1; glVertex 0 , $tex->{height}; 379 glTexCoord 0, 1; glVertex 0 , $tex->{height};
375 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height}; 380 glTexCoord 1, 1; glVertex $tex->{width}, $tex->{height};
430 435
431 my $sw = 1 + int $::WIDTH / 32; 436 my $sw = 1 + int $::WIDTH / 32;
432 my $sh = 1 + int $::HEIGHT / 32; 437 my $sh = 1 + int $::HEIGHT / 32;
433 438
434 if ($::CONN->{mapw} > $sw) { 439 if ($::CONN->{mapw} > $sw) {
435 $xofs = ($sw - $::CONN->{mapw}) * 0.5; 440 $xofs = $mx + ($::CONN->{mapw} - $sw) * 0.5;
436 } else { 441 } else {
437 $xofs = $self->{xofs} = min $mx, max $mx + $::CONN->{mapw} - $sw + 1, $self->{xofs}; 442 $xofs = $self->{xofs} = min $mx, max $mx + $::CONN->{mapw} - $sw + 1, $self->{xofs};
438 } 443 }
439 444
440 if ($::CONN->{maph} > $sh) { 445 if ($::CONN->{maph} > $sh) {
441 $yofs = ($sh - $::CONN->{maph}) * 0.5; 446 $yofs = $my + ($::CONN->{maph} - $sh) * 0.5;
442 } else { 447 } else {
443 $yofs = $self->{yofs} = min $my, max $my + $::CONN->{maph} - $sh + 1, $self->{yofs}; 448 $yofs = $self->{yofs} = min $my, max $my + $::CONN->{maph} - $sh + 1, $self->{yofs};
444 } 449 }
445 450
446 glEnable GL_TEXTURE_2D; 451 glEnable GL_TEXTURE_2D;
447 glEnable GL_BLEND; 452 glEnable GL_BLEND;
448 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; 453 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
449
450 warn "<$mx,$my> <$xofs,$yofs>\n";#d#
451 454
452 for my $x (0 .. $sw - 1) { 455 for my $x (0 .. $sw - 1) {
453 for my $y (0 .. $sh - 1) { 456 for my $y (0 .. $sh - 1) {
454 457
455 my $cell = $map->[$x + $xofs][$y + $yofs] 458 my $cell = $map->[$x + $xofs][$y + $yofs]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines