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]*)$/,
|
RE_LAST_WORD: /(^|\s)([^\s]*)$/,
|
||||||
RGB_MUTE: "#6c2132",
|
RGB_MUTE: "#6c2132",
|
||||||
RGB_POLLY: "#81b1e7",
|
RGB_POLLY: "#81b1e7",
|
||||||
|
COMP_DIV_ID: "MBCHC_AUTOCOMPLETE_HINT",
|
||||||
UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000,
|
UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000,
|
||||||
HAND_PENETRATORS: ["Flogger", "Whip", "TennisRacket", "Gavel", "SmallVibratingWand", "LargeDildo", "Vibrator", "Hairbrush", "SmallDildo", "Baguette", "Spatula", "Broom"],
|
HAND_PENETRATORS: ["Flogger", "Whip", "TennisRacket", "Gavel", "SmallVibratingWand", "LargeDildo", "Vibrator", "Hairbrush", "SmallDildo", "Baguette", "Spatula", "Broom"],
|
||||||
HIDE_SPECIAL: ["Activity","Emoticon"],
|
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)))
|
let action = mbchc.ensure(`invalid action (${verb} ${zone} ${target})`, () => actions.find(name => available.find(a => a.Name === name)))
|
||||||
mbchc.run_activity(char, ag, action)
|
mbchc.run_activity(char, ag, action)
|
||||||
} catch (x) { mbchc.report(x) } },
|
} catch (x) { mbchc.report(x) } },
|
||||||
complete: function(options) {
|
complete: function(options, space = true) {
|
||||||
const chat = document.getElementById("InputChat")
|
const chat = document.getElementById("InputChat")
|
||||||
if (options.length < 1) {
|
if (options.length < 1) {
|
||||||
// TODO: maybe signal no valid options?
|
setTimeout(() => {chat.style.outline = ""}, 100)
|
||||||
return
|
return(chat.style.outline = "solid red")
|
||||||
}
|
}
|
||||||
if (options.length > 1) {
|
if (options.length > 1) {
|
||||||
// TODO
|
let width = Math.max(...options.map(o => o.length))
|
||||||
// autocomplete to common prefix
|
let pref = null
|
||||||
// better hint: replace existing or hide previous on new hint
|
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} }
|
||||||
// better hint: hide on input?
|
if (pref) this.complete([pref], false)
|
||||||
// better hint: increase density
|
this.complete_hint(options)
|
||||||
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]}${space ? " " : ""}`))
|
||||||
} else {
|
},
|
||||||
window.ElementValue("InputChat", chat.value.replace(this.RE_LAST_WORD, `$1${options[0]} `))
|
complete_hint: function(options) {
|
||||||
window.ElementFocus("InputChat")
|
// 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) {
|
complete_target: function(token, me2 = true) {
|
||||||
let locase = token.toLocaleLowerCase()
|
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
|
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 < 1) return
|
||||||
if (tokens.length < 2) return(mbchc.complete([`${mbchc.CommandsKey}${this.Tag}`]))
|
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
|
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 verb = tokens[1].toLocaleLowerCase()
|
||||||
let ags = mbchc.DO_DATA.verbs[verb]
|
let ags = mbchc.DO_DATA.verbs[verb]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user