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.376 by root, Mon Jul 16 20:20:23 2007 UTC vs.
Revision 1.380 by root, Tue Jul 17 17:39:07 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) = @_;
1080 expand => 1, 1085 expand => 1,
1081 scroll_x => $self->{scroll_x}, 1086 scroll_x => $self->{scroll_x},
1082 scroll_y => $self->{scroll_y}, 1087 scroll_y => $self->{scroll_y},
1083 on_changed => sub { 1088 on_changed => sub {
1084 my ($vp, $x, $y) = @_; 1089 my ($vp, $x, $y) = @_;
1090
1085 $vp->{parent}{hslider}->set_value ($x); 1091 $vp->{parent}{hslider}->set_value ($x);
1086 $vp->{parent}{vslider}->set_value ($y); 1092 $vp->{parent}{vslider}->set_value ($y);
1087 1093
1088 0 1094 0
1089 }, 1095 },
3487 ); 3493 );
3488 3494
3489 if ($self->{anim} && $self->{animspeed}) { 3495 if ($self->{anim} && $self->{animspeed}) {
3490 CFPlus::weaken (my $widget = $self); 3496 CFPlus::weaken (my $widget = $self);
3491 3497
3498 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed};
3499 $widget->{anim_start} = $self->{animspeed} * Event::time / $self->{animspeed};
3492 $self->{timer} = Event->timer ( 3500 $self->{timer} = Event->timer (
3493 at => $self->{animspeed} * int $::NOW / $self->{animspeed},
3494 hard => 1, 3501 parked => 1,
3495 interval => $self->{animspeed},
3496 cb => sub { 3502 cb => sub {
3497 return unless $::CONN; 3503 return unless $::CONN && $widget;
3498 3504
3499 ++$widget->{frame}; 3505 ++$widget->{frame};
3500 $self->update_face; 3506 $widget->update_face;
3501 $self->update; 3507 $widget->update;
3508
3509 $widget->update_timer;
3502 }, 3510 },
3503 ); 3511 );
3504 3512
3505 $self->update_face; 3513 $self->update_face;
3514 $self->update_timer;
3506 } 3515 }
3507 3516
3508 $self 3517 $self
3518}
3519
3520sub update_timer {
3521 my ($self) = @_;
3522
3523 return unless $self->{timer};
3524
3525 if ($self->{visible}) {
3526 $self->{timer}->at (
3527 $self->{anim_start}
3528 + $self->{animspeed}
3529 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3530 );
3531 $self->{timer}->start;
3532 } else {
3533 $self->{timer}->stop;
3534 }
3509} 3535}
3510 3536
3511sub update_face { 3537sub update_face {
3512 my ($self) = @_; 3538 my ($self) = @_;
3513 3539
3545 return unless $self->{visible}; 3571 return unless $self->{visible};
3546 3572
3547 $self->SUPER::update; 3573 $self->SUPER::update;
3548} 3574}
3549 3575
3576sub invoke_visibility_change {
3577 my ($self) = @_;
3578
3579 $self->update_timer;
3580
3581 0
3582}
3583
3550sub _draw { 3584sub _draw {
3551 my ($self) = @_; 3585 my ($self) = @_;
3552 3586
3553 return unless $::CONN; 3587 return unless $::CONN;
3554 3588
3569} 3603}
3570 3604
3571sub destroy { 3605sub destroy {
3572 my ($self) = @_; 3606 my ($self) = @_;
3573 3607
3574 $self->{timer}->cancel 3608 (delete $self->{timer})->cancel
3575 if $self->{timer}; 3609 if $self->{timer};
3576 3610
3577 $self->SUPER::destroy; 3611 $self->SUPER::destroy;
3578} 3612}
3579 3613

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines