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.197 by root, Fri May 5 19:05:47 2006 UTC vs.
Revision 1.201 by root, Mon May 8 18:31:01 2006 UTC

76our $MAPWIDGET; 76our $MAPWIDGET;
77our $BUTTONBAR; 77our $BUTTONBAR;
78our $LOGVIEW; 78our $LOGVIEW;
79our $CONSOLE; 79our $CONSOLE;
80our $METASERVER; 80our $METASERVER;
81our $LOGIN_BUTTON;
81 82
82our $FLOORBOX; 83our $FLOORBOX;
83our $GAUGES; 84our $GAUGES;
84our $STATWIDS; 85our $STATWIDS;
85 86
111 status "logging in..."; 112 status "logging in...";
112 113
113 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 114 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
114 115
115 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; 116 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
116
117 $MAP = new CFClient::Map $mapsize, $mapsize; 117 $MAP = new CFClient::Map $mapsize, $mapsize;
118 118
119 my ($host, $port) = split /:/, $CFG->{host}; 119 my ($host, $port) = split /:/, $CFG->{host};
120 120
121 $CONN = eval { 121 $CONN = eval {
128 maph => $mapsize, 128 maph => $mapsize,
129 ; 129 ;
130 }; 130 };
131 131
132 if ($CONN) { 132 if ($CONN) {
133 $LOGIN_BUTTON->set_text ("Logout");
134
133 status "login successful"; 135 status "login successful";
134 136
135 CFClient::lowdelay fileno $CONN->{fh}; 137 CFClient::lowdelay fileno $CONN->{fh};
136 } else { 138 } else {
137 status "unable to connect"; 139 status "unable to connect";
140 stop_game();
138 } 141 }
139} 142}
140 143
141sub stop_game { 144sub stop_game {
145 return unless $CONN;
146
147 status "connection closed";
148 $LOGIN_BUTTON->set_text ("Login");
149 $CONN->destroy;
150 $CONN = 0; # false, does not autovivify
151
152 undef $MAPCACHE;
142 undef $CONN; 153 undef $MAP;
143} 154}
144 155
145sub client_setup { 156sub client_setup {
146 my $dialog = new CFClient::UI::FancyFrame 157 my $dialog = new CFClient::UI::FancyFrame
147 title => "Client Setup", 158 title => "Client Setup",
571 582
572} 583}
573 584
574sub metaserver_dialog { 585sub metaserver_dialog {
575 my $dialog = new CFClient::UI::FancyFrame 586 my $dialog = new CFClient::UI::FancyFrame
576 title => "Metaserver", 587 title => "Server List",
577 child => (my $vbox = new CFClient::UI::VBox); 588 child => (my $vbox = new CFClient::UI::VBox);
578 589
579 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 590 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
580 591
581 $dialog 592 $dialog
683 694
684 $METASERVER = metaserver_dialog; 695 $METASERVER = metaserver_dialog;
685 696
686 $vbox->add (new CFClient::UI::Flopper 697 $vbox->add (new CFClient::UI::Flopper
687 expand => 1, 698 expand => 1,
688 text => "Metaserver", 699 text => "Server List",
689 other => $METASERVER, 700 other => $METASERVER,
690 tooltip => "Show a list of avaible crossfire servers", 701 tooltip => "Show a list of available crossfire servers",
691 connect_open => sub { 702 connect_open => sub {
692 update_metaserver $HOST; 703 update_metaserver $HOST;
693 } 704 }
694 ); 705 );
695 } 706 }
726 737
727 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 738 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
728 }, 739 },
729 ); 740 );
730 741
731 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 742 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button
743 expand => 1,
744 align => 0,
745 text => "Login",
746 connect_activate => sub {
747 $CONN ? stop_game
732 start_game; 748 : start_game;
749 },
733 }); 750 );
734 751
735 $dialog 752 $dialog
736} 753}
737 754
738sub message_window { 755sub message_window {
887 undef $SDL_ACTIVE; 904 undef $SDL_ACTIVE;
888} 905}
889 906
890my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 907my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
891my $bgmusic;#TODO#hack#d# 908my $bgmusic;#TODO#hack#d#
909
910sub audio_channel_finished {
911 my ($channel) = @_;
912
913 warn "channel $channel finished\n";#d#
914}
892 915
893sub audio_music_finished { 916sub audio_music_finished {
894 return unless $CFG->{bgm_enable}; 917 return unless $CFG->{bgm_enable};
895 918
896 # TODO: hack, do play loop and mood music 919 # TODO: hack, do play loop and mood music
1321 1344
1322 for my $skill (values %{$self->{skill_info}}) { 1345 for my $skill (values %{$self->{skill_info}}) {
1323 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1346 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1324 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1347 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1325 } 1348 }
1349
1350 $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
1351 $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
1352 $MAPWIDGET->add_command ("pet\\_mode sad", "Search & Destroy - tell pets to roam about and attack enemies");
1353 $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
1354}
1355
1356sub conn::eof {
1357 stop_game;
1326} 1358}
1327 1359
1328sub update_floorbox { 1360sub update_floorbox {
1329 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1361 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1362 return unless $CONN;
1363
1330 $FLOORBOX->clear; 1364 $FLOORBOX->clear;
1331 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1365 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1332 1366
1333 # we basically have to use the same sorting as everybody else 1367 # we basically have to use the same sorting as everybody else
1334 for my $item (@{ $CONN->{container}{0} }) { 1368 for my $item (@{ $CONN->{container}{0} }) {
1398 video_init; 1432 video_init;
1399 } else { 1433 } else {
1400 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1434 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1401 } 1435 }
1402 }, 1436 },
1403 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, 1437 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event,
1404 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, 1438 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event,
1405 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, 1439 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event,
1406 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, 1440 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event,
1407 CFClient::SDL_USEREVENT => \&audio_music_finished, 1441 CFClient::SDL_USEREVENT => sub {
1442 if ($_[0]{code} == 1) {
1443 audio_channel_finished $_[0]{data1};
1444 } elsif ($_[0]{code} == 0) {
1445 audio_music_finished;
1446 }
1447 },
1408); 1448);
1409 1449
1410############################################################################# 1450#############################################################################
1411 1451
1412$SIG{INT} = $SIG{TERM} = sub { exit }; 1452$SIG{INT} = $SIG{TERM} = sub { exit };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines