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.433 by root, Wed Aug 22 21:27:13 2007 UTC vs.
Revision 1.436 by root, Wed Aug 22 21:40:57 2007 UTC

30 $TOOLTIP->{owner} = $widget; 30 $TOOLTIP->{owner} = $widget;
31 $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner}; 31 $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner};
32 32
33 return if $ENV{CFPLUS_DEBUG} & 8; 33 return if $ENV{CFPLUS_DEBUG} & 8;
34 34
35 my $tip = $widget->{tooltip};
36
37 $tip = $tip->($widget) if CODE:: eq ref $tip;
38
39 $TOOLTIP->set_tooltip_from ($widget); 35 $TOOLTIP->set_tooltip_from ($widget);
40 $TOOLTIP->show; 36 $TOOLTIP->show;
41 } 37 }
42 38
43 return; 39 return;
2870 2866
2871sub new { 2867sub new {
2872 my ($class, %arg) = @_; 2868 my ($class, %arg) = @_;
2873 2869
2874 my $self = $class->SUPER::new ( 2870 my $self = $class->SUPER::new (
2871 tooltip => sub {
2872 my ($self) = @_;
2873
2874 sprintf "level %d\n%s points\n%s next level\n%s to go",
2875 $self->{lvl},
2876 ::formsep ($self->{exp}),
2877 ::formsep ($self->{nxt}),
2878 ::formsep ($self->{nxt} - $self->{exp}),
2879 },
2875 %arg 2880 %arg
2876 ); 2881 );
2877 2882
2878 $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) } 2883 $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) }
2879 if $::CONN; 2884 if $::CONN;
2890 $self->SUPER::DESTROY; 2895 $self->SUPER::DESTROY;
2891} 2896}
2892 2897
2893sub set_value { 2898sub set_value {
2894 my ($self, $lvl, $exp) = @_; 2899 my ($self, $lvl, $exp) = @_;
2900
2901 $self->{lvl} = $lvl;
2902 $self->{exp} = $exp;
2895 2903
2896 my $v = -1; 2904 my $v = -1;
2897 2905
2898 if ($::CONN && (my $table = $::CONN->{exp_table})) { 2906 if ($::CONN && (my $table = $::CONN->{exp_table})) {
2899 my $l0 = $table->[$lvl - 1]; 2907 my $l0 = $table->[$lvl - 1];
2900 my $l1 = $table->[$lvl]; 2908 my $l1 = $table->[$lvl];
2909
2910 $self->{nxt} = $l1;
2901 2911
2902 $v = ($exp - $l0) / ($l1 - $l0); 2912 $v = ($exp - $l0) / ($l1 - $l0);
2903 } 2913 }
2904 2914
2905 $self->SUPER::set_value ($v); 2915 $self->SUPER::set_value ($v);
3543} 3553}
3544 3554
3545sub set_tooltip_from { 3555sub set_tooltip_from {
3546 my ($self, $widget) = @_; 3556 my ($self, $widget) = @_;
3547 3557
3548 $widget->{tooltip} = CFPlus::Pod::section_label tooltip => $1
3549 if $widget->{tooltip} =~ /^#(.*)$/;
3550
3551 my $tooltip = $widget->{tooltip}; 3558 my $tip = $widget->{tooltip};
3559 $tip = $tip->($widget) if "CODE" eq ref $tip;
3560
3561 $tip = CFPlus::Pod::section_label tooltip => $1
3562 if $tip =~ /^#(.*)$/;
3552 3563
3553 if ($ENV{CFPLUS_DEBUG} & 2) { 3564 if ($ENV{CFPLUS_DEBUG} & 2) {
3554 $tooltip .= "\n\n" . (ref $widget) . "\n" 3565 $tip .= "\n\n" . (ref $widget) . "\n"
3555 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 3566 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
3556 . "req $widget->{req_w} $widget->{req_h}\n" 3567 . "req $widget->{req_w} $widget->{req_h}\n"
3557 . "visible $widget->{visible}"; 3568 . "visible $widget->{visible}";
3558 } 3569 }
3559 3570
3560 $tooltip =~ s/^\n+//; 3571 $tip =~ s/^\n+//;
3561 $tooltip =~ s/\n+$//; 3572 $tip =~ s/\n+$//;
3562 3573
3563 $self->add (new CFPlus::UI::Label 3574 $self->add (new CFPlus::UI::Label
3564 markup => $tooltip, 3575 markup => $tip,
3565 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 3576 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
3566 fontsize => 0.8, 3577 fontsize => 0.8,
3567 style => 1, # FLAG_INVERSE 3578 style => 1, # FLAG_INVERSE
3568 ellipsise => 0, 3579 ellipsise => 0,
3569 font => ($widget->{tooltip_font} || $::FONT_PROP), 3580 font => ($widget->{tooltip_font} || $::FONT_PROP),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines