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