resolving review comments
This commit is contained in:
parent
2851e8a9a4
commit
a526e645a8
@ -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}}
|
||||
|
@ -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")
|
||||
|
@ -33,10 +33,11 @@
|
||||
<Row preferredHeight="50">
|
||||
<Cell>
|
||||
<Panel padding="10 10 0 0">
|
||||
<!-- this part will be updated via script -->
|
||||
<Text id="notificationHeader"
|
||||
font="font_teutonic-arkham"
|
||||
fontSize="30"
|
||||
alignment="MiddleCenter">New version available: </Text>
|
||||
alignment="MiddleCenter">Placeholder</Text>
|
||||
</Panel>
|
||||
</Cell>
|
||||
</Row>
|
||||
@ -70,7 +71,7 @@
|
||||
padding="10 10 5 10"
|
||||
spacing="10">
|
||||
<Button class="bottomButtons"
|
||||
onClick="onClick_notification(dontNotify)">Don't show again</Button>
|
||||
onClick="onClick_notification(dontShowAgain)">Don't show again</Button>
|
||||
<Button class="bottomButtons"
|
||||
onClick="onClick_notification(close)">Close</Button>
|
||||
</HorizontalLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user