From cada78b2a1fe8fe24b322347e4d343724dea82b5 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Thu, 26 Oct 2023 01:33:36 -0700 Subject: [PATCH] Lightbar confirm/deny Baja mods ported to JS, supporting multi-languages Really, these should just be loadable modules (not loaded via text.dat @exec and global variable magic), and merged into a single module, but for now, this will do. The old yesnobar.src/bin and noyesbar mods aren't used when these .js files are in place, unless you have a copy yesnobar/noyesbar.bin in your mods dir. --- exec/noyesbar.js | 42 ++++++++++++++++++++++++++++++++++++++++++ exec/yesnobar.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 exec/noyesbar.js create mode 100755 exec/yesnobar.js diff --git a/exec/noyesbar.js b/exec/noyesbar.js new file mode 100755 index 0000000000..3220872b89 --- /dev/null +++ b/exec/noyesbar.js @@ -0,0 +1,42 @@ +// JS version of noyesbar.src + +const yes_str = bbs.text(bbs.text.Yes); +const yes_key = yes_str[0]; +const no_str = bbs.text(bbs.text.No); +const no_key = no_str[0]; + +while(console.question.substring(0, 2) == "\r\n") { + console.crlf(); + console.question = console.question.substring(2); +} + +console.putmsg("\x01n\x01b\x01h[\x01c@CHECKMARK@\x01b] \x01y@QUESTION->@? @CLEAR_HOT@"); +var affirm = false; +while(bbs.online && !js.terminated) { + var str; + if(affirm) + str = format("\x01n\x01b\x01h \x01~%s \x014\x01w\x01e[\x01~%s]", no_str, yes_str); + else + str = format("\x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s ", no_str, yes_str); + console.print(str); + var key = console.getkey(0).toUpperCase(); + console.backspace(console.strlen(str)); + console.print("\1n\1h\1>"); + if(console.aborted) { + affirm = false; + break; + } + if(key == '\r') + break; + if(key == yes_key) { + affirm = true; + break; + } + if(key == no_key) { + affirm = false; + break; + } + affirm = !affirm; +} + +console.ungetstr(affirm ? yes_key : no_key); diff --git a/exec/yesnobar.js b/exec/yesnobar.js new file mode 100755 index 0000000000..85bc47e742 --- /dev/null +++ b/exec/yesnobar.js @@ -0,0 +1,42 @@ +// JS version of yesnobar.src + +const yes_str = bbs.text(bbs.text.Yes); +const yes_key = yes_str[0]; +const no_str = bbs.text(bbs.text.No); +const no_key = no_str[0]; + +while(console.question.substring(0, 2) == "\r\n") { + console.crlf(); + console.question = console.question.substring(2); +} + +console.putmsg("\x01n\x01b\x01h[\x01c@CHECKMARK@\x01b] \x01y@QUESTION->@? @CLEAR_HOT@"); +var affirm = true; +while(bbs.online && !js.terminated) { + var str; + if(affirm) + str = format("\x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s ", yes_str, no_str); + else + str = format("\x01n\x01b\x01h \x01~%s \x014\x01w\x01e[\x01~%s]", yes_str, no_str); + console.print(str); + var key = console.getkey(0).toUpperCase(); + console.backspace(console.strlen(str)); + console.print("\1n\1h\1>"); + if(console.aborted) { + affirm = false; + break; + } + if(key == '\r') + break; + if(key == yes_key) { + affirm = true; + break; + } + if(key == no_key) { + affirm = false; + break; + } + affirm = !affirm; +} + +console.ungetstr(affirm ? yes_key : no_key); -- GitLab