--- deliantra/Deliantra-Client/bin/cfplus 2006/07/23 17:03:44 1.101 +++ deliantra/Deliantra-Client/bin/cfplus 2006/07/24 04:24:43 1.102 @@ -254,7 +254,7 @@ ); # center: swap stats - my ($sw1, $sw2) = map +(new CFClient::UI::Combobox + my ($sw1, $sw2) = map +(new CFClient::UI::Selector expand => 1, value => $_, options => [ @@ -690,7 +690,6 @@ can_hover => 1, can_events => 1, tooltip => "The weight limit: you cannot carry more than this."); - $vb->add (my $hb = new CFClient::UI::HBox expand => 1); $hb->add (my $tbl = new CFClient::UI::Table expand => 1); @@ -1262,6 +1261,19 @@ $table } +my %SORT_ORDER = ( + type => undef, + mtime => sub { sort { + ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) + or $b->{mtime} <=> $a->{mtime} + or $a->{type} <=> $b->{type} + } @_ }, + weight => sub { sort { + $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) + or $a->{type} <=> $b->{type} + } @_ }, +); + sub inventory_widget { my $hb = new CFClient::UI::HBox homogeneous => 1; @@ -1272,21 +1284,16 @@ use sort 'stable'; - $hb1->add (new CFClient::UI::Combobox - value => undef, + $hb1->add (new CFClient::UI::Selector + value => $::CFG->{inv_sort}, options => [ - [undef, "Type/Name"], - [ - sub { sort { - $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) - or $a->{type} <=> $b->{type} - } @_ }, - "Weight/Type", - ], - [sub { } => "#TODO#"], + [type => "Type/Name"], + [mtime => "Recent/Normal/Locked"], + [weight => "Weight/Type"], ], on_changed => sub { - $INV->set_sort_order ($_[1]); + $::CFG->{inv_sort} = $_[1]; + $INV->set_sort_order ($SORT_ORDER{$_[1]}); }, ); $hb1->add (new CFClient::UI::Label text => "Weight: ", align => 1, expand => 1); @@ -1569,7 +1576,7 @@ expand => 1, fontsize => 0.8, padding_x => 4); $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); - $buttons->add (my $combo = new CFClient::UI::Combobox + $buttons->add (my $combo = new CFClient::UI::Selector value => undef, options => [ [intro => "Introduction"], @@ -1992,6 +1999,7 @@ output_sync => 1, output_count => 1, pickup => 0, + inv_sort => "mtime", default => "profile", # default profile );