mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Shortened initial loading time by removing double loading of atlas
This commit is contained in:
parent
996f54367d
commit
c7bd528052
@ -70,14 +70,11 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
viewEntireMapForDebug = false
|
viewEntireMapForDebug = false
|
||||||
}
|
}
|
||||||
Current = this
|
Current = this
|
||||||
|
|
||||||
|
|
||||||
GameSaver.customSaveLocationHelper = customSaveLocationHelper
|
GameSaver.customSaveLocationHelper = customSaveLocationHelper
|
||||||
|
|
||||||
// If this takes too long players, especially with older phones, get ANR problems.
|
// If this takes too long players, especially with older phones, get ANR problems.
|
||||||
// Whatever needs graphics needs to be done on the main thread,
|
// Whatever needs graphics needs to be done on the main thread,
|
||||||
// So it's basically a long set of deferred actions.
|
// So it's basically a long set of deferred actions.
|
||||||
settings = GameSaver.getGeneralSettings() // needed for the screen
|
|
||||||
|
|
||||||
|
|
||||||
/** When we recreate the GL context for whatever reason (say - we moved to a split screen on Android),
|
/** When we recreate the GL context for whatever reason (say - we moved to a split screen on Android),
|
||||||
* ALL objects that were related to the old context - need to be recreated.
|
* ALL objects that were related to the old context - need to be recreated.
|
||||||
@ -90,6 +87,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
ImageGetter.atlas = TextureAtlas("game.atlas")
|
ImageGetter.atlas = TextureAtlas("game.atlas")
|
||||||
ImageGetter.setNewRuleset(ImageGetter.ruleset)
|
ImageGetter.setNewRuleset(ImageGetter.ruleset)
|
||||||
CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it
|
CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it
|
||||||
|
settings = GameSaver.getGeneralSettings() // needed for the screen - this also needs the atlas to be configured
|
||||||
|
|
||||||
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
Gdx.graphics.isContinuousRendering = settings.continuousRendering
|
||||||
screen = LoadingScreen()
|
screen = LoadingScreen()
|
||||||
|
@ -30,24 +30,16 @@ object ImageGetter {
|
|||||||
// always have to switch between like 170 different textures.
|
// 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,
|
// 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.
|
// and the atlas is what tells us what was packed where.
|
||||||
var atlas = TextureAtlas("game.atlas")
|
lateinit var atlas: TextureAtlas
|
||||||
var ruleset = Ruleset()
|
var ruleset = Ruleset()
|
||||||
|
|
||||||
// We then shove all the drawables into a hashmap, because the atlas specifically tells us
|
// We then shove all the drawables into a hashmap, because the atlas specifically tells us
|
||||||
// that the search on it is inefficient
|
// that the search on it is inefficient
|
||||||
private val textureRegionDrawables = HashMap<String, TextureRegionDrawable>()
|
private val textureRegionDrawables = HashMap<String, TextureRegionDrawable>()
|
||||||
|
|
||||||
init {
|
/** Required every time the ruleset changes, in order to load mod-specific images */
|
||||||
reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNewRuleset(ruleset: Ruleset) {
|
fun setNewRuleset(ruleset: Ruleset) {
|
||||||
this.ruleset = ruleset
|
this.ruleset = ruleset
|
||||||
reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Required every time the ruleset changes, in order to load mod-specific images */
|
|
||||||
private fun reload() {
|
|
||||||
textureRegionDrawables.clear()
|
textureRegionDrawables.clear()
|
||||||
// These are the drawables from the base game
|
// These are the drawables from the base game
|
||||||
for (region in atlas.regions) {
|
for (region in atlas.regions) {
|
||||||
@ -183,8 +175,7 @@ object ImageGetter {
|
|||||||
cityStateIcon.color = nation.getInnerColor()
|
cityStateIcon.color = nation.getInnerColor()
|
||||||
cityStateIcon.surroundWithCircle(size * 0.9f).apply { circle.color = nation.getOuterColor() }
|
cityStateIcon.surroundWithCircle(size * 0.9f).apply { circle.color = nation.getOuterColor() }
|
||||||
.surroundWithCircle(size, false).apply { circle.color = nation.getInnerColor() }
|
.surroundWithCircle(size, false).apply { circle.color = nation.getInnerColor() }
|
||||||
}
|
} else getCircle().apply { color = nation.getOuterColor() }
|
||||||
else getCircle().apply { color = nation.getOuterColor() }
|
|
||||||
.surroundWithCircle(size).apply { circle.color = nation.getInnerColor() }
|
.surroundWithCircle(size).apply { circle.color = nation.getInnerColor() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +265,8 @@ object ImageGetter {
|
|||||||
|
|
||||||
fun getResourceImage(resourceName: String, size: Float): Actor {
|
fun getResourceImage(resourceName: String, size: Float): Actor {
|
||||||
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
||||||
val resource = ruleset.tileResources[resourceName] ?: return iconGroup // This is the result of a bad modding setup, just give em an empty circle. Their problem.
|
val resource = ruleset.tileResources[resourceName]
|
||||||
|
?: return iconGroup // This is the result of a bad modding setup, just give em an empty circle. Their problem.
|
||||||
iconGroup.circle.color = getColorFromStats(resource)
|
iconGroup.circle.color = getColorFromStats(resource)
|
||||||
|
|
||||||
if (resource.resourceType == ResourceType.Luxury) {
|
if (resource.resourceType == ResourceType.Luxury) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user