… | |
… | |
3596 | } |
3596 | } |
3597 | |
3597 | |
3598 | sub update_face { |
3598 | sub update_face { |
3599 | my ($self) = @_; |
3599 | my ($self) = @_; |
3600 | |
3600 | |
3601 | return unless $::CONN; |
3601 | if ($::CONN) { |
3602 | |
|
|
3603 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3602 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3604 | if ($anim && @$anim) { |
3603 | if ($anim && @$anim) { |
3605 | delete $self->{wait_face}; |
|
|
3606 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
3604 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
|
|
3605 | delete $self->{face_change_cb}; |
|
|
3606 | |
3607 | if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ]) { |
3607 | if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{face}[$self->{face}]{id} ]) { |
3608 | unless ($tex->{name} || $tex->{loading}) { |
3608 | unless ($tex->{name} || $tex->{loading}) { |
3609 | $tex->upload (sub { $self->reconfigure }); |
3609 | $tex->upload (sub { $self->reconfigure }); |
|
|
3610 | } |
3610 | } |
3611 | } |
3611 | } |
3612 | } |
3612 | } |
3613 | } |
3613 | } |
3614 | } |
3614 | } |
3615 | } |
3615 | |
3616 | |
3616 | sub size_request { |
3617 | sub size_request { |
3617 | my ($self) = @_; |
3618 | my ($self) = @_; |
3618 | |
3619 | |
3619 | if ($::CONN) { |
3620 | if ($::CONN) { |
3620 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3621 | if (my $faceid = $::CONN->{face}[$self->{face}]{id}) { |
3621 | if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) { |
3622 | if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) { |
3622 | if ($tex->{name}) { |
3623 | if ($tex->{name}) { |
3623 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3624 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3624 | } elsif (!$tex->{loading}) { |
3625 | } elsif (!$tex->{loading}) { |
3625 | $tex->upload (sub { $self->reconfigure }); |
3626 | $tex->upload (sub { $self->reconfigure }); |
3626 | } |
3627 | } |
3627 | } else { |
|
|
3628 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
|
|
3629 | $self->reconfigure; |
|
|
3630 | }); |
|
|
3631 | } |
3628 | } |
|
|
3629 | |
|
|
3630 | $self->{face_change_cb} ||= $::CONN->on_face_change ($self->{face}, sub { $self->reconfigure }); |
3632 | } |
3631 | } |
3633 | } |
3632 | } |
3634 | |
3633 | |
3635 | ($self->{size_w} || 8, $self->{size_h} || 8) |
3634 | ($self->{size_w} || 8, $self->{size_h} || 8) |
3636 | } |
3635 | } |