Merge branch 'option-panel' of https://github.com/argonui/SCED into option-panel
This commit is contained in:
commit
95f317831d
@ -671,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
|
||||||
params = JSON.decode(urldecode(params))
|
function fallbackDownload(params)
|
||||||
local url = SOURCE_REPO .. '/' .. params.url
|
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))
|
||||||
|
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')
|
||||||
@ -762,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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user