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.188 by elmex, Tue Apr 25 13:27:00 2006 UTC vs.
Revision 1.193 by root, Sat Apr 29 16:17:10 2006 UTC

91our %AUDIO_CHUNKS; # audio files 91our %AUDIO_CHUNKS; # audio files
92 92
93our $ALT_ENTER_MESSAGE; 93our $ALT_ENTER_MESSAGE;
94our $STATUS_LINE; 94our $STATUS_LINE;
95our $DEBUG_STATUS; 95our $DEBUG_STATUS;
96
97our $INVWIN;
98our $INV;
96 99
97sub status { 100sub 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
786sub 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
783sub sdl_init { 795sub 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 });
1309sub update_floorbox { 1323sub 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
1362sub conn::container_add { 1381sub 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
1370sub conn::container_clear { 1392sub 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
1377sub conn::item_delete { 1403sub 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
1385sub conn::item_update { 1414sub 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines