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

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.243 by root, Wed May 24 03:29:20 2006 UTC vs.
Revision 1.252 by root, Thu May 25 03:43:48 2006 UTC

106our $INVR; 106our $INVR;
107our $INVR_LBL; 107our $INVR_LBL;
108our $OPENCONT; 108our $OPENCONT;
109 109
110sub status { 110sub 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
114sub debug { 114sub 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;
342 audio_shutdown (); 342 audio_shutdown ();
343 audio_init (); 343 audio_init ();
344 } 344 }
345 ); 345 );
346 346
347 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd"); 347 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Chat Command");
348 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry 348 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry
349 text => $CFG->{say_command}, 349 text => $CFG->{say_command},
350 tooltip => "This is the command that will be used if you write a line in the message window entry. " 350 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. "
351 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 351 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
352 ."But you could also set it to 'tell &lt;playername&gt;' to only chat with that user.", 352 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
353 connect_changed => sub { 353 connect_changed => sub {
354 my ($self, $value) = @_; 354 my ($self, $value) = @_;
355 $CFG->{say_command} = $value; 355 $CFG->{say_command} = $value;
356 } 356 }
357 ); 357 );
367 367
368sub set_gauge_window_fontsize { 368sub set_gauge_window_fontsize {
369 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 369 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
370 $_->set_fontsize ($::CFG->{gauge_fontsize}); 370 $_->set_fontsize ($::CFG->{gauge_fontsize});
371 } 371 }
372
373# local $GAUGES->{win}{parent};#d#
374# use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D;
375} 372}
376 373
377sub make_gauge_window { 374sub make_gauge_window {
378 my $gh = int $HEIGHT * $CFG->{gauge_size}; 375 my $gh = int $HEIGHT * $CFG->{gauge_size};
379 376
746 $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");
747 $table->add (1, 7, new CFClient::UI::Slider 744 $table->add (1, 7, new CFClient::UI::Slider
748 req_w => 100, 745 req_w => 100,
749 range => [$CFG->{mapsize}, 10, 100, 0, 1], 746 range => [$CFG->{mapsize}, 10, 100, 0, 1],
750 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. "
751 . "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.",
752 connect_changed => sub { 751 connect_changed => sub {
753 my ($self, $value) = @_; 752 my ($self, $value) = @_;
754 753
755 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 754 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
756 }, 755 },
757 ); 756 );
758 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, the client 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
759 $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");
760 $table->add (1, 8, new CFClient::UI::Entry 772 $table->add (1, 9, new CFClient::UI::Entry
761 text => $CFG->{output_count}, 773 text => $CFG->{output_count},
762 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.",
763 connect_changed => sub { $CFG->{output_count} = $_[1] }, 775 connect_changed => sub { $CFG->{output_count} = $_[1] },
764 ); 776 );
765 777
766 $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");
767 $table->add (1, 9, new CFClient::UI::Entry 779 $table->add (1, 10, new CFClient::UI::Entry
768 text => $CFG->{output_sync}, 780 text => $CFG->{output_sync},
769 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.",
770 connect_changed => sub { $CFG->{output_sync} = $_[1] }, 782 connect_changed => sub { $CFG->{output_sync} = $_[1] },
771 ); 783 );
772 784
773 $table->add (1, 10, $LOGIN_BUTTON = new CFClient::UI::Button 785 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button
774 expand => 1, 786 expand => 1,
775 align => 0, 787 align => 0,
776 text => "Login", 788 text => "Login",
777 connect_activate => sub { 789 connect_activate => sub {
778 $CONN ? stop_game 790 $CONN ? stop_game
843 $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?"; 855 $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?";
844 856
845 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); 857 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1);
846 858
847 $vb->add (new CFClient::UI::Label 859 $vb->add (new CFClient::UI::Label
848 text => "You should find a savebed and apply it first!", 860 text => "You should find a savebed and apply it first!",
849 max_w => $WIDTH * 0.25 861 max_w => $WIDTH * 0.25,
862 ellipsize => 0,
850 ); 863 );
851 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 864 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
852 $hb->add (new CFClient::UI::Button 865 $hb->add (new CFClient::UI::Button
853 text => "Ok", 866 text => "Ok",
867 expand => 1,
854 connect_activate => sub { $QUIT_DIALOG->hide }, 868 connect_activate => sub { $QUIT_DIALOG->hide },
855 expand => 1
856 ); 869 );
857 $hb->add (new CFClient::UI::Button 870 $hb->add (new CFClient::UI::Button
858 text => "Quit anyway", 871 text => "Quit anyway",
872 expand => 1,
859 connect_activate => sub { exit 1 }, 873 connect_activate => sub { exit },
860 expand => 1
861 ); 874 );
862 $hb->add (new CFClient::UI::Label "You should find a savebed and apply it first!");
863 875
864 $QUIT_DIALOG->show_centered; 876 $QUIT_DIALOG->show_centered;
865 } else { 877 } else {
866 $QUIT_DIALOG->show_centered; 878 $QUIT_DIALOG->show_centered;
867 } 879 }
895 $vbox->add (my $buttons = new CFClient::UI::HBox); 907 $vbox->add (my $buttons = new CFClient::UI::HBox);
896 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); 908 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8);
897 909
898 for ( 910 for (
899 [intro => "Introduction"], 911 [intro => "Introduction"],
912 [manual => "Manual"],
900 [command_help => "Commands"], 913 [command_help => "Commands"],
901 [skill_help => "Skills"], 914 [skill_help => "Skills"],
902 ) { 915 ) {
903 my ($pod, $label) = @$_; 916 my ($pod, $label) = @$_;
904 917
931sub video_init { 944sub video_init {
932 sdl_init; 945 sdl_init;
933 946
934 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; 947 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
935 948
949 my ($old_w, $old_h) = ($WIDTH, $HEIGHT);
950
936 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 951 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
937 $FULLSCREEN = $CFG->{fullscreen}; 952 $FULLSCREEN = $CFG->{fullscreen};
938 $FAST = $CFG->{fast}; 953 $FAST = $CFG->{fast};
939 954
940 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 955 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
949 964
950 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 965 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
951 966
952 ############################################################################# 967 #############################################################################
953 968
954 unless ($DEBUG_STATUS) { 969 if ($DEBUG_STATUS) {
970 CFClient::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
971 } else {
955 # create the widgets 972 # create the widgets
956 973
957 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1; 974 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1;
958 $DEBUG_STATUS->show; 975 $DEBUG_STATUS->show;
959 976
1009 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 1026 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
1010 1027
1011 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D 1028 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
1012 1029
1013 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, 1030 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window,
1014 tooltip => "Toggles the statistics window, where all your Stats and Resistances are beign displaye at all times."); 1031 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times.");
1015 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, 1032 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window,
1016 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."); 1033 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :).");
1017 1034
1018 $BUTTONBAR->add (new CFClient::UI::Button 1035 $BUTTONBAR->add (new CFClient::UI::Button
1019 text => "Save Config", 1036 text => "Save Config",
1356 1373
1357 return; 1374 return;
1358 } 1375 }
1359 } 1376 }
1360 1377
1361 $self->SUPER::send_mapinfo ($data, $cb); 1378 $self->Crossfire::Protocol::send_mapinfo ($data, $cb);
1362} 1379}
1363 1380
1364# this method does a "flood fill" into every tile direction 1381# this method does a "flood fill" into every tile direction
1365# it assumes that tiles are arranged in a rectangular grid, 1382# it assumes that tiles are arranged in a rectangular grid,
1366# i.e. a map is the same as the left of the right map etc. 1383# i.e. a map is the same as the left of the right map etc.
1479gotid: 1496gotid:
1480 $face->{id} = $id; 1497 $face->{id} = $id;
1481 $MAP->set_face ($facenum => $id); 1498 $MAP->set_face ($facenum => $id);
1482 $self->{faceid}[$facenum] = $id;#d# 1499 $self->{faceid}[$facenum] = $id;#d#
1483 1500
1484 $TILECACHE->get ($id) || do { 1501 my $face = $TILECACHE->get ($id);
1502
1503 if ($face) {
1504 $self->face_prefetch;
1505 $face
1506 } else {
1485 my $tex = $self->{noface}; 1507 my $tex = $self->{noface};
1486 $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}});
1487 undef 1509 undef
1488 }; 1510 };
1489} 1511}
1536 title => "Query", 1558 title => "Query",
1537 child => my $vbox = new CFClient::UI::VBox; 1559 child => my $vbox = new CFClient::UI::VBox;
1538 1560
1539 $vbox->add (new CFClient::UI::Label 1561 $vbox->add (new CFClient::UI::Label
1540 max_w => $::WIDTH * 0.4, 1562 max_w => $::WIDTH * 0.4,
1563 ellipsise => 0,
1541 text => $prompt); 1564 text => $prompt);
1542 1565
1543 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) { 1566 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) {
1544 $vbox->add (my $hbox = new CFClient::HBox); 1567 $vbox->add (my $hbox = new CFClient::HBox);
1545 $hbox->add (new CFClient::Button 1568 $hbox->add (new CFClient::Button
1553 $hbox->add (new CFClient::Button 1576 $hbox->add (new CFClient::Button
1554 text => "Yes", 1577 text => "Yes",
1555 connect_activate => sub { 1578 connect_activate => sub {
1556 $self->send ("reply y"); 1579 $self->send ("reply y");
1557 $dialog->destroy; 1580 $dialog->destroy;
1558 $MAPWIDGET->focus_in;
1559 }, 1581 },
1560 ); 1582 );
1561 1583
1562 $dialog->focus_in; 1584 $dialog->focus_in;
1563 1585
1565 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 1587 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
1566 $vbox->add (my $entry = new CFClient::UI::Entry 1588 $vbox->add (my $entry = new CFClient::UI::Entry
1567 connect_changed => sub { 1589 connect_changed => sub {
1568 $self->send ("reply $_[1]"); 1590 $self->send ("reply $_[1]");
1569 $dialog->destroy; 1591 $dialog->destroy;
1570 $MAPWIDGET->focus_in;
1571 }, 1592 },
1572 ); 1593 );
1573 1594
1574 $entry->focus_in; 1595 $entry->focus_in;
1575 1596
1579 $vbox->add (my $entry = new CFClient::UI::Entry 1600 $vbox->add (my $entry = new CFClient::UI::Entry
1580 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), 1601 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
1581 connect_activate => sub { 1602 connect_activate => sub {
1582 $self->send ("reply $_[1]"); 1603 $self->send ("reply $_[1]");
1583 $dialog->destroy; 1604 $dialog->destroy;
1584 $MAPWIDGET->focus_in;
1585 }, 1605 },
1586 ); 1606 );
1587 1607
1588 $entry->focus_in; 1608 $entry->focus_in;
1589 } 1609 }
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
1630sub conn::drawextinfo { 1650sub conn::drawextinfo {
1674sub conn::eof { 1694sub conn::eof {
1675 $MAPWIDGET->clr_commands; 1695 $MAPWIDGET->clr_commands;
1676 1696
1677 stop_game; 1697 stop_game;
1678} 1698}
1699
1700sub 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
1708sub 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# this should, of course, only run on demand, but
1736# SDL forces worse things on us....
1737
1738Event->timer (after => 1, interval => 1, cb => sub {
1739 $CONN->face_prefetch
1740 if $CONN;
1741});
1679 1742
1680sub update_floorbox { 1743sub update_floorbox {
1681 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1744 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1682 return unless $CONN; 1745 return unless $CONN;
1683 1746
1855 host => "crossfire.schmorp.de", 1918 host => "crossfire.schmorp.de",
1856 say_command => 'say', 1919 say_command => 'say',
1857 audio_enable => 1, 1920 audio_enable => 1,
1858 bgm_enable => 1, 1921 bgm_enable => 1,
1859 bgm_volume => 0.25, 1922 bgm_volume => 0.25,
1923 face_prefetch => 0,
1860 output_sync => 1, 1924 output_sync => 1,
1861 output_count => 1, 1925 output_count => 1,
1862 ); 1926 );
1863 1927
1864 while (my ($k, $v) = each %DEF_CFG) { 1928 while (my ($k, $v) = each %DEF_CFG) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines