diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt index dc1a57ceda..863b9136ad 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt @@ -23,7 +23,8 @@ import kotlin.concurrent.thread class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorScreen){ private val mapNameEditor: TextField = TextField(mapEditorScreen.mapName, skin) - init{ + init { + mapNameEditor.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' } add(mapNameEditor).fillX().row() mapNameEditor.selectAll() mapNameEditor.maxLength = 240 // A few under max for most filesystems diff --git a/core/src/com/unciv/ui/saves/SaveGameScreen.kt b/core/src/com/unciv/ui/saves/SaveGameScreen.kt index fe59599f53..22d29221b2 100644 --- a/core/src/com/unciv/ui/saves/SaveGameScreen.kt +++ b/core/src/com/unciv/ui/saves/SaveGameScreen.kt @@ -22,12 +22,13 @@ class SaveGameScreen : PickerScreen() { init { setDefaultCloseAction() + textField.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' } currentSaves.add("Current saves".toLabel()).row() updateShownSaves(false) - topTable.add(ScrollPane(currentSaves)).height(stage.height*2/3) + topTable.add(ScrollPane(currentSaves)).height(stage.height * 2 / 3) val newSave = Table() - val defaultSaveName = game.gameInfo.currentPlayer+" - "+game.gameInfo.turns+" turns" + val defaultSaveName = game.gameInfo.currentPlayer + " - " + game.gameInfo.turns + " turns" textField.text = defaultSaveName newSave.add("Saved game name".toLabel()).row() @@ -37,7 +38,7 @@ class SaveGameScreen : PickerScreen() { copyJsonButton.onClick { val json = Json().toJson(game.gameInfo) val base64Gzip = Gzip.zip(json) - Gdx.app.clipboard.contents = base64Gzip + Gdx.app.clipboard.contents = base64Gzip } newSave.add(copyJsonButton).row() @@ -45,8 +46,8 @@ class SaveGameScreen : PickerScreen() { val showAutosavesCheckbox = CheckBox("Show autosaves".tr(), skin) showAutosavesCheckbox.isChecked = false showAutosavesCheckbox.onChange { - updateShownSaves(showAutosavesCheckbox.isChecked) - } + updateShownSaves(showAutosavesCheckbox.isChecked) + } newSave.add(showAutosavesCheckbox).row() topTable.add(newSave) @@ -55,7 +56,7 @@ class SaveGameScreen : PickerScreen() { rightSideButton.setText("Save game".tr()) rightSideButton.onClick { rightSideButton.setText("Saving...".tr()) - thread(name="SaveGame") { + thread(name = "SaveGame") { GameSaver.saveGame(UncivGame.Current.gameInfo, textField.text) Gdx.app.postRunnable { UncivGame.Current.setWorldScreen() } } @@ -63,12 +64,12 @@ class SaveGameScreen : PickerScreen() { rightSideButton.enable() } - fun updateShownSaves(showAutosaves:Boolean){ + fun updateShownSaves(showAutosaves: Boolean) { currentSaves.clear() val saves = GameSaver.getSaves() .sortedByDescending { GameSaver.getSave(it).lastModified() } for (saveGameName in saves) { - if(saveGameName.startsWith("Autosave") && !showAutosaves) continue + if (saveGameName.startsWith("Autosave") && !showAutosaves) continue val textButton = TextButton(saveGameName, skin) textButton.onClick { textField.text = saveGameName @@ -77,6 +78,4 @@ class SaveGameScreen : PickerScreen() { } } -} - - +} \ No newline at end of file