review comments

This commit is contained in:
Chr1Z93 2023-06-27 13:32:06 +02:00
parent 7426c4475e
commit 2bf95356dc
2 changed files with 27 additions and 28 deletions

View File

@ -1 +1 @@
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":3,"playAreaSnapTags":true,"showAttachmentHelper":false,"showChaosBagManager":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}}
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"English","playAreaSnapTags":true,"showAttachmentHelper":false,"showChaosBagManager":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}}

View File

@ -46,25 +46,14 @@ local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/
local library, requestObj, modMeta, notificationVisible
local acknowledgedUpgradeVersions = {}
-- language selection
local LANGUAGE_CODES = {
"zh_CN", -- 简体中文
"zh_TW", -- 繁體中文
"de", -- Deutsch
"en", -- English
"es", -- Español
"fr", -- Français
"it" -- Italiano
}
local LANGUAGE_NAMES = {
"简体中文",
"繁體中文",
"Deutsch",
"English",
"Español",
"Français",
"Italiano"
local LANGUAGES = {
{ code = "zh_CN", name = "简体中文" },
{ code = "zh_TW", name = "繁體中文" },
{ code = "de", name = "Deutsch" },
{ code = "en", name = "English" },
{ code = "es", name = "Español" },
{ code = "fr", name = "Français" },
{ code = "it", name = "Italiano" }
}
---------------------------------------------------------
@ -861,19 +850,29 @@ end
-- called by the language selection dropdown
function languageSelected(_, selectedIndex, id)
optionPanel[id] = tonumber(selectedIndex)
optionPanel[id] = LANGUAGES[tonumber(selectedIndex) + 1].name
end
function returnLanguageId(name)
for index, tbl in ipairs(LANGUAGES) do
for key, value in pairs(tbl) do
if key == "name" and value == name then
return index
end
end
end
end
-- sets the option panel to the correct state (corresponding to 'optionPanel')
function updateOptionPanelState()
for id, enabled in pairs(optionPanel) do
if (type(enabled) == "boolean" and enabled)
or (type(enabled) == "string" and enabled)
or (type(enabled) == "table" and #enabled ~= 0) then
for id, optionValue in pairs(optionPanel) do
if id == "cardLanguage" and type(optionValue) == "string" then
local dropdownId = returnLanguageId(optionValue) - 1
UI.setAttribute(id, "value", dropdownId)
elseif (type(optionValue) == "boolean" and optionValue)
or (type(optionValue) == "string" and optionValue)
or (type(optionValue) == "table" and #optionValue ~= 0) then
UI.setAttribute(id, "isOn", true)
-- hard-coded updating of the language selection dropdown
elseif id == "cardLanguage" and type(enabled) == "number" then
UI.setAttribute(id, "value", enabled)
else
UI.setAttribute(id, "isOn", "False")
end