added language dropdown
This commit is contained in:
parent
c78ddec973
commit
ebf79b554c
@ -1 +1 @@
|
|||||||
{"acknowledgedUpgradeVersions":[],"optionPanel":{"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":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}}
|
||||||
|
@ -46,6 +46,27 @@ local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/
|
|||||||
local library, requestObj, modMeta, notificationVisible
|
local library, requestObj, modMeta, notificationVisible
|
||||||
local acknowledgedUpgradeVersions = {}
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- data for tokens
|
-- data for tokens
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -650,14 +671,29 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
function onClick_refreshList()
|
function onClick_refreshList()
|
||||||
local request = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update)
|
local request = WebRequest.get(SOURCE_REPO .. '/content/library.json', completed_list_update)
|
||||||
requestObj = request
|
requestObj = request
|
||||||
startLuaCoroutine(Global, 'downloadCoroutine')
|
startLuaCoroutine(Global, 'downloadCoroutine')
|
||||||
end
|
end
|
||||||
|
|
||||||
function onClick_select(player, params)
|
-- triggers a re-download in english if localized download failed
|
||||||
|
function fallbackDownload(params)
|
||||||
|
onClick_select(_, params, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function onClick_select(_, params, forceEnglish)
|
||||||
|
-- don't decode on fallback run
|
||||||
|
if type(params) == "string" then
|
||||||
params = JSON.decode(urldecode(params))
|
params = JSON.decode(urldecode(params))
|
||||||
local url = SOURCE_REPO .. '/' .. params.url
|
end
|
||||||
|
|
||||||
|
local languageCode = (LANGUAGE_CODES[optionPanel["cardLanguage"] + 1])
|
||||||
|
|
||||||
|
-- override languageCode to english if localized download failed
|
||||||
|
if forceEnglish then languageCode = "en" end
|
||||||
|
|
||||||
|
-- bundle URL and start the download
|
||||||
|
local url = SOURCE_REPO .. "/content/" .. languageCode .. "/" .. params.url
|
||||||
local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end )
|
local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end )
|
||||||
requestObj = request
|
requestObj = request
|
||||||
startLuaCoroutine(Global, 'downloadCoroutine')
|
startLuaCoroutine(Global, 'downloadCoroutine')
|
||||||
@ -741,7 +777,13 @@ end
|
|||||||
function complete_obj_download(request, params)
|
function complete_obj_download(request, params)
|
||||||
assert(request.is_done)
|
assert(request.is_done)
|
||||||
if request.is_error or request.response_code ~= 200 then
|
if request.is_error or request.response_code ~= 200 then
|
||||||
print('error: ' .. request.error)
|
print('Error: ' .. request.error)
|
||||||
|
|
||||||
|
-- retrigger download if localized version was requested
|
||||||
|
if (LANGUAGE_CODES[optionPanel["cardLanguage"] + 1]) ~= "en" then
|
||||||
|
printToAll("Couldn't find content in requested card language. Defaulting to english instead.", "Yellow")
|
||||||
|
fallbackDownload(params)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if pcall(function()
|
if pcall(function()
|
||||||
local replaced_object
|
local replaced_object
|
||||||
@ -838,15 +880,23 @@ function onClick_toggleOption(_, id)
|
|||||||
applyOptionPanelChange(id, state)
|
applyOptionPanelChange(id, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- called by the language selection dropdown
|
||||||
|
function languageSelected(_, selectedIndex, id)
|
||||||
|
optionPanel[id] = tonumber(selectedIndex)
|
||||||
|
end
|
||||||
|
|
||||||
-- sets the option panel to the correct state (corresponding to 'optionPanel')
|
-- sets the option panel to the correct state (corresponding to 'optionPanel')
|
||||||
function updateOptionPanelState()
|
function updateOptionPanelState()
|
||||||
for id, enabled in pairs(optionPanel) do
|
for id, enabled in pairs(optionPanel) do
|
||||||
if (type(enabled) == "boolean" and enabled)
|
if (type(enabled) == "boolean" and enabled)
|
||||||
or (type(enabled) == "string" and enabled)
|
or (type(enabled) == "string" and enabled)
|
||||||
or (type(enabled) == "table" and #enabled ~= 0) then
|
or (type(enabled) == "table" and #enabled ~= 0) then
|
||||||
self.UI.setAttribute(id, "isOn", true)
|
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
|
else
|
||||||
self.UI.setAttribute(id, "isOn", "False")
|
UI.setAttribute(id, "isOn", "False")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
<Toggle isOn="False"
|
<Toggle isOn="False"
|
||||||
rectAlignment="MiddleRight" />
|
rectAlignment="MiddleRight" />
|
||||||
|
|
||||||
|
<Dropdown rectAlignment="MiddleCenter" />
|
||||||
|
|
||||||
<Cell dontUseTableCellBackground="true"
|
<Cell dontUseTableCellBackground="true"
|
||||||
outlineSize="0 1"
|
outlineSize="0 1"
|
||||||
outline="grey" />
|
outline="grey" />
|
||||||
@ -26,7 +28,7 @@
|
|||||||
<Row class="group-header"
|
<Row class="group-header"
|
||||||
preferredHeight="54" />
|
preferredHeight="54" />
|
||||||
<Cell class="group-header"
|
<Cell class="group-header"
|
||||||
columnSpan="2"
|
columnSpan="3"
|
||||||
color="#222222" />
|
color="#222222" />
|
||||||
<Panel class="group-header"
|
<Panel class="group-header"
|
||||||
padding="5 0 0 0" />
|
padding="5 0 0 0" />
|
||||||
@ -38,9 +40,16 @@
|
|||||||
<Row class="option-text"
|
<Row class="option-text"
|
||||||
preferredHeight="70"/>
|
preferredHeight="70"/>
|
||||||
<Cell class="option-text"
|
<Cell class="option-text"
|
||||||
color="#333333"/>
|
color="#333333"
|
||||||
|
columnSpan="2"/>
|
||||||
<Cell class="option-button"
|
<Cell class="option-button"
|
||||||
color="#333333"/>
|
color="#333333"/>
|
||||||
|
<Cell class="option-dropdowntext"
|
||||||
|
color="#333333"
|
||||||
|
columnSpan="1"/>
|
||||||
|
<Cell class="option-dropdown"
|
||||||
|
color="#333333"
|
||||||
|
columnSpan="2"/>
|
||||||
<VerticalLayout class="text-column"
|
<VerticalLayout class="text-column"
|
||||||
padding="10 0 0 0"
|
padding="10 0 0 0"
|
||||||
spacing="5"/>
|
spacing="5"/>
|
||||||
@ -87,9 +96,9 @@
|
|||||||
<Row>
|
<Row>
|
||||||
<Cell>
|
<Cell>
|
||||||
<VerticalScrollView horizontalScrollbarVisibility="AutohideAndExpandViewport">
|
<VerticalScrollView horizontalScrollbarVisibility="AutohideAndExpandViewport">
|
||||||
<TableLayout columnWidths="0 75"
|
<TableLayout columnWidths="0 100 75"
|
||||||
autoCalculateHeight="1"
|
autoCalculateHeight="1"
|
||||||
cellPadding="10 0 5 5">
|
cellPadding="10 5 5 5">
|
||||||
|
|
||||||
<!-- Group: general settings -->
|
<!-- Group: general settings -->
|
||||||
<Row class="group-header">
|
<Row class="group-header">
|
||||||
@ -101,6 +110,30 @@
|
|||||||
</Cell>
|
</Cell>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
<!-- Option: card language -->
|
||||||
|
<Row class="option-text">
|
||||||
|
<Cell class="option-dropdowntext">
|
||||||
|
<VerticalLayout class="text-column">
|
||||||
|
<Text class="option-header">Card language</Text>
|
||||||
|
<Text class="description">Downloading a supported campaign or importing a deck will use this language for the cards.</Text>
|
||||||
|
</VerticalLayout>
|
||||||
|
</Cell>
|
||||||
|
<Cell class="option-dropdown">
|
||||||
|
<Panel padding="0 17 13 13">
|
||||||
|
<Dropdown id="cardLanguage"
|
||||||
|
onValueChanged="languageSelected(selectedIndex)">
|
||||||
|
<Option>简体中文</Option>
|
||||||
|
<Option>繁體中文</Option>
|
||||||
|
<Option>Deutsch</Option>
|
||||||
|
<Option>English</Option>
|
||||||
|
<Option>Español</Option>
|
||||||
|
<Option>Français</Option>
|
||||||
|
<Option>Italiano</Option>
|
||||||
|
</Dropdown>
|
||||||
|
</Panel>
|
||||||
|
</Cell>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<!-- Option: play area snap tags -->
|
<!-- Option: play area snap tags -->
|
||||||
<Row class="option-text">
|
<Row class="option-text">
|
||||||
<Cell class="option-text">
|
<Cell class="option-text">
|
||||||
@ -171,7 +204,7 @@
|
|||||||
<Row class="option-text">
|
<Row class="option-text">
|
||||||
<Cell class="option-text">
|
<Cell class="option-text">
|
||||||
<VerticalLayout class="text-column">
|
<VerticalLayout class="text-column">
|
||||||
<Text class="option-header">Use clickable clue-counters</Text>
|
<Text class="option-header">Use clickable clue counters</Text>
|
||||||
<Text class="description">Instead of automatically counting clues in the respective area on your playermat, this displays a clickable counter for clues.</Text>
|
<Text class="description">Instead of automatically counting clues in the respective area on your playermat, this displays a clickable counter for clues.</Text>
|
||||||
</VerticalLayout>
|
</VerticalLayout>
|
||||||
</Cell>
|
</Cell>
|
||||||
@ -185,7 +218,7 @@
|
|||||||
<Row class="option-text">
|
<Row class="option-text">
|
||||||
<Cell class="option-text">
|
<Cell class="option-text">
|
||||||
<VerticalLayout class="text-column">
|
<VerticalLayout class="text-column">
|
||||||
<Text class="option-header">Use clickable resource counters</Text>
|
<Text class="option-header">Use clickable resource tokens</Text>
|
||||||
<Text class="description">This enables spawning of clickable resource tokens for player cards.</Text>
|
<Text class="description">This enables spawning of clickable resource tokens for player cards.</Text>
|
||||||
</VerticalLayout>
|
</VerticalLayout>
|
||||||
</Cell>
|
</Cell>
|
||||||
|
Loading…
Reference in New Issue
Block a user