Quantcast

- Post per discussion

urnati [12-30-25 - 14:47]
- Post per discussion
- Titan open config fix for 12.0
- XP fix for output 'played' spam to Chat
Filename
Titan/Titan.lua
TitanPost/TitanPost.lua
TitanXP/TitanXP.lua
diff --git a/Titan/Titan.lua b/Titan/Titan.lua
index 9ccf8ef..282f22a 100644
--- a/Titan/Titan.lua
+++ b/Titan/Titan.lua
@@ -18,6 +18,18 @@ local AceTimer = LibStub("AceTimer-3.0")
 local media = LibStub("LibSharedMedia-3.0")
 local AceConfigDialog = LibStub("AceConfigDialog-3.0")

+---Open the WoW config to the requested place.
+--- Use AceConfigDialog:Open to open a specific part of the Titan config as a distinct frame
+---@param ... unknown
+local function OpenConfig(...)
+	-- WoW 12.0 (Midnight) changed the API to open their Config.
+	if C_SettingsUtil and C_SettingsUtil.OpenSettingsPanel then
+		C_SettingsUtil.OpenSettingsPanel(...)
+	else
+		Settings.OpenToCategory(...)
+	end
+end
+
 --	TitanDebug (cmd.." : "..p1.." "..p2.." "..p3.." "..#cmd_list)

 --------------------------------------------------------------
@@ -25,8 +37,6 @@ local AceConfigDialog = LibStub("AceConfigDialog-3.0")

 --[[
 Note:
-- Use Settings.OpenToCategory to open all of Titan configa.
-- Use AceConfigDialog:Open to open a specific part of the Titan config.

 --]]
 ---Titan Give the user an are you sure popup whether to reload the UI or not.
@@ -264,7 +274,6 @@ local function RegisterAddonCompartment()
 				func = function(button, menuInputData, menu)
 					TitanUpdateConfig("init")
 					AceConfigDialog:Open("Titan Panel Main")
---					Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About)
 				end,
 				funcOnEnter = function(button)
 					MenuUtil.ShowTooltip(button, function(tooltip)
@@ -734,9 +743,6 @@ local function handle_giu_cmds(cmd_list)
 	end

 	AceConfigDialog:Open("Titan Panel Panel Control")
-	-- DF changed how options are called. The best I get is the Titan 'about', not deeper.
---	Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About, TITAN_PANEL_CONFIG.topic.scale)
-	-- so the below does not work as expected...
 end

 ---local Helper to handle profile commands - Set to profile if not using global profile.
@@ -1953,8 +1959,7 @@ local function BuildMainMenu(frame)
 		info.value = "Config";
 		info.func = function()
 			TitanUpdateConfig("init")
-			Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.About)
---			AceConfigDialog:Open("Titan Panel Main")
+			OpenConfig(TITAN_PANEL_CONFIG.topic.About)
 		end
 		TitanPanelRightClickMenu_AddButton(info);
 	end
@@ -1972,7 +1977,6 @@ local function BuildMainMenu(frame)
 	info.func = function()
 		TitanUpdateConfig("init")
 		AceConfigDialog:Open("Titan Panel Addon Chars")
-		--			Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.profiles)
 	end
 	TitanPanelRightClickMenu_AddButton(info);

@@ -1992,7 +1996,6 @@ local function BuildMainMenu(frame)
 	info.func = function()
 		TitanUpdateConfig("init")
 		AceConfigDialog:Open("Titan Panel Help List")
-		--			Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.profiles)
 	end
 	TitanPanelRightClickMenu_AddButton(info);

diff --git a/TitanPost/TitanPost.lua b/TitanPost/TitanPost.lua
index c55b5fd..b8a7ffa 100644
--- a/TitanPost/TitanPost.lua
+++ b/TitanPost/TitanPost.lua
@@ -63,7 +63,10 @@ local MAIL_OPENED = "Mail Opened"
 local CHAR = "Character"

 local NEW_PRE = " + "
-local EXP_PRE = " !! "
+local EXP_PRE = " ! "
+local NEW_TT_POST = " : New Mail this session "
+local EXP_TT_POST = " : Characters with expiring Mail "
+local MAIL_TT_PRE = "Mail opened : "

 local MENU_SERVER = "Server_list"
 local MENU_CHAR = "Char_name"
