added helper function

This commit is contained in:
Chr1Z93 2024-02-19 20:09:38 +01:00
parent 7c2bfc36e4
commit a10041f435
2 changed files with 21 additions and 2 deletions

View File

@ -1103,12 +1103,31 @@ function updateDownloadItemList()
end
contentList.attributes.height = #contentList.children * 27
UI.setXmlTable(globalXml)
updateGlobalXml(globalXml)
-- select the first item
Wait.time(onClick_select, 0.2)
end
-- this helper function updates the global XML while preserving the visibility of windows
function updateGlobalXml(newXml)
-- preserve visibility settings for these elements
local windowIdList = {
"playAreaGallery",
"downloadWindow",
"optionPanel"
}
-- get current state and update newXml
for _, windowId in ipairs(windowIdList) do
local element = getXmlTableElementById(newXml, windowId)
element.attributes.active = UI.getAttribute(windowId, "active")
element.attributes.visibility = UI.getAttribute(windowId, "visibility")
end
UI.setXmlTable(newXml)
end
-- called after the webrequest of downloading an item
-- deletes the placeholder and spawns the downloaded item
function contentDownloadCallback(request, params)

View File

@ -88,7 +88,7 @@ function updatePlayAreaGallery()
end
playareaList.attributes.height = round(#playareaList.children / 2, 0) * 380
UI.setXmlTable(globalXml)
Global.call("updateGlobalXml", globalXml)
Wait.time(highlightTabAndItem, 0.1)
end