Resolved #2794 - Save games and maps cannot have slashes/backslashes, to avoid foldername/filename confusion
This commit is contained in:
parent
329cad660e
commit
0271fdead2
2 changed files with 12 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue