mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-24 13:41:08 +07:00
Fix option change not reloading main menu properly (#7170)
This commit is contained in:
parent
89a7cc7246
commit
1bbc11cc47
@ -204,12 +204,12 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
}
|
||||
|
||||
/** Re-creates the current [worldScreen], if there is any. */
|
||||
fun reloadWorldscreen() {
|
||||
suspend fun reloadWorldscreen() {
|
||||
val curWorldScreen = worldScreen
|
||||
val curGameInfo = gameInfo
|
||||
if (curWorldScreen == null || curGameInfo == null) return
|
||||
|
||||
Concurrency.run { loadGame(curGameInfo) }
|
||||
loadGame(curGameInfo)
|
||||
}
|
||||
|
||||
private data class NewScreens(val screenToShow: BaseScreen, val worldScreen: WorldScreen) {
|
||||
|
@ -28,6 +28,9 @@ import com.unciv.ui.utils.extensions.toCheckBox
|
||||
import com.unciv.ui.utils.extensions.toGdxArray
|
||||
import com.unciv.ui.utils.extensions.toLabel
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import com.unciv.utils.concurrency.Concurrency
|
||||
import com.unciv.utils.concurrency.Dispatcher
|
||||
import com.unciv.utils.concurrency.withGLContext
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
/**
|
||||
@ -133,8 +136,20 @@ class OptionsPopup(
|
||||
|
||||
/** Reload this Popup after major changes (resolution, tileset, language, font) */
|
||||
private fun reloadWorldAndOptions() {
|
||||
Concurrency.run("Reload from options") {
|
||||
settings.save()
|
||||
val screen = UncivGame.Current.screen
|
||||
if (screen is WorldScreen) {
|
||||
UncivGame.Current.reloadWorldscreen()
|
||||
} else if (screen is MainMenuScreen) {
|
||||
withGLContext {
|
||||
UncivGame.Current.setScreen(MainMenuScreen())
|
||||
}
|
||||
}
|
||||
withGLContext {
|
||||
UncivGame.Current.screen?.openOptionsPopup(tabs.activePage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addCheckbox(table: Table, text: String, initialState: Boolean, updateWorld: Boolean = false, action: ((Boolean) -> Unit)) {
|
||||
|
Loading…
Reference in New Issue
Block a user