… | |
… | |
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 | |
135 | sub stop_game { |
141 | sub stop_game { |
136 | undef $CONN; |
142 | undef $CONN; |
137 | } |
143 | } |
… | |
… | |
858 | |
864 | |
859 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
865 | $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); |
866 | $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); |
867 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
862 | |
868 | |
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 |
869 | 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 |
|
|
870 | |
864 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
871 | $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); |
872 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
866 | |
873 | |
867 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
874 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
868 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
875 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
… | |
… | |
1322 | sub update_floorbox { |
1329 | sub update_floorbox { |
1323 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1330 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1324 | $FLOORBOX->clear; |
1331 | $FLOORBOX->clear; |
1325 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1332 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1326 | |
1333 | |
1327 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1328 | |
|
|
1329 | # we basically have to use the same sorting as everybody else |
1334 | # we basically have to use the same sorting as everybody else |
1330 | @items = sort { $a->{type} <=> $b->{type} } @items; |
1335 | for my $item (@{ $CONN->{container}{0} }) { |
1331 | |
|
|
1332 | for my $item (reverse @items) { |
|
|
1333 | my $desc = $item->{nrof} < 2 |
1336 | my $desc = $item->{nrof} < 2 |
1334 | ? $item->{name} |
1337 | ? $item->{name} |
1335 | : "$item->{nrof} $item->{name_pl}"; |
1338 | : "$item->{nrof} $item->{name_pl}"; |
1336 | # todo: animation widget, face widget, weight(?) etc. |
1339 | # todo: animation widget, face widget, weight(?) etc. |
1337 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
1340 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
… | |
… | |
1452 | |
1455 | |
1453 | ############################################################################# |
1456 | ############################################################################# |
1454 | |
1457 | |
1455 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1458 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1456 | |
1459 | |
|
|
1460 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1461 | |
1457 | $TILECACHE = CFClient::db_table "tilecache"; |
1462 | $TILECACHE = CFClient::db_table "tilecache"; |
1458 | $FACEMAP = CFClient::db_table "facemap"; |
1463 | $FACEMAP = CFClient::db_table "facemap"; |
1459 | |
|
|
1460 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1461 | |
1464 | |
1462 | my %DEF_CFG = ( |
1465 | my %DEF_CFG = ( |
1463 | sdl_mode => 0, |
1466 | sdl_mode => 0, |
1464 | width => 640, |
1467 | width => 640, |
1465 | height => 480, |
1468 | height => 480, |