Quantcast

- Location : Add display of Realm (optional); Connected Realms to tooltip

urnati [10-15-24 - 19:25]
- Location : Add display of Realm (optional); Connected Realms to tooltip
- Gold : Hopefully fix error some see on start Ticket #1415. Make show of Warbank bank gold optional.
- Loot : Additional comments; use # over deprecated table.getn
- Titan : Add'l comments for AutoHide
Filename
Titan/TitanAutoHide.lua
Titan/TitanHistory.lua
Titan/_TitanIDE.lua
Titan/locale/Localization.lua
TitanGold/TitanGold.lua
TitanLootType/TitanClassicLootType.lua
diff --git a/Titan/TitanAutoHide.lua b/Titan/TitanAutoHide.lua
index 9bd7b99..531fc59 100644
--- a/Titan/TitanAutoHide.lua
+++ b/Titan/TitanAutoHide.lua
@@ -17,12 +17,9 @@ local Dewdrop = nil
 if AceLibrary and AceLibrary:HasInstance("Dewdrop-2.0") then Dewdrop = AceLibrary("Dewdrop-2.0") end

 -- local routines
---[[ local
-NAME: Titan_AutoHide_SetIcon
-DESC: Set the icon for the plugin.
-VAR: self - The bar
-OUT: None
---]]
+
+---local Set the icon for the plugin.
+---@param self table Titan bar frame
 local function Titan_AutoHide_SetIcon(self)
 	local frame_auto_hide = self:GetName()
 	local icon = _G[frame_auto_hide.."Icon"]
@@ -37,6 +34,9 @@ local function Titan_AutoHide_SetIcon(self)
 	end
 end

+---local Create tooltip text
+---@param self table Titan bar frame
+---@return string toolt_tip
 local function GetTooltipText(self)
 	local returnstring = ""
 	if self.registry.titan_bar then
@@ -52,21 +52,16 @@ local function GetTooltipText(self)
 	return returnstring
 end

---[[
-NAME: Titan_AutoHide_Init
-DESC: Show / hide the given bar per the user requested settings
-VAR: self - The bar
-OUT: None
---]]
+---Titan Initialize the Titan full bar
+---@param frame string Titan bar name
 function Titan_AutoHide_Init(frame)
 	if _G[frame] then -- sanity check
 		local bar = TitanBarData[frame].name

 		-- Make sure the bar should be processed
-		if TitanBarDataVars[frame].show then --if (TitanPanelGetVar(bar.."_Show")) then
+		if TitanBarDataVars[frame].show then
 			-- Hide / show the bar
 			if TitanBarDataVars[frame].auto_hide then
---			if (TitanPanelGetVar(bar.."_Hide")) then
 				TitanPanelBarButton_Hide(frame);
 			else
 				TitanPanelBarButton_Show(frame);
@@ -84,15 +79,11 @@ function Titan_AutoHide_Init(frame)
 	end
 end

---[[
-NAME: Titan_AutoHide_ToggleAutoHide
-DESC: Toggle the user requested show / hide setting then show / hide given bar
-VAR: self - The bar
-OUT: None
---]]
+---Titan Toggle the user requested show / hide setting then show / hide given bar
+---@param bar string
 function Titan_AutoHide_ToggleAutoHide(bar)
 	local frame_str  = TitanVariables_GetFrameName(bar)
-
+
 	-- toggle the correct auto hide variable
 	TitanBarDataVars[frame_str].auto_hide = not TitanBarDataVars[frame_str].auto_hide
 	-- Hide / show the requested Titan bar
@@ -100,12 +91,9 @@ function Titan_AutoHide_ToggleAutoHide(bar)
 end

 -- Event handlers
---[[
-NAME: Titan_AutoHide_OnLoad
-DESC: Setup the plugin on the given bar.
-VAR: self - The bar
-OUT: None
---]]
+
+---local Setup the plugin on the given bar.
+---@param self table Titan bar frame
 local function Titan_AutoHide_OnLoad(self)
 	local frame = self:GetName()
 	local bar = self.short_name
@@ -127,99 +115,83 @@ local function Titan_AutoHide_OnLoad(self)
 	};
 end

---[[
-NAME: Titan_AutoHide_OnShow
-DESC: Show the plugin on the given bar.
-VAR: self - The bar
-OUT: None
---]]
+---local Show the plugin on the given bar.
+---@param self table Titan bar frame
 local function Titan_AutoHide_OnShow(self)
 	Titan_AutoHide_SetIcon(self)
 end

---[[
-NAME: Titan_AutoHide_OnClick
-DESC: Handle button clicks on the given bar.
-VAR: self - The bar
-VAR: button - The mouse button clicked
-OUT:  None
---]]
+---local Handle button clicks on the given bar.
+---@param self table Titan bar frame
+---@param button string mouse button name
 local function Titan_AutoHide_OnClick(self, button)
 	if (button == "LeftButton") then
 		Titan_AutoHide_ToggleAutoHide(self.registry.short_name);
 	end
 end

---[[
-NAME: Handle_OnUpdateAutoHide
-DESC: Hide the bar if the user has auto hide after the cursor leaves the display bar.
-VAR: frame - The bar
-OUT: None
---]]
+---Titan Hide the bar if the user has auto hide after the cursor leaves the display bar.
+---@param frame string Titan bar name
 function Handle_OnUpdateAutoHide(frame)
-	if TitanPanelRightClickMenu_IsVisible()
-	or (Tablet20Frame and Tablet20Frame:IsVisible())
+	if TitanPanelRightClickMenu_IsVisible()
+	or (Tablet20Frame and Tablet20Frame:IsVisible())
 	or (Dewdrop and Dewdrop:IsOpen())then
 		return
 	end
-
+
 	local data = TitanBarData[frame] or nil
 	if not data then -- sanity check
 		return
 	end
---	local bar = (data.name or nil)
-
-	local hide = TitanBarDataVars[frame].auto_hide -- TitanPanelGetVar(bar.."_Hide")
-	--
+
+	local hide = TitanBarDataVars[frame].auto_hide
 	if hide then
+---@diagnostic disable-next-line: param-type-mismatch
 		AceTimer.CancelAllTimers(frame)
 		TitanPanelBarButton_Hide(frame)
 	end
 end

 -- Auto hide routines
---[[
-NAME: Titan_AutoHide_Timers
-DESC: This routine accepts the display bar frame and whether the cursor is entering or leaving. On enter kill the timers that are looking to hide the bar. On leave start the timer to hide the bar.
-VAR: frame - The bar
-VAR: action - "Enter" | "Leave"
-OUT:  None
---]]
+
+---Titan This routine accepts the display bar frame and whether the cursor is entering or leaving. On enter kill the timers that are looking to hide the bar. On leave start the timer to hide the bar.
+---@param frame? string Titan bar name
+---@param action string "Enter" | "Leave"
 function Titan_AutoHide_Timers(frame, action)
 	if not frame or not action then
 		return
 	end
-	local bar = TitanBarData[frame].name --(frame.bar_name or nil)
-	local hide = TitanBarDataVars[frame].auto_hide -- (bar and TitanPanelGetVar(bar.."_Hide") or nil)
-
+	local bar = TitanBarData[frame].name
+	local hide = TitanBarDataVars[frame].auto_hide
+
 	if bar and hide then
 		if (action == "Enter") then
+---@diagnostic disable-next-line: param-type-mismatch
 				AceTimer.CancelAllTimers(frame)
 		end
 		if (action == "Leave") then
 			-- pass the bar as an arg so we can get it back
+---@diagnostic disable-next-line: param-type-mismatch
 			AceTimer.ScheduleRepeatingTimer(frame, Handle_OnUpdateAutoHide, 0.5, frame)
 		end
 	end
 end
-
---
---==========================
--- Routines to handle moving and sizing of short bars
---
+---local Create the 'push pin' for the given full bar
+---@param bar string Titan full bar short name
+---@param f  table Titan bar frame
 local function Create_Hide_Button(bar, f)
 	local name = AUTOHIDE_PREFIX..bar..AUTOHIDE_SUFFIX
 	local plugin = CreateFrame("Button", name, f, "TitanPanelIconTemplate")
 	plugin:SetFrameStrata("FULLSCREEN")
-
+
 	plugin.short_name = bar -- set the short bar name for the .registry

 	-- Using SetScript("OnLoad",   does not work
 	Titan_AutoHide_OnLoad(plugin);
 --	TitanPanelButton_OnLoad(plugin); -- Titan XML template calls this...
-
-	plugin:SetScript("OnShow", function(self)
-		Titan_AutoHide_OnShow(self)
+
+plugin:SetScript("OnShow", function(self)
+		Titan_AutoHide_OnShow(self)
 	end)
 	plugin:SetScript("OnClick", function(self, button)
 		Titan_AutoHide_OnClick(self, button);
@@ -227,17 +199,15 @@ local function Create_Hide_Button(bar, f)
 	end)
 end

---local function Create_Frames()
+---local Create all the hide button / 'push pins' for user
 local function Titan_AutoHide_Create_Frames()
-	--====== Titan Auto hide plugin buttons ==============================
-	-- general container frame
+	-- general container frame as a parent
 	local f = CreateFrame("Frame", nil, UIParent)

 	Create_Hide_Button("Bar", f)
 	Create_Hide_Button("Bar2", f)
 	Create_Hide_Button("AuxBar2", f)
 	Create_Hide_Button("AuxBar", f)
-
 end

 Titan_AutoHide_Create_Frames() -- do the work
diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua
index ae41f42..c0fc2c5 100644
--- a/Titan/TitanHistory.lua
+++ b/Titan/TitanHistory.lua
@@ -21,6 +21,19 @@ Titan_Global.recent_changes = ""
 .. "- Add display of Realm (optional)."
 .. "- Add display of Connected Realms to tooltip."
 )
+.. TitanUtils_GetGreenText("Gold : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Hopefully fix error some see on start Ticket #1415."
+.. "- Make show of Warbank bank gold optional."
+)
+.. TitanUtils_GetGreenText("Loot : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Additional comments; use # over deprecated table.getn."
+)
+.. TitanUtils_GetGreenText("Titan : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Additional comments."
+)
 .. "\n\n"
 .. TitanUtils_GetGoldText("8.1.2 : 2024/08/24\n")
 .. TitanUtils_GetGreenText("Titan : \n")
diff --git a/Titan/_TitanIDE.lua b/Titan/_TitanIDE.lua
index 5a01704..56da416 100644
--- a/Titan/_TitanIDE.lua
+++ b/Titan/_TitanIDE.lua
@@ -35,6 +35,9 @@
     Note the diagnostic could be by line, file, or workspace / project.
 --]]

+-- Use Linux command below to get a rough line count of a Titan release.
+-- find . -wholename "*.tga" -prune -o -wholename "*.code*" -prune -o -wholename "*.blp" -prune -o -wholename "*/libs/*" -prune -o -wholename "*/Artwork/*" -prune -o -print | xargs wc -l
+
 --====== Frames from Titan Template XML
 TitanPanelButtonTemplate = {}
 TitanPanelTextTemplate = {}
diff --git a/Titan/locale/Localization.lua b/Titan/locale/Localization.lua
index 2baf2f3..7717f97 100644
--- a/Titan/locale/Localization.lua
+++ b/Titan/locale/Localization.lua
@@ -58,6 +58,7 @@ L["TITAN_GOLD_FACTION_PLAYER_HORDE"] = "Horde";
 L["TITAN_GOLD_GOLD"] = "g";
 L["TITAN_GOLD_GROUP_BY_REALM"] = "Group By Realm";
 L["TITAN_GOLD_IGNORE_FACTION"] = IGNORE.." "..FACTION
+L["TITAN_GOLD_INCLUDE_WARBANK"] = "Include Warbank Gold";
 L["TITAN_GOLD_ITEMNAME"] = "Titan Gold";
 L["TITAN_GOLD_MENU_TEXT"] = "Gold";
 L["TITAN_GOLD_MERGE"] = "Merge Servers";
diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua
index ff9582e..d689917 100644
--- a/TitanGold/TitanGold.lua
+++ b/TitanGold/TitanGold.lua
@@ -67,7 +67,7 @@ function Warband.SetSum()
 	--	Warband.debug("SetSum")
 end

----local Return Warband Bank info
+---local Set Warband Bank info
 function Warband.Init()
 	-- check for func even though it does not work atm... 2024 Aug  (Added 11.0.0)
 	Warband.active = (C_Bank and C_Bank.CanUseBank) and true or false
@@ -80,6 +80,23 @@ function Warband.Init()
 	--	Warband.debug("Init")
 end

+---local Check if Warband Bank is in this version and user requested
+---@return boolean
+function Warband.Use()
+	local res = false
+	if Warband.active then
+		if TitanGetVar(TITAN_GOLD_ID, "ShowWarband") then
+			res = true
+		else
+			-- Not requested by user
+		end
+	else
+		-- Likely Classic version
+	end
+
+	return res
+end
+
 ---local Return Warband Bank info
 ---@return number
 function Warband.GetSum()
@@ -152,12 +169,21 @@ local function SortByIndex(gold_table)
 	return gold_table
 end

----local Create Gold index <character>_<server>::<faction>
+---local Create Gold index <character>_<server>::<faction>and see if the toon is in the table.
 ---@param character string
 ---@param charserver string
 ---@param char_faction string
 local function CreateIndex(character, charserver, char_faction)
 	local index = character .. "_" .. charserver .. "::" .. char_faction
+
+	-- See if this is a new toon to Gold;
+	-- There may be a timing issue on some systems where Gold is told to 'Show'
+	-- by Titan before Gold processes PEW event.
+	if (GoldSave[GOLD_INDEX] == nil) then
+		GoldSave[GOLD_INDEX] = {}
+		GoldSave[GOLD_INDEX] = { gold = 0, name = player_name }
+	end
+
 	return index
 end

@@ -498,11 +524,8 @@ local function TotalGold()
 	end

 	--
-	-- === Add Warband Bank
-	--
-	-- Warband is not a toon so add it.
-	-- For now it can not be shown / hidden from totals.
-	if Warband.active then
+	-- === Add Warband Bank, if enabled and requested
+	if Warband.Use() then
 		ttlgold = ttlgold + Warband.GetSum()
 	end

@@ -613,7 +636,7 @@ local function GetTooltipText()
 	--
 	-- === Add Warband Bank
 	--
-	if Warband.active then
+	if Warband.Use() then
 		currentMoneyRichText = currentMoneyRichText .. "\n"
 			.. "------ \t +" .. "\n"
 			.. Warband.GetName() -- localized
@@ -739,7 +762,8 @@ local function ResetSession()
 	DEFAULT_CHAT_FRAME:AddMessage(TitanUtils_GetGreenText(L["TITAN_GOLD_SESSION_RESET"]));
 end

----local Build the gold array from saved vars, if any; get current total and session start time
+---local See if this toon is in saved vars AFTER PEW event.
+--- Get current total and session start time. Toon gold is available via API AFTER PEW event.
 ---@param self Button
 local function Initialize_Array(self)
 	if (GOLD_INITIALIZED) then
@@ -994,6 +1018,21 @@ local function CreateMenu()

 		TitanPanelRightClickMenu_AddSeparator();

+		if Warband.active then
+			-- Function to toggle show / hide of Warbank gold
+			info = {};
+			info.text = L["TITAN_GOLD_INCLUDE_WARBANK"] -- .. " - " .. NiceTextCash(Warband.GetSum()).."";
+
+			info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowWarband");
+			info.func = function()
+				TitanToggleVar(TITAN_GOLD_ID, "ShowWarband")
+				TitanPanelButton_UpdateButton(TITAN_GOLD_ID)
+			end
+			TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel())
+		else
+			-- Warbank not in this expansion
+		end
+
 		-- Show / delete toons
 		info = {};
 		info.notCheckable = true
@@ -1166,7 +1205,8 @@ local function OnLoad(self)
 			IgnoreFaction = false,
 			GroupByRealm = false,
 			gold = { total = "112233", neg = false },
-			ShowSessionInfo = true
+			ShowSessionInfo = true,
+			ShowWarband = true,
 		}
 	};

@@ -1191,6 +1231,7 @@ local function OnShow(self)
 		-- timer running or user does not want gold per hour
 	end

+	-- Leave active so user can toggle
 	if Warband.active then
 		Warband.SetSum()
 		self:RegisterEvent("ACCOUNT_MONEY") -- register for changes
diff --git a/TitanLootType/TitanClassicLootType.lua b/TitanLootType/TitanClassicLootType.lua
index 65ccbff..9462248 100644
--- a/TitanLootType/TitanClassicLootType.lua
+++ b/TitanLootType/TitanClassicLootType.lua
@@ -1137,7 +1137,7 @@ function Track.UpdateRollList()

 	--	TitanPanelLootTypeFrameStatusText:SetFont(Tool.Font, Tool.FontSize)
 	TitanPanelLootTypeFrameStatusText:SetText(string.format(L["TITAN_LOOTTYPE_TRACKER_MSGNBROLLS"],
-		table.getn(Track.rollArray)))
+		#Track.rollArray))

 	--	TitanPanelLootTypeFrameClearButton:SetFont(Tool.Font, Tool.FontSize)
 	TitanPanelLootTypeFrameClearButton:SetText(L["TITAN_LOOTTYPE_TRACKER_BTNCLEAR"])