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.226 by root, Wed May 17 20:21:28 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
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
933my $bgmusic;#TODO#hack#d# 955my $bgmusic;#TODO#hack#d#
934 956
935sub audio_channel_finished { 957sub audio_channel_finished {
936 my ($channel) = @_; 958 my ($channel) = @_;
937 959
938 warn "channel $channel finished\n";#d# 960 #warn "channel $channel finished\n";#d#
939} 961}
940 962
941sub audio_music_finished { 963sub audio_music_finished {
942 return unless $CFG->{bgm_enable}; 964 return unless $CFG->{bgm_enable};
943 965
1029 delete $animate_object{$widget}; 1051 delete $animate_object{$widget};
1030} 1052}
1031 1053
1032@conn::ISA = Crossfire::Protocol::; 1054@conn::ISA = Crossfire::Protocol::;
1033 1055
1056sub conn::new {
1057 my $class = shift;
1058
1059 my $self = $class->Crossfire::Protocol::new (@_);
1060
1061 $MAPWIDGET->clr_commands;
1062
1063 my $parser = new Pod::POM;
1064 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod");
1065
1066 for my $head2 ($pod->head2) {
1067 $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
1068 or next;
1069
1070 my $cmd = $1;
1071 my @args = split /\|/, $2;
1072 @args = (".*") unless @args;
1073
1074 my $text = CFClient::pod_to_pango $head2->content;
1075
1076 for my $arg (@args) {
1077 $arg = $arg eq ".*" ? "" : " $arg";
1078
1079 $MAPWIDGET->add_command ("$cmd$arg", $text);
1080 }
1081 }
1082
1083 $self
1084}
1085
1034sub conn::stats_update { 1086sub conn::stats_update {
1035 my ($self, $stats) = @_; 1087 my ($self, $stats) = @_;
1088
1089 if (my $exp = $stats->{Crossfire::Protocol::CS_STAT_EXP64}) {
1090 my $diff = $exp - $self->{prev_exp};
1091 $STATUSBOX->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5)
1092 if exists $self->{prev_exp} && $diff;
1093 $self->{prev_exp} = $exp;
1094 }
1036 1095
1037 update_stats_window ($stats); 1096 update_stats_window ($stats);
1038} 1097}
1039 1098
1040sub conn::user_send { 1099sub conn::user_send {
1365sub conn::spell_add { 1424sub conn::spell_add {
1366 my ($self, $spell) = @_; 1425 my ($self, $spell) = @_;
1367 1426
1368 # TODO 1427 # TODO
1369 # create a widget dynamically, using spell face (CF::Protocol downloads them) 1428 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1370 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}); 1429 $MAPWIDGET->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
1371 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}); 1430 $MAPWIDGET->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
1372} 1431}
1373 1432
1374sub conn::spell_delete { 1433sub conn::spell_delete {
1375 my ($self, $spell) = @_; 1434 my ($self, $spell) = @_;
1376} 1435}
1377 1436
1378sub conn::addme_success { 1437sub conn::addme_success {
1379 my ($self) = @_; 1438 my ($self) = @_;
1380 1439
1381 $MAPWIDGET->clr_commands; 1440 $self->send ("command output-sync $CFG->{output_sync}");
1441 $self->send ("command output-count $CFG->{output_count}");
1382 1442
1383 for my $skill (values %{$self->{skill_info}}) { 1443 for my $skill (values %{$self->{skill_info}}) {
1384 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1444 $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'"); 1445 $MAPWIDGET->add_command ("use_skill $skill", CFClient::UI::Label::escape "Immediately use the skill '$skill'");
1386 } 1446 }
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} 1447}
1459 1448
1460sub conn::eof { 1449sub conn::eof {
1461 $MAPWIDGET->clr_commands; 1450 $MAPWIDGET->clr_commands;
1462 1451
1641 host => "crossfire.schmorp.de", 1630 host => "crossfire.schmorp.de",
1642 say_command => 'say', 1631 say_command => 'say',
1643 audio_enable => 1, 1632 audio_enable => 1,
1644 bgm_enable => 1, 1633 bgm_enable => 1,
1645 bgm_volume => 0.25, 1634 bgm_volume => 0.25,
1635 output_sync => 1,
1636 output_count => 1,
1646 ); 1637 );
1647 1638
1648 while (my ($k, $v) = each %DEF_CFG) { 1639 while (my ($k, $v) = each %DEF_CFG) {
1649 $CFG->{$k} = $v unless exists $CFG->{$k}; 1640 $CFG->{$k} = $v unless exists $CFG->{$k};
1650 } 1641 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines