added option panel hook

This commit is contained in:
Chr1Z93 2023-11-29 13:24:14 +01:00
parent 01da266b67
commit 0e4beda950
2 changed files with 14 additions and 4 deletions

View File

@ -208,15 +208,15 @@ PLAYAREA_IMAGE_DATA = {
URL = "http://cloud-3.steamusercontent.com/ugc/2279446315725447579/F7C3FB9E31147430C1384684887FC66E616D0302/"
},
{
Name = "II - The Doom of Etzli 1",
Name = "II - The Doom of Eztli 1",
URL = "http://cloud-3.steamusercontent.com/ugc/2279446315725447752/44EF68E1BF3C2D9DCD5306DD90B4CCCFBE03891C/"
},
{
Name = "II - The Doom of Etzli 2",
Name = "II - The Doom of Eztli 2",
URL = "http://cloud-3.steamusercontent.com/ugc/2279446315725448027/F5F14EC590C33BC87D8F0CFF43D7E4DF80D61133/"
},
{
Name = "II - The Doom of Etzli 3",
Name = "II - The Doom of Eztli 3",
URL = "http://cloud-3.steamusercontent.com/ugc/2279446315725448215/BFD9D940DB8EC9AC8D818C48BBAE3338A8E48A3B/"
},
{

View File

@ -1,4 +1,5 @@
require("core/PlayAreaImageData") -- this fills the variable "PLAYAREA_IMAGE_DATA"
local optionPanelApi = require("core/OptionPanelApi")
local playAreaApi = require("core/PlayAreaApi")
local typeIndex, selectionIndex, plainNameCache
@ -150,6 +151,10 @@ function round(num, numDecimalPlaces)
end
function maybeUpdatePlayAreaImage(scenarioName)
-- check if option is enabled
local optionPanelState = optionPanelApi.getOptions()
if not optionPanelState["changePlayAreaImage"] then return end
-- initialize cache if nil
if not plainNameCache then
plainNameCache = {}
@ -157,7 +162,12 @@ function maybeUpdatePlayAreaImage(scenarioName)
for j, dataForCycle in pairs(dataForType) do
for k, data in ipairs(dataForCycle) do
local plainName = getPlainName(data.Name)
log(plainName)
-- override plainName for all images in the "Other Images" category (except the default image)
if i == "Other Images" and data.Name ~= "Default Image" then
plainName = "Generic"
end
if not plainNameCache[plainName] then
plainNameCache[plainName] = {}
end