… | |
… | |
104 | our $INV; |
104 | our $INV; |
105 | our $INVR; |
105 | our $INVR; |
106 | our $INV_RIGHT_HB; |
106 | our $INV_RIGHT_HB; |
107 | |
107 | |
108 | our $BIND_WINDOW; |
108 | our $BIND_WINDOW; |
|
|
109 | our $BIND_EDITOR; |
|
|
110 | |
|
|
111 | our $SPELL_LIST; |
109 | |
112 | |
110 | sub status { |
113 | sub status { |
111 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
114 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
112 | } |
115 | } |
113 | |
116 | |
… | |
… | |
863 | on_activate => sub { |
866 | on_activate => sub { |
864 | my ($input, $text) = @_; |
867 | my ($input, $text) = @_; |
865 | $input->set_text (''); |
868 | $input->set_text (''); |
866 | |
869 | |
867 | if ($text =~ /^\/bind\s+(.*)$/) { |
870 | if ($text =~ /^\/bind\s+(.*)$/) { |
868 | CFClient::Recorder::open_binding_dialog ([$1]); |
871 | CFClient::Binder::open_binding_dialog (sub { |
|
|
872 | my ($mod, $sym) = @_; |
|
|
873 | $::CFG->{bindings}->{$mod}->{$sym} = [$1]; |
|
|
874 | }); |
869 | } elsif ($text =~ /^\/(.*)/) { |
875 | } elsif ($text =~ /^\/(.*)/) { |
870 | $::CONN->user_send ($1); |
876 | $::CONN->user_send ($1); |
871 | } else { |
877 | } else { |
872 | my $say_cmd = $::CFG->{say_command} || 'say'; |
878 | my $say_cmd = $::CFG->{say_command} || 'say'; |
873 | $::CONN->user_send ("$say_cmd $text"); |
879 | $::CONN->user_send ("$say_cmd $text"); |
… | |
… | |
926 | x => "center", |
932 | x => "center", |
927 | y => "center", |
933 | y => "center", |
928 | force_w => $WIDTH * 9/10, |
934 | force_w => $WIDTH * 9/10, |
929 | force_h => $HEIGHT * 9/10, |
935 | force_h => $HEIGHT * 9/10, |
930 | title => "Inventory", |
936 | title => "Inventory", |
931 | name => "inventory_window", |
|
|
932 | ; |
937 | ; |
933 | |
938 | |
934 | $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); |
939 | $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); |
935 | |
940 | |
936 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
941 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
… | |
… | |
947 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
952 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
948 | |
953 | |
949 | $invwin |
954 | $invwin |
950 | } |
955 | } |
951 | |
956 | |
|
|
957 | sub make_spell_list { |
|
|
958 | $SPELL_LIST = new CFClient::UI::SpellList |
|
|
959 | force_w => $WIDTH * (9/10), |
|
|
960 | force_h => $HEIGHT * (9/10); |
|
|
961 | $SPELL_LIST |
|
|
962 | } |
|
|
963 | |
952 | sub make_binding_window { |
964 | sub make_binding_window { |
953 | my $binding_list = new CFClient::UI::VBox; |
965 | my $binding_list = new CFClient::UI::VBox; |
954 | |
966 | |
|
|
967 | my $refresh; |
955 | my $refresh = sub { |
968 | $refresh = sub { |
956 | $binding_list->clear (); |
969 | $binding_list->clear (); |
957 | |
970 | |
958 | for my $mod (keys %{$::CFG->{bindings}}) { |
971 | for my $mod (keys %{$::CFG->{bindings}}) { |
959 | for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { |
972 | for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { |
960 | my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; |
973 | my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; |
961 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
974 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
962 | |
975 | |
963 | my $lbl = join "; ", @$cmds; |
976 | my $lbl = join "; ", @$cmds; |
964 | my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); |
977 | my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); |
965 | $binding_list->add (my $hb = new CFClient::UI::HBox); |
978 | $binding_list->add (my $hb = new CFClient::UI::HBox); |
966 | $hb->add (new CFClient::UI::Button |
979 | $hb->add (new CFClient::UI::Button |
967 | text => "delete", |
980 | text => "delete", |
|
|
981 | tooltip => "Deletes the binding", |
968 | on_activate => sub { |
982 | on_activate => sub { |
969 | $binding_list->remove ($hb); |
983 | $binding_list->remove ($hb); |
970 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
984 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
971 | }); |
985 | }); |
|
|
986 | |
|
|
987 | $hb->add (new CFClient::UI::Button |
|
|
988 | text => "edit", |
|
|
989 | tooltip => "Edits the binding", |
|
|
990 | on_activate => sub { |
|
|
991 | $::BIND_EDITOR->set_binding ( |
|
|
992 | $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, |
|
|
993 | sub { |
|
|
994 | my ($nmod, $nsym, $ncmds) = @_; |
|
|
995 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
|
|
996 | $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; |
|
|
997 | $refresh->(); |
|
|
998 | $::BIND_WINDOW->show; |
|
|
999 | }, |
|
|
1000 | sub { |
|
|
1001 | $::BIND_WINDOW->show; |
|
|
1002 | }); |
|
|
1003 | $::BIND_EDITOR->show; |
|
|
1004 | $::BIND_WINDOW->hide; |
|
|
1005 | }); |
|
|
1006 | |
972 | $hb->add (new CFClient::UI::Label text => "($nam)"); |
1007 | $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); |
973 | $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); |
1008 | $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); |
974 | } |
1009 | } |
975 | } |
1010 | } |
976 | }; |
1011 | }; |
977 | |
1012 | |
… | |
… | |
984 | on_visibility_change => sub { |
1019 | on_visibility_change => sub { |
985 | my ($self, $visible) = @_; |
1020 | my ($self, $visible) = @_; |
986 | $refresh->() if $visible; |
1021 | $refresh->() if $visible; |
987 | }; |
1022 | }; |
988 | |
1023 | |
|
|
1024 | $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox); |
989 | $BIND_WINDOW->add ($binding_list); |
1025 | $vb->add ($binding_list); |
|
|
1026 | $vb->add (my $hb = new CFClient::UI::HBox); |
|
|
1027 | $hb->add (new CFClient::UI::Button |
|
|
1028 | text => "record new", |
|
|
1029 | expand => 1, |
|
|
1030 | tooltip => "This button opens the binding editor with an empty binding.", |
|
|
1031 | on_activate => sub { |
|
|
1032 | $::BIND_EDITOR->set_binding (undef, undef, [], |
|
|
1033 | sub { |
|
|
1034 | my ($mod, $sym, $cmds) = @_; |
|
|
1035 | $::CFG->{bindings}->{$mod}->{$sym} = $cmds; |
|
|
1036 | $refresh->(); |
|
|
1037 | $::BIND_WINDOW->show; |
|
|
1038 | }, |
|
|
1039 | sub { |
|
|
1040 | $::BIND_WINDOW->show; |
|
|
1041 | }); |
|
|
1042 | $::BIND_WINDOW->hide; |
|
|
1043 | $::BIND_EDITOR->show; |
|
|
1044 | }, |
|
|
1045 | ); |
|
|
1046 | $hb->add (new CFClient::UI::Button |
|
|
1047 | text => "close", |
|
|
1048 | tooltip => "Closes the binding window", |
|
|
1049 | expand => 1, |
|
|
1050 | on_activate => sub { |
|
|
1051 | $::BIND_WINDOW->hide; |
|
|
1052 | } |
|
|
1053 | ); |
|
|
1054 | |
990 | $refresh->(); |
1055 | $refresh->(); |
991 | $BIND_WINDOW |
1056 | $BIND_WINDOW |
992 | } |
1057 | } |
993 | |
1058 | |
994 | sub make_help_window { |
1059 | sub make_help_window { |
… | |
… | |
1070 | padding => 0, |
1135 | padding => 0, |
1071 | z => 100, |
1136 | z => 100, |
1072 | force_x => "max", |
1137 | force_x => "max", |
1073 | force_y => 0; |
1138 | force_y => 0; |
1074 | $DEBUG_STATUS->show; |
1139 | $DEBUG_STATUS->show; |
1075 | |
1140 | |
|
|
1141 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
|
|
1142 | |
1076 | $STATUSBOX = new CFClient::UI::Statusbox; |
1143 | $STATUSBOX = new CFClient::UI::Statusbox; |
1077 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1144 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1078 | |
1145 | |
1079 | (new CFClient::UI::Frame |
1146 | (new CFClient::UI::Frame |
1080 | bg => [0, 0, 0, 0.4], |
1147 | bg => [0, 0, 0, 0.4], |
… | |
… | |
1130 | 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 |
1197 | 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 |
1131 | |
1198 | |
1132 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1199 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, |
1133 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1200 | tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); |
1134 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1201 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, |
1135 | tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."); |
1202 | tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)." |
|
|
1203 | ."You can also hit the Tab-key to show/hide the Inventory."); |
1136 | |
1204 | |
1137 | $BUTTONBAR->add (new CFClient::UI::Button |
1205 | $BUTTONBAR->add (new CFClient::UI::Button |
1138 | text => "Save Config", |
1206 | text => "Save Config", |
1139 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1207 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
1140 | on_activate => sub { |
1208 | on_activate => sub { |
… | |
… | |
1148 | tooltip => "View Documentation"); |
1216 | tooltip => "View Documentation"); |
1149 | |
1217 | |
1150 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1218 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1151 | text => "Bindings", |
1219 | text => "Bindings", |
1152 | other => make_binding_window, |
1220 | other => make_binding_window, |
1153 | tooltip => "Lets you delete bindings you have made with the recorder" |
1221 | tooltip => |
1154 | ); |
1222 | "Lets you define, edit and delete bindings." |
1155 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "[Rec]", other => CFClient::Recorder::make_window, |
1223 | ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " |
1156 | tooltip => "This feature lets you record a series of actions (eg. walking a path or ready a skill) and bind them to keys"); |
1224 | ."with nothing set and the recording started. After doing the actions you " |
|
|
1225 | ."want to record press Insert and you will be asked to press a key-combo." |
|
|
1226 | ."After pressing the combo the binding will be saved automatically and the " |
|
|
1227 | ."binding editor closes"); |
|
|
1228 | |
|
|
1229 | $BUTTONBAR->add (new CFClient::UI::Flopper |
|
|
1230 | text => "Spells", |
|
|
1231 | other => make_spell_list, |
|
|
1232 | tooltip => "The spell list"); |
1157 | |
1233 | |
1158 | $BUTTONBAR->add (new CFClient::UI::Button |
1234 | $BUTTONBAR->add (new CFClient::UI::Button |
1159 | text => "Quit", |
1235 | text => "Quit", |
1160 | tooltip => "Terminates the program", |
1236 | tooltip => "Terminates the program", |
1161 | on_activate => sub { |
1237 | on_activate => sub { |
… | |
… | |
1246 | |
1322 | |
1247 | my %demo;#d# |
1323 | my %demo;#d# |
1248 | |
1324 | |
1249 | sub force_refresh { |
1325 | sub force_refresh { |
1250 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1326 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1251 | debug sprintf "%3.2f", $fps; |
1327 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
1252 | |
1328 | |
1253 | $CFClient::UI::ROOT->draw; |
1329 | $CFClient::UI::ROOT->draw; |
1254 | |
1330 | |
1255 | $WANT_REFRESH = 0; |
1331 | $WANT_REFRESH = 0; |
1256 | $CAN_REFRESH = 0; |
1332 | $CAN_REFRESH = 0; |