--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/25 03:42:40 1.233 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/25 16:24:44 1.234 @@ -324,6 +324,11 @@ sub set_tooltip { my ($self, $tooltip) = @_; + $tooltip =~ s/^\s+//; + $tooltip =~ s/\s+$//; + + return if $self->{tooltip} eq $tooltip; + $self->{tooltip} = $tooltip; if ($CFClient::UI::TOOLTIP->{owner} == $self) { @@ -422,10 +427,10 @@ glColor 1, 1, 0, 1; glTranslate $self->{x} + 0.375, $self->{y} + 0.375; glBegin GL_LINE_LOOP; - glVertex 0 , 0; - glVertex $self->{w}, 0; - glVertex $self->{w}, $self->{h}; - glVertex 0 , $self->{h}; + glVertex 0 , 0; + glVertex $self->{w} - 1, 0; + glVertex $self->{w} - 1, $self->{h} - 1; + glVertex 0 , $self->{h} - 1; glEnd; glPopMatrix; #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; @@ -765,6 +770,16 @@ our @ISA = CFClient::UI::Window::; +sub new { + my $class = shift; + + $class->SUPER::new ( + scroll_x => 0, + scroll_y => 1, + @_, + ) +} + sub size_request { my ($self) = @_; @@ -776,9 +791,10 @@ sub size_allocate { my ($self, $w, $h) = @_; - my ($cw, $ch) = @$self{qw(child_w child_h)}; -# $w = $self->{w}; - $self->child->configure (0, 0, $cw, $ch); + $w = $self->{child_w} if $self->{scroll_x} && $self->{child_w}; + $h = $self->{child_h} if $self->{scroll_y} && $self->{child_h}; + + $self->child->configure (0, 0, $w, $h); $self->update; } @@ -1083,7 +1099,7 @@ $class->SUPER::new ( col_expand => [], - @_ + @_, ) } @@ -2625,7 +2641,8 @@ my $class = shift; my $self = $class->SUPER::new ( - aspect => 1, + aspect => 1, + can_events => 0, @_, ); @@ -2698,32 +2715,6 @@ our @ISA = CFClient::UI::HBox::; -sub _item_to_desc { - my ($item) = @_; - - my $desc = - $item->{nrof} < 2 - ? $item->{name} - : "$item->{nrof} × $item->{name_pl}"; - - $item->{flags} & Crossfire::Protocol::F_OPEN - and $desc .= " (open)"; - $item->{flags} & Crossfire::Protocol::F_APPLIED - and $desc .= " (applied)"; - $item->{flags} & Crossfire::Protocol::F_UNPAID - and $desc .= " (unpaid)"; - $item->{flags} & Crossfire::Protocol::F_MAGIC - and $desc .= " (magic)"; - $item->{flags} & Crossfire::Protocol::F_CURSED - and $desc .= " (cursed)"; - $item->{flags} & Crossfire::Protocol::F_DAMNED - and $desc .= " (damned)"; - $item->{flags} & Crossfire::Protocol::F_LOCKED - and $desc .= " *"; - - $desc -} - sub new { my $class = shift; @@ -2731,7 +2722,7 @@ my $item = delete $args{item}; - my $desc = _item_to_desc ($item); + my $desc = CFClient::Item::desc_string $item; my $self = $class->SUPER::new ( can_hover => 1, @@ -2799,7 +2790,7 @@ sub update_item { my ($self) = @_; - my $desc = _item_to_desc ($self->{item}); + my $desc = CFClient::Item::desc_string ($self->{item}); $self->{name_lbl}->set_text ($desc); } @@ -2814,7 +2805,7 @@ my $class = shift; my $self = $class->SUPER::new ( - scrolled => (new CFClient::UI::Table), + scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]), @_, ); @@ -2834,17 +2825,15 @@ $self->{real_items} = \@items; + my $row = 0; for my $item (@items) { - $item->{item} = $item; - $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item; - $item->update_item (); - } + CFClient::Item::update_widgets $item; + + $self->{scrolled}->add (0, $row, $item->{face_widget}); + $self->{scrolled}->add (1, $row, $item->{desc_widget}); + $self->{scrolled}->add (2, $row, $item->{weight_widget}); - my $i = 0; - for (@items) { - $self->{scrolled}->add (0, $i, $_); - my $nrof = $_->{item}->{nrof} || 1; - $self->{scrolled}->add (1, $i++, new CFClient::UI::Label text => ($_->{item}->{weight} * $nrof) / 1000); + $row++; } # $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];