… | |
… | |
91 | our %AUDIO_CHUNKS; # audio files |
91 | our %AUDIO_CHUNKS; # audio files |
92 | |
92 | |
93 | our $ALT_ENTER_MESSAGE; |
93 | our $ALT_ENTER_MESSAGE; |
94 | our $STATUS_LINE; |
94 | our $STATUS_LINE; |
95 | our $DEBUG_STATUS; |
95 | our $DEBUG_STATUS; |
|
|
96 | |
|
|
97 | our $INVWIN; |
|
|
98 | our $INV; |
96 | |
99 | |
97 | sub status { |
100 | sub status { |
98 | $STATUS_LINE->set_text ($_[0]); |
101 | $STATUS_LINE->set_text ($_[0]); |
99 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
102 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
100 | } |
103 | } |
… | |
… | |
434 | |
437 | |
435 | my $row = 0; |
438 | my $row = 0; |
436 | my $col = 0; |
439 | my $col = 0; |
437 | |
440 | |
438 | my %resist_names = ( |
441 | my %resist_names = ( |
439 | slow => "Slow", |
442 | slow => "Slow (slows you down when you are hit by the spell. Monsters will have an opportunity to come near you faster and hit you more often.)", |
440 | holyw => "Holy Word", |
443 | holyw => "Holy Word (resistance you against getting the fear when someone whose god doesn't like you spells the holy word on you.)", |
441 | conf => "Confusion", |
444 | conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
442 | fire => "Fire", |
445 | fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
443 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
446 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
444 | magic => "Magic", |
447 | magic => "Magic (resistance to magic spells like magic missile or similar)", |
445 | drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)", |
448 | drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)", |
446 | acid => "Acid", |
449 | acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
447 | pois => "Poison", |
450 | pois => "Poison (resistance to getting poisoned)", |
448 | para => "Paralysation", |
451 | para => "Paralysation (this resistance affects the chance you get paralysed)", |
449 | deat => "Death (resistance against death spells)", |
452 | deat => "Death (resistance against death spells)", |
450 | phys => "Physical", |
453 | phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)", |
451 | blind => "Blind", |
454 | blind => "Blind (blind resistance affects the chance of a successful blinding attack)", |
452 | fear => "Fear", |
455 | fear => "Fear (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)", |
453 | tund => "Turn undead", |
456 | tund => "Turn undead", |
454 | elec => "Electricity", |
457 | elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)", |
455 | cold => "Cold", |
458 | cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
456 | ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)", |
459 | ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)", |
457 | ); |
460 | ); |
458 | for (qw/slow holyw conf fire depl magic |
461 | for (qw/slow holyw conf fire depl magic |
459 | drain acid pois para deat phys |
462 | drain acid pois para deat phys |
460 | blind fear tund elec cold ghit/) |
463 | blind fear tund elec cold ghit/) |
… | |
… | |
778 | }; |
781 | }; |
779 | |
782 | |
780 | $window |
783 | $window |
781 | } |
784 | } |
782 | |
785 | |
|
|
786 | sub make_inventory_window { |
|
|
787 | 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); |
|
|
790 | $hb->add (my $rng = new CFClient::UI::Slider vertical => 1); |
|
|
791 | $INV->set_range ($rng); |
|
|
792 | $invwin |
|
|
793 | } |
|
|
794 | |
783 | sub sdl_init { |
795 | sub sdl_init { |
784 | CFClient::SDL_Init |
796 | CFClient::SDL_Init |
785 | and die "SDL::Init failed!\n"; |
797 | and die "SDL::Init failed!\n"; |
786 | } |
798 | } |
787 | |
799 | |
… | |
… | |
821 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
833 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
822 | |
834 | |
823 | CFClient::UI::FancyFrame->new ( |
835 | CFClient::UI::FancyFrame->new ( |
824 | border_bg => [1, 1, 1, 192/255], |
836 | border_bg => [1, 1, 1, 192/255], |
825 | bg => [1, 1, 1, 0], |
837 | bg => [1, 1, 1, 0], |
826 | child => $MAPMAP = new CFClient::MapWidget::MapMap |
838 | child => ($MAPMAP = new CFClient::MapWidget::MapMap), |
827 | )->show; |
839 | )->show; |
828 | |
840 | |
829 | $MAPWIDGET = new CFClient::MapWidget; |
841 | $MAPWIDGET = new CFClient::MapWidget; |
830 | $MAPWIDGET->connect (activate_console => sub { |
842 | $MAPWIDGET->connect (activate_console => sub { |
831 | my ($mapwidget, $preset) = @_; |
843 | my ($mapwidget, $preset) = @_; |
… | |
… | |
846 | |
858 | |
847 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
859 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
848 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
860 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
849 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
861 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
850 | |
862 | |
851 | $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 |
863 | 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 |
|
|
864 | |
852 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
865 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
866 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
853 | |
867 | |
854 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
868 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
855 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
869 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
856 | status "Configuration Saved"; |
870 | status "Configuration Saved"; |
857 | }); |
871 | }); |
… | |
… | |
1309 | sub update_floorbox { |
1323 | sub update_floorbox { |
1310 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1324 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1311 | $FLOORBOX->clear; |
1325 | $FLOORBOX->clear; |
1312 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1326 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1313 | |
1327 | |
1314 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1315 | |
|
|
1316 | # we basically have to use the same sorting as everybody else |
1328 | # we basically have to use the same sorting as everybody else |
1317 | @items = sort { $a->{type} <=> $b->{type} } @items; |
1329 | for my $item (@{ $CONN->{container}{0} }) { |
1318 | |
|
|
1319 | for my $item (reverse @items) { |
|
|
1320 | my $desc = $item->{nrof} < 2 |
1330 | my $desc = $item->{nrof} < 2 |
1321 | ? $item->{name} |
1331 | ? $item->{name} |
1322 | : "$item->{nrof} $item->{name_pl}"; |
1332 | : "$item->{nrof} $item->{name_pl}"; |
1323 | # todo: animation widget, face widget, weight(?) etc. |
1333 | # todo: animation widget, face widget, weight(?) etc. |
1324 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
1334 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
… | |
… | |
1333 | if ($ev->{button} == 1) { |
1343 | if ($ev->{button} == 1) { |
1334 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
1344 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
1335 | } elsif ($ev->{button} == 2) { |
1345 | } elsif ($ev->{button} == 2) { |
1336 | $CONN->send ("apply $item->{tag}"); |
1346 | $CONN->send ("apply $item->{tag}"); |
1337 | } elsif ($ev->{button} == 3) { |
1347 | } elsif ($ev->{button} == 3) { |
1338 | # examine, lock, mark, maybe other things |
1348 | CFClient::UI::Menu->new ( |
1339 | warn "MENU not implemented yet\n"; |
1349 | items => [ |
|
|
1350 | ["examine", sub { $CONN->send ("examine $item->{tag}") }], |
|
|
1351 | [ |
|
|
1352 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
|
|
1353 | sub { $CONN->send ("lock $item->{tag}") }, |
|
|
1354 | ], |
|
|
1355 | ["mark", sub { $CONN->send ("mark $item->{tag}") }], |
|
|
1356 | ["apply", sub { $CONN->send ("apply $item->{tag}") }], |
|
|
1357 | ], |
|
|
1358 | )->popup ($ev); |
1340 | } |
1359 | } |
1341 | |
1360 | |
1342 | 1 |
1361 | 1 |
1343 | }, |
1362 | }, |
1344 | ); |
1363 | ); |
… | |
… | |
1361 | |
1380 | |
1362 | sub conn::container_add { |
1381 | sub conn::container_add { |
1363 | my ($self, $id, $items) = @_; |
1382 | my ($self, $id, $items) = @_; |
1364 | |
1383 | |
1365 | update_floorbox if $id == 0; |
1384 | update_floorbox if $id == 0; |
|
|
1385 | if ($self->{player}{tag} == $id) { |
|
|
1386 | $INV->set_items ($self->{container}{$self->{player}{tag}}); |
|
|
1387 | } |
1366 | # $self-<{player}{tag} => player inv |
1388 | # $self-<{player}{tag} => player inv |
1367 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1389 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1368 | } |
1390 | } |
1369 | |
1391 | |
1370 | sub conn::container_clear { |
1392 | sub conn::container_clear { |
1371 | my ($self, $id) = @_; |
1393 | my ($self, $id) = @_; |
1372 | |
1394 | |
1373 | update_floorbox if $id == 0; |
1395 | update_floorbox if $id == 0; |
|
|
1396 | if ($self->{player}{tag} == $id) { |
|
|
1397 | $INV->set_items ($self->{container}{$id}); |
|
|
1398 | } |
|
|
1399 | |
1374 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1400 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1375 | } |
1401 | } |
1376 | |
1402 | |
1377 | sub conn::item_delete { |
1403 | sub conn::item_delete { |
1378 | my ($self, @items) = @_; |
1404 | my ($self, @items) = @_; |
1379 | |
1405 | |
1380 | for (@items) { |
1406 | for (@items) { |
1381 | update_floorbox if $_->{container} == 0; |
1407 | update_floorbox if $_->{container} == 0; |
|
|
1408 | if ($self->{player}{tag} == $_->{container}) { |
|
|
1409 | $INV->set_items ($self->{container}{$_->{container}}); |
|
|
1410 | } |
1382 | } |
1411 | } |
1383 | } |
1412 | } |
1384 | |
1413 | |
1385 | sub conn::item_update { |
1414 | sub conn::item_update { |
1386 | my ($self, $item) = @_; |
1415 | my ($self, $item) = @_; |
1387 | |
1416 | |
1388 | update_floorbox if $item->{container} == 0; |
1417 | update_floorbox if $item->{container} == 0; |
|
|
1418 | if ($self->{player}{tag} == $item->{container}) { |
|
|
1419 | $INV->set_items ($self->{container}{$item->{container}}); |
|
|
1420 | } |
1389 | } |
1421 | } |
1390 | |
1422 | |
1391 | %SDL_CB = ( |
1423 | %SDL_CB = ( |
1392 | CFClient::SDL_QUIT => sub { |
1424 | CFClient::SDL_QUIT => sub { |
1393 | Event::unloop -1; |
1425 | Event::unloop -1; |