Files
ueblueprint/js/entity/KeyBindingEntity.js
barsdeveloper 365732a99c WIP
2024-12-03 22:15:17 +02:00

39 lines
1.4 KiB
JavaScript
Executable File

import P from "parsernostrum"
import Grammar from "../serialization/Grammar.js"
import BooleanEntity from "./BooleanEntity.js"
import IEntity from "./IEntity.js"
import StringEntity from "./StringEntity.js"
import SymbolEntity from "./SymbolEntity.js"
export default class KeyBindingEntity extends IEntity {
static attributes = {
...super.attributes,
ActionName: StringEntity,
bShift: BooleanEntity,
bCtrl: BooleanEntity,
bAlt: BooleanEntity,
bCmd: BooleanEntity,
Key: SymbolEntity,
}
static grammar = this.createGrammar()
constructor(values) {
super(values)
/** @type {InstanceType<typeof KeyBindingEntity.attributes.ActionName>} */ this.ActionName
/** @type {InstanceType<typeof KeyBindingEntity.attributes.bShift>} */ this.bShift
/** @type {InstanceType<typeof KeyBindingEntity.attributes.bCtrl>} */ this.bCtrl
/** @type {InstanceType<typeof KeyBindingEntity.attributes.bAlt>} */ this.bAlt
/** @type {InstanceType<typeof KeyBindingEntity.attributes.bCmd>} */ this.bCmd
/** @type {InstanceType<typeof KeyBindingEntity.attributes.Key>} */ this.Key
}
/** @returs {P<KeyBindingEntity>} */
static createGrammar() {
return P.alt(
SymbolEntity.grammar.map(identifier => new this({ Key: identifier })),
Grammar.createEntityGrammar(this),
)
}
}