Skip to content

Commit

Permalink
SQUASH: feat(ui/walk): 用小键盘走路
Browse files Browse the repository at this point in the history
+ 增加所有的常用键名
+ 增加 Bind/UnBind API
+ 增加 get-all 和 killall 以及 look
  • Loading branch information
dzpao committed Apr 18, 2024
1 parent cac7f9c commit d158a11
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 6 deletions.
47 changes: 46 additions & 1 deletion etc/ui-settings.tin
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,58 @@ VAR {小键盘走路的键盘扫描码} {global-keypad-code} {
{ShiftCenter} {\e[1;2G}
{ShiftPageUp} {\e[5;2~}
{ShiftPageDown} {\e[6;2~}
{KeyA} {a}
{KeyB} {b}
{KeyC} {c}
{KeyD} {d}
{KeyE} {e}
{KeyF} {f}
{KeyG} {g}
{KeyH} {h}
{KeyI} {i}
{KeyJ} {j}
{KeyK} {k}
{KeyL} {l}
{KeyM} {m}
{KeyN} {n}
{KeyO} {o}
{KeyP} {p}
{KeyQ} {q}
{KeyR} {r}
{KeyS} {s}
{KeyT} {t}
{KeyU} {u}
{KeyV} {v}
{KeyW} {w}
{KeyX} {x}
{KeyY} {y}
{KeyZ} {z}
{ShiftKeyA} {A}
{ShiftKeyB} {B}
{ShiftKeyC} {C}
{ShiftKeyD} {D}
{ShiftKeyE} {E}
{ShiftKeyF} {F}
{ShiftKeyG} {G}
{ShiftKeyH} {H}
{ShiftKeyI} {I}
{ShiftKeyJ} {J}
{ShiftKeyK} {K}
{ShiftKeyL} {L}
{ShiftKeyM} {M}
{ShiftKeyN} {N}
{ShiftKeyO} {O}
{ShiftKeyP} {P}
{ShiftKeyQ} {Q}
{ShiftKeyR} {R}
{ShiftKeyS} {S}
{ShiftKeyT} {T}
{ShiftKeyU} {U}
{ShiftKeyV} {V}
{ShiftKeyW} {W}
{ShiftKeyX} {X}
{ShiftKeyY} {Y}
{ShiftKeyZ} {Z}
};

VAR {小键盘走路的功能映射表} {global-keypad-walking} {};
Expand All @@ -91,12 +135,13 @@ VAR {小键盘走路的功能映射表} {global-keypad-walking} {};
{{key}{ShiftDown} {type}{dir} {args}{southup;south}}
{{key}{ShiftLeft} {type}{dir} {args}{westup;west}}
{{key}{ShiftRight} {type}{dir} {args}{eastup;east}}
{{key}{Enter} {type}{cmd} {args}{get all}}
{{key}{Enter} {type}{cmd} {args}{get-all}}
{{key}{Center} {type}{cmd} {args}{look}}
{{key}{KeyK} {type}{dir} {args}{northdown;north;northup;up;northwest;northeast}}
{{key}{KeyJ} {type}{dir} {args}{southdown;south;southup;down;southwest;southeast}}
{{key}{KeyH} {type}{dir} {args}{westdown;west;westup;out;northwest;southwest}}
{{key}{KeyL} {type}{dir} {args}{eastdown;east;eastup;enter;northeast;southeast}}
{{key}{KeyO} {type}{cmd} {args}{look}}
{{key}{ShiftKeyK} {type}{dir} {args}{northup;north}}
{{key}{ShiftKeyJ} {type}{dir} {args}{southup;south}}
{{key}{ShiftKeyH} {type}{dir} {args}{westup;west}}
Expand Down
20 changes: 20 additions & 0 deletions mud/pkuxkx/plugins/shortcut.tin
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,26 @@ VAR 服务器重启时间 gServerRebootTime {0};
};
};

#alias {get-all} {
#local idc {};
#local idx {};
#foreach {*gMapRoom[objs][]} {idx} {
#local id {$gMapRoom[objs][$idx][id]};
math.Inc idc[$id];
#if { "$id" == "{corpse|skeleton}" } {
get gold from $id $idc[$id];
get silver from $id $idc[$id];
get gem from $id $idc[$id];
};
#elseif { "$id" == "{cash|gold|silver}" } {
get $id;
};
#elseif { "$id" == "({tian|ze|huo|lei|feng|shui|shan|di} {jin|mu|bing|jing|sui|ri|yue|gu|yu|jiao|jia})" } {
get $id;
};
};
};

#alias {%S_%S} {node walk %0} 9;

