--- deliantra/Deliantra-Client/bin/cfplus 2006/05/25 16:54:29 1.3 +++ deliantra/Deliantra-Client/bin/cfplus 2006/05/25 21:24:40 1.6 @@ -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, @@ -886,12 +896,12 @@ $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); - $vb1->add (my $lbl = new CFClient::UI::Label); + $vb1->add (my $lbl = new CFClient::UI::Label xalign => 0.5); $lbl->set_text ("Player"); $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1); - $vb2->add ($INVR_LBL = new CFClient::UI::Label); + $vb2->add ($INVR_LBL = new CFClient::UI::Label xalign => 0.5); $INVR_LBL->set_text ("Floor"); $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); @@ -1269,6 +1279,8 @@ $self->{noface} = new_from_file CFClient::Texture CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; + $self->{open_container} = 0; + $self } @@ -1766,6 +1778,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 +1798,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::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT})); - $INVR->set_items ($self->{container}{$tag}); + update_container ($tag); } # $self-<{player}{tag} => player inv @@ -1796,16 +1816,9 @@ 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}{$tag}) - } else { - $OPENCONT = $tag; - $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT})); - $INVR->set_items ($self->{container}{$tag}); } # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; @@ -1819,16 +1832,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::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT})); - $INVR->set_items ($self->{container}{$_->{container}}); + update_container ($_->{tag}); } } } @@ -1836,21 +1844,24 @@ 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}); + update_container (0); } elsif ($item->{container} == $self->{player}{tag}) { $INV->set_items ($self->{container}{$item->{container}}) }