From c9b0be74ce876cbc360544daa7398de75be6c955 Mon Sep 17 00:00:00 2001 From: dzp Date: Thu, 18 Apr 2024 00:21:35 +0800 Subject: [PATCH] =?UTF-8?q?SQUASH:=20feat(ui/walk):=20=E7=94=A8=E5=B0=8F?= =?UTF-8?q?=E9=94=AE=E7=9B=98=E8=B5=B0=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/ui-settings.tin | 35 +++++++++++++++++++++++--------- plugins/lib/ui/walk.tin | 44 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/etc/ui-settings.tin b/etc/ui-settings.tin index 3fa9cec7..de2bdf45 100644 --- a/etc/ui-settings.tin +++ b/etc/ui-settings.tin @@ -45,15 +45,32 @@ VAR {命令提示符,默认为空} prompt-prompt {}; {{key}{\cok} {meaning}{开启/关闭小键盘走路} {action}{option.Toggle KeypadWalk}} }; -VAR {小键盘走路的键盘扫描码} {global-keypad-walking} { - {north} {\e[A} - {south} {\e[B} - {east} {\e[C} - {west} {\e[D} - {northeast} {\e[5~} - {southeast} {\e[6~} - {northwest} {\e[H} - {southwest} {\e[F} +VAR {小键盘走路的键盘扫描码} {global-keypad-code} { + {Home} {\e[H} + {End} {\e[F} + {Up} {\e[A} + {Down} {\e[B} + {Left} {\e[D} + {Right} {\e[C} + {Center} {\e[G} + {PageUp} {\e[5~} + {PageDown} {\e[6~} + {Enter} {\n} +}; + +VAR {小键盘走路的功能映射表} {global-keypad-walking} {}; + +#list {global-keypad-walking} create { + {{key}{Up} {type}{dir} {args}{north;northdown;northup;up;northwest;northeast}} + {{key}{Down} {type}{dir} {args}{south;southdown;southup;down;southwest;southeast}} + {{key}{Left} {type}{dir} {args}{west;westdown;westup;out;northwest;southwest}} + {{key}{Right} {type}{dir} {args}{east;eastdown;eastup;enter;northeast;southeast}} + {{key}{Home} {type}{dir} {args}{northwest;westup;northup}} + {{key}{End} {type}{dir} {args}{southwest;westdown;southup}} + {{key}{PageUp} {type}{dir} {args}{northeast;eastup;northdown}} + {{key}{PageDown} {type}{dir} {args}{southeast;eastdown;southdown}} + {{key}{Enter} {type}{cmd} {args}{get all}} + {{key}{Center} {type}{cmd} {args}{look}} }; VAR {HP摘要刷新时机,三选一:{总是|从不|自动}} char.HPSummarize.Echo {自动}; diff --git a/plugins/lib/ui/walk.tin b/plugins/lib/ui/walk.tin index df18a32a..8380ff4b 100644 --- a/plugins/lib/ui/walk.tin +++ b/plugins/lib/ui/walk.tin @@ -226,11 +226,47 @@ VAR {触屏走路插件的走路命令,默认为 go} ui.walk.cmd {go}; #else { okLog 小键盘走路已开启。; #class ui.walk.Keypad open; - #local dir {}; - #foreach {*global-keypad-walking[]} {dir} { - #local code {$global-keypad-walking[$dir]}; - #line sub var #macro {$code} {ui.walk.go $dir}; + #local idx {}; + #foreach {*global-keypad-walking[]} {idx} { + #local entry {$global-keypad-walking[$idx]}; + #local name {$entry[key]}; + #local type {$entry[type]}; + #local args {$entry[args]}; + #if { &global-keypad-code[$name] == 0 } { + #continue; + }; + #local code {$global-keypad-code[$name]}; + #line sub var #macro {$code} {ui.walk.keypad.do $name $type {$args}}; }; #class ui.walk.Keypad close; }; }; + +#alias {ui.walk.keypad.do} { + #local key {%1}; + #local type {%2}; + #local args {%3}; + + #if { "$key" == "Enter" } { + #local input {}; + #cursor get input; + #if { {$input} !== {} } { + #cursor clear; + $input; + #return; + }; + }; + + #if { "$type" == "cmd" } { + $args; + #return; + }; + + #local dir {}; + #foreach {$args} {dir} { + #if { @sset.Contains{{$gMapRoom[exits]};$dir} } { + ui.walk.go $dir; + #return; + }; + }; +};