mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Resolved #2794 - Save games and maps cannot have slashes/backslashes, to avoid foldername/filename confusion
This commit is contained in:
parent
329cad660e
commit
0271fdead2
@ -23,7 +23,8 @@ import kotlin.concurrent.thread
|
|||||||
class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorScreen){
|
class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorScreen){
|
||||||
private val mapNameEditor: TextField = TextField(mapEditorScreen.mapName, skin)
|
private val mapNameEditor: TextField = TextField(mapEditorScreen.mapName, skin)
|
||||||
|
|
||||||
init{
|
init {
|
||||||
|
mapNameEditor.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' }
|
||||||
add(mapNameEditor).fillX().row()
|
add(mapNameEditor).fillX().row()
|
||||||
mapNameEditor.selectAll()
|
mapNameEditor.selectAll()
|
||||||
mapNameEditor.maxLength = 240 // A few under max for most filesystems
|
mapNameEditor.maxLength = 240 // A few under max for most filesystems
|
||||||
|
@ -22,12 +22,13 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
init {
|
init {
|
||||||
setDefaultCloseAction()
|
setDefaultCloseAction()
|
||||||
|
|
||||||
|
textField.textFieldFilter = TextField.TextFieldFilter { _, char -> char != '\\' && char != '/' }
|
||||||
currentSaves.add("Current saves".toLabel()).row()
|
currentSaves.add("Current saves".toLabel()).row()
|
||||||
updateShownSaves(false)
|
updateShownSaves(false)
|
||||||
topTable.add(ScrollPane(currentSaves)).height(stage.height*2/3)
|
topTable.add(ScrollPane(currentSaves)).height(stage.height * 2 / 3)
|
||||||
|
|
||||||
val newSave = Table()
|
val newSave = Table()
|
||||||
val defaultSaveName = game.gameInfo.currentPlayer+" - "+game.gameInfo.turns+" turns"
|
val defaultSaveName = game.gameInfo.currentPlayer + " - " + game.gameInfo.turns + " turns"
|
||||||
textField.text = defaultSaveName
|
textField.text = defaultSaveName
|
||||||
|
|
||||||
newSave.add("Saved game name".toLabel()).row()
|
newSave.add("Saved game name".toLabel()).row()
|
||||||
@ -37,7 +38,7 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
copyJsonButton.onClick {
|
copyJsonButton.onClick {
|
||||||
val json = Json().toJson(game.gameInfo)
|
val json = Json().toJson(game.gameInfo)
|
||||||
val base64Gzip = Gzip.zip(json)
|
val base64Gzip = Gzip.zip(json)
|
||||||
Gdx.app.clipboard.contents = base64Gzip
|
Gdx.app.clipboard.contents = base64Gzip
|
||||||
}
|
}
|
||||||
newSave.add(copyJsonButton).row()
|
newSave.add(copyJsonButton).row()
|
||||||
|
|
||||||
@ -45,8 +46,8 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
val showAutosavesCheckbox = CheckBox("Show autosaves".tr(), skin)
|
val showAutosavesCheckbox = CheckBox("Show autosaves".tr(), skin)
|
||||||
showAutosavesCheckbox.isChecked = false
|
showAutosavesCheckbox.isChecked = false
|
||||||
showAutosavesCheckbox.onChange {
|
showAutosavesCheckbox.onChange {
|
||||||
updateShownSaves(showAutosavesCheckbox.isChecked)
|
updateShownSaves(showAutosavesCheckbox.isChecked)
|
||||||
}
|
}
|
||||||
newSave.add(showAutosavesCheckbox).row()
|
newSave.add(showAutosavesCheckbox).row()
|
||||||
|
|
||||||
topTable.add(newSave)
|
topTable.add(newSave)
|
||||||
@ -55,7 +56,7 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
rightSideButton.setText("Save game".tr())
|
rightSideButton.setText("Save game".tr())
|
||||||
rightSideButton.onClick {
|
rightSideButton.onClick {
|
||||||
rightSideButton.setText("Saving...".tr())
|
rightSideButton.setText("Saving...".tr())
|
||||||
thread(name="SaveGame") {
|
thread(name = "SaveGame") {
|
||||||
GameSaver.saveGame(UncivGame.Current.gameInfo, textField.text)
|
GameSaver.saveGame(UncivGame.Current.gameInfo, textField.text)
|
||||||
Gdx.app.postRunnable { UncivGame.Current.setWorldScreen() }
|
Gdx.app.postRunnable { UncivGame.Current.setWorldScreen() }
|
||||||
}
|
}
|
||||||
@ -63,12 +64,12 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateShownSaves(showAutosaves:Boolean){
|
fun updateShownSaves(showAutosaves: Boolean) {
|
||||||
currentSaves.clear()
|
currentSaves.clear()
|
||||||
val saves = GameSaver.getSaves()
|
val saves = GameSaver.getSaves()
|
||||||
.sortedByDescending { GameSaver.getSave(it).lastModified() }
|
.sortedByDescending { GameSaver.getSave(it).lastModified() }
|
||||||
for (saveGameName in saves) {
|
for (saveGameName in saves) {
|
||||||
if(saveGameName.startsWith("Autosave") && !showAutosaves) continue
|
if (saveGameName.startsWith("Autosave") && !showAutosaves) continue
|
||||||
val textButton = TextButton(saveGameName, skin)
|
val textButton = TextButton(saveGameName, skin)
|
||||||
textButton.onClick {
|
textButton.onClick {
|
||||||
textField.text = saveGameName
|
textField.text = saveGameName
|
||||||
@ -78,5 +79,3 @@ class SaveGameScreen : PickerScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user