--- deliantra/Deliantra-Client/DC/UI.pm 2007/07/15 22:13:43 1.372 +++ deliantra/Deliantra-Client/DC/UI.pm 2007/07/15 22:39:30 1.373 @@ -3330,6 +3330,8 @@ my $class = shift; my $self = $class->SUPER::new ( + size_w => 32, + size_h => 8, aspect => 1, can_events => 0, @_, @@ -3343,18 +3345,49 @@ hard => 1, interval => $self->{animspeed}, cb => sub { - delete $self->{wait_face}; + return unless $::CONN; + ++$widget->{frame}; - $widget->update; + $self->update_face; + $self->update; }, ); + + $self->update_face; } $self } +sub update_face { + my ($self) = @_; + + return unless $::CONN; + + if (my $anim = $::CONN->{anim}[$self->{anim}]) { + if ($anim && @$anim) { + delete $self->{wait_face}; + $self->{face} = $anim->[ $self->{frame} % @$anim ]; + } + } +} + sub size_request { - (32, 8) + my ($self) = @_; + + if ($::CONN) { + if (my $faceid = $::CONN->{faceid}[$self->{face}]) { + if (my $tex = $::CONN->{texture}[$faceid]) { + return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); + } else { + $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { + $self->realloc; + }); + } + } + } + + ($self->{size_w} || 8, $self->{size_h} || 8) } sub update { @@ -3372,16 +3405,7 @@ $self->SUPER::_draw; - my $face; - - if ($self->{frame}) { - my $anim = $::CONN->{anim}[$self->{anim}]; - - $face = $anim->[ $self->{frame} % @$anim ] - if $anim && @$anim; - } - - my $faceid = $::CONN->{faceid}[$face || $self->{face}] + my $faceid = $::CONN->{faceid}[$self->{face}] or return; my $tex = $::CONN->{texture}[$faceid]; @@ -3392,10 +3416,6 @@ glColor 0, 0, 0, 1; $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); glDisable GL_TEXTURE_2D; - } else { - $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { - $self->update; - }); } }