From 627ed773dfb005aff493fdf4d541fe055b3d1899 Mon Sep 17 00:00:00 2001 From: Angen Date: Sat, 7 Nov 2020 15:26:37 +0000 Subject: [PATCH] Always update preview in biome and landscape Introduced in af15d5972d. Landscape and Biome previews are not updated correctly when reopeneing gamesetup. To solve that, remove lastBiome and lastLandscape and always try to update preview if preview file exists and does not match with current one. Differential revision: D3041 Reviewed by: @Freagarach Fixes: #5785 This was SVN commit r24139. --- .../GameSettings/Single/Dropdowns/Biome.js | 17 +++++------------ .../GameSettings/Single/Dropdowns/Landscape.js | 12 ++++-------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Biome.js b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Biome.js index afe2ef7681..0e8665ff50 100644 --- a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Biome.js +++ b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Biome.js @@ -7,8 +7,6 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown this.values = undefined; this.biomeValues = undefined; - this.lastBiome = undefined; - this.randomItem = { "Id": this.RandomBiomeId, "Title": setStringTags(this.RandomBiome, this.RandomItemTags), @@ -49,7 +47,6 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown else this.values = undefined; - this.lastBiome = undefined; } onGameAttributesChange() @@ -65,17 +62,13 @@ GameSettingControls.Biome = class extends GameSettingControlDropdown this.gameSettingsControl.updateGameAttributes(); } - if (this.lastBiome != g_GameAttributes.settings.Biome) - { - let biomePreviewFile = - basename(g_GameAttributes.map) + "_" + - basename(g_GameAttributes.settings.Biome || "") + ".png"; + let biomePreviewFile = + basename(g_GameAttributes.map) + "_" + + basename(g_GameAttributes.settings.Biome || "") + ".png"; - if (Engine.TextureExists(this.mapCache.TexturesPath + this.mapCache.PreviewsPath + biomePreviewFile)) - g_GameAttributes.settings.Preview = biomePreviewFile; + if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != biomePreviewFile && Engine.TextureExists(this.mapCache.TexturesPath + this.mapCache.PreviewsPath + biomePreviewFile)) + g_GameAttributes.settings.Preview = biomePreviewFile; - this.lastBiome = g_GameAttributes.settings.Biome; - } } else if (g_GameAttributes.settings.Biome) { diff --git a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js index eb181a8600..03f7bbfaa1 100644 --- a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js +++ b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js @@ -5,7 +5,6 @@ GameSettingControls.Landscape = class extends GameSettingControlDropdown super(...args); this.values = undefined; - this.lastLandscape = undefined; this.mapData = undefined; } @@ -44,8 +43,6 @@ GameSettingControls.Landscape = class extends GameSettingControlDropdown else this.values = undefined; - this.lastLandscape = undefined; - this.setHidden(!this.values); } @@ -69,11 +66,10 @@ GameSettingControls.Landscape = class extends GameSettingControlDropdown this.gameSettingsControl.updateGameAttributes(); } - if (this.lastLandscape != g_GameAttributes.settings.Landscape) - { - g_GameAttributes.settings.Preview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)]; - this.lastLandscape = g_GameAttributes.settings.Biome; - } + let landscapePreview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)]; + if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != landscapePreview) + g_GameAttributes.settings.Preview = landscapePreview; + } else if (g_GameAttributes.settings.Landscape !== undefined) {