… | |
… | |
70 | |
70 | |
71 | our $FONT_PROP; |
71 | our $FONT_PROP; |
72 | our $FONT_FIXED; |
72 | our $FONT_FIXED; |
73 | |
73 | |
74 | our $MAP; |
74 | our $MAP; |
|
|
75 | our $MAPMAP; |
75 | our $MAPWIDGET; |
76 | our $MAPWIDGET; |
76 | our $BUTTONBAR; |
77 | our $BUTTONBAR; |
77 | our $LOGVIEW; |
78 | our $LOGVIEW; |
78 | our $CONSOLE; |
79 | our $CONSOLE; |
79 | our $METASERVER; |
80 | our $METASERVER; |
… | |
… | |
91 | |
92 | |
92 | our $ALT_ENTER_MESSAGE; |
93 | our $ALT_ENTER_MESSAGE; |
93 | our $STATUS_LINE; |
94 | our $STATUS_LINE; |
94 | our $DEBUG_STATUS; |
95 | our $DEBUG_STATUS; |
95 | |
96 | |
|
|
97 | our $INVWIN; |
|
|
98 | our $INV; |
|
|
99 | |
96 | sub status { |
100 | sub 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 | } |
100 | |
104 | |
… | |
… | |
112 | |
116 | |
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) { |
126 | status "login successful"; |
133 | status "login successful"; |
127 | |
134 | |
128 | CFClient::lowdelay fileno $CONN->{fh}; |
135 | CFClient::lowdelay fileno $CONN->{fh}; |
|
|
136 | } else { |
|
|
137 | status "unable to connect"; |
|
|
138 | } |
129 | } |
139 | } |
130 | |
140 | |
131 | sub stop_game { |
141 | sub stop_game { |
132 | undef $CONN; |
142 | undef $CONN; |
133 | } |
143 | } |
… | |
… | |
313 | audio_shutdown (); |
323 | audio_shutdown (); |
314 | audio_init (); |
324 | audio_init (); |
315 | } |
325 | } |
316 | ); |
326 | ); |
317 | |
327 | |
|
|
328 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Communication cmd"); |
|
|
329 | $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry |
|
|
330 | text => $CFG->{say_command}, |
|
|
331 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
|
|
332 | ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
|
|
333 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
|
|
334 | connect_changed => sub { |
|
|
335 | my ($self, $value) = @_; |
|
|
336 | $CFG->{say_command} = $value; |
|
|
337 | } |
|
|
338 | ); |
|
|
339 | |
318 | $dialog |
340 | $dialog |
319 | } |
341 | } |
320 | |
342 | |
321 | sub set_stats_window_fontsize { |
343 | sub set_stats_window_fontsize { |
322 | for (values %{$STATWIDS}) { |
344 | for (values %{$STATWIDS}) { |
… | |
… | |
379 | |
401 | |
380 | $win |
402 | $win |
381 | } |
403 | } |
382 | |
404 | |
383 | sub make_stats_window { |
405 | sub make_stats_window { |
384 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
406 | my $tgw = new CFClient::UI::FancyFrame x => $WIDTH * 2/5, y => 0, title => "Stats"; |
385 | |
407 | |
386 | $tgw->add (my $vb = new CFClient::UI::VBox); |
408 | $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); |
409 | $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); |
410 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
389 | |
411 | |
390 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
412 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
391 | |
413 | |
… | |
… | |
410 | [2, 5, st_wspd => "WSp", 10.54, "Weapon Speed, how many attacks you may make per unit of time (0.120s). Higher values indicate faster attack speed. Current weapon and Dex effect the value of weapon speed."], |
432 | [2, 5, st_wspd => "WSp", 10.54, "Weapon Speed, how many attacks you may make per unit of time (0.120s). Higher values indicate faster attack speed. Current weapon and Dex effect the value of weapon speed."], |
411 | ) { |
433 | ) { |
412 | my ($col, $row, $id, $label, $template, $tooltip) = @$_; |
434 | my ($col, $row, $id, $label, $template, $tooltip) = @$_; |
413 | |
435 | |
414 | $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label |
436 | $tbl->add ($col , $row, $STATWIDS->{$id} = new CFClient::UI::Label |
415 | can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
437 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, align => +1, template => $template, tooltip => $tooltip); |
416 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
438 | $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFClient::UI::Label |
417 | can_hover => 1, can_events => 1, fg => $black, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
439 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $black, valign => 0, align => -1, text => $label, tooltip => $tooltip); |
418 | } |
440 | } |
419 | |
441 | |
420 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
442 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
421 | |
443 | |
422 | my $row = 0; |
444 | my $row = 0; |
423 | my $col = 0; |
445 | my $col = 0; |
424 | |
446 | |
425 | my %resist_names = ( |
447 | my %resist_names = ( |
426 | slow => "Slow", |
448 | 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", |
449 | 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", |
450 | conf => "Confusion (If you are hit by confusion you will move into random directions, and likely into monsters.)", |
429 | fire => "Fire", |
451 | 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)", |
452 | depl => "Depletion (some monsters and other effects can cause stats depletion)", |
431 | magic => "Magic", |
453 | 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)", |
454 | drain => "Draining (some monsters (e.g. vampires) and other effects can steal experience)", |
433 | acid => "Acid", |
455 | acid => "Acid (resistance to acid, acid hurts pretty much and also corrodes your weapons)", |
434 | pois => "Poison", |
456 | pois => "Poison (resistance to getting poisoned)", |
435 | para => "Paralysation", |
457 | para => "Paralysation (this resistance affects the chance you get paralysed)", |
436 | deat => "Death (resistance against death spells)", |
458 | deat => "Death (resistance against death spells)", |
437 | phys => "Physical", |
459 | phys => "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat)", |
438 | blind => "Blind", |
460 | blind => "Blind (blind resistance affects the chance of a successful blinding attack)", |
439 | fear => "Fear", |
461 | 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", |
462 | tund => "Turn undead", |
441 | elec => "Electricity", |
463 | elec => "Electricity (resistance againt electricity, spells like large lightning, small lightning, ...)", |
442 | cold => "Cold", |
464 | 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)", |
465 | ghit => "Ghost hit (special attack used by ghosts and ghost-like beings)", |
444 | ); |
466 | ); |
445 | for (qw/slow holyw conf fire depl magic |
467 | for (qw/slow holyw conf fire depl magic |
446 | drain acid pois para deat phys |
468 | drain acid pois para deat phys |
447 | blind fear tund elec cold ghit/) |
469 | blind fear tund elec cold ghit/) |
448 | { |
470 | { |
449 | $tbl2->add ($col, $row, |
471 | $tbl2->add ($col, $row, |
450 | $STATWIDS->{"res_$_"} = |
472 | $STATWIDS->{"res_$_"} = |
451 | new CFClient::UI::Label |
473 | new CFClient::UI::Label |
|
|
474 | font => $FONT_FIXED, |
452 | template => "-100%", |
475 | template => "-100%", |
453 | align => +1, |
476 | align => +1, |
454 | valign => 0, |
477 | valign => 0, |
455 | can_events => 1, |
478 | can_events => 1, |
456 | can_hover => 1, |
479 | can_hover => 1, |
457 | tooltip => $resist_names{$_}, |
480 | tooltip => $resist_names{$_}, |
458 | ); |
481 | ); |
459 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
482 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
|
|
483 | font => $FONT_FIXED, |
460 | can_hover => 1, |
484 | can_hover => 1, |
461 | can_events => 1, |
485 | can_events => 1, |
462 | image => "ui/resist/resist_$_.png", |
486 | image => "ui/resist/resist_$_.png", |
463 | tooltip => $resist_names{$_}, |
487 | tooltip => $resist_names{$_}, |
464 | ); |
488 | ); |
… | |
… | |
689 | my ($self, $value) = @_; |
713 | my ($self, $value) = @_; |
690 | $CFG->{password} = $value; |
714 | $CFG->{password} = $value; |
691 | } |
715 | } |
692 | ); |
716 | ); |
693 | |
717 | |
694 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
|
|
695 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
|
|
696 | text => $CFG->{say_command}, |
|
|
697 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
|
|
698 | ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
|
|
699 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
|
|
700 | connect_changed => sub { |
|
|
701 | my ($self, $value) = @_; |
|
|
702 | $CFG->{say_command} = $value; |
|
|
703 | } |
|
|
704 | ); |
|
|
705 | |
|
|
706 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
718 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
707 | $table->add (1, 7, new CFClient::UI::Slider |
719 | $table->add (1, 7, new CFClient::UI::Slider |
708 | req_w => 100, |
720 | req_w => 100, |
709 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
721 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
710 | tooltip => "This is the size of the portion of the map update the server sends you. " |
722 | tooltip => "This is the size of the portion of the map update the server sends you. " |
… | |
… | |
724 | } |
736 | } |
725 | |
737 | |
726 | sub message_window { |
738 | sub message_window { |
727 | my $window = new CFClient::UI::FancyFrame |
739 | my $window = new CFClient::UI::FancyFrame |
728 | title => "Messages", |
740 | title => "Messages", |
729 | border_bg => [1, 1, 1, 0.5], |
741 | border_bg => [1, 1, 1, 1], |
730 | bg => [0.3, 0.3, 0.3, 0.8], |
742 | bg => [0, 0, 0, 0.5], |
731 | user_w => int $::WIDTH / 3, |
743 | user_w => int $::WIDTH / 3, |
732 | user_h => int $::HEIGHT / 5, |
744 | user_h => int $::HEIGHT / 5, |
733 | child => (my $vbox = new CFClient::UI::VBox); |
745 | child => (my $vbox = new CFClient::UI::VBox); |
734 | |
746 | |
735 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
747 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
… | |
… | |
775 | }; |
787 | }; |
776 | |
788 | |
777 | $window |
789 | $window |
778 | } |
790 | } |
779 | |
791 | |
|
|
792 | sub make_inventory_window { |
|
|
793 | my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory"; |
|
|
794 | $invwin->add ($INV = new CFClient::UI::Inventory expand => 1); |
|
|
795 | $invwin |
|
|
796 | } |
|
|
797 | |
780 | sub sdl_init { |
798 | sub sdl_init { |
781 | CFClient::SDL_Init |
799 | CFClient::SDL_Init |
782 | and die "SDL::Init failed!\n"; |
800 | and die "SDL::Init failed!\n"; |
783 | } |
801 | } |
784 | |
802 | |
… | |
… | |
815 | fontsize => 0.8, |
833 | fontsize => 0.8, |
816 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
834 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
817 | $ALT_ENTER_MESSAGE->show; |
835 | $ALT_ENTER_MESSAGE->show; |
818 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
836 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
819 | |
837 | |
820 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); |
838 | CFClient::UI::FancyFrame->new ( |
821 | $MAPWIDGET->focus_in; |
839 | border_bg => [1, 1, 1, 192/255], |
|
|
840 | bg => [1, 1, 1, 0], |
|
|
841 | child => ($MAPMAP = new CFClient::MapWidget::MapMap), |
|
|
842 | )->show; |
|
|
843 | |
|
|
844 | $MAPWIDGET = new CFClient::MapWidget; |
822 | $MAPWIDGET->connect (activate_console => sub { |
845 | $MAPWIDGET->connect (activate_console => sub { |
823 | my ($mapwidget, $preset) = @_; |
846 | my ($mapwidget, $preset) = @_; |
824 | |
847 | |
825 | if ($CONSOLE) { |
848 | if ($CONSOLE) { |
826 | $CONSOLE->{input}->{auto_activated} = 1; |
849 | $CONSOLE->{input}->{auto_activated} = 1; |
… | |
… | |
829 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
852 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
830 | $CONSOLE->{input}->set_text ($preset); |
853 | $CONSOLE->{input}->set_text ($preset); |
831 | } |
854 | } |
832 | } |
855 | } |
833 | }); |
856 | }); |
|
|
857 | $MAPWIDGET->show; |
|
|
858 | $MAPWIDGET->focus_in; |
834 | |
859 | |
835 | $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); |
860 | $BUTTONBAR = new CFClient::UI::HBox; |
836 | |
861 | |
837 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
862 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
838 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
863 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
839 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
864 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
840 | |
865 | |
841 | $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 |
866 | 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 |
|
|
867 | |
842 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
868 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
869 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
843 | |
870 | |
844 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
871 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
845 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
872 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
846 | status "Configuration Saved"; |
873 | status "Configuration Saved"; |
847 | }); |
874 | }); |
|
|
875 | |
|
|
876 | $BUTTONBAR->show; |
848 | |
877 | |
849 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
878 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
850 | } |
879 | } |
851 | |
880 | |
852 | sub video_shutdown { |
881 | sub video_shutdown { |
… | |
… | |
869 | push @bgmusic, shift @bgmusic; |
898 | push @bgmusic, shift @bgmusic; |
870 | } |
899 | } |
871 | |
900 | |
872 | sub audio_init { |
901 | sub audio_init { |
873 | if ($CFG->{audio_enable}) { |
902 | if ($CFG->{audio_enable}) { |
874 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
903 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
875 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
904 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
876 | CFClient::Mix_AllocateChannels 8; |
905 | CFClient::Mix_AllocateChannels 8; |
877 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
906 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
878 | |
907 | |
879 | audio_music_finished; |
908 | audio_music_finished; |
… | |
… | |
1034 | # at worst. |
1063 | # at worst. |
1035 | sub conn::flood_fill { |
1064 | sub conn::flood_fill { |
1036 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
1065 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
1037 | |
1066 | |
1038 | # the server does not allow map paths > 6 |
1067 | # the server does not allow map paths > 6 |
1039 | return if 6 <= length $path; |
1068 | return if 7 <= length $path; |
1040 | |
1069 | |
1041 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1070 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1042 | |
1071 | |
1043 | for ( |
1072 | for ( |
1044 | [1, 0, -1], |
1073 | [1, 0, -1], |
… | |
… | |
1087 | |
1116 | |
1088 | $self->flush_map; |
1117 | $self->flush_map; |
1089 | |
1118 | |
1090 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
1119 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
1091 | |
1120 | |
1092 | my $mapmapw = 250; |
1121 | my $mapmapw = $MAPMAP->{w}; |
1093 | my $mapmaph = 250; |
1122 | my $mapmaph = $MAPMAP->{h}; |
1094 | |
1123 | |
1095 | $self->{neigh_rect} = [ |
1124 | $self->{neigh_rect} = [ |
1096 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1125 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1097 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1126 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1098 | ]; |
1127 | ]; |
… | |
… | |
1297 | sub update_floorbox { |
1326 | sub update_floorbox { |
1298 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1327 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
1299 | $FLOORBOX->clear; |
1328 | $FLOORBOX->clear; |
1300 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1329 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1301 | |
1330 | |
1302 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1303 | |
|
|
1304 | # we basically have to use the same sorting as everybody else |
1331 | # we basically have to use the same sorting as everybody else |
1305 | @items = sort { $a->{type} <=> $b->{type} } @items; |
1332 | for my $item (@{ $CONN->{container}{0} }) { |
1306 | |
|
|
1307 | for my $item (reverse @items) { |
|
|
1308 | my $desc = $item->{nrof} < 2 |
1333 | my $desc = $item->{nrof} < 2 |
1309 | ? $item->{name} |
1334 | ? $item->{name} |
1310 | : "$item->{nrof} $item->{name_pl}"; |
1335 | : "$item->{nrof} $item->{name_pl}"; |
1311 | # todo: animation widget, face widget, weight(?) etc. |
1336 | # todo: animation widget, face widget, weight(?) etc. |
1312 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
1337 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
… | |
… | |
1321 | if ($ev->{button} == 1) { |
1346 | if ($ev->{button} == 1) { |
1322 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
1347 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
1323 | } elsif ($ev->{button} == 2) { |
1348 | } elsif ($ev->{button} == 2) { |
1324 | $CONN->send ("apply $item->{tag}"); |
1349 | $CONN->send ("apply $item->{tag}"); |
1325 | } elsif ($ev->{button} == 3) { |
1350 | } elsif ($ev->{button} == 3) { |
1326 | # examine, lock, mark, maybe other things |
1351 | CFClient::UI::Menu->new ( |
1327 | warn "MENU not implemented yet\n"; |
1352 | items => [ |
|
|
1353 | ["examine", sub { $CONN->send ("examine $item->{tag}") }], |
|
|
1354 | [ |
|
|
1355 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
|
|
1356 | sub { $CONN->send ("lock $item->{tag}") }, |
|
|
1357 | ], |
|
|
1358 | ["mark", sub { $CONN->send ("mark $item->{tag}") }], |
|
|
1359 | ["apply", sub { $CONN->send ("apply $item->{tag}") }], |
|
|
1360 | ], |
|
|
1361 | )->popup ($ev); |
1328 | } |
1362 | } |
1329 | |
1363 | |
1330 | 1 |
1364 | 1 |
1331 | }, |
1365 | }, |
1332 | ); |
1366 | ); |
… | |
… | |
1349 | |
1383 | |
1350 | sub conn::container_add { |
1384 | sub conn::container_add { |
1351 | my ($self, $id, $items) = @_; |
1385 | my ($self, $id, $items) = @_; |
1352 | |
1386 | |
1353 | update_floorbox if $id == 0; |
1387 | update_floorbox if $id == 0; |
|
|
1388 | if ($self->{player}{tag} == $id) { |
|
|
1389 | $INV->set_items ($self->{container}{$self->{player}{tag}}); |
|
|
1390 | } |
1354 | # $self-<{player}{tag} => player inv |
1391 | # $self-<{player}{tag} => player inv |
1355 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1392 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1356 | } |
1393 | } |
1357 | |
1394 | |
1358 | sub conn::container_clear { |
1395 | sub conn::container_clear { |
1359 | my ($self, $id) = @_; |
1396 | my ($self, $id) = @_; |
1360 | |
1397 | |
1361 | update_floorbox if $id == 0; |
1398 | update_floorbox if $id == 0; |
|
|
1399 | if ($self->{player}{tag} == $id) { |
|
|
1400 | $INV->set_items ($self->{container}{$id}); |
|
|
1401 | } |
|
|
1402 | |
1362 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1403 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1363 | } |
1404 | } |
1364 | |
1405 | |
1365 | sub conn::item_delete { |
1406 | sub conn::item_delete { |
1366 | my ($self, @items) = @_; |
1407 | my ($self, @items) = @_; |
1367 | |
1408 | |
1368 | for (@items) { |
1409 | for (@items) { |
1369 | update_floorbox if $_->{container} == 0; |
1410 | update_floorbox if $_->{container} == 0; |
|
|
1411 | if ($self->{player}{tag} == $_->{container}) { |
|
|
1412 | $INV->set_items ($self->{container}{$_->{container}}); |
|
|
1413 | } |
1370 | } |
1414 | } |
1371 | } |
1415 | } |
1372 | |
1416 | |
1373 | sub conn::item_update { |
1417 | sub conn::item_update { |
1374 | my ($self, $item) = @_; |
1418 | my ($self, $item) = @_; |
1375 | |
1419 | |
1376 | update_floorbox if $item->{container} == 0; |
1420 | update_floorbox if $item->{container} == 0; |
|
|
1421 | if ($self->{player}{tag} == $item->{container}) { |
|
|
1422 | $INV->set_items ($self->{container}{$item->{container}}); |
|
|
1423 | } |
1377 | } |
1424 | } |
1378 | |
1425 | |
1379 | %SDL_CB = ( |
1426 | %SDL_CB = ( |
1380 | CFClient::SDL_QUIT => sub { |
1427 | CFClient::SDL_QUIT => sub { |
1381 | Event::unloop -1; |
1428 | Event::unloop -1; |
… | |
… | |
1405 | |
1452 | |
1406 | ############################################################################# |
1453 | ############################################################################# |
1407 | |
1454 | |
1408 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1455 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1409 | |
1456 | |
|
|
1457 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1458 | |
1410 | $TILECACHE = CFClient::db_table "tilecache"; |
1459 | $TILECACHE = CFClient::db_table "tilecache"; |
1411 | $FACEMAP = CFClient::db_table "facemap"; |
1460 | $FACEMAP = CFClient::db_table "facemap"; |
1412 | |
|
|
1413 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1414 | |
1461 | |
1415 | my %DEF_CFG = ( |
1462 | my %DEF_CFG = ( |
1416 | sdl_mode => 0, |
1463 | sdl_mode => 0, |
1417 | width => 640, |
1464 | width => 640, |
1418 | height => 480, |
1465 | height => 480, |