Update 'mbchc-local.user.js'
hint needs more work, won't show at all for now
This commit is contained in:
parent
c872444b14
commit
87cf188c64
|
@ -43,6 +43,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
|
|||
RE_LAST_WORD: /(^|\s)([^\s]*)$/,
|
||||
RGB_MUTE: "#6c2132",
|
||||
RGB_POLLY: "#81b1e7",
|
||||
COMP_DIV_ID: "MBCHC_AUTOCOMPLETE_HINT",
|
||||
UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000,
|
||||
HAND_PENETRATORS: ["Flogger", "Whip", "TennisRacket", "Gavel", "SmallVibratingWand", "LargeDildo", "Vibrator", "Hairbrush", "SmallDildo", "Baguette", "Spatula", "Broom"],
|
||||
HIDE_SPECIAL: ["Activity","Emoticon"],
|
||||
|
@ -411,23 +412,35 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
|
|||
let action = mbchc.ensure(`invalid action (${verb} ${zone} ${target})`, () => actions.find(name => available.find(a => a.Name === name)))
|
||||
mbchc.run_activity(char, ag, action)
|
||||
} catch (x) { mbchc.report(x) } },
|
||||
complete: function(options) {
|
||||
complete: function(options, space = true) {
|
||||
const chat = document.getElementById("InputChat")
|
||||
if (options.length < 1) {
|
||||
// TODO: maybe signal no valid options?
|
||||
return
|
||||
setTimeout(() => {chat.style.outline = ""}, 100)
|
||||
return(chat.style.outline = "solid red")
|
||||
}
|
||||
if (options.length > 1) {
|
||||
// TODO
|
||||
// autocomplete to common prefix
|
||||
// better hint: replace existing or hide previous on new hint
|
||||
// better hint: hide on input?
|
||||
// better hint: increase density
|
||||
this.inform(options.sort().map(s => `<div>${s}</div>`).join(""), 10000)
|
||||
} else {
|
||||
window.ElementValue("InputChat", chat.value.replace(this.RE_LAST_WORD, `$1${options[0]} `))
|
||||
window.ElementFocus("InputChat")
|
||||
let width = Math.max(...options.map(o => o.length))
|
||||
let pref = null
|
||||
for (let i = width; i > 0; i -= 1) { let test = options[0].slice(0, i); if (options.every(o => o.startsWith(test))) {pref = test; break} }
|
||||
if (pref) this.complete([pref], false)
|
||||
this.complete_hint(options)
|
||||
} else window.ElementValue("InputChat", chat.value.replace(this.RE_LAST_WORD, `$1${options[0]}${space ? " " : ""}`))
|
||||
},
|
||||
complete_hint: function(options) {
|
||||
// TODO increase text density
|
||||
// TODO show the hint
|
||||
// TODO hide the hint
|
||||
let log = document.getElementById("TextAreaChatLog")
|
||||
if (!log) return
|
||||
let div = document.getElementById(this.COMP_DIV_ID)
|
||||
if (!div) {
|
||||
div = document.createElement("div")
|
||||
div.id = this.COMP_DIV_ID
|
||||
div.setAttribute('style', `background-color:${this.bg_colour()}`)
|
||||
}
|
||||
let hint = options.sort().map(s => `<div>${s}</div>`).join("")
|
||||
div.innerHTML = `<div style="font-weight:bold">Available completions:</div>${hint}`
|
||||
// log.appendChild(div)
|
||||
},
|
||||
complete_target: function(token, me2 = true) {
|
||||
let locase = token.toLocaleLowerCase()
|
||||
|
@ -462,7 +475,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
|
|||
complete_do: function(args, locase, cmdline) { const [mbchc, input, tokens] = window.MBCHC.complete_common(); // `this` is command object
|
||||
if (tokens.length < 1) return
|
||||
if (tokens.length < 2) return(mbchc.complete([`${mbchc.CommandsKey}${this.Tag}`]))
|
||||
// FIXME filter only available actions
|
||||
// now, we *could* run a filter to exclude impossible activities, but it isn't very useful, and also seems like a lot of CPU to iterate over every action on every zone of every char in the room
|
||||
if (tokens.length < 3) return(mbchc.complete(Object.keys(mbchc.DO_DATA.verbs).filter(c => c.startsWith(tokens[1])))) // complete verb
|
||||
let verb = tokens[1].toLocaleLowerCase()
|
||||
let ags = mbchc.DO_DATA.verbs[verb]
|
||||
|
|
Loading…
Reference in New Issue
Block a user