Skip to content

Commit

Permalink
More Early Access Updates and Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkthnx committed Aug 23, 2024
1 parent 195f2a5 commit e5be1ba
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 52 deletions.
158 changes: 123 additions & 35 deletions KkthnxUI/Core/CheckVersion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,47 @@ local string_format = string.format
local string_gsub = string.gsub
local string_split = string.split
local tonumber = tonumber

local Ambiguate = Ambiguate
local C_ChatInfo_RegisterAddonMessagePrefix = C_ChatInfo.RegisterAddonMessagePrefix
local C_ChatInfo_SendAddonMessage = C_ChatInfo.SendAddonMessage
local CreateFrame = CreateFrame
local GetTime = GetTime
local Ambiguate = Ambiguate
local IsInGroup = IsInGroup
local IsInGuild = IsInGuild
local IsInRaid = IsInRaid
local IsPartyLFG = IsPartyLFG
local print = print

local C_ChatInfo_RegisterAddonMessagePrefix = C_ChatInfo.RegisterAddonMessagePrefix
local C_ChatInfo_SendAddonMessage = C_ChatInfo.SendAddonMessage

local lastVCTime, isVCInit = 0
local tn = tonumber
local lastVCTime, isVCInit = 0
local debugTest = false

local function HandleVersonTag(version)
local major, minor = strsplit(".", version)
-- Debugging function to track issues
local function DebugLog(message)
if K.isDeveloper and debugTest then
print("|cffFF0000[DEBUG]:|r " .. message)
end
end

local function HandleVersonTag(version, author)
local major, minor = string_split(".", version)
major, minor = tn(major), tn(minor)

if K.LibBase64:CV(major) then
major, minor = 0, 0
if K.isDeveloper and author then
print("Moron: " .. author)
DebugLog("Invalid version from author: " .. author)
end
end

return major, minor
end

function Module:VersionCheck_Compare(new, old, author)
local new1, new2 = HandleVersonTag(new, author)
local old1, old2 = HandleVersonTag(old)

if new1 > old1 or (new1 == old1 and new2 > old2) then
return "IsNew"
elseif new1 < old1 or (new1 == old1 and new2 < old2) then
Expand All @@ -43,32 +58,69 @@ end

function Module:CreateUpdateNoticeFrame()
local frame = CreateFrame("Frame", "KKUI_UpdateNotice", UIParent)
frame:SetSize(420, 150)
frame:SetSize(420, 180)
frame:SetPoint("CENTER", UIParent, "CENTER")
frame:CreateBorder()

-- Set background texture to 'adventureguide-pane-small'
frame.Background = frame:CreateTexture(nil, "BACKGROUND")
frame.Background:SetAtlas("adventureguide-pane-small")
frame.Background:SetAllPoints(frame)
frame.Background:SetBlendMode("ADD")

frame.Texture = frame:CreateTexture(nil, "OVERLAY")
frame.Texture:SetTexture("Interface\\HELPFRAME\\HelpIcon-ReportAbuse")
frame.Texture:SetPoint("TOP", frame, "TOP", 0, 8)
frame.Texture:SetPoint("TOP", frame, "TOP", 0, -4)

frame.Text = frame:CreateFontString(nil, "OVERLAY")
frame.Text:SetWidth(400)
frame.Text:SetFontObject(K.UIFont)
frame.Text:SetFont(select(1, frame.Text:GetFont()), 15, select(3, frame.Text:GetFont()))
frame.Text:SetPoint("CENTER", frame, "CENTER")
frame.Text:SetPoint("TOP", frame, "TOP", 0, -70)

frame.EditBox = CreateFrame("EditBox", nil, frame)
frame.EditBox:SetPoint("BOTTOM", frame, "BOTTOM", 0, 8)
frame.EditBox:SetWidth(330)
frame.EditBox:SetHeight(19)
frame.EditBox:SetMultiLine(false)
frame.EditBox:SetAutoFocus(false)
frame.EditBox:SetFontObject(K.UIFont)
frame.EditBox:CreateBorder()
-- CurseForge link
frame.CurseLink = CreateFrame("EditBox", nil, frame)
frame.CurseLink:SetPoint("CENTER", frame, "CENTER", 0, -40)
frame.CurseLink:SetWidth(330)
frame.CurseLink:SetHeight(19)
frame.CurseLink:SetMultiLine(false)
frame.CurseLink:SetAutoFocus(false)
frame.CurseLink:SetFontObject(K.UIFont)
frame.CurseLink:SetText("https://www.curseforge.com/wow/addons/kkthnxui")
frame.CurseLink:CreateBorder()

frame.EditBox.Text = frame.EditBox:CreateFontString(nil, "OVERLAY")
frame.EditBox.Text:SetFontObject(K.UIFont)
frame.EditBox.Text:SetPoint("BOTTOM", frame.EditBox, "TOP", 0, 2)
-- Tooltip for CurseForge link
frame.CurseLink:SetScript("OnEnter", function()
GameTooltip:SetOwner(frame.CurseLink, "ANCHOR_TOP")
GameTooltip:AddLine("CurseForge Link", 1, 1, 1)
GameTooltip:AddLine("This is the stable release version.", 0.7, 0.7, 0.7)
GameTooltip:Show()
end)
frame.CurseLink:SetScript("OnLeave", function()
GameTooltip:Hide()
end)

-- GitHub link
frame.GitHubLink = CreateFrame("EditBox", nil, frame)
frame.GitHubLink:SetPoint("CENTER", frame, "CENTER", 0, -70)
frame.GitHubLink:SetWidth(330)
frame.GitHubLink:SetHeight(19)
frame.GitHubLink:SetMultiLine(false)
frame.GitHubLink:SetAutoFocus(false)
frame.GitHubLink:SetFontObject(K.UIFont)
frame.GitHubLink:SetText("https://github.com/Kkthnx-Wow/KkthnxUI")
frame.GitHubLink:CreateBorder()

-- Tooltip for GitHub link
frame.GitHubLink:SetScript("OnEnter", function()
GameTooltip:SetOwner(frame.GitHubLink, "ANCHOR_TOP")
GameTooltip:AddLine("GitHub Link", 1, 1, 1)
GameTooltip:AddLine("This is the bleeding edge version and may contain bugs.", 0.7, 0.7, 0.7)
GameTooltip:Show()
end)
frame.GitHubLink:SetScript("OnLeave", function()
GameTooltip:Hide()
end)

frame.OkayButton = CreateFrame("Button", nil, frame)
frame.OkayButton:SetPoint("TOP", frame, "BOTTOM", 0, -6)
Expand All @@ -80,29 +132,29 @@ function Module:CreateUpdateNoticeFrame()
end
end)

-- Set background texture to 'GarrMissionLocation-Maw-ButtonBG'
frame.Background = frame:CreateTexture(nil, "BACKGROUND")
frame.Background:SetAtlas("GarrMissionLocation-Maw-ButtonBG")
frame.Background:SetAllPoints(frame.OkayButton)
frame.Background:SetBlendMode("ADD")

frame.OkayButton.Text = frame.OkayButton:CreateFontString(nil, "ARTWORK")
frame.OkayButton.Text:SetFontObject(K.UIFont)
frame.OkayButton.Text:SetFont(select(1, frame.OkayButton.Text:GetFont()), 13, select(3, frame.OkayButton.Text:GetFont()))
frame.OkayButton.Text:SetText("I am going to update right now")
frame.OkayButton.Text:SetTextColor(0, 1, 0)
frame.OkayButton.Text:SetPoint("CENTER", frame.OkayButton, "CENTER", 0, 0)
K.AddTooltip(frame.OkayButton, "ANCHOR_BOTTOM", K.SystemColor .. "Obviously |cff669dffKkthnx|r is trusting you to go update and not complain about a missing feature or a bug because you are out of date |CFFFF0000<3|r")
K.AddTooltip(frame.OkayButton, "ANCHOR_BOTTOM", K.SystemColor .. "Please update to the latest version!")

return frame
end

function Module:VersionCheck_Create(text)
if not C["General"].VersionCheck then
DebugLog("VersionCheck is disabled in settings.")
return
end

-- HelpTip:Show(ChatFrame1, {
-- text = text,
-- buttonStyle = HelpTip.ButtonStyle.Okay,
-- targetPoint = HelpTip.Point.TopEdgeCenter,
-- offsetY = 10,
-- })

local frame = Module:CreateUpdateNoticeFrame()
frame.Text:SetText(text)
frame:Show()
Expand All @@ -111,59 +163,95 @@ end
function Module:VersionCheck_Init()
if not isVCInit then
local status = Module:VersionCheck_Compare(KkthnxUIDB.DetectVersion, K.Version)

if status == "IsNew" then
local release = gsub(KkthnxUIDB.DetectVersion, "(%d+)$", "0")
Module:VersionCheck_Create(format("|cff669dffKkthnxUI|r is out of date, the latest release is |cff70C0F5%s|r", release))
local release = string_gsub(KkthnxUIDB.DetectVersion, "(%d+)$", "0")
Module:VersionCheck_Create(string_format("|cff669dffKkthnxUI|r is out of date!|nPlease update to the latest version: |cff70C0F5%s|r.", release))
elseif status == "IsOld" then
KkthnxUIDB.DetectVersion = K.Version
end

isVCInit = true
DebugLog("VersionCheck initialized.")
else
DebugLog("VersionCheck already initialized.")
end
end

function Module:VersionCheck_Send(channel)
if GetTime() - lastVCTime >= 10 then
C_ChatInfo_SendAddonMessage("KKUIVersionCheck", KkthnxUIDB.DetectVersion, channel)
lastVCTime = GetTime()
DebugLog("VersionCheck message sent to channel: " .. channel)
else
DebugLog("VersionCheck message not sent due to cooldown.")
end
end

function Module:VersionCheck_Update(...)
local prefix, msg, distType, author = ...
function Module:VersionCheck_Update(prefix, msg, distType, author)
if prefix ~= "KKUIVersionCheck" then
return
end

if Ambiguate(author, "none") == K.Name then
DebugLog("VersionCheck ignored message from self.")
return
end

local status = Module:VersionCheck_Compare(msg, KkthnxUIDB.DetectVersion, author)

if status == "IsNew" then
KkthnxUIDB.DetectVersion = msg
DebugLog("Detected new version: " .. msg)
elseif status == "IsOld" then
Module:VersionCheck_Send(distType)
DebugLog("Detected outdated version. Sending current version to: " .. distType)
end

Module:VersionCheck_Init()
end

function Module:VersionCheck_UpdateGroup()
if not IsInGroup() then
DebugLog("Not in a group, skipping version check.")
return
end
Module:VersionCheck_Send(IsPartyLFG() and "INSTANCE_CHAT" or IsInRaid() and "RAID" or "PARTY")

local channel = IsPartyLFG() and "INSTANCE_CHAT" or IsInRaid() and "RAID" or "PARTY"
Module:VersionCheck_Send(channel)
end

function Module:OnEnable()
Module:VersionCheck_Init()

C_ChatInfo_RegisterAddonMessagePrefix("KKUIVersionCheck")
K:RegisterEvent("CHAT_MSG_ADDON", Module.VersionCheck_Update)

if IsInGuild() then
C_ChatInfo_SendAddonMessage("KKUIVersionCheck", K.Version, "GUILD")
lastVCTime = GetTime()
DebugLog("VersionCheck message sent to guild.")
end

Module:VersionCheck_UpdateGroup()
K:RegisterEvent("GROUP_ROSTER_UPDATE", Module.VersionCheck_UpdateGroup)
end

-- Add this function to manually trigger a test of the version check frame
function Module:VersionCheck_Test()
-- Fake version for testing purposes
local fakeVersion = "9.9.9"

-- Force the creation of the update notice frame with fake text
local fakeText = string_format("|cff669dffKkthnxUI|r is out of date!|nPlease update to the latest version: |cff70C0F5%s|r.", fakeVersion)
Module:VersionCheck_Create(fakeText)

-- Print debug message for testing
DebugLog("Triggered VersionCheck test with version: " .. fakeVersion)
end

