mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Trim savegame names
This commit is contained in:
parent
1cd52f6dbd
commit
d0aa6db630
@ -17,6 +17,8 @@ import { getApplicationSettingById } from "../profile/application_settings";
|
|||||||
import { FormElementInput } from "../core/modal_dialog_forms";
|
import { FormElementInput } from "../core/modal_dialog_forms";
|
||||||
import { DialogWithForm } from "../core/modal_dialog_elements";
|
import { DialogWithForm } from "../core/modal_dialog_elements";
|
||||||
|
|
||||||
|
const trim = require("trim");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import("../savegame/savegame_typedefs").SavegameMetadata} SavegameMetadata
|
* @typedef {import("../savegame/savegame_typedefs").SavegameMetadata} SavegameMetadata
|
||||||
* @typedef {import("../profile/setting_types").EnumSetting} EnumSetting
|
* @typedef {import("../profile/setting_types").EnumSetting} EnumSetting
|
||||||
@ -436,7 +438,7 @@ export class MainMenuState extends GameState {
|
|||||||
label: null,
|
label: null,
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
defaultValue: game.name || "",
|
defaultValue: game.name || "",
|
||||||
validator: val => val.match(regex),
|
validator: val => val.match(regex) && trim(val).length > 0,
|
||||||
});
|
});
|
||||||
const dialog = new DialogWithForm({
|
const dialog = new DialogWithForm({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
@ -449,7 +451,7 @@ export class MainMenuState extends GameState {
|
|||||||
|
|
||||||
// When confirmed, save the name
|
// When confirmed, save the name
|
||||||
dialog.buttonSignals.ok.add(() => {
|
dialog.buttonSignals.ok.add(() => {
|
||||||
game.name = nameInput.getValue();
|
game.name = trim(nameInput.getValue());
|
||||||
this.app.savegameMgr.writeAsync();
|
this.app.savegameMgr.writeAsync();
|
||||||
this.renderSavegames();
|
this.renderSavegames();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user