1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-07-09 21:23:55 +00:00

scripting: don't need $$reset (i think?)

This commit is contained in:
Steven Hugg
2021-08-22 14:46:57 -05:00
parent 8fc94aad25
commit 65a16db7b7
2 changed files with 11 additions and 21 deletions

View File

@ -13,18 +13,16 @@ export class ScriptUISliderType implements ScriptUIType {
readonly max: number,
readonly step: number
) {
this.value = min;
}
}
export class ScriptUISlider extends ScriptUISliderType implements io.Loadable {
initvalue: number;
initial(value: number) {
this.initvalue = value;
this.value = value;
return this;
}
$$reset() {
this.value = this.initvalue != null ? this.initvalue : this.min;
}
$$getstate() {
return { value: this.value };
}
@ -39,23 +37,21 @@ export function slider(min: number, max: number, step?: number) {
export class ScriptUISelectType<T> implements ScriptUIType {
readonly uitype = 'select';
value: T;
index: number = -1;
index: number;
constructor(
readonly options: T[]
) {
this.value = null;
this.index = -1;
}
}
export class ScriptUISelect<T> extends ScriptUISelectType<T> implements io.Loadable {
initindex : number;
initial(index: number) {
this.initindex = index;
this.index = index;
this.value = this.options[index];
return this;
}
$$reset() {
this.index = this.initindex >= 0 ? this.initindex : -1;
this.value = null;
}
$$getstate() {
return { value: this.value, index: this.index };
}