From a526e645a8de9922c69659d8536f8bed8e34c300 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 19 Apr 2023 20:04:45 +0200 Subject: [PATCH] resolving review comments --- objects/LuaScriptState.luascriptstate | 2 +- src/core/Global.ttslua | 44 ++++++++++----------------- xml/UpdateNotification.xml | 5 +-- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/objects/LuaScriptState.luascriptstate b/objects/LuaScriptState.luascriptstate index 9f3b03e0..1ebd1cec 100644 --- a/objects/LuaScriptState.luascriptstate +++ b/objects/LuaScriptState.luascriptstate @@ -1 +1 @@ -{"dontNotify":[],"optionPanel":{"playAreaSnapTags":true,"showAttachmentHelper":false,"showChaosBagManager":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showNavigationOverlay":false,"showSearchAssistant":[],"showTitleSplash":true,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}} +{"acknowledgedUpgradeVersions":[],"optionPanel":{"playAreaSnapTags":true,"showAttachmentHelper":false,"showChaosBagManager":false,"showCleanUpHelper":false,"showCustomPlaymatImages":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showNavigationOverlay":false,"showSearchAssistant":[],"showTitleSplash":true,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}} diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 726ae367..0a16260c 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -43,7 +43,7 @@ local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local MOD_VERSION = "3.1.0" local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' local library, requestObj, modMeta, notificationVisible -local dontNotify = {} +local acknowledgedUpgradeVersions = {} --------------------------------------------------------- -- data for tokens @@ -104,13 +104,13 @@ local tokenDrawingStats = { --------------------------------------------------------- -- saving state of optionPanel to restore later -function onSave() return JSON.encode({ optionPanel = optionPanel, dontNotify = dontNotify }) end +function onSave() return JSON.encode({ optionPanel = optionPanel, acknowledgedUpgradeVersions = acknowledgedUpgradeVersions }) end function onLoad(savedData) if savedData then - loadedData = JSON.decode(savedData) + loadedData = JSON.decode(savedData) optionPanel = loadedData.optionPanel - dontNotify = loadedData.dontNotify + acknowledgedUpgradeVersions = loadedData.acknowledgedUpgradeVersions updateOptionPanelState() else print("Saved state could not be found!") @@ -1059,10 +1059,11 @@ function compareVersion(request) -- global variable to make it accessible for other functions modMeta = JSON.decode(request.text) - -- stop here if on latest version or "don't show again" was clicked + -- stop here if on latest version if MOD_VERSION == modMeta["latestVersion"] then return end - if dontNotify[modMeta["latestVersion"]] then return end + -- stop here if "don't show again" was clicked for this version before + if acknowledgedUpgradeVersions[modMeta["latestVersion"]] then return end -- end here if no release notes are found if modMeta["releaseNotes"][modMeta["latestVersion"]] == nil then @@ -1078,34 +1079,21 @@ end -- updates the XML update notification based on the mod metadata function updateNotificationLoading() -- grab data - local highlights = modMeta["releaseNotes"][modMeta["latestVersion"]]["Highlights"] - local ui = UI.getXmlTable() + local highlights = modMeta["releaseNotes"][modMeta["latestVersion"]]["highlights"] - -- update the header - local header = find_tag_with_id(ui, 'notificationHeader') - header.value = header.value .. modMeta["latestVersion"] - - -- update the release highlights + -- concatenate the release highlights local highlightText = "• " .. highlights[1] - for i, entry in pairs(highlights) do if i ~= 1 then highlightText = highlightText .. "\n• " .. entry end end - - local releaseHighlightText = find_tag_with_id(ui, 'releaseHighlightText') - releaseHighlightText.value = highlightText - - -- set height for amount of highlights - local highlightRow = find_tag_with_id(ui, 'highlightRow') - highlightRow.attributes.preferredHeight = 20*#highlights - - local window = find_tag_with_id(ui, 'updateNotification') - window.attributes.height = highlightRow.attributes.preferredHeight + 125 - + -- update the XML UI - UI.setXmlTable(ui) + UI.setValue("notificationHeader", "New version available: ".. modMeta["latestVersion"]) + UI.setValue("releaseHighlightText", highlightText) + UI.setAttribute("highlightRow", "preferredHeight", 20*#highlights) + UI.setAttribute("updateNotification", "height", 20*#highlights + 125) end -- triggered by clicking on the Finn Icon @@ -1121,9 +1109,9 @@ end -- close / don't show again buttons on the update notification function onClick_notification(_, parameter) - if parameter == "dontNotify" then + if parameter == "dontShowAgain" then -- this variable tracks if "don't show again" was pressed for a version - dontNotify[modMeta["latestVersion"]] = true + acknowledgedUpgradeVersions[modMeta["latestVersion"]] = true end UI.hide("FinnIcon") UI.hide("updateNotification") diff --git a/xml/UpdateNotification.xml b/xml/UpdateNotification.xml index 20510598..21dedd89 100644 --- a/xml/UpdateNotification.xml +++ b/xml/UpdateNotification.xml @@ -33,10 +33,11 @@ + New version available: + alignment="MiddleCenter">Placeholder @@ -70,7 +71,7 @@ padding="10 10 5 10" spacing="10"> + onClick="onClick_notification(dontShowAgain)">Don't show again