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.186 by root, Tue Apr 25 12:10:58 2006 UTC vs.
Revision 1.202 by root, Mon May 8 20:39:35 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;
81our $LOGIN_BUTTON;
80 82
81our $FLOORBOX; 83our $FLOORBOX;
82our $GAUGES; 84our $GAUGES;
83our $STATWIDS; 85our $STATWIDS;
84 86
91 93
92our $ALT_ENTER_MESSAGE; 94our $ALT_ENTER_MESSAGE;
93our $STATUS_LINE; 95our $STATUS_LINE;
94our $DEBUG_STATUS; 96our $DEBUG_STATUS;
95 97
98our $INVWIN;
99our $INV;
100
96sub status { 101sub status {
97 $STATUS_LINE->set_text ($_[0]); 102 $STATUS_LINE->set_text ($_[0]);
98 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 103 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
99} 104}
100 105
107 status "logging in..."; 112 status "logging in...";
108 113
109 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 114 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
110 115
111 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; 116 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
112
113 $MAP = new CFClient::Map $mapsize, $mapsize; 117 $MAP = new CFClient::Map $mapsize, $mapsize;
114 118
115 my ($host, $port) = split /:/, $CFG->{host}; 119 my ($host, $port) = split /:/, $CFG->{host};
116 120
117 $CONN = new conn 121 $CONN = eval {
122 new conn
118 host => $host, 123 host => $host,
119 port => $port || 13327, 124 port => $port || 13327,
120 user => $CFG->{user}, 125 user => $CFG->{user},
121 pass => $CFG->{password}, 126 pass => $CFG->{password},
122 mapw => $mapsize, 127 mapw => $mapsize,
123 maph => $mapsize, 128 maph => $mapsize,
129 ;
124 ; 130 };
125 131
132 if ($CONN) {
133 $LOGIN_BUTTON->set_text ("Logout");
134
126 status "login successful"; 135 status "login successful";
127 136
128 CFClient::lowdelay fileno $CONN->{fh}; 137 CFClient::lowdelay fileno $CONN->{fh};
138 } else {
139 status "unable to connect";
140 stop_game();
141 }
129} 142}
130 143
131sub stop_game { 144sub stop_game {
145 return unless $CONN;
146
147 status "connection closed";
148 $LOGIN_BUTTON->set_text ("Login");
149 $CONN->destroy;
150 $CONN = 0; # false, does not autovivify
151
152 undef $MAPCACHE;
132 undef $CONN; 153 undef $MAP;
133} 154}
134 155
135sub client_setup { 156sub client_setup {
136 my $dialog = new CFClient::UI::FancyFrame 157 my $dialog = new CFClient::UI::FancyFrame
137 title => "Client Setup", 158 title => "Client Setup",
313 audio_shutdown (); 334 audio_shutdown ();
314 audio_init (); 335 audio_init ();
315 } 336 }
316 ); 337 );
317 338
339 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd");
340 $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry
341 text => $CFG->{say_command},
342 tooltip => "This is the command that will be used if you write a line in the message window entry. "
343 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
344 ."But you could also set it to 'tell <playername>' to only chat with that user.",
345 connect_changed => sub {
346 my ($self, $value) = @_;
347 $CFG->{say_command} = $value;
348 }
349 );
350
318 $dialog 351 $dialog
319} 352}
320 353
321sub set_stats_window_fontsize { 354sub set_stats_window_fontsize {
322 for (values %{$STATWIDS}) { 355 for (values %{$STATWIDS}) {
421 454
422 my $row = 0; 455 my $row = 0;
423 my $col = 0; 456 my $col = 0;
424 457
425 my %resist_names = ( 458 my %resist_names = (
426 slow => "Slow", 459 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", 460 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", 461 conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)",
429 fire => "Fire", 462 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)", 463 depl => "Depletion (some monsters and other effects can cause stats depletion)",
431 magic => "Magic", 464 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)", 465 drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)",
433 acid => "Acid", 466 acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)",
434 pois => "Poison", 467 pois => "Poison (resistance to getting poisoned)",
435 para => "Paralysation", 468 para => "Paralysation (this resistance affects the chance you get paralysed)",
436 deat => "Death (resistance against death spells)", 469 deat => "Death (resistance against death spells)",
437 phys => "Physical", 470 phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)",
438 blind => "Blind", 471 blind => "Blind (blind resistance affects the chance of a successful blinding attack)",
439 fear => "Fear", 472 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", 473 tund => "Turn undead",
441 elec => "Electricity", 474 elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)",
442 cold => "Cold", 475 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)", 476 ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)",
444 ); 477 );
445 for (qw/slow holyw conf fire depl magic 478 for (qw/slow holyw conf fire depl magic
446 drain acid pois para deat phys 479 drain acid pois para deat phys
447 blind fear tund elec cold ghit/) 480 blind fear tund elec cold ghit/)
549 582
550} 583}
551 584
552sub metaserver_dialog { 585sub metaserver_dialog {
553 my $dialog = new CFClient::UI::FancyFrame 586 my $dialog = new CFClient::UI::FancyFrame
554 title => "Metaserver", 587 title => "Server List",
555 child => (my $vbox = new CFClient::UI::VBox); 588 child => (my $vbox = new CFClient::UI::VBox);
556 589
557 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 590 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
558 591
559 $dialog 592 $dialog
661 694
662 $METASERVER = metaserver_dialog; 695 $METASERVER = metaserver_dialog;
663 696
664 $vbox->add (new CFClient::UI::Flopper 697 $vbox->add (new CFClient::UI::Flopper
665 expand => 1, 698 expand => 1,
666 text => "Metaserver", 699 text => "Server List",
667 other => $METASERVER, 700 other => $METASERVER,
668 tooltip => "Show a list of avaible crossfire servers", 701 tooltip => "Show a list of available crossfire servers",
669 connect_open => sub { 702 connect_open => sub {
670 update_metaserver $HOST; 703 update_metaserver $HOST;
671 } 704 }
672 ); 705 );
673 } 706 }
688 hidden => 1, 721 hidden => 1,
689 tooltip => "The password for your character", 722 tooltip => "The password for your character",
690 connect_changed => sub { 723 connect_changed => sub {
691 my ($self, $value) = @_; 724 my ($self, $value) = @_;
692 $CFG->{password} = $value; 725 $CFG->{password} = $value;
693 }
694 );
695
696 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
697 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
698 text => $CFG->{say_command},
699 tooltip => "This is the command that will be used if you write a line in the message window entry. "
700 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
701 ."But you could also set it to 'tell <playername>' to only chat with that user.",
702 connect_changed => sub {
703 my ($self, $value) = @_;
704 $CFG->{say_command} = $value;
705 } 726 }
706 ); 727 );
707 728
708 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 729 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
709 $table->add (1, 7, new CFClient::UI::Slider 730 $table->add (1, 7, new CFClient::UI::Slider
716 737
717 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 738 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
718 }, 739 },
719 ); 740 );
720 741
721 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 742 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button
743 expand => 1,
744 align => 0,
745 text => "Login",
746 connect_activate => sub {
747 $CONN ? stop_game
722 start_game; 748 : start_game;
749 },
723 }); 750 );
724 751
725 $dialog 752 $dialog
726} 753}
727 754
728sub message_window { 755sub message_window {
777 }; 804 };
778 805
779 $window 806 $window
780} 807}
781 808
809sub make_inventory_window {
810 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
811 $invwin->add ($INV = new CFClient::UI::Inventory expand => 1);
812 $invwin
813}
814
782sub sdl_init { 815sub sdl_init {
783 CFClient::SDL_Init 816 CFClient::SDL_Init
784 and die "SDL::Init failed!\n"; 817 and die "SDL::Init failed!\n";
785} 818}
786 819
787sub video_init { 820sub video_init {
788 sdl_init; 821 sdl_init;
789 822
823 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
824
790 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 825 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
791 $FULLSCREEN = $CFG->{fullscreen}; 826 $FULLSCREEN = $CFG->{fullscreen};
792 $FAST = $CFG->{fast}; 827 $FAST = $CFG->{fast};
793 828
794 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 829 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
795 or die "SDL_SetVideoMode failed!\n"; 830 or die "SDL_SetVideoMode failed!\n";
796 831
797 $SDL_ACTIVE = 1; 832 $SDL_ACTIVE = 1;
798
799 $LAST_REFRESH = time - 0.01; 833 $LAST_REFRESH = time - 0.01;
800 834
801 CFClient::gl_init; 835 CFClient::gl_init;
802 836
803 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 837 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
804 838
839 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
840
805 ############################################################################# 841 #############################################################################
806 842
843 if ($DEBUG_STATUS) {
844 # reconfigure all widgets
845 $CFClient::UI::ROOT->reconfigure;
846
847 } else {
848 # create the widgets
849
807 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 850 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
808 $DEBUG_STATUS->show; 851 $DEBUG_STATUS->show;
809 852
810 $STATUS_LINE = new CFClient::UI::Label 853 $STATUS_LINE = new CFClient::UI::Label
811 padding => 0, 854 padding => 0,
812 y => $HEIGHT - $FONTSIZE * 1.8; 855 y => $HEIGHT - $FONTSIZE * 1.8;
813 $STATUS_LINE->show; 856 $STATUS_LINE->show;
814 857
815 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 858 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
816 padding => 0, 859 padding => 0,
817 fontsize => 0.8, 860 fontsize => 0.8,
818 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 861 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
819 $ALT_ENTER_MESSAGE->show; 862 $ALT_ENTER_MESSAGE->show;
820 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 863 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
821 864
822 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); 865 CFClient::UI::FancyFrame->new (
823 $MAPWIDGET->focus_in; 866 border_bg => [1, 1, 1, 192/255],
867 bg => [1, 1, 1, 0],
868 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
869 )->show;
870
871 $MAPWIDGET = new CFClient::MapWidget;
824 $MAPWIDGET->connect (activate_console => sub { 872 $MAPWIDGET->connect (activate_console => sub {
825 my ($mapwidget, $preset) = @_; 873 my ($mapwidget, $preset) = @_;
826 874
827 if ($CONSOLE) { 875 if ($CONSOLE) {
828 $CONSOLE->{input}->{auto_activated} = 1; 876 $CONSOLE->{input}->{auto_activated} = 1;
829 $CONSOLE->{input}->focus_in; 877 $CONSOLE->{input}->focus_in;
830 878
831 if ($preset && $CONSOLE->{input}->get_text eq '') { 879 if ($preset && $CONSOLE->{input}->get_text eq '') {
832 $CONSOLE->{input}->set_text ($preset); 880 $CONSOLE->{input}->set_text ($preset);
881 }
833 } 882 }
834 } 883 });
835 }); 884 $MAPWIDGET->show;
885 $MAPWIDGET->focus_in;
836 886
837 $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); 887 $BUTTONBAR = new CFClient::UI::HBox;
838 888
839 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 889 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
840 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 890 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
841 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 891 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
842 892
843 $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 893 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
894
844 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 895 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
896 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
845 897
846 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 898 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
847 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 899 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
848 status "Configuration Saved"; 900 status "Configuration Saved";
849 }); 901 });
850 902
903 $BUTTONBAR->show;
904
851 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 905 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
906 }
852} 907}
853 908
854sub video_shutdown { 909sub video_shutdown {
855 $CFClient::UI::ROOT->{children} = [];
856 undef $CFClient::UI::GRAB;
857 undef $CFClient::UI::HOVER;
858 undef $SDL_ACTIVE; 910 undef $SDL_ACTIVE;
859} 911}
860 912
861my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 913my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
862my $bgmusic;#TODO#hack#d# 914my $bgmusic;#TODO#hack#d#
915
916sub audio_channel_finished {
917 my ($channel) = @_;
918
919 warn "channel $channel finished\n";#d#
920}
863 921
864sub audio_music_finished { 922sub audio_music_finished {
865 return unless $CFG->{bgm_enable}; 923 return unless $CFG->{bgm_enable};
866 924
867 # TODO: hack, do play loop and mood music 925 # TODO: hack, do play loop and mood music
871 push @bgmusic, shift @bgmusic; 929 push @bgmusic, shift @bgmusic;
872} 930}
873 931
874sub audio_init { 932sub audio_init {
875 if ($CFG->{audio_enable}) { 933 if ($CFG->{audio_enable}) {
876 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 934 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") {
877 $SDL_MIXER = !CFClient::Mix_OpenAudio; 935 $SDL_MIXER = !CFClient::Mix_OpenAudio;
878 CFClient::Mix_AllocateChannels 8; 936 CFClient::Mix_AllocateChannels 8;
879 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 937 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
880 938
881 audio_music_finished; 939 audio_music_finished;
1036# at worst. 1094# at worst.
1037sub conn::flood_fill { 1095sub conn::flood_fill {
1038 my ($self, $gx, $gy, $path, $hash, $flags) = @_; 1096 my ($self, $gx, $gy, $path, $hash, $flags) = @_;
1039 1097
1040 # the server does not allow map paths > 6 1098 # the server does not allow map paths > 6
1041 return if 6 <= length $path; 1099 return if 7 <= length $path;
1042 1100
1043 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; 1101 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}};
1044 1102
1045 for ( 1103 for (
1046 [1, 0, -1], 1104 [1, 0, -1],
1089 1147
1090 $self->flush_map; 1148 $self->flush_map;
1091 1149
1092 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 1150 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
1093 1151
1094 my $mapmapw = 250; 1152 my $mapmapw = $MAPMAP->{w};
1095 my $mapmaph = 250; 1153 my $mapmaph = $MAPMAP->{h};
1096 1154
1097 $self->{neigh_rect} = [ 1155 $self->{neigh_rect} = [
1098 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, 1156 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
1099 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, 1157 $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h,
1100 ]; 1158 ];
1292 1350
1293 for my $skill (values %{$self->{skill_info}}) { 1351 for my $skill (values %{$self->{skill_info}}) {
1294 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1352 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1295 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1353 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1296 } 1354 }
1355
1356 $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
1357 $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
1358 $MAPWIDGET->add_command ("pet\\_mode sad", "Search &amp; Destroy - tell pets to roam about and attack enemies");
1359 $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
1360}
1361
1362sub conn::eof {
1363 stop_game;
1297} 1364}
1298 1365
1299sub update_floorbox { 1366sub update_floorbox {
1300 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1367 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1368 return unless $CONN;
1369
1301 $FLOORBOX->clear; 1370 $FLOORBOX->clear;
1302 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1371 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1303 1372
1304 my @items = values %{ $CONN->{container}{0} };
1305
1306 # we basically have to use the same sorting as everybody else 1373 # we basically have to use the same sorting as everybody else
1307 @items = sort { $a->{type} <=> $b->{type} } @items; 1374 for my $item (@{ $CONN->{container}{0} }) {
1308 1375 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item);
1309 for my $item (reverse @items) {
1310 my $desc = $item->{nrof} < 2
1311 ? $item->{name}
1312 : "$item->{nrof} $item->{name_pl}";
1313 # todo: animation widget, face widget, weight(?) etc.
1314 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1315 tooltip => (CFClient::UI::Label->escape ($desc)
1316 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1317 can_hover => 1,
1318 can_events => 1,
1319 connect_button_down => sub {
1320 my ($self, $ev, $x, $y) = @_;
1321
1322 # todo: maybe put examine on 1? but should just be a tooltip :(
1323 if ($ev->{button} == 1) {
1324 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1325 } elsif ($ev->{button} == 2) {
1326 $CONN->send ("apply $item->{tag}");
1327 } elsif ($ev->{button} == 3) {
1328 # examine, lock, mark, maybe other things
1329 warn "MENU not implemented yet\n";
1330 }
1331
1332 1
1333 },
1334 );
1335
1336 $hbox->add (new CFClient::UI::Face
1337 can_events => 0,
1338 face => $item->{face},
1339 anim => $item->{anim},
1340 animspeed => $item->{animspeed},
1341 );
1342
1343 $hbox->add (new CFClient::UI::Label
1344 can_events => 0,
1345 text => $desc,
1346 );
1347 } 1376 }
1348 }); 1377 });
1349 refresh; 1378 refresh;
1350} 1379}
1351 1380
1352sub conn::container_add { 1381sub conn::container_add {
1353 my ($self, $id, $items) = @_; 1382 my ($self, $id, $items) = @_;
1354 1383
1355 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 }
1356 # $self-<{player}{tag} => player inv 1388 # $self-<{player}{tag} => player inv
1357 #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}};
1358} 1390}
1359 1391
1360sub conn::container_clear { 1392sub conn::container_clear {
1361 my ($self, $id) = @_; 1393 my ($self, $id) = @_;
1362 1394
1363 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
1364# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1400# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1365} 1401}
1366 1402
1367sub conn::item_delete { 1403sub conn::item_delete {
1368 my ($self, @items) = @_; 1404 my ($self, @items) = @_;
1369 1405
1370 for (@items) { 1406 for (@items) {
1371 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 }
1372 } 1411 }
1373} 1412}
1374 1413
1375sub conn::item_update { 1414sub conn::item_update {
1376 my ($self, $item) = @_; 1415 my ($self, $item) = @_;
1377 1416
1378 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 }
1379} 1421}
1380 1422
1381%SDL_CB = ( 1423%SDL_CB = (
1382 CFClient::SDL_QUIT => sub { 1424 CFClient::SDL_QUIT => sub {
1383 Event::unloop -1; 1425 Event::unloop -1;
1396 video_init; 1438 video_init;
1397 } else { 1439 } else {
1398 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1440 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1399 } 1441 }
1400 }, 1442 },
1401 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, 1443 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event,
1402 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, 1444 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event,
1403 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, 1445 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event,
1404 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, 1446 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event,
1405 CFClient::SDL_USEREVENT => \&audio_music_finished, 1447 CFClient::SDL_USEREVENT => sub {
1448 if ($_[0]{code} == 1) {
1449 audio_channel_finished $_[0]{data1};
1450 } elsif ($_[0]{code} == 0) {
1451 audio_music_finished;
1452 }
1453 },
1406); 1454);
1407 1455
1408############################################################################# 1456#############################################################################
1409 1457
1410$SIG{INT} = $SIG{TERM} = sub { exit }; 1458$SIG{INT} = $SIG{TERM} = sub { exit };
1459
1460CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1411 1461
1412$TILECACHE = CFClient::db_table "tilecache"; 1462$TILECACHE = CFClient::db_table "tilecache";
1413$FACEMAP = CFClient::db_table "facemap"; 1463$FACEMAP = CFClient::db_table "facemap";
1414
1415CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1416 1464
1417my %DEF_CFG = ( 1465my %DEF_CFG = (
1418 sdl_mode => 0, 1466 sdl_mode => 0,
1419 width => 640, 1467 width => 640,
1420 height => 480, 1468 height => 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines