… | |
… | |
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); |
|
|
1017 | $vb->add (new CFClient::UI::Button |
|
|
1018 | text => "record new", |
|
|
1019 | tooltip => "This button opens the binding editor with an empty binding.", |
|
|
1020 | on_activate => sub { |
|
|
1021 | $::BIND_EDITOR->set_binding (undef, undef, [], |
|
|
1022 | sub { |
|
|
1023 | my ($mod, $sym, $cmds) = @_; |
|
|
1024 | $::CFG->{bindings}->{$mod}->{$sym} = $cmds; |
|
|
1025 | $refresh->(); |
|
|
1026 | $::BIND_WINDOW->show; |
|
|
1027 | }, |
|
|
1028 | sub { |
|
|
1029 | $::BIND_WINDOW->show; |
|
|
1030 | }); |
|
|
1031 | $::BIND_WINDOW->hide; |
|
|
1032 | $::BIND_EDITOR->show; |
|
|
1033 | }, |
|
|
1034 | ); |
989 | $BIND_WINDOW->add ($binding_list); |
1035 | $vb->add ($binding_list); |
990 | $refresh->(); |
1036 | $refresh->(); |
991 | $BIND_WINDOW |
1037 | $BIND_WINDOW |
992 | } |
1038 | } |
993 | |
1039 | |
994 | sub make_help_window { |
1040 | sub make_help_window { |
… | |
… | |
1070 | padding => 0, |
1116 | padding => 0, |
1071 | z => 100, |
1117 | z => 100, |
1072 | force_x => "max", |
1118 | force_x => "max", |
1073 | force_y => 0; |
1119 | force_y => 0; |
1074 | $DEBUG_STATUS->show; |
1120 | $DEBUG_STATUS->show; |
1075 | |
1121 | |
|
|
1122 | $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); |
|
|
1123 | |
1076 | $STATUSBOX = new CFClient::UI::Statusbox; |
1124 | $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]); |
1125 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); |
1078 | |
1126 | |
1079 | (new CFClient::UI::Frame |
1127 | (new CFClient::UI::Frame |
1080 | bg => [0, 0, 0, 0.4], |
1128 | bg => [0, 0, 0, 0.4], |
… | |
… | |
1150 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1198 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1151 | text => "Bindings", |
1199 | text => "Bindings", |
1152 | other => make_binding_window, |
1200 | other => make_binding_window, |
1153 | tooltip => "Lets you delete bindings you have made with the recorder" |
1201 | tooltip => "Lets you delete bindings you have made with the recorder" |
1154 | ); |
1202 | ); |
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 | |
1203 | |
1158 | $BUTTONBAR->add (new CFClient::UI::Button |
1204 | $BUTTONBAR->add (new CFClient::UI::Button |
1159 | text => "Quit", |
1205 | text => "Quit", |
1160 | tooltip => "Terminates the program", |
1206 | tooltip => "Terminates the program", |
1161 | on_activate => sub { |
1207 | on_activate => sub { |