Move LinuxX11SaverLoader to Desktop as should be

This commit is contained in:
yairm210
2024-12-30 11:46:32 +02:00
parent d352dfe53b
commit 38b44ec2e1
4 changed files with 7 additions and 9 deletions

View File

@ -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")

View File

@ -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.
*

View File

@ -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.

View File

@ -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
@ -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