Skip to content

Commit

Permalink
Adds update available text notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Slivo-fr committed May 27, 2021
1 parent 0c37ac1 commit 79a4b89
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
4 changes: 4 additions & 0 deletions locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ local L = {
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)",

--- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",
}

TranqRotate.L = L
4 changes: 4 additions & 0 deletions locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ local L = {
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Ce joueur n'utilise pas TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Ou possède une version obsolète inférieure à 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(Il est possible de désactiver l'icone et/ou l'infobulle dans les options)",

--- Available update
["UPDATE_AVAILABLE"] = "Une nouvelle version est disponible, faites la mise à jour pour profiter des derniers ajouts",
["BREAKING_UPDATE_AVAILABLE"] = "Une nouvelle version MAJEURE est disponible, vous DEVEZ faire la mise à jour le plus rapidement possible! Votre version pourrait ne pas fonctionner correctement avec celle des utilisateurs disposant de la mise à jour.",
}

TranqRotate.L = L
4 changes: 4 additions & 0 deletions locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ local L = {
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Этот игрок не использует TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Или используется версия ниже 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(Вы можете отключить этот значок и/или эту подсказку в настройках)",

--- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",
}

TranqRotate.L = L
4 changes: 4 additions & 0 deletions locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ local L = {
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "此玩家没有使用TranqRotate插件",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "或者运行低于1.6.0的过时版本",
["TOOLTIP_DISABLE_SETTINGS"] = "(您可以在设置中禁用此图标或此工具提示)",

--- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",
}

TranqRotate.L = L
4 changes: 4 additions & 0 deletions locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ local L = {
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)",

--- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",
}

TranqRotate.L = L
59 changes: 59 additions & 0 deletions src/tranqRotate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ function TranqRotate:updatePlayerAddonVersion(player, version)
if (hunter) then
TranqRotate:updateBlindIcon(hunter)
end

local updateRequired, breakingUpdate = TranqRotate:isUpdateRequired(version)
if (updateRequired) then
TranqRotate:notifyUserAboutAvailableUpdate(breakingUpdate)
end
end

-- Prints to the chat the addon version of every hunter and addon users
Expand Down Expand Up @@ -304,3 +309,57 @@ function TranqRotate:runDemo()
5
)
end

-- Parse version string
-- @return major, minor, fix, isStable
function TranqRotate:parseVersionString(versionString)

local version, type = strsplit("-", versionString)
local major, minor, fix = strsplit( ".", version)

return tonumber(major), tonumber(minor), tonumber(fix), type == nil
end

-- Check if the given version would require updating
-- @return requireUpdate, breakingUpdate
function TranqRotate:isUpdateRequired(versionString)

local remoteMajor, remoteMinor, remoteFix, isRemoteStable = self:parseVersionString(versionString)
local localMajor, localMinor, localFix, isLocalStable = self:parseVersionString(TranqRotate.version)

if (isRemoteStable) then

if (remoteMajor > localMajor) then
return true, true
elseif (remoteMajor < localMajor) then
return false, false
end

if (remoteMinor > localMinor) then
return true, false
elseif (remoteMinor < localMinor) then
return false, false
end

if (remoteFix > localFix) then
return true, false
end
end

return false, false
end

-- Notify user about a new version available
function TranqRotate:notifyUserAboutAvailableUpdate(isBreakingUpdate)
if (isBreakingUpdate) then
if (TranqRotate.notifiedBreakingUpdate ~= true) then
TranqRotate:printPrefixedMessage('|cffff3d3d' .. L['BREAKING_UPDATE_AVAILABLE'] .. '|r')
TranqRotate.notifiedBreakingUpdate = true
end
else
if (TranqRotate.notifiedUpdate ~= true and TranqRotate.notifiedBreakingUpdate ~= true) then
TranqRotate:printPrefixedMessage(L['UPDATE_AVAILABLE'])
TranqRotate.notifiedUpdate = true
end
end
end

0 comments on commit 79a4b89

Please sign in to comment.