From 13325c1e89278de1e96fc253d917a96cebb8b67c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 14 Oct 2023 02:10:19 +0200 Subject: [PATCH] performance improvement --- src/core/Global.ttslua | 49 +++++++++++++++-------------------- xml/Global/DownloadWindow.xml | 4 +++ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0869664f..99fa2aa6 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -704,56 +704,46 @@ function onMouseEnter_item(player, param) -- get metadata from library local item = library[contentToShow][index] - UI.setValue("previewTitle", item.name or "Unknown Name") - UI.setValue("previewAuthor", "by " .. (item.author or "Unknown")) - UI.setValue("previewDescription", item.description or "Unknown") + -- error handling + if not item.name + or not item.author + or not item.description + or not item.boxsize + or not item.boxart then + return + end - -- update box art - if not item.boxsize or not item.boxart then return end + UI.setValue("previewTitle", item.name) + UI.setValue("previewAuthor", "by " .. item.author) + UI.setValue("previewDescription", item.description) - local ui = UI.getXmlTable() - local previewArtPanel = find_tag_with_id(ui, 'previewArtPanel') - -- update mask according to size + local maskData = {} if item.boxsize == "big" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-big", width = "870", height = "435", offsetXY = "154 60" } - } elseif item.boxsize == "small" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-small", width = "668", height = "501", offsetXY = "120 10" } - } elseif item.boxsize == "wide" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-wide", width = "780", height = "650", offsetXY = "-195 -70" } - } end -- insert the image itself - previewArtPanel.children.children = { - tag = "Image", - attributes = { image = item.boxart } - } - - UI.setXmlTable(ui) + UI.setAttribute("previewArtImage", "image", item.boxart) -- update the preview window height according to box size local hWindow, hArt, offsetXY @@ -771,9 +761,12 @@ function onMouseEnter_item(player, param) offsetXY = "-510 210" end - UI.setAttribute("previewWindow", "height", hWindow) - UI.setAttribute("previewWindow", "offsetXY", offsetXY) + UI.setAttributes("previewArtMask", maskData) UI.setAttribute("previewArtPanel", "preferredHeight", hArt) + UI.setAttributes("previewWindow", { + height = hWindow, + offsetXY = offsetXY + }) -- show the window UI.show("previewWindow") diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 12f81d12..816f9244 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -108,6 +108,10 @@ + + + +