--- deliantra/Deliantra-Client/bin/cfplus 2006/05/25 16:24:45 1.1 +++ deliantra/Deliantra-Client/bin/cfplus 2006/05/26 18:28:23 1.10 @@ -36,6 +36,7 @@ use Compress::LZF; use CFClient; +use CFClient::OpenGL (); use CFClient::UI; use CFClient::MapWidget; @@ -105,7 +106,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]); @@ -385,7 +385,7 @@ (new CFClient::UI::HBox expand => 1), (new CFClient::UI::VBox children => [ (new CFClient::UI::Empty expand => 1), - (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)), + (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::Table)), ]), (my $vbox = new CFClient::UI::VBox), ], @@ -434,6 +434,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 +577,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 +897,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); @@ -958,7 +969,7 @@ $SDL_ACTIVE = 1; $LAST_REFRESH = time - 0.01; - CFClient::gl_init; + CFClient::OpenGL::init; $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; @@ -1249,7 +1260,7 @@ my $parser = new Pod::POM; my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod"); - for my $head2 ($pod->head2) { + for my $head2 ($pod->head1->[-2]->head2) { $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x or next; @@ -1269,6 +1280,8 @@ $self->{noface} = new_from_file CFClient::Texture CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; + $self->{open_container} = 0; + $self } @@ -1677,7 +1690,7 @@ my %skill_tooltip; - for my $head2 ($pod->head2) { + for my $head2 ($pod->head1->[-2]->head2) { $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; } @@ -1745,14 +1758,20 @@ return unless $CONN; $FLOORBOX->clear; - $FLOORBOX->add (new CFClient::UI::Empty expand => 1); - my $count = 7; + my $row; for (@{ $CONN->{container}{0} }) { - if (--$count) { - $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_); + if ($row < 7) { + local $_->{face_widget}; # hack to force recreation of widget + local $_->{desc_widget}; # hack to force recreation of widget + CFClient::Item::update_widgets $_; + + $FLOORBOX->add (0, $row, $_->{face_widget}); + $FLOORBOX->add (1, $row, $_->{desc_widget}); + + $row++; } else { - $FLOORBOX->add (new CFClient::UI::Label text => "More..."); + $FLOORBOX->add (1, $row, new CFClient::UI::Label text => "More..."); last; } } @@ -1761,6 +1780,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) = @_; @@ -1768,16 +1800,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 @@ -1791,16 +1818,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}; @@ -1814,16 +1834,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}); } } } @@ -1831,21 +1846,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}}) }