mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
change enum default to use id
This commit is contained in:
parent
50f22ab5de
commit
86cef32bc2
@ -1,5 +1,6 @@
|
||||
import { BaseItem } from "../game/base_item";
|
||||
import { ClickDetector } from "./click_detector";
|
||||
import { createLogger } from "./logging";
|
||||
import { Signal } from "./signal";
|
||||
import { safeModulo } from "./utils";
|
||||
|
||||
@ -14,6 +15,8 @@ import { safeModulo } from "./utils";
|
||||
* ***************************************************
|
||||
*/
|
||||
|
||||
const logger = createLogger("dialog_forms");
|
||||
|
||||
export class FormElement {
|
||||
constructor(id, label) {
|
||||
this.id = id;
|
||||
@ -263,12 +266,20 @@ export class FormElementItemChooser extends FormElement {
|
||||
}
|
||||
|
||||
export class FormElementEnum extends FormElement {
|
||||
constructor({ id, label = null, options, defaultValue = 0, valueGetter, textGetter }) {
|
||||
constructor({ id, label = null, options, defaultValue = null, valueGetter, textGetter }) {
|
||||
super(id, label);
|
||||
this.options = options;
|
||||
this.valueGetter = valueGetter;
|
||||
this.textGetter = textGetter;
|
||||
this.index = defaultValue;
|
||||
this.index = 0;
|
||||
if (defaultValue !== null) {
|
||||
const index = this.options.findIndex(option => option.id === defaultValue);
|
||||
if (index >= 0) {
|
||||
this.index = index;
|
||||
} else {
|
||||
logger.warn("Option ID", defaultValue, "not found in", options, "!");
|
||||
}
|
||||
}
|
||||
|
||||
this.element = null;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ export class HUDScreenshotExporter extends BaseHUDPart {
|
||||
id: "screenshotQuality",
|
||||
label: "Quality",
|
||||
options: screenshotQualities,
|
||||
defaultValue: 1,
|
||||
defaultValue: "medium",
|
||||
valueGetter: quality => quality.resolution,
|
||||
// @TODO: translation (T.dialogs.exportScreenshotWarning.qualityLabel)
|
||||
textGetter: quality => qualityNames[quality.id],
|
||||
|
Loading…
Reference in New Issue
Block a user