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.191 by elmex, Fri Apr 28 05:17:24 2006 UTC vs.
Revision 1.197 by root, Fri May 5 19:05:47 2006 UTC

116 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 = new conn 121 $CONN = eval {
122 new conn
122 host => $host, 123 host => $host,
123 port => $port || 13327, 124 port => $port || 13327,
124 user => $CFG->{user}, 125 user => $CFG->{user},
125 pass => $CFG->{password}, 126 pass => $CFG->{password},
126 mapw => $mapsize, 127 mapw => $mapsize,
127 maph => $mapsize, 128 maph => $mapsize,
129 ;
128 ; 130 };
129 131
132 if ($CONN) {
130 status "login successful"; 133 status "login successful";
131 134
132 CFClient::lowdelay fileno $CONN->{fh}; 135 CFClient::lowdelay fileno $CONN->{fh};
136 } else {
137 status "unable to connect";
138 }
133} 139}
134 140
135sub stop_game { 141sub stop_game {
136 undef $CONN; 142 undef $CONN;
137} 143}
783 $window 789 $window
784} 790}
785 791
786sub make_inventory_window { 792sub make_inventory_window {
787 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory"; 793 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
788 $invwin->add (my $hb = new CFClient::UI::HBox);
789 $hb->add ($INV = new CFClient::UI::Inventory expand => 1); 794 $invwin->add ($INV = new CFClient::UI::Inventory expand => 1);
790 $hb->add (my $rng = new CFClient::UI::Slider vertical => 1);
791 $INV->set_range ($rng);
792 $invwin 795 $invwin
793} 796}
794 797
795sub sdl_init { 798sub sdl_init {
796 CFClient::SDL_Init 799 CFClient::SDL_Init
797 and die "SDL::Init failed!\n"; 800 and die "SDL::Init failed!\n";
798} 801}
799 802
800sub video_init { 803sub video_init {
801 sdl_init; 804 sdl_init;
805
806 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
802 807
803 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 808 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
804 $FULLSCREEN = $CFG->{fullscreen}; 809 $FULLSCREEN = $CFG->{fullscreen};
805 $FAST = $CFG->{fast}; 810 $FAST = $CFG->{fast};
806 811
858 863
859 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 864 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
860 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 865 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
861 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 866 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
862 867
863 $CFClient::UI::ROOT->add (make_gauge_window); # 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 868 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
869
864 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 870 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
865 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); 871 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
866 872
867 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 873 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
868 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 874 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
894 push @bgmusic, shift @bgmusic; 900 push @bgmusic, shift @bgmusic;
895} 901}
896 902
897sub audio_init { 903sub audio_init {
898 if ($CFG->{audio_enable}) { 904 if ($CFG->{audio_enable}) {
899 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 905 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") {
900 $SDL_MIXER = !CFClient::Mix_OpenAudio; 906 $SDL_MIXER = !CFClient::Mix_OpenAudio;
901 CFClient::Mix_AllocateChannels 8; 907 CFClient::Mix_AllocateChannels 8;
902 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 908 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
903 909
904 audio_music_finished; 910 audio_music_finished;
1322sub update_floorbox { 1328sub update_floorbox {
1323 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1329 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1324 $FLOORBOX->clear; 1330 $FLOORBOX->clear;
1325 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1331 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1326 1332
1327 my @items = values %{ $CONN->{container}{0} };
1328
1329 # we basically have to use the same sorting as everybody else 1333 # we basically have to use the same sorting as everybody else
1330 @items = sort { $a->{type} <=> $b->{type} } @items; 1334 for my $item (@{ $CONN->{container}{0} }) {
1331 1335 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item);
1332 for my $item (reverse @items) {
1333 my $desc = $item->{nrof} < 2
1334 ? $item->{name}
1335 : "$item->{nrof} $item->{name_pl}";
1336 # todo: animation widget, face widget, weight(?) etc.
1337 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1338 tooltip => (CFClient::UI::Label->escape ($desc)
1339 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1340 can_hover => 1,
1341 can_events => 1,
1342 connect_button_down => sub {
1343 my ($self, $ev, $x, $y) = @_;
1344
1345 # todo: maybe put examine on 1? but should just be a tooltip :(
1346 if ($ev->{button} == 1) {
1347 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1348 } elsif ($ev->{button} == 2) {
1349 $CONN->send ("apply $item->{tag}");
1350 } elsif ($ev->{button} == 3) {
1351 CFClient::UI::Menu->new (
1352 items => [
1353 ["examine", sub { $CONN->send ("examine $item->{tag}") }],
1354 [
1355 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
1356 sub { $CONN->send ("lock $item->{tag}") },
1357 ],
1358 ["mark", sub { $CONN->send ("mark $item->{tag}") }],
1359 ["apply", sub { $CONN->send ("apply $item->{tag}") }],
1360 ],
1361 )->popup ($ev);
1362 }
1363
1364 1
1365 },
1366 );
1367
1368 $hbox->add (new CFClient::UI::Face
1369 can_events => 0,
1370 face => $item->{face},
1371 anim => $item->{anim},
1372 animspeed => $item->{animspeed},
1373 );
1374
1375 $hbox->add (new CFClient::UI::Label
1376 can_events => 0,
1377 text => $desc,
1378 );
1379 } 1336 }
1380 }); 1337 });
1381 refresh; 1338 refresh;
1382} 1339}
1383 1340
1452 1409
1453############################################################################# 1410#############################################################################
1454 1411
1455$SIG{INT} = $SIG{TERM} = sub { exit }; 1412$SIG{INT} = $SIG{TERM} = sub { exit };
1456 1413
1414CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1415
1457$TILECACHE = CFClient::db_table "tilecache"; 1416$TILECACHE = CFClient::db_table "tilecache";
1458$FACEMAP = CFClient::db_table "facemap"; 1417$FACEMAP = CFClient::db_table "facemap";
1459
1460CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1461 1418
1462my %DEF_CFG = ( 1419my %DEF_CFG = (
1463 sdl_mode => 0, 1420 sdl_mode => 0,
1464 width => 640, 1421 width => 640,
1465 height => 480, 1422 height => 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines