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.1 by root, Thu May 25 16:24:45 2006 UTC vs.
Revision 1.5 by elmex, Thu May 25 18:48:45 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
383 $win->add (my $hbox = new CFClient::UI::HBox 382 $win->add (my $hbox = new CFClient::UI::HBox
384 children => [ 383 children => [
385 (new CFClient::UI::HBox expand => 1), 384 (new CFClient::UI::HBox expand => 1),
386 (new CFClient::UI::VBox children => [ 385 (new CFClient::UI::VBox children => [
387 (new CFClient::UI::Empty expand => 1), 386 (new CFClient::UI::Empty expand => 1),
388 (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)), 387 (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::Table)),
389 ]), 388 ]),
390 (my $vbox = new CFClient::UI::VBox), 389 (my $vbox = new CFClient::UI::VBox),
391 ], 390 ],
392 ); 391 );
393 392
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}
1743sub update_floorbox { 1753sub update_floorbox {
1744 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1754 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1745 return unless $CONN; 1755 return unless $CONN;
1746 1756
1747 $FLOORBOX->clear; 1757 $FLOORBOX->clear;
1748 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1758 $FLOORBOX->add (0, 1, new CFClient::UI::Empty expand => 1);
1749 1759
1750 my $count = 7; 1760 my $row;
1751 for (@{ $CONN->{container}{0} }) { 1761 for (@{ $CONN->{container}{0} }) {
1752 if (--$count) { 1762 if (++$row < 7) {
1753 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_); 1763 local $_->{face_widget}; # hack to force recreation of widget
1764 local $_->{desc_widget}; # hack to force recreation of widget
1765 CFClient::Item::update_widgets $_;
1766
1767 $FLOORBOX->add (0, $row, $_->{face_widget});
1768 $FLOORBOX->add (1, $row, $_->{desc_widget});
1754 } else { 1769 } else {
1755 $FLOORBOX->add (new CFClient::UI::Label text => "More..."); 1770 $FLOORBOX->add (new CFClient::UI::Label text => "More...");
1756 last; 1771 last;
1757 } 1772 }
1758 } 1773 }
1759 }); 1774 });
1760 1775
1761 $WANT_REFRESH++; 1776 $WANT_REFRESH++;
1762} 1777}
1763 1778
1779sub set_opencont {
1780 my ($conn, $tag, $name) = @_;
1781 $conn->{open_container} = $tag;
1782 $INVR_LBL->set_text ($name);
1783 $INVR->set_items ($conn->{container}{$tag});
1784}
1785
1786sub update_container {
1787 my ($tag) = @_;
1788 $INVR->set_items ($::CONN->{container}{$CONN->{open_container}})
1789 if $tag == $CONN->{open_container};
1790}
1791
1764sub conn::container_add { 1792sub conn::container_add {
1765 my ($self, $tag, $items) = @_; 1793 my ($self, $tag, $items) = @_;
1766 1794
1767 #d# print "container_add: container $tag ($self->{player}{tag})\n"; 1795 #d# print "container_add: container $tag ($self->{player}{tag})\n";
1768 1796
1769 if ($tag == 0) { 1797 if ($tag == 0) {
1770 update_floorbox; 1798 update_floorbox;
1771 $OPENCONT = 0; 1799 update_container (0);
1772 $INVR_LBL->set_text ("Floor");
1773 $INVR->set_items ($self->{container}{0});
1774 } elsif ($tag == $self->{player}{tag}) { 1800 } elsif ($tag == $self->{player}{tag}) {
1775 $INVR_LBL->set_text ("Player");
1776 $INV->set_items ($self->{container}{$self->{player}{tag}}) 1801 $INV->set_items ($self->{container}{$self->{player}{tag}})
1777 } else { 1802 } else {
1778 $OPENCONT = $tag; 1803 update_container ($tag);
1779 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1780 $INVR->set_items ($self->{container}{$tag});
1781 } 1804 }
1782 1805
1783 # $self-<{player}{tag} => player inv 1806 # $self-<{player}{tag} => player inv
1784 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1807 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1785} 1808}
1789 1812
1790 #d# print "container_clear: container $tag ($self->{player}{tag})\n"; 1813 #d# print "container_clear: container $tag ($self->{player}{tag})\n";
1791 1814
1792 if ($tag == 0) { 1815 if ($tag == 0) {
1793 update_floorbox; 1816 update_floorbox;
1794 $OPENCONT = 0;
1795 $INVR_LBL->set_text ("Floor");
1796 $INVR->set_items ($self->{container}{0});
1797 } elsif ($tag == $self->{player}{tag}) { 1817 } elsif ($tag == $self->{player}{tag}) {
1798 $INVR_LBL->set_text ("Player");
1799 $INV->set_items ($self->{container}{$tag}) 1818 $INV->set_items ($self->{container}{$tag})
1800 } else {
1801 $OPENCONT = $tag;
1802 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1803 $INVR->set_items ($self->{container}{$tag});
1804 } 1819 }
1805 1820
1806# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1821# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1807} 1822}
1808 1823
1812 for (@items) { 1827 for (@items) {
1813 #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n"; 1828 #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n";
1814 1829
1815 if ($_->{container} == 0) { 1830 if ($_->{container} == 0) {
1816 update_floorbox; 1831 update_floorbox;
1817 $OPENCONT = 0; 1832 update_container ($_->{tag});
1818 $INVR_LBL->set_text ("Floor");
1819 $INVR->set_items ($self->{container}{0});
1820 } elsif ($_->{container} == $self->{player}{tag}) { 1833 } elsif ($_->{container} == $self->{player}{tag}) {
1821 $INVR_LBL->set_text ("Player");
1822 $INV->set_items ($self->{container}{$self->{player}{tag}}) 1834 $INV->set_items ($self->{container}{$self->{player}{tag}})
1823 } else { 1835 } else {
1824 $OPENCONT = $_->{container}; 1836 update_container ($_->{tag});
1825 $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
1826 $INVR->set_items ($self->{container}{$_->{container}});
1827 } 1837 }
1828 } 1838 }
1829} 1839}
1830 1840
1831sub conn::item_update { 1841sub conn::item_update {
1832 my ($self, $item) = @_; 1842 my ($self, $item) = @_;
1833 1843
1834 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($OPENCONT)\n"; 1844 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($CONN->{open_container})\n";
1835 1845
1846 if ($item->{tag} == $self->{player}{tag}) {
1847 $STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000);
1848 return
1849 }
1850
1851 CFClient::Item::update_widgets $item;
1852
1836 if ($item->{tag} == $OPENCONT && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { 1853 if ($item->{tag} == $CONN->{open_container} && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) {
1837 $OPENCONT = 0; 1854 set_opencont ($CONN, 0, "Floor");
1838 $INVR_LBL->set_text ("Floor");
1839 $INVR->set_items ($self->{container}{0});
1840 1855
1841 $item->{widget}->update_item 1856 } elsif ($item->{flags} & Crossfire::Protocol::F_OPEN) {
1842 if $item->{widget}; 1857 set_opencont ($CONN, $item->{tag}, CFClient::Item::desc_string $item);
1843 } else { 1858 } else {
1844 if ($item->{container} == 0) { 1859 if ($item->{container} == 0) {
1845 update_floorbox; 1860 update_floorbox;
1846 $OPENCONT = 0;
1847 $INVR_LBL->set_text ("Floor");
1848 $INVR->set_items ($self->{container}{0});
1849 } elsif ($item->{container} == $self->{player}{tag}) { 1861 } elsif ($item->{container} == $self->{player}{tag}) {
1850 $INV->set_items ($self->{container}{$item->{container}}) 1862 $INV->set_items ($self->{container}{$item->{container}})
1851 } 1863 }
1852 } 1864 }
1853} 1865}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines