Simplified init resources on new game

This commit is contained in:
Yair Morgenstern 2022-10-22 21:38:46 +03:00
parent a450ddbb2c
commit 3f1a385747
2 changed files with 4 additions and 12 deletions

View File

@ -226,16 +226,12 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
/** The new game info may have different mods or rulesets, which may use different resources that need to be loaded. */
private suspend fun initializeResources(prevGameInfo: GameInfo?, newGameInfo: GameInfo) {
if (prevGameInfo == null || prevGameInfo.ruleSet != newGameInfo.ruleSet) {
if (prevGameInfo == null
|| prevGameInfo.gameParameters.baseRuleset != newGameInfo.gameParameters.baseRuleset
|| prevGameInfo.gameParameters.mods != newGameInfo.gameParameters.mods) {
withGLContext {
ImageGetter.setNewRuleset(newGameInfo.ruleSet)
}
}
if (prevGameInfo == null ||
prevGameInfo.gameParameters.baseRuleset != newGameInfo.gameParameters.baseRuleset ||
prevGameInfo.gameParameters.mods != newGameInfo.gameParameters.mods
) {
val fullModList = newGameInfo.gameParameters.getModsAndBaseRuleset()
musicController.setModList(fullModList)
}

View File

@ -36,11 +36,7 @@ import kotlin.math.sqrt
object ImageGetter {
private const val whiteDotLocation = "OtherIcons/whiteDot"
// When we used to load images directly from different files, without using a texture atlas,
// The draw() phase of the main screen would take a really long time because the BatchRenderer would
// always have to switch between like 170 different textures.
// So, we now use TexturePacker in the DesktopLauncher class to pack all the different images into single images,
// and the atlas is what tells us what was packed where.
// We use texture atlases to minimize texture swapping - see https://yairm210.medium.com/the-libgdx-performance-guide-1d068a84e181
lateinit var atlas: TextureAtlas
private val atlases = HashMap<String, TextureAtlas>()
var ruleset = Ruleset()