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.434 by root, Wed Aug 22 21:32:09 2007 UTC vs.
Revision 1.438 by root, Sat Sep 1 07:22:21 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;
273 $self->emit ("destroy"); 269 $self->emit ("destroy");
274 %$self = (); 270 %$self = ();
275} 271}
276 272
277sub TO_JSON { 273sub TO_JSON {
278 { __w_ => $_[0]{s_id} } 274 { "\fw" => $_[0]{s_id} }
279} 275}
280 276
281sub show { 277sub show {
282 my ($self) = @_; 278 my ($self) = @_;
283 279
2237 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); 2233 @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text);
2238 } 2234 }
2239 2235
2240 glColor_premultiply @{$self->{active_fg}}; 2236 glColor_premultiply @{$self->{active_fg}};
2241 glBegin GL_LINES; 2237 glBegin GL_LINES;
2242 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; 2238 glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy};
2243 glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; 2239 glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy} + $self->{cur_h};
2244 glEnd; 2240 glEnd;
2245 2241
2246 glLineWidth 3; 2242 glLineWidth 3;
2247 glColor @{$self->{active_outline}}; 2243 glColor @{$self->{active_outline}};
2248 glRect_lineloop 0, 0, $self->{w} - 1, $self->{h} - 1; 2244 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2249 glLineWidth 1; 2245 glLineWidth 1;
2250 2246
2251 } else { 2247 } else {
2252 glColor @{$self->{outline}}; 2248 glColor @{$self->{outline}};
2253 glTranslate .375, .375;
2254 glBegin GL_LINE_STRIP; 2249 glBegin GL_LINE_STRIP;
2255 glVertex 0, $self->{h} * .5; 2250 glVertex .5, $self->{h} * .5;
2256 glVertex 0, $self->{h} - 3; 2251 glVertex .5, $self->{h} - 2.5;
2257 glVertex $self->{w} - 1, $self->{h} - 3; 2252 glVertex $self->{w} - .5, $self->{h} - 2.5;
2258 glVertex $self->{w} - 1, $self->{h} * .5; 2253 glVertex $self->{w} - .5, $self->{h} * .5;
2259 glEnd; 2254 glEnd;
2260 } 2255 }
2261} 2256}
2262 2257
2263############################################################################# 2258#############################################################################
2512sub _draw { 2507sub _draw {
2513 my ($self) = @_; 2508 my ($self) = @_;
2514 2509
2515 $self->SUPER::_draw; 2510 $self->SUPER::_draw;
2516 2511
2517 glTranslate $self->{padding_x} + 0.375, $self->{padding_y} + 0.375, 0; 2512 glTranslate $self->{padding_x}, $self->{padding_y}, 0;
2518 2513
2519 my ($w, $h) = @$self{qw(w h)}; 2514 my ($w, $h) = @$self{qw(w h)};
2520 2515
2521 my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; 2516 my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2;
2522 2517
2841 2836
2842 glEnable GL_BLEND; 2837 glEnable GL_BLEND;
2843 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; 2838 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
2844 2839
2845 if ($self->{value} >= 0) { 2840 if ($self->{value} >= 0) {
2846 my $s = 3 + ($self->{w} - 6) * $self->{value}; 2841 my $s = int 2 + ($self->{w} - 4) * $self->{value};
2847 2842
2848 glColor_premultiply @{$self->{bar}}; 2843 glColor_premultiply @{$self->{bar}};
2849 glRect 2, 2, $s, $self->{h} - 2; 2844 glRect 2, 2, $s, $self->{h} - 2;
2850 glColor_premultiply @{$self->{bg}}; 2845 glColor_premultiply @{$self->{bg}};
2851 glRect $s + 1, 0, $self->{w} - 2, $self->{h} - 2; 2846 glRect $s, 2, $self->{w} - 2, $self->{h} - 2;
2852 } 2847 }
2853 2848
2854 glColor_premultiply @{$self->{outline}}; 2849 glColor_premultiply @{$self->{outline}};
2855 glRect_lineloop 1, 1, $self->{w} - 2, $self->{h} - 2; 2850 glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5;
2856 2851
2857 glDisable GL_BLEND; 2852 glDisable GL_BLEND;
2858 2853
2859 { 2854 {
2860 local $self->{bg}; # do not draw background 2855 local $self->{bg}; # do not draw background
2873 2868
2874 my $self = $class->SUPER::new ( 2869 my $self = $class->SUPER::new (
2875 tooltip => sub { 2870 tooltip => sub {
2876 my ($self) = @_; 2871 my ($self) = @_;
2877 2872
2878 sprintf "%s points experience (level %d).\n%s points to next level %s.", 2873 sprintf "level %d\n%s points\n%s next level\n%s to go",
2879 ::formsep $self->{exp},
2880 $self->{lvl}, 2874 $self->{lvl},
2875 ::formsep ($self->{exp}),
2881 ::formsep $self->{nxt} 2876 ::formsep ($self->{nxt}),
2877 ::formsep ($self->{nxt} - $self->{exp}),
2882 }, 2878 },
2883 %arg 2879 %arg
2884 ); 2880 );
2885 2881
2886 $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) } 2882 $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) }
2899} 2895}
2900 2896
2901sub set_value { 2897sub set_value {
2902 my ($self, $lvl, $exp) = @_; 2898 my ($self, $lvl, $exp) = @_;
2903 2899
2904 $self->{lvl} = $exp; 2900 $self->{lvl} = $lvl;
2905 $self->{exp} = $exp; 2901 $self->{exp} = $exp;
2906 2902
2907 my $v = -1; 2903 my $v = -1;
2908 2904
2909 if ($::CONN && (my $table = $::CONN->{exp_table})) { 2905 if ($::CONN && (my $table = $::CONN->{exp_table})) {
3556} 3552}
3557 3553
3558sub set_tooltip_from { 3554sub set_tooltip_from {
3559 my ($self, $widget) = @_; 3555 my ($self, $widget) = @_;
3560 3556
3561 $widget->{tooltip} = CFPlus::Pod::section_label tooltip => $1
3562 if $widget->{tooltip} =~ /^#(.*)$/;
3563
3564 my $tooltip = $widget->{tooltip}; 3557 my $tip = $widget->{tooltip};
3558 $tip = $tip->($widget) if "CODE" eq ref $tip;
3559
3560 $tip = CFPlus::Pod::section_label tooltip => $1
3561 if $tip =~ /^#(.*)$/;
3565 3562
3566 if ($ENV{CFPLUS_DEBUG} & 2) { 3563 if ($ENV{CFPLUS_DEBUG} & 2) {
3567 $tooltip .= "\n\n" . (ref $widget) . "\n" 3564 $tip .= "\n\n" . (ref $widget) . "\n"
3568 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 3565 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
3569 . "req $widget->{req_w} $widget->{req_h}\n" 3566 . "req $widget->{req_w} $widget->{req_h}\n"
3570 . "visible $widget->{visible}"; 3567 . "visible $widget->{visible}";
3571 } 3568 }
3572 3569
3573 $tooltip =~ s/^\n+//; 3570 $tip =~ s/^\n+//;
3574 $tooltip =~ s/\n+$//; 3571 $tip =~ s/\n+$//;
3575 3572
3576 $self->add (new CFPlus::UI::Label 3573 $self->add (new CFPlus::UI::Label
3577 markup => $tooltip, 3574 markup => $tip,
3578 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 3575 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
3579 fontsize => 0.8, 3576 fontsize => 0.8,
3580 style => 1, # FLAG_INVERSE 3577 style => 1, # FLAG_INVERSE
3581 ellipsise => 0, 3578 ellipsise => 0,
3582 font => ($widget->{tooltip_font} || $::FONT_PROP), 3579 font => ($widget->{tooltip_font} || $::FONT_PROP),
3620} 3617}
3621 3618
3622sub _draw { 3619sub _draw {
3623 my ($self) = @_; 3620 my ($self) = @_;
3624 3621
3625 glTranslate 0.375, 0.375;
3626
3627 my ($w, $h) = @$self{qw(w h)}; 3622 my ($w, $h) = @$self{qw(w h)};
3628 3623
3629 glColor 1, 0.8, 0.4; 3624 glColor 1, 0.8, 0.4;
3630 glRect 0, 0, $w, $h; 3625 glRect 0, 0, $w, $h;
3631 3626
3632 glColor 0, 0, 0; 3627 glColor 0, 0, 0;
3633 glRect_lineloop 0, 0, $w, $h; 3628 glRect_lineloop .5, .5, $w + .5, $h + .5;
3634 3629
3635 glTranslate 2 - 0.375, 2 - 0.375; 3630 glTranslate 2, 2;
3636 3631
3637 $self->SUPER::_draw; 3632 $self->SUPER::_draw;
3638} 3633}
3639 3634
3640############################################################################# 3635#############################################################################
3967 my $class = shift; 3962 my $class = shift;
3968 3963
3969 my $self = $class->SUPER::new ( 3964 my $self = $class->SUPER::new (
3970 buttonbar => (new CFPlus::UI::Buttonbar), 3965 buttonbar => (new CFPlus::UI::Buttonbar),
3971 multiplexer => (new CFPlus::UI::Multiplexer expand => 1), 3966 multiplexer => (new CFPlus::UI::Multiplexer expand => 1),
3972 active_outline => [1, 1, 0], 3967 active_outline => [.7, .7, 0.2],
3973 # filter => # will be put between multiplexer and $self 3968 # filter => # will be put between multiplexer and $self
3974 @_, 3969 @_,
3975 ); 3970 );
3976 3971
3977 $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; 3972 $self->{filter}->add ($self->{multiplexer}) if $self->{filter};
4058 4053
4059 $self->SUPER::_draw (); 4054 $self->SUPER::_draw ();
4060 4055
4061 if (my $cur = $self->{multiplexer}{current}) { 4056 if (my $cur = $self->{multiplexer}{current}) {
4062 if ($cur = $cur->{c_tab_}) { 4057 if ($cur = $cur->{c_tab_}) {
4063 glTranslate $cur->{x}, $cur->{y}; 4058 glTranslate $self->{buttonbar}{x} + $cur->{x},
4059 $self->{buttonbar}{y} + $cur->{y};
4064 glLineWidth 3; 4060 glLineWidth 3;
4061 #glEnable GL_BLEND;
4062 #glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
4065 glColor @{$self->{active_outline}}; 4063 glColor @{$self->{active_outline}};
4066 glRect_lineloop 1, 1, $cur->{w} - 2, $cur->{h} - 2; 4064 glRect_lineloop 1.5, 1.5, $cur->{w} - 1.5, $cur->{h} - 1.5;
4067 glLineWidth 1; 4065 glLineWidth 1;
4066 #glDisable GL_BLEND;
4068 } 4067 }
4069 } 4068 }
4070} 4069}
4071 4070
4072############################################################################# 4071#############################################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines