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.223 by elmex, Wed May 17 14:55:15 2006 UTC vs.
Revision 1.230 by root, Fri May 19 23:18:42 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6# do things only needed for single-binary version (par)
6BEGIN { 7BEGIN {
7 if (%PAR::LibCache) { 8 if (%PAR::LibCache) {
8 @INC = grep ref, @INC; # weed out all paths except pars loader refs 9 @INC = grep ref, @INC; # weed out all paths except pars loader refs
9 10
10 while (my ($filename, $zip) = each %PAR::LibCache) { 11 while (my ($filename, $zip) = each %PAR::LibCache) {
13 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1") 14 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
14 unless -e "$ENV{PAR_TEMP}/$1"; 15 unless -e "$ENV{PAR_TEMP}/$1";
15 } 16 }
16 } 17 }
17 18
19 # TODO: pango-rc file, anybody?
20
18 unshift @INC, $ENV{PAR_TEMP}; 21 unshift @INC, $ENV{PAR_TEMP};
19
20 if ($^O eq "MSWin32") {
21 $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc";
22 }
23 } 22 }
24} 23}
25 24
26# need to do it again because that pile of garbage called PAR nukes it before main 25# need to do it again because that pile of garbage called PAR nukes it before main
27unshift @INC, $ENV{PAR_TEMP}; 26unshift @INC, $ENV{PAR_TEMP}
27 if %PAR::LibCache;
28 28
29use Time::HiRes 'time'; 29use Time::HiRes 'time';
30use Pod::POM;
30use Event; 31use Event;
31 32
32use Crossfire; 33use Crossfire;
33use Crossfire::Protocol; 34use Crossfire::Protocol;
34 35
104our $INVR; 105our $INVR;
105our $INVR_LBL; 106our $INVR_LBL;
106our $OPENCONT; 107our $OPENCONT;
107 108
108sub status { 109sub status {
109 $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]); 110 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]);
110} 111}
111 112
112sub debug { 113sub debug {
113 $DEBUG_STATUS->set_text ($_[0]); 114 $DEBUG_STATUS->set_text ($_[0]);
114 my ($w, $h) = $DEBUG_STATUS->size_request; 115 my ($w, $h) = $DEBUG_STATUS->size_request;
135 maph => $mapsize, 136 maph => $mapsize,
136 ; 137 ;
137 }; 138 };
138 139
139 if ($CONN) { 140 if ($CONN) {
141 CFClient::lowdelay fileno $CONN->{fh};
142
140 $LOGIN_BUTTON->set_text ("Logout"); 143 $LOGIN_BUTTON->set_text ("Logout");
141
142 status "login successful"; 144 status "login successful";
143 145
144 CFClient::lowdelay fileno $CONN->{fh}; 146 $BUTTONBAR->{children}[1]->emit ("activate")
147 if $BUTTONBAR->{children}[1]->{state};
148
145 } else { 149 } else {
146 status "unable to connect"; 150 status "unable to connect";
147 stop_game(); 151 stop_game();
148 } 152 }
149} 153}
153 157
154 status "connection closed"; 158 status "connection closed";
155 $LOGIN_BUTTON->set_text ("Login"); 159 $LOGIN_BUTTON->set_text ("Login");
156 $CONN->destroy; 160 $CONN->destroy;
157 $CONN = 0; # false, does not autovivify 161 $CONN = 0; # false, does not autovivify
162
163 $BUTTONBAR->{children}[1]->emit ("activate")
164 unless $BUTTONBAR->{children}[1]->{state};
158 165
159 undef $MAPCACHE; 166 undef $MAPCACHE;
160 undef $MAP; 167 undef $MAP;
161} 168}
162 169
666 $HOST->set_text ($CFG->{host} = $host); 673 $HOST->set_text ($CFG->{host} = $host);
667 }), 674 }),
668 (new CFClient::UI::Empty expand => 1), 675 (new CFClient::UI::Empty expand => 1),
669 ]); 676 ]);
670 677
671 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) 678 $table->add ($_ + 1, $y, new CFClient::UI::Label
679 ellipsise => 0, align => $align[$_], text => $m->[$_], fontsize => 0.8)
672 for 0 .. $#$m; 680 for 0 .. $#$m;
673 } 681 }
674 } 682 }
675 }); 683 });
676} 684}
742 750
743 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 751 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
744 }, 752 },
745 ); 753 );
746 754
755 $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Count");
756 $table->add (1, 8, new CFClient::UI::Entry
757 text => $CFG->{output_count},
758 tooltip => "Should be set to 1 unless you know what you are doing",
759 connect_changed => sub { $CFG->{output_count} = $_[1] },
760 );
761
762 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Sync");
763 $table->add (1, 9, new CFClient::UI::Entry
764 text => $CFG->{output_sync},
765 tooltip => "Should be set to 1 unless you know what you are doing",
766 connect_changed => sub { $CFG->{output_sync} = $_[1] },
767 );
768
747 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button 769 $table->add (1, 10, $LOGIN_BUTTON = new CFClient::UI::Button
748 expand => 1, 770 expand => 1,
749 align => 0, 771 align => 0,
750 text => "Login", 772 text => "Login",
751 connect_activate => sub { 773 connect_activate => sub {
752 $CONN ? stop_game 774 $CONN ? stop_game
764 bg => [0, 0, 0, 0.5], 786 bg => [0, 0, 0, 0.5],
765 user_w => int $::WIDTH / 3, 787 user_w => int $::WIDTH / 3,
766 user_h => int $::HEIGHT / 5, 788 user_h => int $::HEIGHT / 5,
767 child => (my $vbox = new CFClient::UI::VBox); 789 child => (my $vbox = new CFClient::UI::VBox);
768 790
769 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 791 $vbox->add ($LOGVIEW);
770 expand => 1,
771 font => $FONT_FIXED,
772 fontsize => $::CFG->{log_fontsize},
773 );
774 792
775 $vbox->add (my $input = new CFClient::UI::Entry 793 $vbox->add (my $input = new CFClient::UI::Entry
776 connect_focus_in => sub { 794 connect_focus_in => sub {
777 my ($input, $prev_focus) = @_; 795 my ($input, $prev_focus) = @_;
778 796
813 831
814sub make_inventory_window { 832sub make_inventory_window {
815 my $invwin = new CFClient::UI::FancyFrame 833 my $invwin = new CFClient::UI::FancyFrame
816 user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; 834 user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory";
817 835
818 $invwin->add (my $hb = new CFClient::UI::HBox); 836 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1);
819 837
820 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); 838 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1);
821 $vb1->add (my $lbl = new CFClient::UI::Label); 839 $vb1->add (my $lbl = new CFClient::UI::Label);
822 $lbl->set_text ("Player"); 840 $lbl->set_text ("Player");
823 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 841 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1);
843 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 861 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
844 $FULLSCREEN = $CFG->{fullscreen}; 862 $FULLSCREEN = $CFG->{fullscreen};
845 $FAST = $CFG->{fast}; 863 $FAST = $CFG->{fast};
846 864
847 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 865 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
848 or die "SDL_SetVideoMode failed!\n"; 866 or die "SDL_SetVideoMode failed: " . (CFClient::SDL_GetError) . "\n";
849 867
850 $SDL_ACTIVE = 1; 868 $SDL_ACTIVE = 1;
851 $LAST_REFRESH = time - 0.01; 869 $LAST_REFRESH = time - 0.01;
852 870
853 CFClient::gl_init; 871 CFClient::gl_init;
893 } 911 }
894 }); 912 });
895 $MAPWIDGET->show; 913 $MAPWIDGET->show;
896 $MAPWIDGET->focus_in; 914 $MAPWIDGET->focus_in;
897 915
916 $LOGVIEW = new CFClient::UI::TextView
917 expand => 1,
918 font => $FONT_FIXED,
919 fontsize => $::CFG->{log_fontsize},
920 ;
921
898 $BUTTONBAR = new CFClient::UI::HBox; 922 $BUTTONBAR = new CFClient::UI::HBox;
899 923
900 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 924 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
901 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 925 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
902 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 926 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
933my $bgmusic;#TODO#hack#d# 957my $bgmusic;#TODO#hack#d#
934 958
935sub audio_channel_finished { 959sub audio_channel_finished {
936 my ($channel) = @_; 960 my ($channel) = @_;
937 961
938 warn "channel $channel finished\n";#d# 962 #warn "channel $channel finished\n";#d#
939} 963}
940 964
941sub audio_music_finished { 965sub audio_music_finished {
942 return unless $CFG->{bgm_enable}; 966 return unless $CFG->{bgm_enable};
943 967
1029 delete $animate_object{$widget}; 1053 delete $animate_object{$widget};
1030} 1054}
1031 1055
1032@conn::ISA = Crossfire::Protocol::; 1056@conn::ISA = Crossfire::Protocol::;
1033 1057
1058sub conn::new {
1059 my $class = shift;
1060
1061 my $self = $class->Crossfire::Protocol::new (@_);
1062
1063 $MAPWIDGET->clr_commands;
1064
1065 my $parser = new Pod::POM;
1066 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod");
1067
1068 for my $head2 ($pod->head2) {
1069 $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
1070 or next;
1071
1072 my $cmd = $1;
1073 my @args = split /\|/, $2;
1074 @args = (".*") unless @args;
1075
1076 my $text = CFClient::pod_to_pango $head2->content;
1077
1078 for my $arg (@args) {
1079 $arg = $arg eq ".*" ? "" : " $arg";
1080
1081 $MAPWIDGET->add_command ("$cmd$arg", $text);
1082 }
1083 }
1084
1085 $self
1086}
1087
1034sub conn::stats_update { 1088sub conn::stats_update {
1035 my ($self, $stats) = @_; 1089 my ($self, $stats) = @_;
1090
1091 if (my $exp = $stats->{Crossfire::Protocol::CS_STAT_EXP64}) {
1092 my $diff = $exp - $self->{prev_exp};
1093 $STATUSBOX->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5)
1094 if exists $self->{prev_exp} && $diff;
1095 $self->{prev_exp} = $exp;
1096 }
1036 1097
1037 update_stats_window ($stats); 1098 update_stats_window ($stats);
1038} 1099}
1039 1100
1040sub conn::user_send { 1101sub conn::user_send {
1365sub conn::spell_add { 1426sub conn::spell_add {
1366 my ($self, $spell) = @_; 1427 my ($self, $spell) = @_;
1367 1428
1368 # TODO 1429 # TODO
1369 # create a widget dynamically, using spell face (CF::Protocol downloads them) 1430 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1370 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}); 1431 $MAPWIDGET->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
1371 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}); 1432 $MAPWIDGET->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
1372} 1433}
1373 1434
1374sub conn::spell_delete { 1435sub conn::spell_delete {
1375 my ($self, $spell) = @_; 1436 my ($self, $spell) = @_;
1376} 1437}
1377 1438
1378sub conn::addme_success { 1439sub conn::addme_success {
1379 my ($self) = @_; 1440 my ($self) = @_;
1380 1441
1381 $MAPWIDGET->clr_commands; 1442 $self->send ("command output-sync $CFG->{output_sync}");
1443 $self->send ("command output-count $CFG->{output_count}");
1382 1444
1383 for my $skill (values %{$self->{skill_info}}) { 1445 for my $skill (values %{$self->{skill_info}}) {
1384 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1446 $MAPWIDGET->add_command ("ready_skill $skill", CFClient::UI::Label::escape "Ready the skill '$skill'");
1385 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1447 $MAPWIDGET->add_command ("use_skill $skill", CFClient::UI::Label::escape "Immediately use the skill '$skill'");
1386 } 1448 }
1387
1388 $MAPWIDGET->add_command ("petmode defend", "Tell pets to stay close to you and defend you");
1389 $MAPWIDGET->add_command ("petmode arena", "Same as petmode sad, but also attack other players");
1390 $MAPWIDGET->add_command ("petmode sad", "Search & Destroy - tell pets to roam about and attack enemies");
1391 $MAPWIDGET->add_command ("killpets", "Kill your pets");
1392 $MAPWIDGET->add_command ("chat", "chat TEXT\nChat with all other players");
1393 $MAPWIDGET->add_command ("shout", "shout TEXT\nShout loudly, used for emergencies");
1394 $MAPWIDGET->add_command ("tell", "tell USERNAME TEXT\nPrivately tell a specific player");
1395
1396 # TODO: add documentation on these
1397 for (qw(
1398 afk
1399 apply
1400 body
1401 bowmode
1402 brace
1403 build
1404 disarm
1405 dm
1406 dmhide
1407 drop
1408 dropall
1409 examine
1410 get
1411 gsay
1412 help
1413 hiscore
1414 inventory
1415 invoke
1416 killpets
1417 listen
1418 logs
1419 mapinfo
1420 maps
1421 mark
1422 motd
1423 output-count
1424 output-sync
1425 party
1426 peaceful
1427 petmode
1428 pickup
1429 players
1430 prepare
1431 quests
1432 rename
1433 resistances
1434 rotateshoottype
1435 save
1436 say
1437 search
1438 search-items
1439 showpets
1440 skills
1441 sound
1442 take
1443 throw
1444 time
1445 title
1446 usekeys
1447 version
1448 weather
1449 whereabouts
1450 whereami
1451 who
1452 wimpy
1453 )) {
1454 $MAPWIDGET->add_command ($_, "$_: no help available (yet)");
1455 }
1456
1457 #TODO: add " and ' "aliases" etc.
1458} 1449}
1459 1450
1460sub conn::eof { 1451sub conn::eof {
1461 $MAPWIDGET->clr_commands; 1452 $MAPWIDGET->clr_commands;
1462 1453
1626 sdl_mode => 0, 1617 sdl_mode => 0,
1627 width => 640, 1618 width => 640,
1628 height => 480, 1619 height => 480,
1629 fullscreen => 0, 1620 fullscreen => 0,
1630 fast => 0, 1621 fast => 0,
1631 map_scale => 0.5, 1622 map_scale => 1,
1632 fow_enable => 1, 1623 fow_enable => 1,
1633 fow_intensity => 0.45, 1624 fow_intensity => 0.45,
1634 fow_smooth => 0, 1625 fow_smooth => 0,
1635 gui_fontsize => 1, 1626 gui_fontsize => 1,
1636 log_fontsize => 1, 1627 log_fontsize => 1,
1641 host => "crossfire.schmorp.de", 1632 host => "crossfire.schmorp.de",
1642 say_command => 'say', 1633 say_command => 'say',
1643 audio_enable => 1, 1634 audio_enable => 1,
1644 bgm_enable => 1, 1635 bgm_enable => 1,
1645 bgm_volume => 0.25, 1636 bgm_volume => 0.25,
1637 output_sync => 1,
1638 output_count => 1,
1646 ); 1639 );
1647 1640
1648 while (my ($k, $v) = each %DEF_CFG) { 1641 while (my ($k, $v) = each %DEF_CFG) {
1649 $CFG->{$k} = $v unless exists $CFG->{$k}; 1642 $CFG->{$k} = $v unless exists $CFG->{$k};
1650 } 1643 }
1755 1748
1756Typing B<climb> will display a list of commands with I<climb> in their 1749Typing B<climb> will display a list of commands with I<climb> in their
1757name, such as I<ready_skill climbing> and I<use_skill climbing>. 1750name, such as I<ready_skill climbing> and I<use_skill climbing>.
1758 1751
1759You can abbreviate commands by typing only the first character of every 1752You can abbreviate commands by typing only the first character of every
1760word. For example, typing I<iwor> will likely select I<invoke word of 1753word (or even characters within the word - the client will try to make
1761recall>, while I<ccfo> will select I<cast create food>. Likewise, I<rscli> 1754a good guess, as long as the characters are in order). For example,
1762will likely select I<ready_skill climbing> and I<usl> will give you 1755typing I<iwor> will likely select I<invoke word of recall>, while I<ccfo>
1763I<use_skill levitation>. 1756will select I<cast create food>. Likewise, I<rscli> will likely select
1757I<ready_skill climbing> and I<usl> will give you I<use_skill levitation>.
1758
1759You can enter space and other text as arguemnt to the command. For
1760example, C<cfoo waybread> will expand to C<cast create food waybread>.
1764 1761
1765=head2 The map overview 1762=head2 The map overview
1766 1763
1767#TODO# 1764#TODO#
1768 1765

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines