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.233 by root, Thu May 25 03:42:40 2006 UTC vs.
Revision 1.234 by root, Thu May 25 16:24:44 2006 UTC

322} 322}
323 323
324sub set_tooltip { 324sub set_tooltip {
325 my ($self, $tooltip) = @_; 325 my ($self, $tooltip) = @_;
326 326
327 $tooltip =~ s/^\s+//;
328 $tooltip =~ s/\s+$//;
329
330 return if $self->{tooltip} eq $tooltip;
331
327 $self->{tooltip} = $tooltip; 332 $self->{tooltip} = $tooltip;
328 333
329 if ($CFClient::UI::TOOLTIP->{owner} == $self) { 334 if ($CFClient::UI::TOOLTIP->{owner} == $self) {
330 delete $CFClient::UI::TOOLTIP->{owner}; 335 delete $CFClient::UI::TOOLTIP->{owner};
331 CFClient::UI::check_tooltip; 336 CFClient::UI::check_tooltip;
420 if ($ENV{PCLIENT_DEBUG}) { 425 if ($ENV{PCLIENT_DEBUG}) {
421 glPushMatrix; 426 glPushMatrix;
422 glColor 1, 1, 0, 1; 427 glColor 1, 1, 0, 1;
423 glTranslate $self->{x} + 0.375, $self->{y} + 0.375; 428 glTranslate $self->{x} + 0.375, $self->{y} + 0.375;
424 glBegin GL_LINE_LOOP; 429 glBegin GL_LINE_LOOP;
425 glVertex 0 , 0; 430 glVertex 0 , 0;
426 glVertex $self->{w}, 0; 431 glVertex $self->{w} - 1, 0;
427 glVertex $self->{w}, $self->{h}; 432 glVertex $self->{w} - 1, $self->{h} - 1;
428 glVertex 0 , $self->{h}; 433 glVertex 0 , $self->{h} - 1;
429 glEnd; 434 glEnd;
430 glPopMatrix; 435 glPopMatrix;
431 #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; 436 #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
432 } 437 }
433} 438}
763 768
764package CFClient::UI::ViewPort; 769package CFClient::UI::ViewPort;
765 770
766our @ISA = CFClient::UI::Window::; 771our @ISA = CFClient::UI::Window::;
767 772
773sub new {
774 my $class = shift;
775
776 $class->SUPER::new (
777 scroll_x => 0,
778 scroll_y => 1,
779 @_,
780 )
781}
782
768sub size_request { 783sub size_request {
769 my ($self) = @_; 784 my ($self) = @_;
770 785
771 @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; 786 @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)};
772 787
774} 789}
775 790
776sub size_allocate { 791sub size_allocate {
777 my ($self, $w, $h) = @_; 792 my ($self, $w, $h) = @_;
778 793
779 my ($cw, $ch) = @$self{qw(child_w child_h)}; 794 $w = $self->{child_w} if $self->{scroll_x} && $self->{child_w};
780# $w = $self->{w}; 795 $h = $self->{child_h} if $self->{scroll_y} && $self->{child_h};
796
781 $self->child->configure (0, 0, $cw, $ch); 797 $self->child->configure (0, 0, $w, $h);
782 $self->update; 798 $self->update;
783} 799}
784 800
785sub set_offset { 801sub set_offset {
786 my ($self, $x, $y) = @_; 802 my ($self, $x, $y) = @_;
1081sub new { 1097sub new {
1082 my $class = shift; 1098 my $class = shift;
1083 1099
1084 $class->SUPER::new ( 1100 $class->SUPER::new (
1085 col_expand => [], 1101 col_expand => [],
1086 @_ 1102 @_,
1087 ) 1103 )
1088} 1104}
1089 1105
1090sub add { 1106sub add {
1091 my ($self, $x, $y, $child) = @_; 1107 my ($self, $x, $y, $child) = @_;
2623 2639
2624sub new { 2640sub new {
2625 my $class = shift; 2641 my $class = shift;
2626 2642
2627 my $self = $class->SUPER::new ( 2643 my $self = $class->SUPER::new (
2628 aspect => 1, 2644 aspect => 1,
2645 can_events => 0,
2629 @_, 2646 @_,
2630 ); 2647 );
2631 2648
2632 if ($self->{anim} && $self->{animspeed}) { 2649 if ($self->{anim} && $self->{animspeed}) {
2633 Scalar::Util::weaken (my $widget = $self); 2650 Scalar::Util::weaken (my $widget = $self);
2696 2713
2697package CFClient::UI::InventoryItem; 2714package CFClient::UI::InventoryItem;
2698 2715
2699our @ISA = CFClient::UI::HBox::; 2716our @ISA = CFClient::UI::HBox::;
2700 2717
2701sub _item_to_desc {
2702 my ($item) = @_;
2703
2704 my $desc =
2705 $item->{nrof} < 2
2706 ? $item->{name}
2707 : "$item->{nrof} × $item->{name_pl}";
2708
2709 $item->{flags} & Crossfire::Protocol::F_OPEN
2710 and $desc .= " (open)";
2711 $item->{flags} & Crossfire::Protocol::F_APPLIED
2712 and $desc .= " (applied)";
2713 $item->{flags} & Crossfire::Protocol::F_UNPAID
2714 and $desc .= " (unpaid)";
2715 $item->{flags} & Crossfire::Protocol::F_MAGIC
2716 and $desc .= " (magic)";
2717 $item->{flags} & Crossfire::Protocol::F_CURSED
2718 and $desc .= " (cursed)";
2719 $item->{flags} & Crossfire::Protocol::F_DAMNED
2720 and $desc .= " (damned)";
2721 $item->{flags} & Crossfire::Protocol::F_LOCKED
2722 and $desc .= " *";
2723
2724 $desc
2725}
2726
2727sub new { 2718sub new {
2728 my $class = shift; 2719 my $class = shift;
2729 2720
2730 my %args = @_; 2721 my %args = @_;
2731 2722
2732 my $item = delete $args{item}; 2723 my $item = delete $args{item};
2733 2724
2734 my $desc = _item_to_desc ($item); 2725 my $desc = CFClient::Item::desc_string $item;
2735 2726
2736 my $self = $class->SUPER::new ( 2727 my $self = $class->SUPER::new (
2737 can_hover => 1, 2728 can_hover => 1,
2738 can_events => 1, 2729 can_events => 1,
2739 tooltip => ((CFClient::UI::Label::escape $desc) 2730 tooltip => ((CFClient::UI::Label::escape $desc)
2797} 2788}
2798 2789
2799sub update_item { 2790sub update_item {
2800 my ($self) = @_; 2791 my ($self) = @_;
2801 2792
2802 my $desc = _item_to_desc ($self->{item}); 2793 my $desc = CFClient::Item::desc_string ($self->{item});
2803 2794
2804 $self->{name_lbl}->set_text ($desc); 2795 $self->{name_lbl}->set_text ($desc);
2805} 2796}
2806 2797
2807############################################################################# 2798#############################################################################
2812 2803
2813sub new { 2804sub new {
2814 my $class = shift; 2805 my $class = shift;
2815 2806
2816 my $self = $class->SUPER::new ( 2807 my $self = $class->SUPER::new (
2817 scrolled => (new CFClient::UI::Table), 2808 scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]),
2818 @_, 2809 @_,
2819 ); 2810 );
2820 2811
2821 $self 2812 $self
2822} 2813}
2832 or ($a->{name} cmp $b->{name}) 2823 or ($a->{name} cmp $b->{name})
2833 } @$items; 2824 } @$items;
2834 2825
2835 $self->{real_items} = \@items; 2826 $self->{real_items} = \@items;
2836 2827
2828 my $row = 0;
2837 for my $item (@items) { 2829 for my $item (@items) {
2838 $item->{item} = $item; 2830 CFClient::Item::update_widgets $item;
2839 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item;
2840 $item->update_item ();
2841 }
2842 2831
2843 my $i = 0; 2832 $self->{scrolled}->add (0, $row, $item->{face_widget});
2844 for (@items) { 2833 $self->{scrolled}->add (1, $row, $item->{desc_widget});
2845 $self->{scrolled}->add (0, $i, $_); 2834 $self->{scrolled}->add (2, $row, $item->{weight_widget});
2846 my $nrof = $_->{item}->{nrof} || 1; 2835
2847 $self->{scrolled}->add (1, $i++, new CFClient::UI::Label text => ($_->{item}->{weight} * $nrof) / 1000); 2836 $row++;
2848 } 2837 }
2849 2838
2850# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2839# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];
2851} 2840}
2852 2841

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines