Skip to content

Commit

Permalink
show new version info in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoizame committed May 1, 2021
1 parent 8dcb67c commit 6f28fc0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ globals = {
"LibStub",

-- FrameXML misc
"C_ChatInfo",
"ChatEdit_InsertLink",
"ChatFrameEditBox",
"FACTION_BAR_COLORS",
Expand Down
56 changes: 56 additions & 0 deletions AtlasLootClassic/AtlasLoot.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local ALName, ALPrivate = ...
-- ----------------------------------------------------------------------------
-- Localized Lua globals.
-- ----------------------------------------------------------------------------
Expand All @@ -22,6 +23,9 @@ local LibStub = _G.LibStub
-- lua

-- WoW
local SendAddonMessage = C_ChatInfo.SendAddonMessage
local RegisterAddonMessagePrefix = C_ChatInfo.RegisterAddonMessagePrefix

-- DisableAddOn

local EventFrame = CreateFrame("FRAME")
Expand Down Expand Up @@ -72,9 +76,14 @@ function AtlasLoot:OnInitialize()

self.dbGlobal.__addonrevision = self.IsDevVersion and 0 or self.__addonrevision

RegisterAddonMessagePrefix(ALPrivate.ADDON_MSG_PREFIX)

-- bindings
BINDING_HEADER_ATLASLOOT = AL["AtlasLoot"]
BINDING_NAME_ATLASLOOT_TOGGLE = AL["Toggle AtlasLoot"]

-- version
AtlasLoot.SendAddonVersion("GUILD")
end

function AtlasLoot:AddInitFunc(func, module)
Expand Down Expand Up @@ -103,4 +112,51 @@ function AtlasLoot:GetColoredClassNames()
end
end
return CLASS_NAMES_WITH_COLORS
end

-- #############################
-- UpdateChecker
-- #############################
local UpdateSendMsg = "#v:"
local UpdateGetMsg = "#v:(%d+)"
local UpdateCheckerFrame = CreateFrame("FRAME")
local IsAddonUpdateAviable = false
local UpdatedVersionRev = AtlasLoot.__addonrevision

local function UpdateCheckFrameOnEvent(frame, event, arg1, ...)
if event == "CHAT_MSG_ADDON" and arg1 == ALPrivate.ADDON_MSG_PREFIX then
local text, channel, sender, target, zoneChannelID, localID, name, instanceID = ...
--if sender ~= ALPrivate.PLAYER_NAME then
local v = text:match(UpdateGetMsg)
v = tonumber(v or 0)
if v and v > 0 and v > UpdatedVersionRev and v < 99999999 then
IsAddonUpdateAviable = true
UpdatedVersionRev = v
AtlasLoot.GUI.RefreshVersionUpdate()
end
--end
elseif event == "GROUP_JOINED" then
AtlasLoot.SendAddonVersion("RAID")
AtlasLoot.SendAddonVersion("PARTY")
elseif event == "RAID_ROSTER_UPDATE" then
AtlasLoot.SendAddonVersion("RAID")
end
end

UpdateCheckerFrame:SetScript("OnEvent", UpdateCheckFrameOnEvent)
UpdateCheckerFrame:RegisterEvent("CHAT_MSG_ADDON")
UpdateCheckerFrame:RegisterEvent("GROUP_JOINED")
UpdateCheckerFrame:RegisterEvent("RAID_ROSTER_UPDATE")

function AtlasLoot.SendAddonVersion(channel, target)
if AtlasLoot.IsDevVersion then return end
if not channel then return end
if channel == "GUILD" and not IsInGuild() then return end
if channel == "PARTY" and not IsInGroup() then return end
if channel == "RAID" and not IsInRaid() then return end
SendAddonMessage(ALPrivate.ADDON_MSG_PREFIX, UpdateSendMsg..UpdatedVersionRev, channel, target)
end

function AtlasLoot.IsAddonUpdateAviable()
return IsAddonUpdateAviable
end
5 changes: 4 additions & 1 deletion AtlasLootClassic/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ALPrivate.IS_BC = AtlasLoot:GetGameVersion() == 2

-- Account specific
ALPrivate.ACCOUNT_LOCALE = GetLocale()
ALPrivate.PLAYER_NAME = UnitName("player")

-- Image path
ALPrivate.IMAGE_PATH = "Interface\\AddOns\\"..ALName.."\\Images\\"
Expand Down Expand Up @@ -114,4 +115,6 @@ ALPrivate.CLASS_NAME_TO_ID = {}
for classID = 1, #ALPrivate.CLASS_SORT do ALPrivate.CLASS_NAME_TO_ID[ALPrivate.CLASS_SORT[classID]] = classID end

ALPrivate.LOC_CLASSES = {}
FillLocalizedClassList(ALPrivate.LOC_CLASSES)
FillLocalizedClassList(ALPrivate.LOC_CLASSES)

ALPrivate.ADDON_MSG_PREFIX = "ATLASLOOT_MSG"
19 changes: 19 additions & 0 deletions AtlasLootClassic/GUI/GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,14 @@ function GUI:Create()
frame.titleFrame.version:SetJustifyV("BOTTOM")
frame.titleFrame.version:SetText(AtlasLoot.__addonversion)

frame.titleFrame.newVersion = frame.titleFrame:CreateFontString(nil, "ARTWORK")
frame.titleFrame.newVersion:SetPoint("LEFT", frame.titleFrame, "LEFT", 5, 1)
frame.titleFrame.newVersion:SetTextColor(0, 1, 0, 1)
frame.titleFrame.newVersion:SetFont(_G["SystemFont_Tiny"]:GetFont(), 10)
frame.titleFrame.newVersion:SetJustifyH("LEFT")
frame.titleFrame.newVersion:SetJustifyV("MIDDLE")
frame.titleFrame.newVersion:SetText(AL["New version aviable!"])

frame.gameVersionButton = CreateFrame("Button", frameName.."-gameVersionButton", frame)
frame.gameVersionButton:SetPoint("TOPLEFT", frame, "TOPLEFT", 258, -37)
frame.gameVersionButton:SetWidth(64)
Expand Down Expand Up @@ -1186,6 +1194,8 @@ function GUI:Create()
-- Set itemframe as start frame
frame.contentFrame.shownFrame = GUI.ItemFrame.frame
--self.SoundFrame:Create()

GUI.RefreshVersionUpdate()
end

function GUI:ForceUpdate()
Expand Down Expand Up @@ -1246,6 +1256,15 @@ function GUI.Temp_SetParPoint(self, ...)
end
end

function GUI.RefreshVersionUpdate()
if not GUI.frame then return end
if AtlasLoot.IsAddonUpdateAviable() then
GUI.frame.titleFrame.newVersion:Show()
else
GUI.frame.titleFrame.newVersion:Hide()
end
end

-- ################################
-- Option functions
-- ################################
Expand Down

0 comments on commit 6f28fc0

Please sign in to comment.