-- Add a slash command to manually trigger the test during runtime
SLASH_KKUI_VERSIONCHECK1 = "/vctest"
SlashCmdList["KKUI_VERSIONCHECK"] = function()
Module:VersionCheck_Test()
end
2 changes: 1 addition & 1 deletion KkthnxUI/KkthnxUI.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
## Title: |cff669DFFKkthnxUI|r
## Notes: Empty toc for Curseforge
## Author: Josh "Kkthnx" Russell
## Version: 10.5.1
## Version: 10.5.2
## IconTexture: Interface\AddOns\KkthnxUI\Media\KkthnxUI_Spell_Icon
## X-Support: TWW
2 changes: 1 addition & 1 deletion KkthnxUI/KkthnxUI_Mainline.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Title: |cff669DFFKkthnxUI|r
## Notes: Enhances the game's user interface (UI) by providing a clean, minimalist design and a range of customizable features.|n|n|cff669DFFDeveloper|cffffffff:|r |nJosh "|CFF7b8489Kkthnx|r" Russell|n|n|cff009cdePayPal|r|cffffffff:|r |n|cffffffffwww.paypal.me/KkthnxTV|r|n|n|cfff96854Patreon|r|cffffffff:|r |n|cffffffffwww.patreon.com/Kkthnx|r
## Author: Josh "Kkthnx" Russell
## Version: 10.5.1
## Version: 10.5.2
## IconTexture: Interface\AddOns\KkthnxUI\Media\KkthnxUI_Spell_Icon
## X-Support: TWW
## SavedVariables: KkthnxUIDB
Expand Down
5 changes: 5 additions & 0 deletions KkthnxUI/Modules/Maps/Elements/CollectButtons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function Module:CreateRecycleBin()
local ignoredButtons = {
["GatherMatePin"] = true,
["HandyNotes.-Pin"] = true,
["TTMinimapButton"] = true,
}

local function isButtonIgnored(name)
Expand Down Expand Up @@ -167,6 +168,10 @@ function Module:CreateRecycleBin()
child:SetScript("OnMouseUp", nil)
elseif name == "BagSync_MinimapButton" then
child:HookScript("OnMouseUp", clickFunc)
elseif name == "WIM3MinimapButton" then
child.SetParent = K.Noop
child:SetFrameStrata("DIALOG")
child.SetFrameStrata = K.Noop
end

child.styled = true
Expand Down
17 changes: 2 additions & 15 deletions KkthnxUI/Modules/UnitFrames/Elements/Tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ oUF.Tags.Methods["pppower"] = function(unit)
end
oUF.Tags.Events["pppower"] = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_DISPLAYPOWER"

local PatchInfoCheck = select(4, GetBuildInfo()) >= 110000 -- 11.0.0
local NameOnlyGuild = false
local NameOnlyTitle = true
oUF.Tags.Methods["npctitle"] = function(unit)
Expand All @@ -292,23 +291,11 @@ oUF.Tags.Methods["npctitle"] = function(unit)
scanTip:SetOwner(UIParent, "ANCHOR_NONE")
scanTip:SetUnit(unit)

local title = _G[format("KKUI_ScanTooltipTextLeft%d", GetCVarBool("colorblindmode") and 3 or 2)]:GetText()
local textLine = _G[format("KKUI_ScanTooltipTextLeft%d", GetCVarBool("colorblindmode") and 3 or 2)]
local title = textLine and textLine:GetText()
if title and not strfind(title, "^" .. LEVEL) then
return title
end

-- local data = not PatchInfoCheck and C_TooltipInfo.GetUnit(unit) -- FIXME: ColorMixin error
-- if not data then
-- return ""
-- end

-- local lineData = data.lines[GetCVarBool("colorblindmode") and 3 or 2]
-- if lineData then
-- local title = lineData.leftText
-- if title and not strfind(title, "^" .. LEVEL) then
-- return title
-- end
-- end
end
end
oUF.Tags.Events["npctitle"] = "UNIT_NAME_UPDATE"
Expand Down

0 comments on commit e5be1ba

Please sign in to comment.