--- deliantra/Deliantra-Client/bin/cfplus 2006/05/25 17:52:29 1.4 +++ deliantra/Deliantra-Client/bin/cfplus 2006/05/25 18:48:45 1.5 @@ -105,7 +105,6 @@ our $INV; our $INVR; our $INVR_LBL; -our $OPENCONT; sub status { $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); @@ -434,6 +433,15 @@ can_hover => 1, can_events => 1, tooltip => "The map you are currently on (if supported by the server)."); + $vb->add (my $hb0 = new CFClient::UI::HBox); + $hb0->add ($STATWIDS->{weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, + can_hover => 1, can_events => 1, + tooltip => "This is the amount the Player weights."); + $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, + can_hover => 1, can_events => 1, + tooltip => "The weight limit, you can't carry more than this."); + + $vb->add (my $hb = new CFClient::UI::HBox expand => 1); $hb->add (my $tbl = new CFClient::UI::Table expand => 1); @@ -568,6 +576,8 @@ $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED}); $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP}); + $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{Crossfire::Protocol::CS_STAT_WEIGHT_LIM} / 1000); + my %tbl = ( phys => 100, magic => 101, @@ -1766,6 +1776,19 @@ $WANT_REFRESH++; } +sub set_opencont { + my ($conn, $tag, $name) = @_; + $conn->{open_container} = $tag; + $INVR_LBL->set_text ($name); + $INVR->set_items ($conn->{container}{$tag}); +} + +sub update_container { + my ($tag) = @_; + $INVR->set_items ($::CONN->{container}{$CONN->{open_container}}) + if $tag == $CONN->{open_container}; +} + sub conn::container_add { my ($self, $tag, $items) = @_; @@ -1773,16 +1796,11 @@ if ($tag == 0) { update_floorbox; - $OPENCONT = 0; - $INVR_LBL->set_text ("Floor"); - $INVR->set_items ($self->{container}{0}); + update_container (0); } elsif ($tag == $self->{player}{tag}) { - $INVR_LBL->set_text ("Player"); $INV->set_items ($self->{container}{$self->{player}{tag}}) } else { - $OPENCONT = $tag; - $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); - $INVR->set_items ($self->{container}{$tag}); + update_container ($tag); } # $self-<{player}{tag} => player inv @@ -1796,16 +1814,8 @@ if ($tag == 0) { update_floorbox; - $OPENCONT = 0; - $INVR_LBL->set_text ("Floor"); - $INVR->set_items ($self->{container}{0}); } elsif ($tag == $self->{player}{tag}) { - $INVR_LBL->set_text ("Player"); $INV->set_items ($self->{container}{$tag}) - } else { - $OPENCONT = $tag; - $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); - $INVR->set_items ($self->{container}{$tag}); } # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; @@ -1819,16 +1829,11 @@ if ($_->{container} == 0) { update_floorbox; - $OPENCONT = 0; - $INVR_LBL->set_text ("Floor"); - $INVR->set_items ($self->{container}{0}); + update_container ($_->{tag}); } elsif ($_->{container} == $self->{player}{tag}) { - $INVR_LBL->set_text ("Player"); $INV->set_items ($self->{container}{$self->{player}{tag}}) } else { - $OPENCONT = $_->{container}; - $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); - $INVR->set_items ($self->{container}{$_->{container}}); + update_container ($_->{tag}); } } } @@ -1836,21 +1841,23 @@ sub conn::item_update { my ($self, $item) = @_; - #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($OPENCONT)\n"; + #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($CONN->{open_container})\n"; + + if ($item->{tag} == $self->{player}{tag}) { + $STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000); + return + } + + CFClient::Item::update_widgets $item; - if ($item->{tag} == $OPENCONT && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { - $OPENCONT = 0; - $INVR_LBL->set_text ("Floor"); - $INVR->set_items ($self->{container}{0}); + if ($item->{tag} == $CONN->{open_container} && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { + set_opencont ($CONN, 0, "Floor"); - $item->{widget}->update_item - if $item->{widget}; + } elsif ($item->{flags} & Crossfire::Protocol::F_OPEN) { + set_opencont ($CONN, $item->{tag}, CFClient::Item::desc_string $item); } else { if ($item->{container} == 0) { update_floorbox; - $OPENCONT = 0; - $INVR_LBL->set_text ("Floor"); - $INVR->set_items ($self->{container}{0}); } elsif ($item->{container} == $self->{player}{tag}) { $INV->set_items ($self->{container}{$item->{container}}) }