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.372 by root, Sun Jul 15 22:13:43 2007 UTC vs.
Revision 1.373 by root, Sun Jul 15 22:39:30 2007 UTC

3328 3328
3329sub new { 3329sub new {
3330 my $class = shift; 3330 my $class = shift;
3331 3331
3332 my $self = $class->SUPER::new ( 3332 my $self = $class->SUPER::new (
3333 size_w => 32,
3334 size_h => 8,
3333 aspect => 1, 3335 aspect => 1,
3334 can_events => 0, 3336 can_events => 0,
3335 @_, 3337 @_,
3336 ); 3338 );
3337 3339
3341 $self->{timer} = Event->timer ( 3343 $self->{timer} = Event->timer (
3342 at => $self->{animspeed} * int $::NOW / $self->{animspeed}, 3344 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3343 hard => 1, 3345 hard => 1,
3344 interval => $self->{animspeed}, 3346 interval => $self->{animspeed},
3345 cb => sub { 3347 cb => sub {
3346 delete $self->{wait_face}; 3348 return unless $::CONN;
3349
3347 ++$widget->{frame}; 3350 ++$widget->{frame};
3351 $self->update_face;
3348 $widget->update; 3352 $self->update;
3349 }, 3353 },
3350 ); 3354 );
3355
3356 $self->update_face;
3351 } 3357 }
3352 3358
3353 $self 3359 $self
3354} 3360}
3355 3361
3362sub update_face {
3363 my ($self) = @_;
3364
3365 return unless $::CONN;
3366
3367 if (my $anim = $::CONN->{anim}[$self->{anim}]) {
3368 if ($anim && @$anim) {
3369 delete $self->{wait_face};
3370 $self->{face} = $anim->[ $self->{frame} % @$anim ];
3371 }
3372 }
3373}
3374
3356sub size_request { 3375sub size_request {
3357 (32, 8) 3376 my ($self) = @_;
3377
3378 if ($::CONN) {
3379 if (my $faceid = $::CONN->{faceid}[$self->{face}]) {
3380 if (my $tex = $::CONN->{texture}[$faceid]) {
3381 return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h});
3382 } else {
3383 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3384 $self->realloc;
3385 });
3386 }
3387 }
3388 }
3389
3390 ($self->{size_w} || 8, $self->{size_h} || 8)
3358} 3391}
3359 3392
3360sub update { 3393sub update {
3361 my ($self) = @_; 3394 my ($self) = @_;
3362 3395
3370 3403
3371 return unless $::CONN; 3404 return unless $::CONN;
3372 3405
3373 $self->SUPER::_draw; 3406 $self->SUPER::_draw;
3374 3407
3375 my $face;
3376
3377 if ($self->{frame}) {
3378 my $anim = $::CONN->{anim}[$self->{anim}];
3379
3380 $face = $anim->[ $self->{frame} % @$anim ]
3381 if $anim && @$anim;
3382 }
3383
3384 my $faceid = $::CONN->{faceid}[$face || $self->{face}] 3408 my $faceid = $::CONN->{faceid}[$self->{face}]
3385 or return; 3409 or return;
3386 3410
3387 my $tex = $::CONN->{texture}[$faceid]; 3411 my $tex = $::CONN->{texture}[$faceid];
3388 3412
3389 if ($tex) { 3413 if ($tex) {
3390 glEnable GL_TEXTURE_2D; 3414 glEnable GL_TEXTURE_2D;
3391 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 3415 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
3392 glColor 0, 0, 0, 1; 3416 glColor 0, 0, 0, 1;
3393 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); 3417 $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h});
3394 glDisable GL_TEXTURE_2D; 3418 glDisable GL_TEXTURE_2D;
3395 } else {
3396 $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub {
3397 $self->update;
3398 });
3399 } 3419 }
3400} 3420}
3401 3421
3402sub destroy { 3422sub destroy {
3403 my ($self) = @_; 3423 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines