… | |
… | |
76 | our $MAPWIDGET; |
76 | our $MAPWIDGET; |
77 | our $BUTTONBAR; |
77 | our $BUTTONBAR; |
78 | our $LOGVIEW; |
78 | our $LOGVIEW; |
79 | our $CONSOLE; |
79 | our $CONSOLE; |
80 | our $METASERVER; |
80 | our $METASERVER; |
|
|
81 | our $LOGIN_BUTTON; |
81 | |
82 | |
82 | our $FLOORBOX; |
83 | our $FLOORBOX; |
83 | our $GAUGES; |
84 | our $GAUGES; |
84 | our $STATWIDS; |
85 | our $STATWIDS; |
85 | |
86 | |
… | |
… | |
92 | |
93 | |
93 | our $ALT_ENTER_MESSAGE; |
94 | our $ALT_ENTER_MESSAGE; |
94 | our $STATUS_LINE; |
95 | our $STATUS_LINE; |
95 | our $DEBUG_STATUS; |
96 | our $DEBUG_STATUS; |
96 | |
97 | |
|
|
98 | our $INVWIN; |
|
|
99 | our $INV; |
|
|
100 | |
97 | sub status { |
101 | sub status { |
98 | $STATUS_LINE->set_text ($_[0]); |
102 | $STATUS_LINE->set_text ($_[0]); |
99 | $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}); |
100 | } |
104 | } |
101 | |
105 | |
… | |
… | |
108 | status "logging in..."; |
112 | status "logging in..."; |
109 | |
113 | |
110 | 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; |
111 | |
115 | |
112 | $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; |
116 | $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; |
113 | |
|
|
114 | $MAP = new CFClient::Map $mapsize, $mapsize; |
117 | $MAP = new CFClient::Map $mapsize, $mapsize; |
115 | |
118 | |
116 | my ($host, $port) = split /:/, $CFG->{host}; |
119 | my ($host, $port) = split /:/, $CFG->{host}; |
117 | |
120 | |
118 | $CONN = new conn |
121 | $CONN = eval { |
|
|
122 | new conn |
119 | host => $host, |
123 | host => $host, |
120 | port => $port || 13327, |
124 | port => $port || 13327, |
121 | user => $CFG->{user}, |
125 | user => $CFG->{user}, |
122 | pass => $CFG->{password}, |
126 | pass => $CFG->{password}, |
123 | mapw => $mapsize, |
127 | mapw => $mapsize, |
124 | maph => $mapsize, |
128 | maph => $mapsize, |
|
|
129 | ; |
125 | ; |
130 | }; |
126 | |
131 | |
|
|
132 | if ($CONN) { |
|
|
133 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
134 | |
127 | status "login successful"; |
135 | status "login successful"; |
128 | |
136 | |
129 | CFClient::lowdelay fileno $CONN->{fh}; |
137 | CFClient::lowdelay fileno $CONN->{fh}; |
|
|
138 | } else { |
|
|
139 | status "unable to connect"; |
|
|
140 | stop_game(); |
|
|
141 | } |
130 | } |
142 | } |
131 | |
143 | |
132 | sub stop_game { |
144 | sub 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; |
133 | undef $CONN; |
153 | undef $MAP; |
134 | } |
154 | } |
135 | |
155 | |
136 | sub client_setup { |
156 | sub client_setup { |
137 | my $dialog = new CFClient::UI::FancyFrame |
157 | my $dialog = new CFClient::UI::FancyFrame |
138 | title => "Client Setup", |
158 | title => "Client Setup", |
… | |
… | |
314 | audio_shutdown (); |
334 | audio_shutdown (); |
315 | audio_init (); |
335 | audio_init (); |
316 | } |
336 | } |
317 | ); |
337 | ); |
318 | |
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 | |
319 | $dialog |
351 | $dialog |
320 | } |
352 | } |
321 | |
353 | |
322 | sub set_stats_window_fontsize { |
354 | sub set_stats_window_fontsize { |
323 | for (values %{$STATWIDS}) { |
355 | for (values %{$STATWIDS}) { |
… | |
… | |
422 | |
454 | |
423 | my $row = 0; |
455 | my $row = 0; |
424 | my $col = 0; |
456 | my $col = 0; |
425 | |
457 | |
426 | my %resist_names = ( |
458 | my %resist_names = ( |
427 | 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.)", |
428 | 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.)", |
429 | conf => "Confusion", |
461 | conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
430 | fire => "Fire", |
462 | fire => "Fire (just your resistance to fire spells like burning hands, dragonbreath, meteor swarm fire, ...)", |
431 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
463 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
432 | magic => "Magic", |
464 | magic => "Magic (resistance to magic spells like magic missile or similar)", |
433 | 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)", |
434 | acid => "Acid", |
466 | acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
435 | pois => "Poison", |
467 | pois => "Poison (resistance to getting poisoned)", |
436 | para => "Paralysation", |
468 | para => "Paralysation (this resistance affects the chance you get paralysed)", |
437 | deat => "Death (resistance against death spells)", |
469 | deat => "Death (resistance against death spells)", |
438 | phys => "Physical", |
470 | phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)", |
439 | blind => "Blind", |
471 | blind => "Blind (blind resistance affects the chance of a successful blinding attack)", |
440 | 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)", |
441 | tund => "Turn undead", |
473 | tund => "Turn undead", |
442 | elec => "Electricity", |
474 | elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)", |
443 | cold => "Cold", |
475 | cold => "Cold (this is your resistance against cold spells like icestorm, snowstorm, ...)", |
444 | 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)", |
445 | ); |
477 | ); |
446 | for (qw/slow holyw conf fire depl magic |
478 | for (qw/slow holyw conf fire depl magic |
447 | drain acid pois para deat phys |
479 | drain acid pois para deat phys |
448 | blind fear tund elec cold ghit/) |
480 | blind fear tund elec cold ghit/) |
… | |
… | |
550 | |
582 | |
551 | } |
583 | } |
552 | |
584 | |
553 | sub metaserver_dialog { |
585 | sub metaserver_dialog { |
554 | my $dialog = new CFClient::UI::FancyFrame |
586 | my $dialog = new CFClient::UI::FancyFrame |
555 | title => "Metaserver", |
587 | title => "Server List", |
556 | child => (my $vbox = new CFClient::UI::VBox); |
588 | child => (my $vbox = new CFClient::UI::VBox); |
557 | |
589 | |
558 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
590 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
559 | |
591 | |
560 | $dialog |
592 | $dialog |
… | |
… | |
662 | |
694 | |
663 | $METASERVER = metaserver_dialog; |
695 | $METASERVER = metaserver_dialog; |
664 | |
696 | |
665 | $vbox->add (new CFClient::UI::Flopper |
697 | $vbox->add (new CFClient::UI::Flopper |
666 | expand => 1, |
698 | expand => 1, |
667 | text => "Metaserver", |
699 | text => "Server List", |
668 | other => $METASERVER, |
700 | other => $METASERVER, |
669 | tooltip => "Show a list of avaible crossfire servers", |
701 | tooltip => "Show a list of available crossfire servers", |
670 | connect_open => sub { |
702 | connect_open => sub { |
671 | update_metaserver $HOST; |
703 | update_metaserver $HOST; |
672 | } |
704 | } |
673 | ); |
705 | ); |
674 | } |
706 | } |
… | |
… | |
689 | hidden => 1, |
721 | hidden => 1, |
690 | tooltip => "The password for your character", |
722 | tooltip => "The password for your character", |
691 | connect_changed => sub { |
723 | connect_changed => sub { |
692 | my ($self, $value) = @_; |
724 | my ($self, $value) = @_; |
693 | $CFG->{password} = $value; |
725 | $CFG->{password} = $value; |
694 | } |
|
|
695 | ); |
|
|
696 | |
|
|
697 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
|
|
698 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
|
|
699 | text => $CFG->{say_command}, |
|
|
700 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
|
|
701 | ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
|
|
702 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
|
|
703 | connect_changed => sub { |
|
|
704 | my ($self, $value) = @_; |
|
|
705 | $CFG->{say_command} = $value; |
|
|
706 | } |
726 | } |
707 | ); |
727 | ); |
708 | |
728 | |
709 | $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"); |
710 | $table->add (1, 7, new CFClient::UI::Slider |
730 | $table->add (1, 7, new CFClient::UI::Slider |
… | |
… | |
717 | |
737 | |
718 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
738 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
719 | }, |
739 | }, |
720 | ); |
740 | ); |
721 | |
741 | |
722 | $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 |
723 | start_game; |
748 | : start_game; |
|
|
749 | }, |
724 | }); |
750 | ); |
725 | |
751 | |
726 | $dialog |
752 | $dialog |
727 | } |
753 | } |
728 | |
754 | |
729 | sub message_window { |
755 | sub message_window { |
… | |
… | |
778 | }; |
804 | }; |
779 | |
805 | |
780 | $window |
806 | $window |
781 | } |
807 | } |
782 | |
808 | |
|
|
809 | sub 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 | |
783 | sub sdl_init { |
815 | sub sdl_init { |
784 | CFClient::SDL_Init |
816 | CFClient::SDL_Init |
785 | and die "SDL::Init failed!\n"; |
817 | and die "SDL::Init failed!\n"; |
786 | } |
818 | } |
787 | |
819 | |
788 | sub video_init { |
820 | sub video_init { |
789 | sdl_init; |
821 | sdl_init; |
|
|
822 | |
|
|
823 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
790 | |
824 | |
791 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
825 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
792 | $FULLSCREEN = $CFG->{fullscreen}; |
826 | $FULLSCREEN = $CFG->{fullscreen}; |
793 | $FAST = $CFG->{fast}; |
827 | $FAST = $CFG->{fast}; |
794 | |
828 | |
… | |
… | |
821 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
855 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
822 | |
856 | |
823 | CFClient::UI::FancyFrame->new ( |
857 | CFClient::UI::FancyFrame->new ( |
824 | border_bg => [1, 1, 1, 192/255], |
858 | border_bg => [1, 1, 1, 192/255], |
825 | bg => [1, 1, 1, 0], |
859 | bg => [1, 1, 1, 0], |
826 | child => $MAPMAP = new CFClient::MapWidget::MapMap |
860 | child => ($MAPMAP = new CFClient::MapWidget::MapMap), |
827 | )->show; |
861 | )->show; |
828 | |
862 | |
829 | $MAPWIDGET = new CFClient::MapWidget; |
863 | $MAPWIDGET = new CFClient::MapWidget; |
830 | $MAPWIDGET->connect (activate_console => sub { |
864 | $MAPWIDGET->connect (activate_console => sub { |
831 | my ($mapwidget, $preset) = @_; |
865 | my ($mapwidget, $preset) = @_; |
… | |
… | |
846 | |
880 | |
847 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
881 | $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); |
882 | $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); |
883 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
850 | |
884 | |
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 |
885 | 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 |
|
|
886 | |
852 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
887 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
888 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
853 | |
889 | |
854 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
890 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
855 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
891 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
856 | status "Configuration Saved"; |
892 | status "Configuration Saved"; |
857 | }); |
893 | }); |
… | |
… | |
869 | } |
905 | } |
870 | |
906 | |
871 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
907 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
872 | my $bgmusic;#TODO#hack#d# |
908 | my $bgmusic;#TODO#hack#d# |
873 | |
909 | |
|
|
910 | sub audio_channel_finished { |
|
|
911 | my ($channel) = @_; |
|
|
912 | |
|
|
913 | warn "channel $channel finished\n";#d# |
|
|
914 | } |
|
|
915 | |
874 | sub audio_music_finished { |
916 | sub audio_music_finished { |
875 | return unless $CFG->{bgm_enable}; |
917 | return unless $CFG->{bgm_enable}; |
876 | |
918 | |
877 | # TODO: hack, do play loop and mood music |
919 | # TODO: hack, do play loop and mood music |
878 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/$bgmusic[0]"; |
920 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/$bgmusic[0]"; |
… | |
… | |
881 | push @bgmusic, shift @bgmusic; |
923 | push @bgmusic, shift @bgmusic; |
882 | } |
924 | } |
883 | |
925 | |
884 | sub audio_init { |
926 | sub audio_init { |
885 | if ($CFG->{audio_enable}) { |
927 | if ($CFG->{audio_enable}) { |
886 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
928 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
887 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
929 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
888 | CFClient::Mix_AllocateChannels 8; |
930 | CFClient::Mix_AllocateChannels 8; |
889 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
931 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
890 | |
932 | |
891 | audio_music_finished; |
933 | audio_music_finished; |
… | |
… | |
1153 | } |
1195 | } |
1154 | |
1196 | |
1155 | gotid: |
1197 | gotid: |
1156 | $face->{id} = $id; |
1198 | $face->{id} = $id; |
1157 | $MAP->set_face ($facenum => $id); |
1199 | $MAP->set_face ($facenum => $id); |
1158 | $self->{faceid}[$facenum] = $id;#d# |
|
|
1159 | $TILECACHE->get ($id) |
1200 | $TILECACHE->get ($id) |
1160 | } |
1201 | } |
1161 | |
1202 | |
1162 | sub conn::face_update { |
1203 | sub conn::face_update { |
1163 | my ($self, $facenum, $face) = @_; |
1204 | my ($self, $facenum, $face) = @_; |
… | |
… | |
1302 | |
1343 | |
1303 | for my $skill (values %{$self->{skill_info}}) { |
1344 | for my $skill (values %{$self->{skill_info}}) { |
1304 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1345 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1305 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1346 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1306 | } |
1347 | } |
|
|
1348 | |
|
|
1349 | $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you"); |
|
|
1350 | $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players"); |
|
|
1351 | $MAPWIDGET->add_command ("pet\\_mode sad", "Search & Destroy - tell pets to roam about and attack enemies"); |
|
|
1352 | $MAPWIDGET->add_command ("kill\\_pets", "kill your pets"); |
|
|
1353 | } |
|
|
1354 | |
|
|
1355 | sub conn::eof { |
|
|
1356 | stop_game; |
1307 | } |
1357 | } |
1308 | |
1358 | |
1309 | sub update_floorbox { |
1359 | sub update_floorbox { |
1310 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1360 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
|
|
1361 | return unless $CONN; |
|
|
1362 | |
1311 | $FLOORBOX->clear; |
1363 | $FLOORBOX->clear; |
1312 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1364 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1313 | |
1365 | |
1314 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1315 | |
|
|
1316 | # we basically have to use the same sorting as everybody else |
1366 | # we basically have to use the same sorting as everybody else |
1317 | @items = sort { $a->{type} <=> $b->{type} } @items; |
1367 | for my $item (@{ $CONN->{container}{0} }) { |
1318 | |
1368 | $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item); |
1319 | for my $item (reverse @items) { |
|
|
1320 | my $desc = $item->{nrof} < 2 |
|
|
1321 | ? $item->{name} |
|
|
1322 | : "$item->{nrof} $item->{name_pl}"; |
|
|
1323 | # todo: animation widget, face widget, weight(?) etc. |
|
|
1324 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
|
|
1325 | tooltip => (CFClient::UI::Label->escape ($desc) |
|
|
1326 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
|
|
1327 | can_hover => 1, |
|
|
1328 | can_events => 1, |
|
|
1329 | connect_button_down => sub { |
|
|
1330 | my ($self, $ev, $x, $y) = @_; |
|
|
1331 | |
|
|
1332 | # todo: maybe put examine on 1? but should just be a tooltip :( |
|
|
1333 | if ($ev->{button} == 1) { |
|
|
1334 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
|
|
1335 | } elsif ($ev->{button} == 2) { |
|
|
1336 | $CONN->send ("apply $item->{tag}"); |
|
|
1337 | } elsif ($ev->{button} == 3) { |
|
|
1338 | # examine, lock, mark, maybe other things |
|
|
1339 | warn "MENU not implemented yet\n"; |
|
|
1340 | } |
|
|
1341 | |
|
|
1342 | 1 |
|
|
1343 | }, |
|
|
1344 | ); |
|
|
1345 | |
|
|
1346 | $hbox->add (new CFClient::UI::Face |
|
|
1347 | can_events => 0, |
|
|
1348 | face => $item->{face}, |
|
|
1349 | anim => $item->{anim}, |
|
|
1350 | animspeed => $item->{animspeed}, |
|
|
1351 | ); |
|
|
1352 | |
|
|
1353 | $hbox->add (new CFClient::UI::Label |
|
|
1354 | can_events => 0, |
|
|
1355 | text => $desc, |
|
|
1356 | ); |
|
|
1357 | } |
1369 | } |
1358 | }); |
1370 | }); |
1359 | refresh; |
1371 | refresh; |
1360 | } |
1372 | } |
1361 | |
1373 | |
1362 | sub conn::container_add { |
1374 | sub conn::container_add { |
1363 | my ($self, $id, $items) = @_; |
1375 | my ($self, $id, $items) = @_; |
1364 | |
1376 | |
1365 | update_floorbox if $id == 0; |
1377 | update_floorbox if $id == 0; |
|
|
1378 | if ($self->{player}{tag} == $id) { |
|
|
1379 | $INV->set_items ($self->{container}{$self->{player}{tag}}); |
|
|
1380 | } |
1366 | # $self-<{player}{tag} => player inv |
1381 | # $self-<{player}{tag} => player inv |
1367 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1382 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1368 | } |
1383 | } |
1369 | |
1384 | |
1370 | sub conn::container_clear { |
1385 | sub conn::container_clear { |
1371 | my ($self, $id) = @_; |
1386 | my ($self, $id) = @_; |
1372 | |
1387 | |
1373 | update_floorbox if $id == 0; |
1388 | update_floorbox if $id == 0; |
|
|
1389 | if ($self->{player}{tag} == $id) { |
|
|
1390 | $INV->set_items ($self->{container}{$id}); |
|
|
1391 | } |
|
|
1392 | |
1374 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1393 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1375 | } |
1394 | } |
1376 | |
1395 | |
1377 | sub conn::item_delete { |
1396 | sub conn::item_delete { |
1378 | my ($self, @items) = @_; |
1397 | my ($self, @items) = @_; |
1379 | |
1398 | |
1380 | for (@items) { |
1399 | for (@items) { |
1381 | update_floorbox if $_->{container} == 0; |
1400 | update_floorbox if $_->{container} == 0; |
|
|
1401 | if ($self->{player}{tag} == $_->{container}) { |
|
|
1402 | $INV->set_items ($self->{container}{$_->{container}}); |
|
|
1403 | } |
1382 | } |
1404 | } |
1383 | } |
1405 | } |
1384 | |
1406 | |
1385 | sub conn::item_update { |
1407 | sub conn::item_update { |
1386 | my ($self, $item) = @_; |
1408 | my ($self, $item) = @_; |
1387 | |
1409 | |
1388 | update_floorbox if $item->{container} == 0; |
1410 | update_floorbox if $item->{container} == 0; |
|
|
1411 | if ($self->{player}{tag} == $item->{container}) { |
|
|
1412 | $INV->set_items ($self->{container}{$item->{container}}); |
|
|
1413 | } |
1389 | } |
1414 | } |
1390 | |
1415 | |
1391 | %SDL_CB = ( |
1416 | %SDL_CB = ( |
1392 | CFClient::SDL_QUIT => sub { |
1417 | CFClient::SDL_QUIT => sub { |
1393 | Event::unloop -1; |
1418 | Event::unloop -1; |
… | |
… | |
1406 | video_init; |
1431 | video_init; |
1407 | } else { |
1432 | } else { |
1408 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1433 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
1409 | } |
1434 | } |
1410 | }, |
1435 | }, |
1411 | CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, |
1436 | CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, |
1412 | CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, |
1437 | CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, |
1413 | CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, |
1438 | CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, |
1414 | CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, |
1439 | CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, |
1415 | CFClient::SDL_USEREVENT => \&audio_music_finished, |
1440 | CFClient::SDL_USEREVENT => sub { |
|
|
1441 | if ($_[0]{code} == 1) { |
|
|
1442 | audio_channel_finished $_[0]{data1}; |
|
|
1443 | } elsif ($_[0]{code} == 0) { |
|
|
1444 | audio_music_finished; |
|
|
1445 | } |
|
|
1446 | }, |
1416 | ); |
1447 | ); |
1417 | |
1448 | |
1418 | ############################################################################# |
1449 | ############################################################################# |
1419 | |
1450 | |
1420 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1451 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
1452 | |
|
|
1453 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
1421 | |
1454 | |
1422 | $TILECACHE = CFClient::db_table "tilecache"; |
1455 | $TILECACHE = CFClient::db_table "tilecache"; |
1423 | $FACEMAP = CFClient::db_table "facemap"; |
1456 | $FACEMAP = CFClient::db_table "facemap"; |
1424 | |
|
|
1425 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1426 | |
1457 | |
1427 | my %DEF_CFG = ( |
1458 | my %DEF_CFG = ( |
1428 | sdl_mode => 0, |
1459 | sdl_mode => 0, |
1429 | width => 640, |
1460 | width => 640, |
1430 | height => 480, |
1461 | height => 480, |