From c26011e942c5a48987255178d175bce15b6067a9 Mon Sep 17 00:00:00 2001 From: peti446 Date: Wed, 6 Dec 2023 21:35:34 +0000 Subject: [PATCH] chore: Improved version checking internal config --- Init.lua | 15 +++++++++++++++ MinimapIcon.lua | 7 ++++++- SwitchSwitch.lua | 1 - 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Init.lua b/Init.lua index b83fbd4..754c750 100644 --- a/Init.lua +++ b/Init.lua @@ -154,6 +154,11 @@ local function GetVersionNumber(str) if(type(str) == "string") then + if(str:match('^v%d+%.%d+%.%d+a?b?%d*$') == nil) then + SwitchSwitch:Print("Invalid version string: " .. str) + return -1 + end + -- Remove beta and alpha form string and add respective number to the str local extraNumber = 0.003 local typeMatch, subVer = string.match(str, "([ab])(%d*)") @@ -170,6 +175,9 @@ local function GetVersionNumber(str) str = string.gsub(str, "a(%d*)", "") end + -- remove V + str = string.gsub(str, "^v", "") + -- Conver .0.0 to .00 if(SwitchSwitch:Repeats(str, "%.") == 2) then local index = SwitchSwitch:findLastInString(str, "%.") @@ -182,6 +190,13 @@ local function GetVersionNumber(str) return str end + +--[===[@non-debug@ +SwitchSwitch.InternalVersion = GetVersionNumber("@project-version@") +--@end-non-debug@]===] +--@debug@ +SwitchSwitch.InternalVersion = GetVersionNumber("v3.0.0b3") +--@end-debug@ function SwitchSwitch:Update() --Get old version string local globalConfigVersion = GetVersionNumber(self.db.global.Version) diff --git a/MinimapIcon.lua b/MinimapIcon.lua index 027cf22..b04c58d 100644 --- a/MinimapIcon.lua +++ b/MinimapIcon.lua @@ -12,7 +12,12 @@ local MenuFrame = nil function LDBSwitchSwitch:OnTooltipShow() local tooltip = self - tooltip:AddLine("Switch Switch " .. C_AddOns.GetAddOnMetadata("SwitchSwitch", "Version")) + local projectVersion = C_AddOns.GetAddOnMetadata("SwitchSwitch", "Version") + if (projectVersion == '@project-version@') then + projectVersion = SwitchSwitch.InternalVersion + end + + tooltip:AddLine("Switch Switch " .. projectVersion) tooltip:AddLine(" ") tooltip:AddLine(("%s%s: %s%s|r"):format(RED_FONT_COLOR_CODE, L["Left Click"], NORMAL_FONT_COLOR_CODE, L["Show config panel"])) tooltip:AddLine(("%s%s: %s%s|r"):format(RED_FONT_COLOR_CODE, L["Right Click"], NORMAL_FONT_COLOR_CODE, L["Quick talents profile change"])) diff --git a/SwitchSwitch.lua b/SwitchSwitch.lua index c753edc..e0246db 100644 --- a/SwitchSwitch.lua +++ b/SwitchSwitch.lua @@ -32,7 +32,6 @@ SwitchSwitch.TalentsUpdate = { PendingProfileID = nil, } -SwitchSwitch.InternalVersion = 30 SwitchSwitch.defaultProfileID = "profile_not_set" SwitchSwitch.CurrentActiveTalentsConfigID = SwitchSwitch.defaultProfileID