@@ -210,30 +213,31 @@ local function CheckExpiry()
 	return expiry_toons, res
 end

+local function GetCountsStr(player)
+	local toon = TitanPostDB[player]
+	local res = ""
+	if (toon.lastUpdate == 0) then
+		res = res .. L["TITAN_PANEL_NA"] --NOT_OPENED for first time yet
+	else
+		res = res .. toon.mailReadNum .. "/" .. toon.mailCount
+	end
+	if mailbox.opened then
+		res = res .. "" -- counts should be accurate
+	else
+		res = res .. "?" -- counts may not be accurate
+	end
+
+	return res
+end
+
 ---Create plugin text
 ---@param id string
 ---@return string Label
 ---@return string Display text
----@return string Label
----@return string Display text
 local function GetButtonText(id)
-	--[[
-	local total = ""
-	local read = ""
+	local res = ""

-	local str = ""
-	if (mailbox.total > 0) then
-		total = tostring(mailbox.total)
-		if (mailbox.read > 0) then
-			read = tostring(mailbox.read)
-		else
-			read = ""
-		end
-		str = str .. "[" .. read .. "/" .. total .. "]"
-	else
-		str = str .. "" --NOT_OPENED
-	end
-	--]]
+	res = GetCountsStr(player)

 	local new = ""
 	if (mailbox.new > 0) then
@@ -249,54 +253,40 @@ local function GetButtonText(id)
 		expiry = ""
 	end

-	return "New : ", new,
-		"Expiry : ", expiry
+	res = res .. new .. expiry
+
+	return "Mail : ", res
 end

 ---Create a tool tip
 ---@return string
 function GetTooltipText()
-	local str = "";
+	local str = ""
+	local res = ""

-	--	local now = _G.time()
-	--	str = FormatTS(now, false) .. "\n" -- date only for comparisions
-
-	local playerData = TitanPostDB[player]
-	if playerData.lastUpdate == 0 then
-		str = UNKNOWN
-	else
-		str = FormatTS(playerData.lastUpdate, true)
-	end
-	str = str .. " last time Mail opened.\n"
+	local toon = TitanPostDB[player]
+	res = MAIL_TT_PRE..FormatTS(toon.lastUpdate, true).."\n"
+	res = res..GetCountsStr(player)

 	local new = ""
 	if (mailbox.new > 0) then
-		new = NEW_PRE .. tostring(mailbox.new) .. " new mail this session.\n"
+		new = NEW_PRE .. tostring(mailbox.new) .. NEW_TT_POST .."\n"
 	else
 		new = ""
 	end

 	local expiry = ""
 	if (mailbox.expiry_num > 0) then
-		expiry = EXP_PRE .. tostring(mailbox.expiry_num) .. " characters with mail expiring!!\n"
+		expiry = EXP_PRE .. tostring(mailbox.expiry_num) .. EXP_TT_POST.."\n"
 	else
 		expiry = ""
 	end

-	--[[
-	local total = (mailbox.total > 0) and tostring(mailbox.total) or ""
-	local read = (mailbox.read > 0) and tostring(mailbox.read) or ""
-	if mailbox.opened then
-		str = str .. "[" .. read .. "/" .. total .. "]"
-	else
-		str = str .. NOT_OPENED
-	end
---]]
-	str = str .. new .. expiry
-	str = str .. "\n"
-	str = str .. mailbox.expiry_text .. "\n"
+	res = res .. new .. expiry
+	res = res .. "\n"
+	res = res .. mailbox.expiry_text .. "\n"

-	return str;
+	return res
 end

 local function convertSeconds(time)
@@ -405,11 +395,6 @@ local function InitVars()
 	end
 	if (not TitanPostDB[player].mailEntries) then
 		TitanPostDB[player].mailEntries = {}
-		local m = TitanPostDB[player].mailEntries
-		m.daysLeft = 0
-		m.senderName = "Init"
-		m.subject = "Init"
-		m.wasRead = false
 	end
 end

@@ -561,8 +546,8 @@ local function BuildMainMenu(frame)
 	info.value = "ConfigProfile";
 	info.func = function()
 		TitanUpdateConfig("init")
+		-- Open the profile config as distinct frame
 		AceConfigDialog:Open("Titan Panel Addon Chars")
-		--			Settings.OpenToCategory(TITAN_PANEL_CONFIG.topic.profiles)
 	end
 	TitanPanelRightClickMenu_AddButton(info);
 	TitanPanelRightClickMenu_AddSpacer();
@@ -736,7 +721,7 @@ function TitanPost.GetMailInfo(playerName)

 			if p.lastUpdate == 0 then
 				-- not opened mail yet
-				res = NOT_OPENED
+				res = L["TITAN_PANEL_NA"]
 			else
 				if (p.mailCount > 0) then
 					if (p.nextExpiry < ExpiryWarn()) then -- add to list for user
@@ -757,10 +742,10 @@ function TitanPost.GetMailInfo(playerName)
 				res = estr .. last
 			end
 		else
-			res = NOT_USED
+			res = L["TITAN_PANEL_NA"]
 		end
 	else
-		res = NOT_SHOWN
+		res = L["TITAN_PANEL_MENU_DISABLED"]
 	end

 	return res
@@ -780,10 +765,10 @@ function TitanPost.ClearMailInfo(playerName)
 		if TitanPostDB and TitanPostDB[playerName] then
 			-- Set mail data to defaults for given toon
 			local p = TitanPostDB[playerName]
-			p.lastUpdate = now
-			p.mailCount = 1
+			p.lastUpdate = 0
+			p.mailCount = 0
 			p.mailReadNum = 0
-			p.nextExpiry = math.floor(30 * SECONDS_PER_DAY) + now -- make timestamp
+			p.nextExpiry = 0

 			table.wipe(p.mailEntries)
 		else
