From cb6de72b93ec436508efd83bc625800227c35ecc Mon Sep 17 00:00:00 2001 From: Sumsebrum Date: Sat, 26 Mar 2022 00:11:34 +0100 Subject: [PATCH] version string trailing zeros --- Gladdy.lua | 6 +++--- Modules/VersionCheck.lua | 14 +++++++------- Options.lua | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Gladdy.lua b/Gladdy.lua index 0270772..5c4f93a 100644 --- a/Gladdy.lua +++ b/Gladdy.lua @@ -17,7 +17,7 @@ local IsActiveBattlefieldArena = IsActiveBattlefieldArena local IsInInstance = IsInInstance local GetNumArenaOpponents = GetNumArenaOpponents local RELEASE_TYPES = { alpha = "Alpha", beta = "Beta", release = "Release"} -local PREFIX = "TBC-Classic_v" +local PREFIX = "Gladdy v" local VERSION_REGEX = PREFIX .. "(%d+%.%d+)%-(%a)" local LibStub = LibStub @@ -27,14 +27,14 @@ local LibStub = LibStub --------------------------- -local MAJOR, MINOR = "Gladdy", 5 +local MAJOR, MINOR = "Gladdy", 6 local Gladdy = LibStub:NewLibrary(MAJOR, MINOR) local L Gladdy.version_major_num = 2 Gladdy.version_minor_num = 0.10 Gladdy.version_num = Gladdy.version_major_num + Gladdy.version_minor_num Gladdy.version_releaseType = RELEASE_TYPES.release -Gladdy.version = PREFIX .. Gladdy.version_num .. "-" .. Gladdy.version_releaseType +Gladdy.version = PREFIX .. string.format("%.2f", Gladdy.version_num) .. "-" .. Gladdy.version_releaseType Gladdy.VERSION_REGEX = VERSION_REGEX Gladdy.debug = false diff --git a/Modules/VersionCheck.lua b/Modules/VersionCheck.lua index 9bbe922..c86c465 100644 --- a/Modules/VersionCheck.lua +++ b/Modules/VersionCheck.lua @@ -1,4 +1,4 @@ -local tonumber, tostring = tonumber, tostring +local tonumber, tostring, str_format = tonumber, tostring, string.format local UnitName = UnitName local IsInGroup, IsInRaid = IsInGroup, IsInRaid @@ -24,11 +24,11 @@ end function VersionCheck:JOINED_ARENA() self:RegisterComm("GladdyVCheck", VersionCheck.OnCommReceived) if IsInRaid(LE_PARTY_CATEGORY_HOME) then - self:SendCommMessage("GladdyVCheck", tostring(Gladdy.version_num), "RAID", self.playerName) + self:SendCommMessage("GladdyVCheck", str_format("%.2f", Gladdy.version_num), "RAID", self.playerName) elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) or IsInRaid(LE_PARTY_CATEGORY_INSTANCE) then - self:SendCommMessage("GladdyVCheck", tostring(Gladdy.version_num), "INSTANCE_CHAT", self.playerName) + self:SendCommMessage("GladdyVCheck", str_format("%.2f", Gladdy.version_num), "INSTANCE_CHAT", self.playerName) elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then - self:SendCommMessage("GladdyVCheck", tostring(Gladdy.version_num), "PARTY", self.playerName) + self:SendCommMessage("GladdyVCheck", str_format("%.2f", Gladdy.version_num), "PARTY", self.playerName) end end @@ -41,9 +41,9 @@ end function VersionCheck.OnCommReceived(prefix, message, distribution, sender) if sender ~= VersionCheck.playerName then - local addonVersion = Gladdy.version_num - message = tonumber(message) - if message and message <= Gladdy.version_num then + local addonVersion = str_format("%.2f", Gladdy.version_num) + local message_num = tonumber(message) or 0 + if message and message_num <= Gladdy.version_num then --Gladdy:Print("Version", "\"".. addonVersion.."\"", "is up to date") else Gladdy:Warn("Current version", "\"".. addonVersion.."\"", "is outdated. Most recent version is", "\"".. message.."\"") diff --git a/Options.lua b/Options.lua index 78f78e1..5268dc6 100644 --- a/Options.lua +++ b/Options.lua @@ -1,5 +1,5 @@ local type, pairs, tinsert, tsort = type, pairs, table.insert, table.sort -local tostring, str_match, tonumber, string_format = tostring, string.match, tonumber, string.format +local tostring, str_match, tonumber, str_format = tostring, string.match, tonumber, string.format local ceil, floor = ceil, floor local ReloadUI = ReloadUI @@ -31,7 +31,7 @@ function Gladdy:FormatTimer(fontString, timeLeft, milibreakpoint, showSeconds) else if time >= 60 then if showSeconds then - fontString:SetText(floor(timeLeft / 60) .. ":" .. string_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60))) + fontString:SetText(floor(timeLeft / 60) .. ":" .. str_format("%02.f", floor(timeLeft - floor(timeLeft / 60) * 60))) else fontString:SetText(ceil(ceil(time / 60)) .. "m") end @@ -279,7 +279,7 @@ function Gladdy:SetupOptions() order = 5, width = 1, type = "description", - name = " Gladdy v" .. Gladdy.version_num .. "-" .. Gladdy.version_releaseType + name = " " .. Gladdy.version }, general = { type = "group",