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.184 by root, Tue Apr 25 11:25:20 2006 UTC vs.
Revision 1.192 by root, Fri Apr 28 18:06:13 2006 UTC

70 70
71our $FONT_PROP; 71our $FONT_PROP;
72our $FONT_FIXED; 72our $FONT_FIXED;
73 73
74our $MAP; 74our $MAP;
75our $MAPMAP;
75our $MAPWIDGET; 76our $MAPWIDGET;
76our $BUTTONBAR; 77our $BUTTONBAR;
77our $LOGVIEW; 78our $LOGVIEW;
78our $CONSOLE; 79our $CONSOLE;
79our $METASERVER; 80our $METASERVER;
90our %AUDIO_CHUNKS; # audio files 91our %AUDIO_CHUNKS; # audio files
91 92
92our $ALT_ENTER_MESSAGE; 93our $ALT_ENTER_MESSAGE;
93our $STATUS_LINE; 94our $STATUS_LINE;
94our $DEBUG_STATUS; 95our $DEBUG_STATUS;
96
97our $INVWIN;
98our $INV;
95 99
96sub status { 100sub status {
97 $STATUS_LINE->set_text ($_[0]); 101 $STATUS_LINE->set_text ($_[0]);
98 $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});
99} 103}
313 audio_shutdown (); 317 audio_shutdown ();
314 audio_init (); 318 audio_init ();
315 } 319 }
316 ); 320 );
317 321
322 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd");
323 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry
324 text => $CFG->{say_command},
325 tooltip => "This is the command that will be used if you write a line in the message window entry. "
326 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
327 ."But you could also set it to 'tell <playername>' to only chat with that user.",
328 connect_changed => sub {
329 my ($self, $value) = @_;
330 $CFG->{say_command} = $value;
331 }
332 );
333
318 $dialog 334 $dialog
319} 335}
320 336
321sub set_stats_window_fontsize { 337sub set_stats_window_fontsize {
322 for (values %{$STATWIDS}) { 338 for (values %{$STATWIDS}) {
381} 397}
382 398
383sub make_stats_window { 399sub make_stats_window {
384 my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats"; 400 my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats";
385 401
386 $tgw->add (my $vb = new CFClient::UI::VBox); 402 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
387 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); 403 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
388 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 404 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
389 405
390 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 406 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
391 407
421 437
422 my $row = 0; 438 my $row = 0;
423 my $col = 0; 439 my $col = 0;
424 440
425 my %resist_names = ( 441 my %resist_names = (
426 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.)",
427 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.)",
428 conf => "Confusion", 444 conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)",
429 fire => "Fire", 445 fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)",
430 depl => "Depletion (some monsters and other effects can cause stats depletion)", 446 depl => "Depletion (some monsters and other effects can cause stats depletion)",
431 magic => "Magic", 447 magic => "Magic (resistance to magic spells like magic missile or similar)",
432 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)",
433 acid => "Acid", 449 acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)",
434 pois => "Poison", 450 pois => "Poison (resistance to getting poisoned)",
435 para => "Paralysation", 451 para => "Paralysation (this resistance affects the chance you get paralysed)",
436 deat => "Death (resistance against death spells)", 452 deat => "Death (resistance against death spells)",
437 phys => "Physical", 453 phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)",
438 blind => "Blind", 454 blind => "Blind (blind resistance affects the chance of a successful blinding attack)",
439 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)",
440 tund => "Turn undead", 456 tund => "Turn undead",
441 elec => "Electricity", 457 elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)",
442 cold => "Cold", 458 cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)",
443 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)",
444 ); 460 );
445 for (qw/slow holyw conf fire depl magic 461 for (qw/slow holyw conf fire depl magic
446 drain acid pois para deat phys 462 drain acid pois para deat phys
447 blind fear tund elec cold ghit/) 463 blind fear tund elec cold ghit/)
456 can_events => 1, 472 can_events => 1,
457 can_hover => 1, 473 can_hover => 1,
458 tooltip => $resist_names{$_}, 474 tooltip => $resist_names{$_},
459 ); 475 );
460 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 476 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
477 font => $FONT_FIXED,
461 can_hover => 1, 478 can_hover => 1,
462 can_events => 1, 479 can_events => 1,
463 image => "ui/resist/resist_$_.png", 480 image => "ui/resist/resist_$_.png",
464 tooltip => $resist_names{$_}, 481 tooltip => $resist_names{$_},
465 ); 482 );
690 my ($self, $value) = @_; 707 my ($self, $value) = @_;
691 $CFG->{password} = $value; 708 $CFG->{password} = $value;
692 } 709 }
693 ); 710 );
694 711
695 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
696 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
697 text => $CFG->{say_command},
698 tooltip => "This is the command that will be used if you write a line in the message window entry. "
699 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
700 ."But you could also set it to 'tell <playername>' to only chat with that user.",
701 connect_changed => sub {
702 my ($self, $value) = @_;
703 $CFG->{say_command} = $value;
704 }
705 );
706
707 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 712 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
708 $table->add (1, 7, new CFClient::UI::Slider 713 $table->add (1, 7, new CFClient::UI::Slider
709 req_w => 100, 714 req_w => 100,
710 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 715 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
711 tooltip => "This is the size of the portion of the map update the server sends you. " 716 tooltip => "This is the size of the portion of the map update the server sends you. "
725} 730}
726 731
727sub message_window { 732sub message_window {
728 my $window = new CFClient::UI::FancyFrame 733 my $window = new CFClient::UI::FancyFrame
729 title => "Messages", 734 title => "Messages",
730 border_bg => [1, 1, 1, 0.5], 735 border_bg => [1, 1, 1, 1],
731 bg => [0.3, 0.3, 0.3, 0.8], 736 bg => [0, 0, 0, 0.5],
732 user_w => int $::WIDTH / 3, 737 user_w => int $::WIDTH / 3,
733 user_h => int $::HEIGHT / 5, 738 user_h => int $::HEIGHT / 5,
734 child => (my $vbox = new CFClient::UI::VBox); 739 child => (my $vbox = new CFClient::UI::VBox);
735 740
736 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 741 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
776 }; 781 };
777 782
778 $window 783 $window
779} 784}
780 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
781sub sdl_init { 795sub sdl_init {
782 CFClient::SDL_Init 796 CFClient::SDL_Init
783 and die "SDL::Init failed!\n"; 797 and die "SDL::Init failed!\n";
784} 798}
785 799
816 fontsize => 0.8, 830 fontsize => 0.8,
817 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 831 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
818 $ALT_ENTER_MESSAGE->show; 832 $ALT_ENTER_MESSAGE->show;
819 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 833 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
820 834
821 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); 835 CFClient::UI::FancyFrame->new (
822 $MAPWIDGET->focus_in; 836 border_bg => [1, 1, 1, 192/255],
837 bg => [1, 1, 1, 0],
838 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
839 )->show;
840
841 $MAPWIDGET = new CFClient::MapWidget;
823 $MAPWIDGET->connect (activate_console => sub { 842 $MAPWIDGET->connect (activate_console => sub {
824 my ($mapwidget, $preset) = @_; 843 my ($mapwidget, $preset) = @_;
825 844
826 if ($CONSOLE) { 845 if ($CONSOLE) {
827 $CONSOLE->{input}->{auto_activated} = 1; 846 $CONSOLE->{input}->{auto_activated} = 1;
830 if ($preset && $CONSOLE->{input}->get_text eq '') { 849 if ($preset && $CONSOLE->{input}->get_text eq '') {
831 $CONSOLE->{input}->set_text ($preset); 850 $CONSOLE->{input}->set_text ($preset);
832 } 851 }
833 } 852 }
834 }); 853 });
854 $MAPWIDGET->show;
855 $MAPWIDGET->focus_in;
835 856
836 $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); 857 $BUTTONBAR = new CFClient::UI::HBox;
837 858
838 $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);
839 $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);
840 $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);
841 862
842 $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
843 $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);
844 867
845 $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 {
846 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 869 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
847 status "Configuration Saved"; 870 status "Configuration Saved";
848 }); 871 });
872
873 $BUTTONBAR->show;
849 874
850 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 875 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
851} 876}
852 877
853sub video_shutdown { 878sub video_shutdown {
1035# at worst. 1060# at worst.
1036sub conn::flood_fill { 1061sub conn::flood_fill {
1037 my ($self, $gx, $gy, $path, $hash, $flags) = @_; 1062 my ($self, $gx, $gy, $path, $hash, $flags) = @_;
1038 1063
1039 # the server does not allow map paths > 6 1064 # the server does not allow map paths > 6
1040 return if 6 <= length $path; 1065 return if 7 <= length $path;
1041 1066
1042 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; 1067 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}};
1043 1068
1044 for ( 1069 for (
1045 [1, 0, -1], 1070 [1, 0, -1],
1088 1113
1089 $self->flush_map; 1114 $self->flush_map;
1090 1115
1091 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 1116 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
1092 1117
1093 my $mapmapw = 250; 1118 my $mapmapw = $MAPMAP->{w};
1094 my $mapmaph = 250; 1119 my $mapmaph = $MAPMAP->{h};
1095 1120
1096 $self->{neigh_rect} = [ 1121 $self->{neigh_rect} = [
1097 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, 1122 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
1098 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, 1123 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h,
1099 ]; 1124 ];
1322 if ($ev->{button} == 1) { 1347 if ($ev->{button} == 1) {
1323 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); 1348 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1324 } elsif ($ev->{button} == 2) { 1349 } elsif ($ev->{button} == 2) {
1325 $CONN->send ("apply $item->{tag}"); 1350 $CONN->send ("apply $item->{tag}");
1326 } elsif ($ev->{button} == 3) { 1351 } elsif ($ev->{button} == 3) {
1327 # examine, lock, mark, maybe other things 1352 CFClient::UI::Menu->new (
1328 warn "MENU not implemented yet\n"; 1353 items => [
1354 ["examine", sub { $CONN->send ("examine $item->{tag}") }],
1355 [
1356 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
1357 sub { $CONN->send ("lock $item->{tag}") },
1358 ],
1359 ["mark", sub { $CONN->send ("mark $item->{tag}") }],
1360 ["apply", sub { $CONN->send ("apply $item->{tag}") }],
1361 ],
1362 )->popup ($ev);
1329 } 1363 }
1330 1364
1331 1 1365 1
1332 }, 1366 },
1333 ); 1367 );
1350 1384
1351sub conn::container_add { 1385sub conn::container_add {
1352 my ($self, $id, $items) = @_; 1386 my ($self, $id, $items) = @_;
1353 1387
1354 update_floorbox if $id == 0; 1388 update_floorbox if $id == 0;
1389 if ($self->{player}{tag} == $id) {
1390 $INV->set_items ($self->{container}{$self->{player}{tag}});
1391 }
1355 # $self-<{player}{tag} => player inv 1392 # $self-<{player}{tag} => player inv
1356 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1393 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1357} 1394}
1358 1395
1359sub conn::container_clear { 1396sub conn::container_clear {
1360 my ($self, $id) = @_; 1397 my ($self, $id) = @_;
1361 1398
1362 update_floorbox if $id == 0; 1399 update_floorbox if $id == 0;
1400 if ($self->{player}{tag} == $id) {
1401 $INV->set_items ($self->{container}{$id});
1402 }
1403
1363# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1404# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1364} 1405}
1365 1406
1366sub conn::item_delete { 1407sub conn::item_delete {
1367 my ($self, @items) = @_; 1408 my ($self, @items) = @_;
1368 1409
1369 for (@items) { 1410 for (@items) {
1370 update_floorbox if $_->{container} == 0; 1411 update_floorbox if $_->{container} == 0;
1412 if ($self->{player}{tag} == $_->{container}) {
1413 $INV->set_items ($self->{container}{$_->{container}});
1414 }
1371 } 1415 }
1372} 1416}
1373 1417
1374sub conn::item_update { 1418sub conn::item_update {
1375 my ($self, $item) = @_; 1419 my ($self, $item) = @_;
1376 1420
1377 update_floorbox if $item->{container} == 0; 1421 update_floorbox if $item->{container} == 0;
1422 if ($self->{player}{tag} == $item->{container}) {
1423 $INV->set_items ($self->{container}{$item->{container}});
1424 }
1378} 1425}
1379 1426
1380%SDL_CB = ( 1427%SDL_CB = (
1381 CFClient::SDL_QUIT => sub { 1428 CFClient::SDL_QUIT => sub {
1382 Event::unloop -1; 1429 Event::unloop -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines