… | |
… | |
106 | our $INVR; |
106 | our $INVR; |
107 | our $INVR_LBL; |
107 | our $INVR_LBL; |
108 | our $OPENCONT; |
108 | our $OPENCONT; |
109 | |
109 | |
110 | sub status { |
110 | sub status { |
111 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]); |
111 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
112 | } |
112 | } |
113 | |
113 | |
114 | sub debug { |
114 | sub debug { |
115 | $DEBUG_STATUS->set_text ($_[0]); |
115 | $DEBUG_STATUS->set_text ($_[0]); |
116 | my ($w, $h) = $DEBUG_STATUS->size_request; |
116 | my ($w, $h) = $DEBUG_STATUS->size_request; |
… | |
… | |
743 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
743 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
744 | $table->add (1, 7, new CFClient::UI::Slider |
744 | $table->add (1, 7, new CFClient::UI::Slider |
745 | req_w => 100, |
745 | req_w => 100, |
746 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
746 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
747 | tooltip => "This is the size of the portion of the map update the server sends you. " |
747 | tooltip => "This is the size of the portion of the map update the server sends you. " |
748 | . "If you set this to a high value you will be able to see further for example.", |
748 | . "If you set this to a high value you will be able to see further, " |
|
|
749 | . "but you also increase bandwidht requirements and latency. " |
|
|
750 | . "This option is only used once at log-in.", |
749 | connect_changed => sub { |
751 | connect_changed => sub { |
750 | my ($self, $value) = @_; |
752 | my ($self, $value) = @_; |
751 | |
753 | |
752 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
754 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
753 | }, |
755 | }, |
754 | ); |
756 | ); |
755 | |
757 | |
|
|
758 | $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Face Prefetch"); |
|
|
759 | $table->add (1, 8, new CFClient::UI::CheckBox |
|
|
760 | state => $CFG->{face_prefetch}, |
|
|
761 | tooltip => "<b>Background Image Prefetch</b>\n\n" |
|
|
762 | . "If enabled, automatically pre-fetches images from the server. " |
|
|
763 | . "This might increase or create lag, but increases the chances " |
|
|
764 | . "of faces being ready for display when you encounter them. " |
|
|
765 | . "It also uses up server bandwidth on every connect, " |
|
|
766 | . "so only set it if you really need to prefetch images. " |
|
|
767 | . "This option can be set and unset any time.", |
|
|
768 | connect_changed => sub { $CFG->{face_prefetch} = $_[1] }, |
|
|
769 | ); |
|
|
770 | |
756 | $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Count"); |
771 | $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Count"); |
757 | $table->add (1, 8, new CFClient::UI::Entry |
772 | $table->add (1, 9, new CFClient::UI::Entry |
758 | text => $CFG->{output_count}, |
773 | text => $CFG->{output_count}, |
759 | tooltip => "Should be set to 1 unless you know what you are doing", |
774 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
760 | connect_changed => sub { $CFG->{output_count} = $_[1] }, |
775 | connect_changed => sub { $CFG->{output_count} = $_[1] }, |
761 | ); |
776 | ); |
762 | |
777 | |
763 | $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Sync"); |
778 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Sync"); |
764 | $table->add (1, 9, new CFClient::UI::Entry |
779 | $table->add (1, 10, new CFClient::UI::Entry |
765 | text => $CFG->{output_sync}, |
780 | text => $CFG->{output_sync}, |
766 | tooltip => "Should be set to 1 unless you know what you are doing", |
781 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
767 | connect_changed => sub { $CFG->{output_sync} = $_[1] }, |
782 | connect_changed => sub { $CFG->{output_sync} = $_[1] }, |
768 | ); |
783 | ); |
769 | |
784 | |
770 | $table->add (1, 10, $LOGIN_BUTTON = new CFClient::UI::Button |
785 | $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button |
771 | expand => 1, |
786 | expand => 1, |
772 | align => 0, |
787 | align => 0, |
773 | text => "Login", |
788 | text => "Login", |
774 | connect_activate => sub { |
789 | connect_activate => sub { |
775 | $CONN ? stop_game |
790 | $CONN ? stop_game |
… | |
… | |
1481 | gotid: |
1496 | gotid: |
1482 | $face->{id} = $id; |
1497 | $face->{id} = $id; |
1483 | $MAP->set_face ($facenum => $id); |
1498 | $MAP->set_face ($facenum => $id); |
1484 | $self->{faceid}[$facenum] = $id;#d# |
1499 | $self->{faceid}[$facenum] = $id;#d# |
1485 | |
1500 | |
1486 | $TILECACHE->get ($id) || do { |
1501 | my $face = $TILECACHE->get ($id); |
|
|
1502 | |
|
|
1503 | if ($face) { |
|
|
1504 | $self->face_prefetch; |
|
|
1505 | $face |
|
|
1506 | } else { |
1487 | my $tex = $self->{noface}; |
1507 | my $tex = $self->{noface}; |
1488 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1508 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1489 | undef |
1509 | undef |
1490 | }; |
1510 | }; |
1491 | } |
1511 | } |
… | |
… | |
1620 | join "\n", map "$time $_", split /\n/, $text); |
1640 | join "\n", map "$time $_", split /\n/, $text); |
1621 | |
1641 | |
1622 | $STATUSBOX->add ($text, |
1642 | $STATUSBOX->add ($text, |
1623 | group => $text, |
1643 | group => $text, |
1624 | fg => $color[$color], |
1644 | fg => $color[$color], |
1625 | timeout => 60, |
1645 | timeout => 10, |
1626 | tooltip_font => $::FONT_FIXED, |
1646 | tooltip_font => $::FONT_FIXED, |
1627 | ); |
1647 | ); |
1628 | } |
1648 | } |
1629 | |
1649 | |
1630 | sub conn::drawextinfo { |
1650 | sub conn::drawextinfo { |
… | |
… | |
1674 | sub conn::eof { |
1694 | sub conn::eof { |
1675 | $MAPWIDGET->clr_commands; |
1695 | $MAPWIDGET->clr_commands; |
1676 | |
1696 | |
1677 | stop_game; |
1697 | stop_game; |
1678 | } |
1698 | } |
|
|
1699 | |
|
|
1700 | sub conn::image_info { |
|
|
1701 | my ($self, $numfaces) = @_; |
|
|
1702 | |
|
|
1703 | $self->{num_faces} = $numfaces; |
|
|
1704 | $self->{face_prefetch} = [1 .. $numfaces]; |
|
|
1705 | $self->face_prefetch; |
|
|
1706 | } |
|
|
1707 | |
|
|
1708 | sub conn::face_prefetch { |
|
|
1709 | my ($self) = @_; |
|
|
1710 | |
|
|
1711 | return unless $CFG->{face_prefetch}; |
|
|
1712 | |
|
|
1713 | if ($self->{num_faces}) { |
|
|
1714 | return if @{ $self->{send_queue} || [] }; |
|
|
1715 | my $todo = @{ $self->{face_prefetch} } |
|
|
1716 | or return; |
|
|
1717 | |
|
|
1718 | my ($face) = splice @{ $self->{face_prefetch} }, 1 + rand @{ $self->{face_prefetch} }, 1, (); |
|
|
1719 | |
|
|
1720 | $self->send ("requestinfo image_sums $face $face"); |
|
|
1721 | |
|
|
1722 | $STATUSBOX->add (CFClient::UI::Label::escape "prefetching $todo", |
|
|
1723 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
|
|
1724 | } elsif (!exists $self->{num_faces}) { |
|
|
1725 | $self->send ("requestinfo image_info"); |
|
|
1726 | |
|
|
1727 | $self->{num_faces} = 0; |
|
|
1728 | |
|
|
1729 | $STATUSBOX->add (CFClient::UI::Label::escape "starting to prefetch", |
|
|
1730 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
|
|
1731 | } |
|
|
1732 | } |
|
|
1733 | |
|
|
1734 | # check once/second for faces that need to be prefetched |
|
|
1735 | |
|
|
1736 | Event->timer (after => 1, interval => 1, cb => sub { |
|
|
1737 | $CONN->face_prefetch |
|
|
1738 | if $CONN; |
|
|
1739 | }); |
1679 | |
1740 | |
1680 | sub update_floorbox { |
1741 | sub update_floorbox { |
1681 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1742 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1682 | return unless $CONN; |
1743 | return unless $CONN; |
1683 | |
1744 | |
… | |
… | |
1855 | host => "crossfire.schmorp.de", |
1916 | host => "crossfire.schmorp.de", |
1856 | say_command => 'say', |
1917 | say_command => 'say', |
1857 | audio_enable => 1, |
1918 | audio_enable => 1, |
1858 | bgm_enable => 1, |
1919 | bgm_enable => 1, |
1859 | bgm_volume => 0.25, |
1920 | bgm_volume => 0.25, |
|
|
1921 | face_prefetch => 0, |
1860 | output_sync => 1, |
1922 | output_sync => 1, |
1861 | output_count => 1, |
1923 | output_count => 1, |
1862 | ); |
1924 | ); |
1863 | |
1925 | |
1864 | while (my ($k, $v) = each %DEF_CFG) { |
1926 | while (my ($k, $v) = each %DEF_CFG) { |