--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/07/19 23:00:07 1.61 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/07/23 08:58:44 1.64 @@ -244,7 +244,7 @@ $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); - $::STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); + $self->update_weight; $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) for keys %RES_TBL; @@ -604,7 +604,7 @@ $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g; $self->{logview}->add_paragraph ($color[$color], $_) - for map "$time $_", split /\n/, $text; + for map "$time $_", split /\n/, $text; $self->{logview}->scroll_to_bottom; $self->{statusbox}->add ($text, @@ -711,11 +711,11 @@ sub update_floorbox { $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { return unless $::CONN; - + $::FLOORBOX->clear; my $row; - for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) { + for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { if ($row < 6) { local $_->{face_widget}; # hack to force recreation of widget local $_->{desc_widget}; # hack to force recreation of widget @@ -733,14 +733,21 @@ last; } } + if ($::CONN->{open_container}) { + $::FLOORBOX->add (1, $row++, new CFClient::UI::Button + text => "Close container", + on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } + ); + } }); - + $::WANT_REFRESH++; } sub set_opencont { my ($conn, $tag, $name) = @_; $conn->{open_container} = $tag; + update_floorbox; $::INV_RIGHT_HB->clear (); $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); @@ -769,8 +776,8 @@ or return; for my $tag (keys %$todo) { + update_floorbox if $tag == 0 or $tag == $self->{open_container}; if ($tag == 0) { - update_floorbox; $::INVR->set_items ($self->{container}{0}) if $tag == $self->{open_container}; } elsif ($tag == $self->{player}{tag}) { @@ -827,7 +834,19 @@ sub player_update { my ($self, $player) = @_; - $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); + + $self->update_weight; +} + +sub update_weight { + my ($self) = @_; + + my $weight = .001 * $self->{player}{weight}; + my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; + + $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); + $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit); + $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); } sub update_server_info { @@ -907,11 +926,14 @@ force_h => $::HEIGHT * 0.7, title => "NPC Dialog", kw => { hi => 0, yes => 0, no => 0 }, + has_close_button => 1, @_, ); Scalar::Util::weaken (my $this = $self); + $self->connect (delete => sub { $this->destroy; 1 }); + # better use a pane... $self->add (my $hbox = new CFClient::UI::HBox); $hbox->add ($self->{textview} = new CFClient::UI::TextScroller expand => 1); @@ -942,7 +964,7 @@ $self->{bye_button} = new CFClient::UI::Button text => "Bye (close)", tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", - on_activate => sub { $this->destroy; 0 }, + on_activate => sub { $this->destroy; 1 }, ; $self->update_options;