load-lib sync;
Expand Down
90 changes: 85 additions & 5 deletions plugins/lib/ui/walk.tin
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ option.Define {KeypadWalk} {Bool} {是否开启小键盘走路} {false};
option.Define {ScreenKeypad} {Bool} {是否开启屏幕虚拟键盘} {false};

#func {lib_ui_walk.Init} {
event.Handle {option/changed} {option/changed/KeypadWalk} {lib/ui/walk} {ui.walk.Keypad.Toggle};
event.Handle {option/changed} {option/changed/ScreenKeypad} {lib/ui/walk} {ui.walk.ScreenKeypad.Toggle};
event.Handle {option/changed} {option/changed/KeypadWalk} {lib/ui/walk} {ui.walk.Keypad.Setup};
event.Handle {option/changed} {option/changed/ScreenKeypad} {lib/ui/walk} {ui.walk.ScreenKeypad.Setup};
event.HandleOnce {user-online} {ui/walk/setup} {pkuxkx/online} {
ui.walk.Keypad.Setup;
ui.walk.ScreenKeypad.Setup;
};
#return {true};
};

Expand All @@ -63,11 +67,11 @@ option.Define {ScreenKeypad} {Bool} {是否开启屏幕虚拟键盘} {false};
};

///=== {
// ## ui.walk.ScreenKeypad.Toggle
// ## ui.walk.ScreenKeypad.Setup
// 开启/关闭屏幕虚拟键盘走路。
// 本别名没有参数。
// };
#alias {ui.walk.ScreenKeypad.Toggle} {
#alias {ui.walk.ScreenKeypad.Setup} {
#if { @option.IsDisable{ScreenKeypad} } {
#class ui.walk.mouse kill;
errLog 屏幕虚拟键盘走路已关闭。;
Expand Down Expand Up @@ -220,7 +224,7 @@ VAR {触屏走路插件的走路命令,默认为 go} ui.walk.cmd {go};
$ui.walk.cmd $dir;
};

#alias {ui.walk.Keypad.Toggle} {
#alias {ui.walk.Keypad.Setup} {
#if { @option.IsDisable{KeypadWalk} } {
#class ui.walk.Keypad kill;
errLog 小键盘走路已关闭。;
Expand All @@ -244,6 +248,82 @@ VAR {触屏走路插件的走路命令,默认为 go} ui.walk.cmd {go};
};
};

///=== {
// ## ui.walk.Keypad.Bind <键名> <功能类型> <参数>
// 为快捷键绑定功能。
// 参数说明:
// 键名:注意这里用的是键名,完整的键名列表可以通过 #var global-keypad-code 查看。
// 功能类型目前就两种:
// - dir: 方向指令。方向指令会根据当前行走模式转换成不同的命令。默认模式是 go,
// 护镖或其它任务需要自行设置,请参考 HELP ui.walk.SetCmd
// - cmd: 普通命令。可以是本地别名,或者服务器指令。
// 参数:如果是方向指令,则应该是英文的方向全称。允许指定多个候选,以分号分隔。
// 如果是普通命令,则只允许一条命令,如果功能复杂建议单独设置一个别名,在这里写别名名称。
// };
#alias {ui.walk.Keypad.Bind} {
#local name {%1};
#local type {%2};
#local args {%3};

#if { "$name" == "" || "$type" != "{dir|cmd}" || "$args" == "" } {
xtt.Usage %90;
#return;
};

#if { &global-keypad-code[$name] == 0 } {
xtt.Usage %90;
#return;
};

#list global-keypad-walking {indexate} key;
#local idx {};
#list global-keypad-walking {find} {$name} idx;

#if { $idx == 0 } {
#list global-keypad-walking {add} {{
{key} {$name}
{type} {$type}
{args} {$args}
}};
};
#else {
#var {global-keypad-walking[$idx]} {
{key} {$name}
{type} {$type}
{args} {$args}
};
};

okLog 已绑定快捷键 $name 为 {$type} {$args};
};

///=== {
// ## ui.walk.Keypad.UnBind <键名>
// 删除快捷键绑定的功能。
// };
#alias {ui.walk.Keypad.UnBind} {
#local name {%1};

#if { "$name" == "" } {
xtt.Usage %90;
#return;
};

#if { &global-keypad-code[$name] == 0 } {
xtt.Usage %90;
#return;
};

#list global-keypad-walking {indexate} key;
#local idx {};
#list global-keypad-walking {find} {$name} idx;

#if { $idx > 0 } {
#list global-keypad-walking {delete} {$idx};
okLog 快捷键 $name 功能已删除。;
};
};

#alias {ui.walk.keypad.do} {
#local key {%1};
#local type {%2};
Expand Down

0 comments on commit d158a11

Please sign in to comment.