… | |
… | |
103 | |
103 | |
104 | our $INVWIN; |
104 | our $INVWIN; |
105 | our $INV; |
105 | our $INV; |
106 | our $INVR; |
106 | our $INVR; |
107 | our $INVR_LBL; |
107 | our $INVR_LBL; |
108 | our $OPENCONT; |
|
|
109 | |
108 | |
110 | sub status { |
109 | sub 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, |
… | |
… | |
1247 | $MAPWIDGET->clr_commands; |
1257 | $MAPWIDGET->clr_commands; |
1248 | |
1258 | |
1249 | my $parser = new Pod::POM; |
1259 | my $parser = new Pod::POM; |
1250 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod"); |
1260 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod"); |
1251 | |
1261 | |
1252 | for my $head2 ($pod->head2) { |
1262 | for my $head2 ($pod->head1->[-2]->head2) { |
1253 | $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
1263 | $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
1254 | or next; |
1264 | or next; |
1255 | |
1265 | |
1256 | my $cmd = $1; |
1266 | my $cmd = $1; |
1257 | my @args = split /\|/, $2; |
1267 | my @args = split /\|/, $2; |
… | |
… | |
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 | |
1275 | sub conn::stats_update { |
1287 | sub conn::stats_update { |
… | |
… | |
1675 | my $parser = new Pod::POM; |
1687 | my $parser = new Pod::POM; |
1676 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
1688 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
1677 | |
1689 | |
1678 | my %skill_tooltip; |
1690 | my %skill_tooltip; |
1679 | |
1691 | |
1680 | for my $head2 ($pod->head2) { |
1692 | for my $head2 ($pod->head1->[-2]->head2) { |
1681 | $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; |
1693 | $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; |
1682 | } |
1694 | } |
1683 | |
1695 | |
1684 | for my $skill (values %{$self->{skill_info}}) { |
1696 | for my $skill (values %{$self->{skill_info}}) { |
1685 | $MAPWIDGET->add_command ("ready_skill $skill", |
1697 | $MAPWIDGET->add_command ("ready_skill $skill", |
… | |
… | |
1743 | sub update_floorbox { |
1755 | sub update_floorbox { |
1744 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1756 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1745 | return unless $CONN; |
1757 | return unless $CONN; |
1746 | |
1758 | |
1747 | $FLOORBOX->clear; |
1759 | $FLOORBOX->clear; |
1748 | $FLOORBOX->add (0, 1, new CFClient::UI::Empty expand => 1); |
|
|
1749 | |
1760 | |
1750 | my $row; |
1761 | my $row; |
1751 | for (@{ $CONN->{container}{0} }) { |
1762 | for (@{ $CONN->{container}{0} }) { |
1752 | if (++$row < 7) { |
1763 | if ($row < 7) { |
1753 | local $_->{face_widget}; # hack to force recreation of widget |
1764 | local $_->{face_widget}; # hack to force recreation of widget |
1754 | local $_->{desc_widget}; # hack to force recreation of widget |
1765 | local $_->{desc_widget}; # hack to force recreation of widget |
1755 | CFClient::Item::update_widgets $_; |
1766 | CFClient::Item::update_widgets $_; |
1756 | |
1767 | |
1757 | $FLOORBOX->add (0, $row, $_->{face_widget}); |
1768 | $FLOORBOX->add (0, $row, $_->{face_widget}); |
1758 | $FLOORBOX->add (1, $row, $_->{desc_widget}); |
1769 | $FLOORBOX->add (1, $row, $_->{desc_widget}); |
|
|
1770 | |
|
|
1771 | $row++; |
1759 | } else { |
1772 | } else { |
1760 | $FLOORBOX->add (new CFClient::UI::Label text => "More..."); |
1773 | $FLOORBOX->add (1, $row, new CFClient::UI::Label text => "More..."); |
1761 | last; |
1774 | last; |
1762 | } |
1775 | } |
1763 | } |
1776 | } |
1764 | }); |
1777 | }); |
1765 | |
1778 | |
1766 | $WANT_REFRESH++; |
1779 | $WANT_REFRESH++; |
1767 | } |
1780 | } |
1768 | |
1781 | |
|
|
1782 | sub set_opencont { |
|
|
1783 | my ($conn, $tag, $name) = @_; |
|
|
1784 | $conn->{open_container} = $tag; |
|
|
1785 | $INVR_LBL->set_text ($name); |
|
|
1786 | $INVR->set_items ($conn->{container}{$tag}); |
|
|
1787 | } |
|
|
1788 | |
|
|
1789 | sub update_container { |
|
|
1790 | my ($tag) = @_; |
|
|
1791 | $INVR->set_items ($::CONN->{container}{$CONN->{open_container}}) |
|
|
1792 | if $tag == $CONN->{open_container}; |
|
|
1793 | } |
|
|
1794 | |
1769 | sub conn::container_add { |
1795 | sub conn::container_add { |
1770 | my ($self, $tag, $items) = @_; |
1796 | my ($self, $tag, $items) = @_; |
1771 | |
1797 | |
1772 | #d# print "container_add: container $tag ($self->{player}{tag})\n"; |
1798 | #d# print "container_add: container $tag ($self->{player}{tag})\n"; |
1773 | |
1799 | |
1774 | if ($tag == 0) { |
1800 | if ($tag == 0) { |
1775 | update_floorbox; |
1801 | update_floorbox; |
1776 | $OPENCONT = 0; |
1802 | update_container (0); |
1777 | $INVR_LBL->set_text ("Floor"); |
|
|
1778 | $INVR->set_items ($self->{container}{0}); |
|
|
1779 | } elsif ($tag == $self->{player}{tag}) { |
1803 | } elsif ($tag == $self->{player}{tag}) { |
1780 | $INVR_LBL->set_text ("Player"); |
|
|
1781 | $INV->set_items ($self->{container}{$self->{player}{tag}}) |
1804 | $INV->set_items ($self->{container}{$self->{player}{tag}}) |
1782 | } else { |
1805 | } else { |
1783 | $OPENCONT = $tag; |
1806 | update_container ($tag); |
1784 | $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); |
|
|
1785 | $INVR->set_items ($self->{container}{$tag}); |
|
|
1786 | } |
1807 | } |
1787 | |
1808 | |
1788 | # $self-<{player}{tag} => player inv |
1809 | # $self-<{player}{tag} => player inv |
1789 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1810 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1790 | } |
1811 | } |
… | |
… | |
1794 | |
1815 | |
1795 | #d# print "container_clear: container $tag ($self->{player}{tag})\n"; |
1816 | #d# print "container_clear: container $tag ($self->{player}{tag})\n"; |
1796 | |
1817 | |
1797 | if ($tag == 0) { |
1818 | if ($tag == 0) { |
1798 | update_floorbox; |
1819 | update_floorbox; |
1799 | $OPENCONT = 0; |
1820 | update_container (0); |
1800 | $INVR_LBL->set_text ("Floor"); |
|
|
1801 | $INVR->set_items ($self->{container}{0}); |
|
|
1802 | } elsif ($tag == $self->{player}{tag}) { |
1821 | } elsif ($tag == $self->{player}{tag}) { |
1803 | $INVR_LBL->set_text ("Player"); |
|
|
1804 | $INV->set_items ($self->{container}{$tag}) |
1822 | $INV->set_items ($self->{container}{$tag}) |
1805 | } else { |
|
|
1806 | $OPENCONT = $tag; |
|
|
1807 | $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); |
|
|
1808 | $INVR->set_items ($self->{container}{$tag}); |
|
|
1809 | } |
1823 | } |
1810 | |
1824 | |
1811 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1825 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1812 | } |
1826 | } |
1813 | |
1827 | |
… | |
… | |
1817 | for (@items) { |
1831 | for (@items) { |
1818 | #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n"; |
1832 | #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n"; |
1819 | |
1833 | |
1820 | if ($_->{container} == 0) { |
1834 | if ($_->{container} == 0) { |
1821 | update_floorbox; |
1835 | update_floorbox; |
1822 | $OPENCONT = 0; |
1836 | update_container ($_->{tag}); |
1823 | $INVR_LBL->set_text ("Floor"); |
|
|
1824 | $INVR->set_items ($self->{container}{0}); |
|
|
1825 | } elsif ($_->{container} == $self->{player}{tag}) { |
1837 | } elsif ($_->{container} == $self->{player}{tag}) { |
1826 | $INVR_LBL->set_text ("Player"); |
|
|
1827 | $INV->set_items ($self->{container}{$self->{player}{tag}}) |
1838 | $INV->set_items ($self->{container}{$self->{player}{tag}}) |
1828 | } else { |
1839 | } else { |
1829 | $OPENCONT = $_->{container}; |
1840 | update_container ($_->{tag}); |
1830 | $INVR_LBL->set_text (CFClient::Item::desc_string $self->{item}->{$OPENCONT}); |
|
|
1831 | $INVR->set_items ($self->{container}{$_->{container}}); |
|
|
1832 | } |
1841 | } |
1833 | } |
1842 | } |
1834 | } |
1843 | } |
1835 | |
1844 | |
1836 | sub conn::item_update { |
1845 | sub conn::item_update { |
1837 | my ($self, $item) = @_; |
1846 | my ($self, $item) = @_; |
1838 | |
1847 | |
1839 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($OPENCONT)\n"; |
1848 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($CONN->{open_container})\n"; |
1840 | |
1849 | |
|
|
1850 | if ($item->{tag} == $self->{player}{tag}) { |
|
|
1851 | $STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000); |
|
|
1852 | return |
|
|
1853 | } |
|
|
1854 | |
|
|
1855 | CFClient::Item::update_widgets $item; |
|
|
1856 | |
1841 | if ($item->{tag} == $OPENCONT && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { |
1857 | if ($item->{tag} == $CONN->{open_container} && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) { |
1842 | $OPENCONT = 0; |
1858 | set_opencont ($CONN, 0, "Floor"); |
1843 | $INVR_LBL->set_text ("Floor"); |
|
|
1844 | $INVR->set_items ($self->{container}{0}); |
|
|
1845 | |
1859 | |
1846 | $item->{widget}->update_item |
1860 | } elsif ($item->{flags} & Crossfire::Protocol::F_OPEN) { |
1847 | if $item->{widget}; |
1861 | set_opencont ($CONN, $item->{tag}, CFClient::Item::desc_string $item); |
1848 | } else { |
1862 | } else { |
1849 | if ($item->{container} == 0) { |
1863 | if ($item->{container} == 0) { |
1850 | update_floorbox; |
1864 | update_floorbox; |
1851 | $OPENCONT = 0; |
1865 | update_container (0); |
1852 | $INVR_LBL->set_text ("Floor"); |
|
|
1853 | $INVR->set_items ($self->{container}{0}); |
|
|
1854 | } elsif ($item->{container} == $self->{player}{tag}) { |
1866 | } elsif ($item->{container} == $self->{player}{tag}) { |
1855 | $INV->set_items ($self->{container}{$item->{container}}) |
1867 | $INV->set_items ($self->{container}{$item->{container}}) |
1856 | } |
1868 | } |
1857 | } |
1869 | } |
1858 | } |
1870 | } |