… | |
… | |
654 | $class->SUPER::new ( |
654 | $class->SUPER::new ( |
655 | #bg => [0, 0, 0, 0.2], |
655 | #bg => [0, 0, 0, 0.2], |
656 | #active_bg => [1, 1, 1, 0.5], |
656 | #active_bg => [1, 1, 1, 0.5], |
657 | @_ |
657 | @_ |
658 | ) |
658 | ) |
|
|
659 | } |
|
|
660 | |
|
|
661 | sub set_bg { |
|
|
662 | my ($self, $bg) = @_; |
|
|
663 | |
|
|
664 | $self->{bg} = $bg; |
|
|
665 | $self->update; |
659 | } |
666 | } |
660 | |
667 | |
661 | sub _draw { |
668 | sub _draw { |
662 | my ($self) = @_; |
669 | my ($self) = @_; |
663 | |
670 | |
… | |
… | |
2941 | my $self = $class->SUPER::new ( |
2948 | my $self = $class->SUPER::new ( |
2942 | %arg, |
2949 | %arg, |
2943 | tooltip => sub { |
2950 | tooltip => sub { |
2944 | my ($self) = @_; |
2951 | my ($self) = @_; |
2945 | |
2952 | |
2946 | sprintf "%slevel %d\n%s points\n%s next level\n%s to go / %d%%", |
2953 | sprintf "%slevel %d\n%s points\n%s next level\n%s to go, %d%% done", |
2947 | $tt, |
2954 | $tt, |
2948 | $self->{lvl}, |
2955 | $self->{lvl}, |
2949 | ::formsep ($self->{exp}), |
2956 | ::formsep ($self->{exp}), |
2950 | ::formsep ($self->{nxt}), |
2957 | ::formsep ($self->{nxt}), |
2951 | ::formsep ($self->{nxt} - $self->{exp}), |
2958 | ::formsep ($self->{nxt} - $self->{exp}), |
… | |
… | |
3726 | aspect => 1, |
3733 | aspect => 1, |
3727 | can_events => 0, |
3734 | can_events => 0, |
3728 | @_, |
3735 | @_, |
3729 | ); |
3736 | ); |
3730 | |
3737 | |
3731 | if ($self->{anim} && $self->{animspeed}) { |
|
|
3732 | DC::weaken (my $widget = $self); |
|
|
3733 | |
|
|
3734 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
|
|
3735 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
|
|
3736 | return unless $::CONN; |
|
|
3737 | |
|
|
3738 | my $w = $widget |
|
|
3739 | or return; |
|
|
3740 | |
|
|
3741 | ++$w->{frame}; |
|
|
3742 | $w->update_face; |
|
|
3743 | |
|
|
3744 | # somehow, $widget can go away |
|
|
3745 | $w->update; |
|
|
3746 | $w->update_timer; |
|
|
3747 | }; |
|
|
3748 | |
|
|
3749 | $self->update_face; |
|
|
3750 | $self->update_timer; |
3738 | $self->update_anim; |
3751 | } |
|
|
3752 | |
3739 | |
3753 | $self |
3740 | $self |
3754 | } |
3741 | } |
3755 | |
3742 | |
3756 | sub update_timer { |
3743 | sub update_timer { |
… | |
… | |
3779 | $tex->upload (sub { $self->reconfigure }); |
3766 | $tex->upload (sub { $self->reconfigure }); |
3780 | } |
3767 | } |
3781 | } |
3768 | } |
3782 | } |
3769 | } |
3783 | } |
3770 | } |
|
|
3771 | } |
|
|
3772 | } |
|
|
3773 | |
|
|
3774 | sub update_anim { |
|
|
3775 | my ($self) = @_; |
|
|
3776 | |
|
|
3777 | if ($self->{anim} && $self->{animspeed}) { |
|
|
3778 | DC::weaken (my $widget = $self); |
|
|
3779 | |
|
|
3780 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
|
|
3781 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
|
|
3782 | return unless $::CONN; |
|
|
3783 | |
|
|
3784 | my $w = $widget |
|
|
3785 | or return; |
|
|
3786 | |
|
|
3787 | ++$w->{frame}; |
|
|
3788 | $w->update_face; |
|
|
3789 | |
|
|
3790 | # somehow, $widget can go away |
|
|
3791 | $w->update; |
|
|
3792 | $w->update_timer; |
|
|
3793 | }; |
|
|
3794 | |
|
|
3795 | $self->update_face; |
|
|
3796 | $self->update_timer; |
|
|
3797 | } else { |
|
|
3798 | delete $self->{timer}; |
3784 | } |
3799 | } |
3785 | } |
3800 | } |
3786 | |
3801 | |
3787 | sub size_request { |
3802 | sub size_request { |
3788 | my ($self) = @_; |
3803 | my ($self) = @_; |
… | |
… | |
3808 | my ($self) = @_; |
3823 | my ($self) = @_; |
3809 | |
3824 | |
3810 | return unless $self->{visible}; |
3825 | return unless $self->{visible}; |
3811 | |
3826 | |
3812 | $self->SUPER::update; |
3827 | $self->SUPER::update; |
|
|
3828 | } |
|
|
3829 | |
|
|
3830 | sub set_face { |
|
|
3831 | my ($self, $face) = @_; |
|
|
3832 | |
|
|
3833 | $self->{face} = $face; |
|
|
3834 | $self->reconfigure; |
|
|
3835 | } |
|
|
3836 | |
|
|
3837 | sub set_anim { |
|
|
3838 | my ($self, $anim) = @_; |
|
|
3839 | |
|
|
3840 | $self->{anim} = $anim; |
|
|
3841 | $self->update_anim; |
|
|
3842 | } |
|
|
3843 | |
|
|
3844 | sub set_animspeed { |
|
|
3845 | my ($self, $animspeed) = @_; |
|
|
3846 | |
|
|
3847 | $self->{animspeed} = $animspeed; |
|
|
3848 | $self->update_anim; |
3813 | } |
3849 | } |
3814 | |
3850 | |
3815 | sub invoke_visibility_change { |
3851 | sub invoke_visibility_change { |
3816 | my ($self) = @_; |
3852 | my ($self) = @_; |
3817 | |
3853 | |