@@ -833,6 +818,8 @@ Create_Frames() -- do the work
 --[===[
 print("======")
 local TITAN_POST_ID = "Post";
+local TITAN_BUTTON = "TitanPanel" .. TITAN_POST_ID .. "Button"
+
 local SECONDS_PER_DAY = 24 * 60 * 60
 local now = _G.time()
 local player = "Syldil@Staghelm"
@@ -868,6 +855,8 @@ TitanDumpTable(TitanPostDB) --(playerData)
 --
 --

+TitanPanelButton_UpdateButton(TITAN_POST_ID)
+--

 -- Simulate an event manually DOES NOT WORK
 TitanPanelPostButton:OnEvent("PLAYER_REGEN_ENABLED", "player")
diff --git a/TitanXP/TitanXP.lua b/TitanXP/TitanXP.lua
index e48ceb5..5c9c545 100644
--- a/TitanXP/TitanXP.lua
+++ b/TitanXP/TitanXP.lua
@@ -23,7 +23,7 @@ local AceTimer = LibStub("AceTimer-3.0")
 local XPTimer = {}
 ---@diagnostic disable-next-line: missing-fields
 XPTimer.timer = nil -- set & cancelled as needed
-XPTimer.delay = 10 -- seconds
+XPTimer.delay = 10  -- seconds
 XPTimer.running = false
 XPTimer.last = 0

@@ -46,47 +46,40 @@ local txp = {

 --****** overload the 'time played' text to Chat - if XP requested the API call
 local requesting
-local orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed
--- Override the output to Chat
-ChatFrame_DisplayTimePlayed = function(...)
-	if requesting then
-		-- XP requested time played, do not spam Chat
-		requesting = false
-	else
-		-- XP did not request time played so output
-		orig_ChatFrame_DisplayTimePlayed(...)
-	end
-end
---[===[
+
 -- Save orignal output to Chat
 -- somewhere in 11.* (The World Within) this changed
-local orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed
---[[
+local orig_ChatFrame_DisplayTimePlayed = function(...) end
+
 if Titan_Global.switch.chat_class then
 	orig_ChatFrame_DisplayTimePlayed = ChatFrameUtil.DisplayTimePlayed
+
+	ChatFrameUtil.DisplayTimePlayed = function(...) --TimePlayed(...)
+		if requesting then
+			-- XP requested time played, do not spam Chat
+			requesting = false
+		else
+			-- XP did not request time played so output
+			---@diagnostic disable-next-line: need-check-nil
+			orig_ChatFrame_DisplayTimePlayed(...)
+		end
+	end
 else
 	orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed
-end
---]]

-local function TimePlayed(...)
-	if requesting then
-		-- XP requested time played, do not spam Chat
-		requesting = false
-	else
-		-- XP did not request time played so output
----@diagnostic disable-next-line: need-check-nil
-		orig_ChatFrame_DisplayTimePlayed(...)
+	ChatFrameUtil.DisplayTimePlayed = function(...) --TimePlayed(...)
+		if requesting then
+			-- XP requested time played, do not spam Chat
+			requesting = false
+		else
+			-- XP did not request time played so output
+			---@diagnostic disable-next-line: need-check-nil
+			orig_ChatFrame_DisplayTimePlayed(...)
+		end
 	end
 end

--- Override the output to Chat for the correct WoW version running
-if Titan_Global.switch.chat_class then
-	ChatFrameUtil.DisplayTimePlayed = TimePlayed(...)
-else
-	ChatFrame_DisplayTimePlayed = TimePlayed(...)
-end
---]===]
+
 -- ******************************** Functions *******************************

 ---local Set icon based on faction
@@ -147,7 +140,7 @@ end
 --[[ 2024 Apr
 Change to a repeating timer instead of OnUpdate to reduce cycles
 The timer, started OnShow, will update session time here
-The prior scheme used OnUpdate which is related to FPS.
+The prior scheme used OnUpdate which is related to FPS.
 XP does not need that level of precision.
 --]]
 ---local Reset session and accumulated variables; used by timer
@@ -162,7 +155,7 @@ local function XPTimeUpdate()
 	if trace then
 		local txt = "XP Text"
 			.. " " .. tostring(format("%0.2f", elapsed)) .. ""
-			TitanPluginDebug(TITAN_XP_ID, txt)
+		TitanPluginDebug(TITAN_XP_ID, txt)
 	end
 end

@@ -475,7 +468,8 @@ local function GetTooltipText()
 				L["TITAN_XP_TOOLTIP_TOTAL_XP"] .. "\t" .. TitanUtils_GetHighlightText(comma_value(totalXP)) .. "\n" ..
 				L["TITAN_XP_TOTAL_RESTED"] ..
 				"\t" ..
-				TitanUtils_GetHighlightText(comma_value(GetXPExhaustion() == nil and "0" or GetXPExhaustion())) .. "\n" ..
+				TitanUtils_GetHighlightText(comma_value(GetXPExhaustion() == nil and "0" or GetXPExhaustion())) ..
+				"\n" ..
 				L["TITAN_XP_TOOLTIP_LEVEL_XP"] ..
 				"\t" ..
 				TitanUtils_GetHighlightText(comma_value(currentXP) .. " " ..
@@ -493,11 +487,13 @@ local function GetTooltipText()
 				"\n" ..
 				L["TITAN_XP_TOOLTIP_XPHR_LEVEL"] ..
 				"\t" ..
-				TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisLevel + 0.5)))) ..
+				TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"],
+					comma_value(math.floor(xpPerHourThisLevel + 0.5)))) ..
 				"\n" ..
 				L["TITAN_XP_TOOLTIP_XPHR_SESSION"] ..
 				"\t" ..
-				TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisSession + 0.5)))) ..
+				TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"],
+					comma_value(math.floor(xpPerHourThisSession + 0.5)))) ..
 				"\n" ..
 				L["TITAN_XP_TOOLTIP_TOLEVEL_LEVEL"] ..
 				"\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisLevel)) .. "\n" ..
@@ -648,7 +644,7 @@ end
 local function OnLoad(self)
 	local notes = ""
 		.. "Adds information to Titan Panel about XP earned and time to level.\n"
-		.."- Updates XP per hour statistics every "..XPTimer.delay.." sec.\n"
+		.. "- Updates XP per hour statistics every " .. XPTimer.delay .. " sec.\n"
 	self.registry = {
 		id = TITAN_XP_ID,
 		category = "Built-ins",