mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 19:43:13 -04:00
Desktop window size restore (#2319)
* Bring Incas into the main game (also changes slinger withdraw ability to inheritable) * Update Nations.json * Small version: remember window size only, and leave positioning to Gdx
This commit is contained in:
parent
8f583732aa
commit
10762a3873
@ -51,6 +51,7 @@ class UncivGame(
|
||||
|
||||
var music: Music? = null
|
||||
val musicLocation = "music/thatched-villagers.mp3"
|
||||
private var isSizeRestored = false
|
||||
var isInitialized = false
|
||||
|
||||
|
||||
@ -93,9 +94,18 @@ class UncivGame(
|
||||
crashController = CrashController.Impl(crashReportSender)
|
||||
}
|
||||
|
||||
private 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 autoLoadGame() {
|
||||
if (!GameSaver().getSave("Autosave").exists())
|
||||
if (!GameSaver().getSave("Autosave").exists()) {
|
||||
restoreSize()
|
||||
return setScreen(LanguagePickerScreen())
|
||||
}
|
||||
try {
|
||||
loadGame("Autosave")
|
||||
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
@ -124,6 +134,7 @@ class UncivGame(
|
||||
this.gameInfo = gameInfo
|
||||
ImageGetter.ruleset = gameInfo.ruleSet
|
||||
ImageGetter.refreshAtlas()
|
||||
restoreSize()
|
||||
worldScreen = WorldScreen(gameInfo.getPlayerToViewAs())
|
||||
setWorldScreen()
|
||||
}
|
||||
@ -166,8 +177,10 @@ class UncivGame(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
if (::gameInfo.isInitialized)
|
||||
if (::gameInfo.isInitialized) {
|
||||
GameSaver().autoSave(gameInfo)
|
||||
settings.save()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -4,6 +4,8 @@ import com.badlogic.gdx.Application
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.unciv.logic.GameSaver
|
||||
|
||||
data class WindowState (val width:Int=0, val height:Int=0)
|
||||
|
||||
class GameSettings {
|
||||
var showWorkedTiles: Boolean = false
|
||||
var showResourcesAndImprovements: Boolean = true
|
||||
@ -30,6 +32,7 @@ class GameSettings {
|
||||
var multiplayerTurnCheckerPersistentNotificationEnabled = true
|
||||
var multiplayerTurnCheckerDelayInMinutes = 5
|
||||
var orderTradeOffersByAmount = true
|
||||
var windowState = WindowState()
|
||||
|
||||
init {
|
||||
// 26 = Android Oreo. Versions below may display permanent icon in notification bar.
|
||||
@ -39,6 +42,9 @@ class GameSettings {
|
||||
}
|
||||
|
||||
fun save(){
|
||||
if (Gdx.app.type == Application.ApplicationType.Desktop) {
|
||||
windowState = WindowState( Gdx.graphics.width, Gdx.graphics.height)
|
||||
}
|
||||
GameSaver().setGeneralSettings(this)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user