… | |
… | |
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; |
109 | |
110 | |
110 | sub status { |
111 | sub status { |
111 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
112 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
112 | } |
113 | } |
113 | |
114 | |
… | |
… | |
863 | on_activate => sub { |
864 | on_activate => sub { |
864 | my ($input, $text) = @_; |
865 | my ($input, $text) = @_; |
865 | $input->set_text (''); |
866 | $input->set_text (''); |
866 | |
867 | |
867 | if ($text =~ /^\/bind\s+(.*)$/) { |
868 | if ($text =~ /^\/bind\s+(.*)$/) { |
868 | CFClient::Recorder::open_binding_dialog ([$1]); |
869 | CFClient::Binder::open_binding_dialog (sub { |
|
|
870 | my ($mod, $sym) = @_; |
|
|
871 | $::CFG->{bindings}->{$mod}->{$sym} = [$1]; |
|
|
872 | }); |
869 | } elsif ($text =~ /^\/(.*)/) { |
873 | } elsif ($text =~ /^\/(.*)/) { |
870 | $::CONN->user_send ($1); |
874 | $::CONN->user_send ($1); |
871 | } else { |
875 | } else { |
872 | my $say_cmd = $::CFG->{say_command} || 'say'; |
876 | my $say_cmd = $::CFG->{say_command} || 'say'; |
873 | $::CONN->user_send ("$say_cmd $text"); |
877 | $::CONN->user_send ("$say_cmd $text"); |
… | |
… | |
950 | } |
954 | } |
951 | |
955 | |
952 | sub make_binding_window { |
956 | sub make_binding_window { |
953 | my $binding_list = new CFClient::UI::VBox; |
957 | my $binding_list = new CFClient::UI::VBox; |
954 | |
958 | |
|
|
959 | my $refresh; |
955 | my $refresh = sub { |
960 | $refresh = sub { |
956 | $binding_list->clear (); |
961 | $binding_list->clear (); |
957 | |
962 | |
958 | for my $mod (keys %{$::CFG->{bindings}}) { |
963 | for my $mod (keys %{$::CFG->{bindings}}) { |
959 | for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { |
964 | for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { |
960 | my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; |
965 | my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; |
961 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
966 | next unless ref $cmds eq 'ARRAY' and @$cmds > 0; |
962 | |
967 | |
963 | my $lbl = join "; ", @$cmds; |
968 | my $lbl = join "; ", @$cmds; |
964 | my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); |
969 | my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); |
965 | $binding_list->add (my $hb = new CFClient::UI::HBox); |
970 | $binding_list->add (my $hb = new CFClient::UI::HBox); |
966 | $hb->add (new CFClient::UI::Button |
971 | $hb->add (new CFClient::UI::Button |
967 | text => "delete", |
972 | text => "delete", |
|
|
973 | tooltip => "Deletes the binding", |
968 | on_activate => sub { |
974 | on_activate => sub { |
969 | $binding_list->remove ($hb); |
975 | $binding_list->remove ($hb); |
970 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
976 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
971 | }); |
977 | }); |
|
|
978 | |
|
|
979 | $hb->add (new CFClient::UI::Button |
|
|
980 | text => "edit", |
|
|
981 | tooltip => "Edits the binding", |
|
|
982 | on_activate => sub { |
|
|
983 | $::BIND_EDITOR->set_binding ( |
|
|
984 | $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, |
|
|
985 | sub { |
|
|
986 | my ($nmod, $nsym, $ncmds) = @_; |
|
|
987 | delete $::CFG->{bindings}->{$mod}->{$sym}; |
|
|
988 | $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; |
|
|
989 | $refresh->(); |
|
|
990 | $::BIND_WINDOW->show; |
|
|
991 | }, |
|
|
992 | sub { |
|
|
993 | $::BIND_WINDOW->show; |
|
|
994 | }); |
|
|
995 | $::BIND_EDITOR->show; |
|
|
996 | $::BIND_WINDOW->hide; |
|
|
997 | }); |
|
|
998 | |
972 | $hb->add (new CFClient::UI::Label text => "($nam)"); |
999 | $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); |
973 | $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); |
1000 | $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); |
974 | } |
1001 | } |
975 | } |
1002 | } |
976 | }; |
1003 | }; |
977 | |
1004 | |
… | |
… | |
984 | on_visibility_change => sub { |
1011 | on_visibility_change => sub { |
985 | my ($self, $visible) = @_; |
1012 | my ($self, $visible) = @_; |
986 | $refresh->() if $visible; |
1013 | $refresh->() if $visible; |
987 | }; |
1014 | }; |
988 | |
1015 | |
|
|
1016 | $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox); |
989 | $BIND_WINDOW->add ($binding_list); |
1017 | $vb->add ($binding_list); |
|
|
1018 | $vb->add (my $hb = new CFClient::UI::HBox); |
|
|
1019 | $hb->add (new CFClient::UI::Button |
|
|
1020 | text => "record new", |
|
|
1021 | expand => 1, |
|
|
1022 | tooltip => "This button opens the binding editor with an empty binding.", |
|
|
1023 | on_activate => sub { |
|
|
1024 | $::BIND_EDITOR->set_binding (undef, undef, [], |
|
|
1025 | sub { |
|
|
1026 | my ($mod, $sym, $cmds) = @_; |
|
|
1027 | $::CFG->{bindings}->{$mod}->{$sym} = $cmds; |
|
|
1028 | $refresh->(); |
|
|
1029 | $::BIND_WINDOW->show; |
|
|
1030 | }, |
|
|
1031 | sub { |
|
|
1032 | $::BIND_WINDOW->show; |
|
|
1033 | }); |
|
|
1034 | $::BIND_WINDOW->hide; |
|
|
1035 | $::BIND_EDITOR->show; |
|
|
1036 | }, |
|
|
1037 | ); |
|
|
1038 | $hb->add (new CFClient::UI::Button |
|
|
1039 | text => "close", |
|
|
1040 | tooltip => "Closes the binding window", |
|
|
1041 | expand => 1, |
|
|
1042 | on_activate => sub { |
|
|
1043 | $::BIND_WINDOW->hide; |
|
|
1044 | } |
|
|
1045 | ); |
|
|
1046 | |
990 | $refresh->(); |
1047 | $refresh->(); |
991 | $BIND_WINDOW |
1048 | $BIND_WINDOW |
992 | } |
1049 | } |
993 | |
1050 | |
994 | sub make_help_window { |
1051 | sub make_help_window { |
… | |
… | |
1070 | padding => 0, |
1127 | padding => 0, |
1071 | z => 100, |
1128 | z => 100, |
1072 | force_x => "max", |
1129 | force_x => "max", |
1073 | force_y => 0; |
1130 | force_y => 0; |
1074 | $DEBUG_STATUS->show; |
1131 | $DEBUG_STATUS->show; |
1075 | |
1132 | |
|
|
1133 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
|
|
1134 | |
1076 | $STATUSBOX = new CFClient::UI::Statusbox; |
1135 | $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]); |
1136 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1078 | |
1137 | |
1079 | (new CFClient::UI::Frame |
1138 | (new CFClient::UI::Frame |
1080 | bg => [0, 0, 0, 0.4], |
1139 | bg => [0, 0, 0, 0.4], |
… | |
… | |
1148 | tooltip => "View Documentation"); |
1207 | tooltip => "View Documentation"); |
1149 | |
1208 | |
1150 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1209 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1151 | text => "Bindings", |
1210 | text => "Bindings", |
1152 | other => make_binding_window, |
1211 | other => make_binding_window, |
1153 | tooltip => "Lets you delete bindings you have made with the recorder" |
1212 | tooltip => |
|
|
1213 | "Lets you define, edit and delete bindings." |
|
|
1214 | ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " |
|
|
1215 | ."with nothing set and the recording started. After doing the actions you " |
|
|
1216 | ."want to record press Insert and you will be asked to press a key-combo." |
|
|
1217 | ."After pressing the combo the binding will be saved automatically and the " |
|
|
1218 | ."binding editor closes" |
1154 | ); |
1219 | ); |
1155 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "[Rec]", other => CFClient::Recorder::make_window, |
|
|
1156 | tooltip => "This feature lets you record a series of actions (eg. walking a path or ready a skill) and bind them to keys"); |
|
|
1157 | |
1220 | |
1158 | $BUTTONBAR->add (new CFClient::UI::Button |
1221 | $BUTTONBAR->add (new CFClient::UI::Button |
1159 | text => "Quit", |
1222 | text => "Quit", |
1160 | tooltip => "Terminates the program", |
1223 | tooltip => "Terminates the program", |
1161 | on_activate => sub { |
1224 | on_activate => sub { |