Skip to content

Commit

Permalink
chore: Improved version checking internal config
Browse files Browse the repository at this point in the history
  • Loading branch information
peti446 committed Dec 6, 2023
1 parent 40df3e2 commit c26011e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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*)")
Expand All @@ -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, "%.")
Expand All @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion MinimapIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
Expand Down
1 change: 0 additions & 1 deletion SwitchSwitch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ SwitchSwitch.TalentsUpdate = {
PendingProfileID = nil,
}

SwitchSwitch.InternalVersion = 30
SwitchSwitch.defaultProfileID = "profile_not_set"
SwitchSwitch.CurrentActiveTalentsConfigID = SwitchSwitch.defaultProfileID

Expand Down

0 comments on commit c26011e

Please sign in to comment.