Skip to content

Commit

Permalink
Move LinuxX11SaverLoader to Desktop as should be
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Dec 30, 2024
1 parent d352dfe commit 38b44ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ project(":desktop") {

dependencies {
"implementation"(project(":core"))
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
"implementation"("com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion")
"implementation"("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop")

Expand Down
5 changes: 0 additions & 5 deletions core/src/com/unciv/logic/files/UncivFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,6 @@ class UncivFiles(
* Platform dependent saver-loader to custom system locations
*/
var saverLoader: PlatformSaverLoader = PlatformSaverLoader.None
get() {
if (field.javaClass.simpleName == "DesktopSaverLoader" && LinuxX11SaverLoader.isRequired())
field = LinuxX11SaverLoader()
return field
}

/** Specialized function to access settings before Gdx is initialized.
*
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/com/unciv/app/desktop/DesktopLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal object DesktopLauncher {
Fonts.fontImplementation = DesktopFont()

// Setup Desktop saver-loader
UncivFiles.saverLoader = DesktopSaverLoader()
UncivFiles.saverLoader = if (LinuxX11SaverLoader.isRequired()) LinuxX11SaverLoader() else DesktopSaverLoader()
UncivFiles.preferExternalStorage = false

// Solves a rendering problem in specific GPUs and drivers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.unciv.logic.files
package com.unciv.app.desktop

import com.badlogic.gdx.Gdx
import com.unciv.UncivGame
import com.unciv.logic.files.FileChooser
import com.unciv.logic.files.PlatformSaverLoader
import com.unciv.utils.Concurrency
import java.awt.GraphicsEnvironment
import java.io.File
Expand All @@ -24,8 +26,8 @@ class LinuxX11SaverLoader : PlatformSaverLoader {
if (suggestedLocation.startsWith(File.separator)) Gdx.files.absolute(suggestedLocation)
else if (Gdx.files.external(suggestedLocation).parent().exists()) Gdx.files.external(suggestedLocation)
else UncivGame.Current.files.getLocalFile(suggestedLocation)
FileChooser.createSaveDialog(stage, "Save game", startLocation) {
success, file ->

FileChooser.createSaveDialog(stage, "Save game", startLocation) { success, file ->
if (!success)
onError(PlatformSaverLoader.Cancelled())
else
Expand Down

0 comments on commit 38b44ec

Please sign in to comment.