From e77eaf5fa593e19cb0bcefac981a469772f9cb59 Mon Sep 17 00:00:00 2001 From: lishaoxia1985 <49801619+lishaoxia1985@users.noreply.github.com> Date: Thu, 3 Jun 2021 07:02:46 -0500 Subject: [PATCH] Fix the app window changing may lead to that the app can't open in macOS (#4042) --- core/src/com/unciv/UncivGame.kt | 10 ---------- desktop/src/com/unciv/app/desktop/DesktopLauncher.kt | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index bf24edc579..e75bc09f75 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -62,7 +62,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() { var music: Music? = null val musicLocation = "music/thatched-villagers.mp3" - private var isSizeRestored = false var isInitialized = false @@ -118,7 +117,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() { thread(name="Music") { startMusic() } - restoreSize() if (settings.isFreshlyCreated) { setScreen(LanguagePickerScreen()) @@ -129,14 +127,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() { crashController = CrashController.Impl(crashReportSender) } - fun restoreSize() { - if (!isSizeRestored && Gdx.app.type == Application.ApplicationType.Desktop && settings.windowState.height>39 && settings.windowState.width>39) { - isSizeRestored = true - Gdx.graphics.setWindowedMode(settings.windowState.width, settings.windowState.height) - } - } - - fun loadGame(gameInfo: GameInfo) { this.gameInfo = gameInfo ImageGetter.setNewRuleset(gameInfo.ruleSet) diff --git a/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt b/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt index 2a4f46b9e6..0534d6c1c1 100644 --- a/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt +++ b/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt @@ -6,10 +6,14 @@ import club.minnced.discord.rpc.DiscordRichPresence import com.badlogic.gdx.Files import com.badlogic.gdx.backends.lwjgl.LwjglApplication import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration +import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.tools.texturepacker.TexturePacker +import com.unciv.JsonParser import com.unciv.UncivGame import com.unciv.UncivGameParameters +import com.unciv.logic.GameSaver +import com.unciv.models.metadata.GameSettings import com.unciv.models.translations.tr import com.unciv.ui.utils.Fonts import io.ktor.application.* @@ -39,6 +43,11 @@ internal object DesktopLauncher { config.addIcon("ExtraImages/Icon.png", Files.FileType.Internal) config.title = "Unciv" config.useHDPI = true + if (FileHandle(GameSaver.settingsFileName).exists()) { + val settings = JsonParser().getFromJson(GameSettings::class.java, FileHandle(GameSaver.settingsFileName)) + config.width = settings.windowState.width + config.height = settings.windowState.height + } val versionFromJar = DesktopLauncher.javaClass.`package`.specificationVersion ?: "Desktop"