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.377 by root, Mon Jul 16 20:20:30 2007 UTC vs.
Revision 1.379 by root, Tue Jul 17 12:04:18 2007 UTC

986} 986}
987 987
988sub set_offset { 988sub set_offset {
989 my ($self, $x, $y) = @_; 989 my ($self, $x, $y) = @_;
990 990
991 $self->{view_x} = max 0, min $self->child->{w} - $self->{w}, int $x; 991 my $x = max 0, min $self->child->{w} - $self->{w}, int $x;
992 $self->{view_y} = max 0, min $self->child->{h} - $self->{h}, int $y; 992 my $y = max 0, min $self->child->{h} - $self->{h}, int $y;
993 993
994 $self->emit (changed => $self->{view_x}, $self->{view_y}); 994 if ($x != $self->{view_x} or $y != $self->{view_y}) {
995 $self->{view_x} = $x;
996 $self->{view_y} = $y;
997
998 $self->emit (changed => $x, $y);
995 $self->update; 999 $self->update;
1000 }
996} 1001}
997 1002
998# hmm, this does not work for topleft of $self... but we should not ask for that 1003# hmm, this does not work for topleft of $self... but we should not ask for that
999sub coord2local { 1004sub coord2local {
1000 my ($self, $x, $y) = @_; 1005 my ($self, $x, $y) = @_;
3488 ); 3493 );
3489 3494
3490 if ($self->{anim} && $self->{animspeed}) { 3495 if ($self->{anim} && $self->{animspeed}) {
3491 CFPlus::weaken (my $widget = $self); 3496 CFPlus::weaken (my $widget = $self);
3492 3497
3498 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3499 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed};
3493 $self->{timer} = Event->timer ( 3500 $self->{timer} = Event->timer (
3494 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3495 hard => 1, 3501 parked => 1,
3496 interval => $self->{animspeed},
3497 cb => sub { 3502 cb => sub {
3498 return unless $::CONN; 3503 return unless $::CONN;
3499 3504
3505 if (!$widget) {#d#
3506 warn "animation widget timer active but widgetd estroyed\n";#d#
3507 warn $_[0]->w->active;#d#
3508 }#d#
3509
3500 ++$widget->{frame}; 3510 ++$widget->{frame};
3501 $self->update_face; 3511 $widget->update_face;
3502 $self->update; 3512 $widget->update;
3513
3514 $widget->update_timer;
3503 }, 3515 },
3504 ); 3516 );
3505 3517
3506 $self->update_face; 3518 $self->update_face;
3519 $self->update_timer;
3507 } 3520 }
3508 3521
3509 $self 3522 $self
3523}
3524
3525sub update_timer {
3526 my ($self) = @_;
3527
3528 return unless $self->{timer};
3529
3530 if ($self->{visible}) {
3531 $self->{timer}->at (
3532 $self->{anim_start}
3533 + $self->{animspeed}
3534 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3535 );
3536 $self->{timer}->start;
3537 } else {
3538 $self->{timer}->stop;
3539 }
3510} 3540}
3511 3541
3512sub update_face { 3542sub update_face {
3513 my ($self) = @_; 3543 my ($self) = @_;
3514 3544
3546 return unless $self->{visible}; 3576 return unless $self->{visible};
3547 3577
3548 $self->SUPER::update; 3578 $self->SUPER::update;
3549} 3579}
3550 3580
3581sub invoke_visibility_change {
3582 my ($self) = @_;
3583
3584 $self->update_timer;
3585
3586 0
3587}
3588
3551sub _draw { 3589sub _draw {
3552 my ($self) = @_; 3590 my ($self) = @_;
3553 3591
3554 return unless $::CONN; 3592 return unless $::CONN;
3555 3593
3570} 3608}
3571 3609
3572sub destroy { 3610sub destroy {
3573 my ($self) = @_; 3611 my ($self) = @_;
3574 3612
3575 $self->{timer}->cancel 3613 (delete $self->{timer})->cancel
3576 if $self->{timer}; 3614 if $self->{timer};
3577 3615
3578 $self->SUPER::destroy; 3616 $self->SUPER::destroy;
3579} 3617}
3580 3618

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines