ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.2 by root, Thu May 25 16:35:42 2006 UTC vs.
Revision 1.7 by root, Thu May 25 21:48:22 2006 UTC

103 103
104our $INVWIN; 104our $INVWIN;
105our $INV; 105our $INV;
106our $INVR; 106our $INVR;
107our $INVR_LBL; 107our $INVR_LBL;
108our $OPENCONT;
109 108
110sub status { 109sub status {
111 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 110 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
112} 111}
113 112
431 can_hover => 1, can_events => 1, 430 can_hover => 1, can_events => 1,
432 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 431 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
433 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, 432 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
434 can_hover => 1, can_events => 1, 433 can_hover => 1, can_events => 1,
435 tooltip => "The map you are currently on (if supported by the server)."); 434 tooltip => "The map you are currently on (if supported by the server).");
435
436 $vb->add (my $hb0 = new CFClient::UI::HBox);
437 $hb0->add ($STATWIDS->{weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
438 can_hover => 1, can_events => 1,
439 tooltip => "This is the amount the Player weights.");
440 $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
441 can_hover => 1, can_events => 1,
442 tooltip => "The weight limit, you can't carry more than this.");
443
436 444
437 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 445 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
438 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 446 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
439 447
440 my $color2 = [1, 1, 0]; 448 my $color2 = [1, 1, 0];
566 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); 574 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
567 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); 575 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
568 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED}); 576 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED});
569 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP}); 577 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP});
570 578
579 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{Crossfire::Protocol::CS_STAT_WEIGHT_LIM} / 1000);
580
571 my %tbl = ( 581 my %tbl = (
572 phys => 100, 582 phys => 100,
573 magic => 101, 583 magic => 101,
574 fire => 102, 584 fire => 102,
575 elec => 103, 585 elec => 103,
884 user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory"; 894 user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory";
885 895
886 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); 896 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1);
887 897
888 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); 898 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1);
889 $vb1->add (my $lbl = new CFClient::UI::Label); 899 $vb1->add (my $lbl = new CFClient::UI::Label xalign => 0.5);
890 $lbl->set_text ("Player"); 900 $lbl->set_text ("Player");
891 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 901 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1);
892 902
893 $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1); 903 $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1);
894 $vb2->add ($INVR_LBL = new CFClient::UI::Label); 904 $vb2->add ($INVR_LBL = new CFClient::UI::Label xalign => 0.5);
895 $INVR_LBL->set_text ("Floor"); 905 $INVR_LBL->set_text ("Floor");
896 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); 906 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1);
897 907
898 $invwin 908 $invwin
899} 909}
1266 } 1276 }
1267 } 1277 }
1268 1278
1269 $self->{noface} = new_from_file CFClient::Texture 1279 $self->{noface} = new_from_file CFClient::Texture
1270 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; 1280 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1;
1281
1282 $self->{open_container} = 0;
1271 1283
1272 $self 1284 $self
1273} 1285}
1274 1286
1275sub conn::stats_update { 1287sub conn::stats_update {
1748 $FLOORBOX->add (0, 1, new CFClient::UI::Empty expand => 1); 1760 $FLOORBOX->add (0, 1, new CFClient::UI::Empty expand => 1);
1749 1761
1750 my $row; 1762 my $row;
1751 for (@{ $CONN->{container}{0} }) { 1763 for (@{ $CONN->{container}{0} }) {
1752 if (++$row < 7) { 1764 if (++$row < 7) {
1765 local $_->{face_widget}; # hack to force recreation of widget
1766 local $_->{desc_widget}; # hack to force recreation of widget
1753 CFClient::Item::update_widgets $_; 1767 CFClient::Item::update_widgets $_;
1768
1754 $FLOORBOX->add (0, $row, $_->{face_widget}); 1769 $FLOORBOX->add (0, $row, $_->{face_widget});
1755 $FLOORBOX->add (1, $row, $_->{desc_widget}); 1770 $FLOORBOX->add (1, $row, $_->{desc_widget});
1756 } else { 1771 } else {
1757 $FLOORBOX->add (new CFClient::UI::Label text => "More..."); 1772 $FLOORBOX->add (1, ++$row, new CFClient::UI::Label text => "More...");
1758 last; 1773 last;
1759 } 1774 }
1760 } 1775 }
1761 }); 1776 });
1762 1777
1763 $WANT_REFRESH++; 1778 $WANT_REFRESH++;
1764} 1779}
1765 1780
1781sub set_opencont {
1782 my ($conn, $tag, $name) = @_;
1783 $conn->{open_container} = $tag;
1784 $INVR_LBL->set_text ($name);
1785 $INVR->set_items ($conn->{container}{$tag});
1786}
1787
1788sub update_container {
1789 my ($tag) = @_;
1790 $INVR->set_items ($::CONN->{container}{$CONN->{open_container}})
1791 if $tag == $CONN->{open_container};
1792}
1793
1766sub conn::container_add { 1794sub conn::container_add {
1767 my ($self, $tag, $items) = @_; 1795 my ($self, $tag, $items) = @_;
1768 1796
1769 #d# print "container_add: container $tag ($self->{player}{tag})\n"; 1797 #d# print "container_add: container $tag ($self->{player}{tag})\n";
1770 1798
1771 if ($tag == 0) { 1799 if ($tag == 0) {
1772 update_floorbox; 1800 update_floorbox;
1773 $OPENCONT = 0; 1801 update_container (0);
1774 $INVR_LBL->set_text ("Floor");
1775 $INVR->set_items ($self->{container}{0});
1776 } elsif ($tag == $self->{player}{tag}) { 1802 } elsif ($tag == $self->{player}{tag}) {
1777 $INVR_LBL->set_text ("Player");
1778 $INV->set_items ($self->{container}{$self->{player}{tag}}) 1803 $INV->set_items ($self->{container}{$self->{player}{tag}})
1779 } else { 1804 } else {
1780 $OPENCONT = $tag; 1805 update_container ($tag);
1781 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1782 $INVR->set_items ($self->{container}{$tag});
1783 } 1806 }
1784 1807
1785 # $self-<{player}{tag} => player inv 1808 # $self-<{player}{tag} => player inv
1786 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1809 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1787} 1810}
1791 1814
1792 #d# print "container_clear: container $tag ($self->{player}{tag})\n"; 1815 #d# print "container_clear: container $tag ($self->{player}{tag})\n";
1793 1816
1794 if ($tag == 0) { 1817 if ($tag == 0) {
1795 update_floorbox; 1818 update_floorbox;
1796 $OPENCONT = 0; 1819 update_container (0);
1797 $INVR_LBL->set_text ("Floor");
1798 $INVR->set_items ($self->{container}{0});
1799 } elsif ($tag == $self->{player}{tag}) { 1820 } elsif ($tag == $self->{player}{tag}) {
1800 $INVR_LBL->set_text ("Player");
1801 $INV->set_items ($self->{container}{$tag}) 1821 $INV->set_items ($self->{container}{$tag})
1802 } else {
1803 $OPENCONT = $tag;
1804 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1805 $INVR->set_items ($self->{container}{$tag});
1806 } 1822 }
1807 1823
1808# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1824# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1809} 1825}
1810 1826
1814 for (@items) { 1830 for (@items) {
1815 #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n"; 1831 #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n";
1816 1832
1817 if ($_->{container} == 0) { 1833 if ($_->{container} == 0) {
1818 update_floorbox; 1834 update_floorbox;
1819 $OPENCONT = 0; 1835 update_container ($_->{tag});
1820 $INVR_LBL->set_text ("Floor");
1821 $INVR->set_items ($self->{container}{0});
1822 } elsif ($_->{container} == $self->{player}{tag}) { 1836 } elsif ($_->{container} == $self->{player}{tag}) {
1823 $INVR_LBL->set_text ("Player");
1824 $INV->set_items ($self->{container}{$self->{player}{tag}}) 1837 $INV->set_items ($self->{container}{$self->{player}{tag}})
1825 } else { 1838 } else {
1826 $OPENCONT = $_->{container}; 1839 update_container ($_->{tag});
1827 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1828 $INVR->set_items ($self->{container}{$_->{container}});
1829 } 1840 }
1830 } 1841 }
1831} 1842}
1832 1843
1833sub conn::item_update { 1844sub conn::item_update {
1834 my ($self, $item) = @_; 1845 my ($self, $item) = @_;
1835 1846
1836 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($OPENCONT)\n"; 1847 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($CONN->{open_container})\n";
1837 1848
1849 if ($item->{tag} == $self->{player}{tag}) {
1850 $STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000);
1851 return
1852 }
1853
1854 CFClient::Item::update_widgets $item;
1855
1838 if ($item->{tag} == $OPENCONT && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { 1856 if ($item->{tag} == $CONN->{open_container} && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) {
1839 $OPENCONT = 0; 1857 set_opencont ($CONN, 0, "Floor");
1840 $INVR_LBL->set_text ("Floor");
1841 $INVR->set_items ($self->{container}{0});
1842 1858
1843 $item->{widget}->update_item 1859 } elsif ($item->{flags} & Crossfire::Protocol::F_OPEN) {
1844 if $item->{widget}; 1860 set_opencont ($CONN, $item->{tag}, CFClient::Item::desc_string $item);
1845 } else { 1861 } else {
1846 if ($item->{container} == 0) { 1862 if ($item->{container} == 0) {
1847 update_floorbox; 1863 update_floorbox;
1848 $OPENCONT = 0; 1864 update_container (0);
1849 $INVR_LBL->set_text ("Floor");
1850 $INVR->set_items ($self->{container}{0});
1851 } elsif ($item->{container} == $self->{player}{tag}) { 1865 } elsif ($item->{container} == $self->{player}{tag}) {
1852 $INV->set_items ($self->{container}{$item->{container}}) 1866 $INV->set_items ($self->{container}{$item->{container}})
1853 } 1867 }
1854 } 1868 }
1855} 1869}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines