Quantcast

- Another Gold fix for some seeing 0 gold at start

urnati [02-03-25 - 19:28]
- Another Gold fix for some seeing 0 gold at start
- Gray Hide if only one bar shown
Filename
Titan/Titan.lua
Titan/TitanHistory.lua
Titan/TitanUtils.lua
TitanGold/TitanGold.lua
diff --git a/Titan/Titan.lua b/Titan/Titan.lua
index 65e7219..29f7d55 100644
--- a/Titan/Titan.lua
+++ b/Titan/Titan.lua
@@ -1951,6 +1951,7 @@ local function BuildMainMenu(frame)
 	info.text = (HIDE or "Hide")
 	info.value = "HideMe"
 	info.notCheckable = true
+	info.disabled = (TitanUtils_NumActiveBars() == 1)
 	info.arg1 = frame;
 	info.func = function(self, frame_str)
 		TitanBarDataVars[frame_str].show = not TitanBarDataVars[frame_str].show
diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua
index 79ba334..0493ac2 100644
--- a/Titan/TitanHistory.lua
+++ b/Titan/TitanHistory.lua
@@ -15,41 +15,39 @@ Green - 'header' - Titan or plugin
 Highlight - notes. tips. and details
 --]]
 Titan_Global.recent_changes = ""
+.. TitanUtils_GetGoldText("8.2.1 : 2025/02/03\n")
+.. TitanUtils_GetGreenText("Titan : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Gray (disable) Hide if the bar is the only bar.\n"
+)
+.. TitanUtils_GetGreenText("Gold : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Another fix when logging into an 'old' toon.\n"
+.. "- Fix error on 'reset database'.\n"
+)
+.. "\n\n"
 .. TitanUtils_GetGoldText("8.2.0 : 2025/01/03\n")
 .. TitanUtils_GetGreenText("Titan : \n")
 .. TitanUtils_GetHighlightText(""
-.. "- Internal fixes to prevent timing issues for built-in plugins on init - any splash screen ."
+.. "- Internal fixes to prevent timing issues for built-in plugins on init - any splash screen .\n"
 )
 .. "\n\n"
 .. TitanUtils_GetGoldText("8.1.7 : 2024/12/22\n")
 .. TitanUtils_GetGreenText("Gold : \n")
 .. TitanUtils_GetHighlightText(""
-.. "- Hopefully fix an error on character start ocurring on some systems."
+.. "- Hopefully fix an error on character start ocurring on some systems.\n"
 )
 .. "\n\n"
 .. TitanUtils_GetGoldText("8.1.6 : 2024/12/09\n")
 .. TitanUtils_GetGreenText("Gold : \n")
 .. TitanUtils_GetHighlightText(""
-.. "- Warband gold updated properly in tooltip."
+.. "- Warband gold updated properly in tooltip.\n"
 )
 .. TitanUtils_GetGreenText("Titan : \n")
 .. TitanUtils_GetHighlightText(""
 .. "- Update ACE3 libs."
-.. "- Bars - Config Color picker now works; changed in 10.2.5 (Jan 2024)."
-.. "- Bars - Config when selecting Skin vs Color the 'other' controls are disabled."
-)
-.. "\n\n"
-.. TitanUtils_GetGoldText("8.1.5 : 2024/11/20\n")
-.. TitanUtils_GetGreenText("Loot - Classic Era : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Code changes per change in API."
-.. "- Code changes per change in XML parsing."
-)
-.. TitanUtils_GetGreenText("Titan : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Retail TOC to 11.0.5."
-.. "- Cata TOC to 4.4.1."
-.. "- Classic Era TOC to 1.15.5"
+.. "- Bars - Config Color picker now works; changed in 10.2.5 (Jan 2024).\n"
+.. "- Bars - Config when selecting Skin vs Color the 'other' controls are disabled.\n"
 )
 .. "\n\n"

diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua
index 3d52b15..270e4e5 100644
--- a/Titan/TitanUtils.lua
+++ b/Titan/TitanUtils.lua
@@ -463,6 +463,20 @@ but was removed during DragonFlight to give users more flexibility.
 	return found
 end

+---Titan Return the number of bars user has active, includes auto hide.
+---@return integer Num Active bars
+function TitanUtils_NumActiveBars()
+	local num_bars = 0
+
+	for idx, bar in pairs(TitanBarDataVars) do
+		if TitanBarDataVars[idx].show then --if TitanPanelGetVar(bar_name.."_Show") then
+			num_bars = num_bars + 1
+		end
+	end
+
+	return num_bars
+end
+
 --====== General util routines

 ---API Return b (a = true) or c (a = false)
@@ -2398,41 +2412,6 @@ function TitanPluginDebug(id, debug_message)
 	_G["DEFAULT_CHAT_FRAME"]:AddMessage(msg)
 end

----API: Output a topic debug message in a consistent format.
----@param id string Plugin id
----@param topic integer Topic id
----@param debug_message string Message to output to Chat
-function TitanTopicDebug(id, topic, debug_message)
-
-	local plugin = TitanUtils_GetPlugin(id) ---@type PluginRegistryType
-	local str = ""
-	local id_str = id or "?"
-	local dbg = id_str.." "..tostring(topic).." "
-
-	if plugin and plugin.debugClass then
-		if plugin.debugClass.enabled == true then
-			if plugin.debugClass.topics[topic] then
-				if plugin.debugClass.topics[topic].enabled == true then -- topic description exists
-					str = tostring(topic) .. " " .. plugin.debugClass.topics[topic].topic
-					local msg =
-					TitanUtils_GetGoldText(date("%H:%M:%S") .. "<" .. tostring(id_str) .. "> " .. str )
-						.. " " .. TitanUtils_GetHexText(tostring(debug_message), Titan_Global.colors.orange)
-					_G["DEFAULT_CHAT_FRAME"]:AddMessage(msg)
-				else
-					dbg = dbg.."~topic enabled"
-				end
-			else
-				dbg = dbg.."~topic"
-			end
-		else
-			dbg = dbg.."~enabled"
-		end
---print(dbg)
-	else
-		-- not sure why this routine was called
-	end
-end
-
 ---Titan: Output the current list of registered plugins.
 function TitanDumpPluginList()
 	-- Just dump the current list of plugins
diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua
index f49635f..1e3c6bc 100644
--- a/TitanGold/TitanGold.lua
+++ b/TitanGold/TitanGold.lua
@@ -804,6 +804,13 @@ local function Initialize_Array()
 	if (GOLD_INITIALIZED) then
 		-- already done
 	else
+		-- See if this is a new toon to Gold saved vars or reset
+		-- Set gold to 0; it will be set properly later
+		if (GoldSave[GOLD_INDEX] == nil) then
+			GoldSave[GOLD_INDEX] = {}
+			GoldSave[GOLD_INDEX] = { gold = 0, name = player_name }
+		end
+
 		Warband.Init()

 		-- Ensure the saved vars are usable
@@ -833,6 +840,11 @@ local function Initialize_Array()
 		GOLD_SESSIONSTART = GetTime();
 		GOLD_INITIALIZED = true;

+		-- added Jan 2025
+		-- Also restore initial gold:
+		-- new toon; Titan install / update / reload
+		GoldSave[GOLD_INDEX].gold = Get_Money()
+
 		info = ""
 		.." "..tostring(GOLD_SESSIONSTART)..""
 		.." "..tostring(GOLD_STARTINGGOLD)..""
@@ -853,6 +865,8 @@ local function ClearData(self)
 	GoldSave = {};
 	Initialize_Array();

+	TitanPanelButton_UpdateButton(TITAN_GOLD_ID)
+
 	DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_DB_CLEARED"]));
 end

@@ -1249,8 +1263,8 @@ end
 ---local When shown, register needed events and start timer for gold per hour
 ---@param self Button
 local function OnShow(self)
-	self:RegisterEvent("PLAYER_MONEY")
 	Initialize_Array()
+	self:RegisterEvent("PLAYER_MONEY")

 	if GoldSave and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then
 		if GoldTimerRunning then
@@ -1298,13 +1312,6 @@ local function OnEvent(self, event, a1, ...)
 			-- Faction is English to use as index NOT display
 			GOLD_INDEX = CreateIndex(player_name, realmName, player_faction)

-			-- See if this is a new toon to Gold saved vars
-			-- Set gold to 0; it will be set properly later
-			if (GoldSave[GOLD_INDEX] == nil) then
-				GoldSave[GOLD_INDEX] = {}
-				GoldSave[GOLD_INDEX] = { gold = 0, name = player_name }
-			end
-
 			self:UnregisterEvent("ADDON_LOADED");
 		else
 			-- Not this addon