--- deliantra/Deliantra-Client/DC/UI.pm 2006/06/05 00:17:47 1.279 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/06/05 01:22:08 1.280 @@ -385,6 +385,8 @@ delete $self->{max_w}; $self->{max_w} = $w if $w; delete $self->{max_h}; $self->{max_h} = $h if $h; + + $self->realloc; } sub set_tooltip { @@ -3069,15 +3071,24 @@ sub new { my $class = shift; - $class->SUPER::new ( + my $self = $class->SUPER::new ( fontsize => 0.8, @_, - ) + ); + + Scalar::Util::weaken (my $this = $self); + + $self->{timer} = Event->timer (after => 1, interval => 1, cb => sub { + $this->reorder; + $this->update; + }); + + $self } sub reorder { my ($self) = @_; - my $NOW = time; + my $NOW = Time::HiRes::time; while (my ($k, $v) = each %{ $self->{item} }) { delete $self->{item}{$k} if $v->{timeout} < $NOW; @@ -3090,6 +3101,8 @@ or $b->{id} <=> $a->{id} } values %{ $self->{item} }; + $self->{timer}->interval (1); + my $count = 10 + 1; for my $item (@items) { last unless --$count; @@ -3113,9 +3126,20 @@ fontsize => $item->{fontsize} || $self->{fontsize}, max_w => $::WIDTH * 0.44, fg => $item->{fg}, + orig_alpha => $item->{fg}[3] || 1, can_events => 1, can_hover => 1 }; + + if ((my $diff = $item->{timeout} - $NOW) < 2) { + $item->{label}{fg}[3] = $item->{label}{orig_alpha} * $diff / 2; + if ($diff < 1) { + $item->{label}{max_h} = $item->{label}{req_h} * $diff; + $item->{label}->realloc; + } + $item->{label}->update; + $self->{timer}->interval (1/30); + } } $self->clear; @@ -3130,7 +3154,7 @@ return unless $text; - my $timeout = time + ((delete $arg{timeout}) || 60); + my $timeout = (int time) + ((delete $arg{timeout}) || 60); my $group = exists $arg{group} ? $arg{group} : ++$self->{id}; @@ -3170,6 +3194,14 @@ $self->SUPER::reconfigure; } +sub DESTROY { + my ($self) = @_; + + $self->{timer}->cancel; + + $self->SUPER::DESTROY; +} + ############################################################################# package CFClient::UI::Inventory; @@ -3471,6 +3503,8 @@ our @ISA = CFClient::UI::Container::; +use List::Util qw(min max); + use CFClient::OpenGL; sub new { @@ -3614,8 +3648,11 @@ my ($w, $h) = $widget->size_request; - $w = List::Util::max $widget->{min_w}, $w + $widget->{padding_x} * 2; - $h = List::Util::max $widget->{min_h}, $h + $widget->{padding_y} * 2; + $w = max $widget->{min_w}, $w + $widget->{padding_x} * 2; + $h = max $widget->{min_h}, $h + $widget->{padding_y} * 2; + + $w = min $widget->{max_w}, $w if exists $widget->{max_w}; + $h = min $widget->{max_h}, $h if exists $widget->{max_h}; $w = $widget->{force_w} if exists $widget->{force_w}; $h = $widget->{force_h} if exists $widget->{force_h};