mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Refactor: change GameSaver from singleton to single instance pattern & move autosave logic into GameSaver (#6846)
* Refactor: change GameSaver from singleton to single instance pattern & move autosave logic info GameSaver Singleton just doesn't make sense anymore when we have to `init(..)` with different arguments, then we should just make a normal class out of it * Fix not correctly checking for missing external files dir * Refactor: use more appropriate library method * Add logging for external files dir
This commit is contained in:
@ -10,7 +10,6 @@ import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.UncivGameParameters
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.ui.utils.Fonts
|
||||
import java.io.File
|
||||
|
||||
@ -24,14 +23,12 @@ open class AndroidLauncher : AndroidApplication() {
|
||||
MultiplayerTurnCheckWorker.createNotificationChannels(applicationContext)
|
||||
|
||||
copyMods()
|
||||
val externalFilesDir = getExternalFilesDir(null)
|
||||
if (externalFilesDir != null) GameSaver.externalFilesDirForAndroid = externalFilesDir.path
|
||||
|
||||
val config = AndroidApplicationConfiguration().apply {
|
||||
useImmersiveMode = true
|
||||
}
|
||||
|
||||
val settings = GameSettings.getSettingsForPlatformLaunchers(filesDir.path)
|
||||
val settings = GameSaver.getSettingsForPlatformLaunchers(filesDir.path)
|
||||
val fontFamily = settings.fontFamily
|
||||
|
||||
// Manage orientation lock
|
||||
@ -73,8 +70,8 @@ open class AndroidLauncher : AndroidApplication() {
|
||||
if (UncivGame.isCurrentInitialized()
|
||||
&& UncivGame.Current.isGameInfoInitialized()
|
||||
&& UncivGame.Current.settings.multiplayerTurnCheckerEnabled
|
||||
&& GameSaver.getSaves(true).any()) {
|
||||
MultiplayerTurnCheckWorker.startTurnChecker(applicationContext, GameSaver, UncivGame.Current.gameInfo, UncivGame.Current.settings)
|
||||
&& UncivGame.Current.gameSaver.getMultiplayerSaves().any()) {
|
||||
MultiplayerTurnCheckWorker.startTurnChecker(applicationContext, UncivGame.Current.gameSaver, UncivGame.Current.gameInfo, UncivGame.Current.settings)
|
||||
}
|
||||
super.onPause()
|
||||
}
|
||||
|
Reference in New Issue
Block a user