diff --git a/Titan/Titan.lua b/Titan/Titan.lua index eb568c0..a35eeca 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -265,49 +265,6 @@ local function RegisterAddonCompartment() end end ---****** overload the 'time played' text to Chat - if XP requested the API call -local requesting ----@diagnostic disable: duplicate-set-field - --- Save orignal output to Chat --- somewhere in 11.* (The World Within) this changed -local orig_ChatFrame_DisplayTimePlayed = function(...) end - --- Do not output Chat messages when using RequestTimePlayed -function TitanPanelBarButton:RequestTimePlayed() - requesting = true - RequestTimePlayed() -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 - - 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 ---****** overload end - local function SetToonZoneInfo() local toon_info = TitanSettings.Players[TitanSettings.Player].Info ---@class CharInfo toon_info.zoneText = GetZoneText() @@ -323,7 +280,7 @@ local function SetToonPlayedInfo(action, total, level) local toon_info = TitanSettings.Players[TitanSettings.Player].Info ---@class CharInfo if action == 'init' then - TitanPanelBarButton:RequestTimePlayed() -- TIME_PLAYED_MSG + TitanUtils_GetTimePlayed("Titan") -- TIME_PLAYED_MSG toon_info.played_start = _G.time() elseif action == 'update' then -- via event TIME_PLAYED_MSG toon_info.played_total = total + GetElapsed(toon_info.played_start) @@ -613,6 +570,7 @@ function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2, arg3, arg4) StopTitan("Could not initialize", ret_val) -- something really bad occured... end + -- Register plugins; set profile; set config call_ok, ret_val = pcall(SetupUser) if call_ok then -- Titan initialized properly diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index 2dba8e8..728a557 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -58,12 +58,14 @@ else end Titan_Global.switch.chat_class = true -- if chat routines moved into ChatFrameUtil +--[[ 2026 Apr at some point, Blizz rolled out ChatFrameUtil to all WoW versions. +-- TODO : Remove check from code if ChatFrameUtil and ChatFrameUtil.DisplayTimePlayed then Titan_Global.switch.chat_class = true -- started in 11.* somewhere else Titan_Global.switch.chat_class = false -- older version end - +--]] Titan_Global.AdjList = { -- TODO : localize ["UIWidgetTopCenterContainerFrame"] = { diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua index 1907f38..c1298e1 100644 --- a/Titan/TitanHistory.lua +++ b/Titan/TitanHistory.lua @@ -10,13 +10,32 @@ These are in a seperate file to --- Release notes. Keep structure; most recent on 'top' local recent_changes = { { + version = "9.2.2", + when = "2026/04/23", + topics = { + { + topic = "Gold", + lines = { + "Fix tooltip for All Servers - special thanks to Liefwing for the code!", + }, + }, + { + topic = "Titan", + lines = { + "Time Played : Move override to Utils so both Titan and XP can use.", + "Tooltip : Fix 'flash' on cursor leaving plugin, especially if using scale less than 1.", + }, + }, + }, + }, + { version = "9.2.1", when = "2026/04/23", topics = { { topic = "Titan", lines = { - "Update : Dur to a git hitch, tooltip, an Alts fix, and History were not included in 9.2.0.", + "Update : Due to a git hitch, tooltip, an Alts fix, and History were not included in 9.2.0.", }, }, }, diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index 902f6f3..b889c0e 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -26,7 +26,7 @@ The available plugin types are: - TitanPanelTextTemplate - * A frame that only displays text ("$parentText") - TitanPanelIconTemplate - * A frame that only displays an icon ("$parentIcon") - TitanPanelComboTemplate - * A frame that displays an icon then text ("$parentIcon" "$parentText") -- TitanOptionsSliderTemplate - A frame that contains the basics for a vertical slider control. See TitanVolume for an example. +- TitanOptionsSliderTemplate - A frame that contains a basic vertical slider control. See TitanVolume for an example. * Templates inherit TitanPanelButtonTemplate for common elements. @@ -156,7 +156,7 @@ end ---@param frame table Tooltip frame ---@param custom boolean If custom / not tooltip frame local function SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame, custom) - -- Changes for 9.1.5 Removed the background template from the Tooltip + -- Changes for WoW 9.1.5 Removed the background template from the Tooltip -- Making changes to it difficult and possibly changing the tooltip globally. if custom then @@ -167,14 +167,16 @@ local function SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePo frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); - -- set font size for the Game Tooltip + -- Set font size for the tooltip; only on show if TitanPanelGetVar("DisableTooltipFont") then -- use UI scale else + --[[ if TitanTooltipScaleSet < 1 then TitanTooltipOrigScale = frame:GetScale(); TitanTooltipScaleSet = TitanTooltipScaleSet + 1; end + --]] frame:SetScale(TitanPanelGetVar("TooltipFont")); end @@ -300,7 +302,6 @@ local function TitanPanelButton_SetTooltip(self) local ok = false local frame = TitanPanelTooltip --GameTooltip local id = self.registry.id ---local frame = CreateFrame("GameTooltip","myTooltipFrame",UIParent,"GameTooltipTemplate") frame.registry_id = id -- for use in other routines frame.plugin_frame = self @@ -325,7 +326,7 @@ local function TitanPanelButton_SetTooltip(self) self.plugin_frame = TitanUtils_ButtonName(id) if (plugin and plugin.tooltipDisplayFrame) then -- 2026 Mar : Added from LDB to take advantage of Titan processing. - -- PLugin is expected to handle its frame! + -- Plugin is expected to handle its frame! -- Titan will position and show only! -- Plugin must handle any timeout and any other features. @@ -771,28 +772,19 @@ function TitanPanelButton_OnLeave(self) local time_out = max (TitanPanelGetVar("TooltipTimeout"), 0.1) TitanUtils_StartFrameCounting(TitanPanelTooltip, time_out) ---[===[ -- The cursor has moved away from the plugin. - -- NOTE: !!! It is possible, especially with Short bars that the - -- user never mouses over the tooltip so start the Hide timer !!! - -- - - -- Let the tooltip SetScripts handle OnEnter and OnLeave if - -- the user mouses over. - if TitanPanelTooltip:IsShown() then - local time_out = TitanPanelGetVar("TooltipTimeout") - TitanUtils_StartFrameCounting(TitanPanelTooltip, time_out) - else - -- nothing to do - end -]===] + -- Notes: + -- - The OnUpdate of the tooltip will Hide it. + -- - Scale set OnShow + --[[ if TitanPanelGetVar("DisableTooltipFont") then -- use game font & scale else -- use Titan font & scale - TitanPanelTooltip:SetScale(TitanTooltipOrigScale); +-- TitanPanelTooltip:SetScale(TitanTooltipOrigScale); TitanTooltipScaleSet = 0; end + --]] end -- local routines for Update Button @@ -1317,7 +1309,7 @@ end local tt_frame = TitanPanelTooltip local tt_init_timeout = .5 ---[===[ +--[===[ GameTooltip does not stay if cursor moves off plugin... tt_frame:SetScript("OnShow", function(self) local time_out = TitanPanelGetVar("TooltipTimeout") local dbg_msg = "OnShow" @@ -1382,8 +1374,7 @@ tt_frame:SetScript("OnUpdate", function(self, elapsed) end --]] - -- Compromise to keep tooltip open if the user stays over plugin - -- and does not mouse over tooltip frame (OnEnter) + -- Keep tooltip open as long as the curser stays over plugin local is_over = self.plugin_frame:IsMouseOver() if is_over then TitanUtils_StopFrameCounting(self) @@ -1394,7 +1385,7 @@ tt_frame:SetScript("OnUpdate", function(self, elapsed) end --[[ - if debug_over ~= debug_over_new then + if debug_over ~= debug_over_new then -- slow output a little... debug_over = debug_over_new local dbg_msg = "OnUpdate" .. " over: " .. tostring(is_over) .. "" diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index f5f70c5..bab6e71 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -1894,6 +1894,35 @@ function TitanUtils_DecompressData(data, dataType) return false, {} end +--====== Overload the 'time played' text to Chat to not show 'time played' to Chat +local requesting = 0 + +-- Save orignal output to Chat +local orig_ChatFrame_DisplayTimePlayed = function(...) end + + orig_ChatFrame_DisplayTimePlayed = ChatFrameUtil.DisplayTimePlayed + + ChatFrameUtil.DisplayTimePlayed = function(...) --TimePlayed(...) + -- A little clunky but calls done rapidly should sort themselves + -- even if the exact call to event does not match. + if requesting > 0 then + -- Titan requested time played, do not spam Chat + requesting = requesting - 1 + else + -- Did not request time played so output + ---@diagnostic disable-next-line: need-check-nil + orig_ChatFrame_DisplayTimePlayed(...) + end + end + +---Titan Get time played in a general way to not spam Chat +---@param reason string For debug +function TitanUtils_GetTimePlayed(reason) + requesting = requesting + 1 + + RequestTimePlayed() +end + -------------------------------------------------------------- -- Various debug routines --[[ diff --git a/TitanAlts/TitanAlts.lua b/TitanAlts/TitanAlts.lua index da54207..7298ae0 100755 --- a/TitanAlts/TitanAlts.lua +++ b/TitanAlts/TitanAlts.lua @@ -13,12 +13,12 @@ local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local QTip = LibStub("LibQTip-1.0") local iconProvider, cellPrototype, baseCellPrototype = QTip:CreateCellProvider(QTip.LabelProvider) --- Required for Create - just call the base init +-- Required for CreateCellProvider - just call the base init function cellPrototype:InitializeCell() baseCellPrototype.InitializeCell(self); end --- Required for Create - override the base Setup to use an icon +-- Required for CreateCellProvider - override the base Setup to use an icon function cellPrototype:SetupCell(tooltip, value, justification, font) local _, height = baseCellPrototype.SetupCell(self, tooltip, format("|T%s:0|t", tostring(value)), "CENTER"); return baseCellPrototype.SetupCell(self, tooltip, @@ -26,7 +26,6 @@ function cellPrototype:SetupCell(tooltip, value, justification, font) end local UNK = TitanUtils_GetGrayText("-") ---]] local artwork_path = "Interface\\AddOns\\TitanAlts\\Artwork\\" local TITAN_PLUGIN = "Alts" @@ -71,7 +70,6 @@ local Alts = {} -- namespace for Alts routines as needed ---@field sync_global boolean -- may implement -- ******************************** Variables ******************************* -local trace = false -- true / false Make true when debug output is needed. local alts_tt = {} -- Holds alt data for tooltip display; gen once except for logged in toon local alts_tt_sort_col = "" -- one sort to rule them all... local alts_tt_sort_ascend = true -- default on click; click again to flip @@ -164,21 +162,23 @@ local function SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePo -- Making changes to it difficult and possibly changing the tooltip globally. if custom then - -- do NOT set owner - it clears the contents! + -- do NOT set owner here - it clears the contents! else frame:SetOwner(parent, "ANCHOR_NONE") end frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); - -- set font size for the Game Tooltip + -- Set font size for the tooltip only on show if TitanPanelGetVar("DisableTooltipFont") then -- use UI scale else + --[[ if TitanTooltipScaleSet < 1 then TitanTooltipOrigScale = frame:GetScale(); TitanTooltipScaleSet = TitanTooltipScaleSet + 1; end + --]] frame:SetScale(TitanPanelGetVar("TooltipFont")); end @@ -1012,11 +1012,10 @@ end -- Handle mouse clicks local function OnClick(self, button) - if trace then - TitanPluginDebug(TITAN_PLUGIN, "Titan Alts click" - .. " " .. tostring(button) .. "" - ) - end + local dbg_msg = "OnClick" + .. " '" .. tostring(TITAN_PLUGIN) .. "'" + .. " " .. tostring(button) .. "" + Titan_Debug.Out('alts', 'flow', dbg_msg) if (button == "LeftButton") then -- C_UI.Reload() --ReloadUI() end @@ -1043,11 +1042,10 @@ local function Create_Frames() return -- if already created end - if trace then - TitanPluginDebug(TITAN_PLUGIN, "TS frames" - .. " '" .. tostring(TITAN_BUTTON) .. "'" - ) - end + local dbg_msg = "Create_Frames" + .. " '" .. tostring(TITAN_PLUGIN) .. "'" + .. " " .. tostring(TITAN_BUTTON) .. "" + Titan_Debug.Out('alts', 'flow', dbg_msg) -- general container frame local f = CreateFrame("Frame", nil, UIParent) @@ -1085,6 +1083,7 @@ local function Create_Frames() end) -- Create tooltip frame for this plugin + -- This is a CUSTOM tooltip to show toon info. -- OnUpdate starts as soon as OnShow is done... tt_frame = CreateFrame("GameTooltip", TITAN_TOOLTIP, UIParent, "GameTooltipTemplate") diff --git a/TitanBag/TitanBag.lua b/TitanBag/TitanBag.lua index 9da20bb..96fbd6f 100644 --- a/TitanBag/TitanBag.lua +++ b/TitanBag/TitanBag.lua @@ -1070,37 +1070,39 @@ Titan_Menu expects an object approach. The older scheme uses a table driven whic --[[ .registry Routines for Tooltip creation If Titan finds a tooltip function, Titan will assume it needs to position, show, and hide the tooltip. -Titan looks for a function to create a tooltip, in order: +Titan looks for a tooltip directive, in order: 1) .tooltipDisplayFrame : New 2026 Mar - 2026 Mar : Added from LDB (.tooltip) to take advantage of Titan processing. - It allows the plugin full control BUT the plugin must take nearly full responsibility. + .tooltipDisplayFrame contains the tooltip frame - not function! + This allows the plugin full control. Titan will position and show only! - Plugin must handle timeout and any other features. - Note: If using a frame of type GameTooltip, the plugin MUST set owner. - If Titan does a set oener on display, it wipes the contents... + Note: The plugin MUST set owner (:SetOwner). If Titan does a set owner, it could wipe the contents... 2) .tooltipTemplateFunction : New 2026 Mar -A game tooltip template is passed to plugin as an explicit agreement + A game tooltip template is passed to plugin as an explicit agreement. + This allows the plugin to use the Titan tooltip with GameTooltip routines such as AddLine() pcall(self.tooltipTemplateFunction, self, frame) -3) .tooltipCustomFunction : Deprecated Midnight (12.0.0) / 2026 Mar : -Assumes GameTooltip as implicit agreement +3) .tooltipCustomFunction : Deprecated for Titan in Midnight (12.0.0) / 2026 Mar : + Assumes GameTooltip as implicit agreement tmp_txt = pcall(self.tooltipCustomFunction, self) 4) .tooltipTextFunction : Titan adds plugin name as Title; expects text in return to fill the tooltip. +5) The plugin may decide to create a custom tooltip without involving Titan. + Titan would find no tooltip directive and do nothing. + The tooltip function is called when the mouse enters the plugin frame - OnEnter. -Titan templates set the OnEnter script for the plugin frame. +Titan templates set the OnEnter script for each plugin frame. On a tooltip error, Titan will usually show part of the error in the tool tip. -If you need to see the full error, search for this attribute in the Titan folder; +If you need to see the full error, search for the attribute in the Titan folder; and uncomment the print of the error message. -Due to changes in Midnight (12.0.0) Titan tooltips have undergone major changes to avoid 'secret' errors. +Due to changes in Midnight (12.0.0 - Early 2026) Titan tooltips have undergone major changes to avoid 'secret' errors. Titan had to move to a custom tooltip rather than use Blizzard's GameTooltip. This causes conflict in the 'custom' scheme which assumes GameTooltip in Titan and the Titan plugin. To resolve this .tooltipTemplateFunction was added (2026 Mar). The new attribute allows plugins to update as needed to Midnight. -It also allows older, possibly abandoned, plugins to run as long as practical. Until a breaking API change. +It also allows older, possibly abandoned, plugins to run as long as practical. --]] diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua index de43f35..bb28038 100644 --- a/TitanGold/TitanGold.lua +++ b/TitanGold/TitanGold.lua @@ -392,6 +392,240 @@ end -- ====== Tool tip routines +---[===[ André Kräußlich <demian1976andre@yahoo.de> +--[[ + In this file I did only the changes for better display and the solving of the problem with the sorting by realm. + Yea, the necessary function is much mor larger als the old, but in my retail it works fine. + + Note: + "".. <-- this chars are not realy necessary and it works without fine, + spaces between brackets and chars also not necessary (see in my func's). + + I hope, I could help to save the old way of TitanGold :-) +]]-- +--- functions to check the work after manipulate an singulary array or an array with subarrays +local function printArray(t)for k, v in pairs(t)do print(k..": ", v)end end +local function printTable(t)for k, v in pairs(t)do if type(v) == "table" then print(k..": ")printArray(v)else print(k..": ", v)end end end + +local function MySort(copy, i, sort_by) + if sort_by == "NameAsc" then table.sort(copy[i], function(key1, key2)return key1.char_name < key2.char_name;end) + elseif sort_by == "GoldAsc" then table.sort(copy[i], function(key1, key2)return key1.gold < key2.gold;end) + elseif sort_by == "GoldDec" then table.sort(copy[i], function(key1, key2)return key1.gold > key2.gold;end) + else end +end + +-- ====== Tool tip routines +---Take a table of toons to sort per user settings: @param gold_table table; @return table sorted May not be need but it is explicit +local function SortByIndex(gold_table) + --- function to hard copy an array + local function deepcopy(orig) + local orig_type = type(orig) + local copy; + if orig_type == 'table' then copy = {} + for orig_key, orig_value in next, orig, nil do copy[deepcopy(orig_key)] = deepcopy(orig_value)end + setmetatable(copy, deepcopy(getmetatable(orig))) + else copy = orig;end + return copy; + end + -- save array for safety + local origin = deepcopy(gold_table) + -- original sourcecode + local sort_by = TitanGetVar(TITAN_GOLD_ID, "SortByName") + --- Yeah, after a feeling from 1000 of hours the function is ready for use (I hope so, because I don't have many Chars in retail). + if TitanGetVar(TITAN_GOLD_ID, "AllServers")then + local copy, sorting, test, a, p = {}, {}, {}, 0, "" --(arrays and container for internal use) + for _, subTable in pairs(gold_table)do + local value = subTable["server"] + if value ~= nil then + if not sorting[value]then + sorting[value] = true; + a = a + 1; + end + end + end + for value, _ in pairs(sorting)do table.insert(test, value)end + table.sort(test, function(key1, key2)return key1 < key2;end) + for i = 1, a do copy[i] = deepcopy(gold_table) + if sort_by == "NameAsc" then table.sort(copy[i], function(key1, key2)return key1.char_name < key2.char_name;end) + elseif sort_by == "GoldAsc" then table.sort(copy[i], function(key1, key2)return key1.gold < key2.gold;end) + elseif sort_by == "GoldDec" then table.sort(copy[i], function(key1, key2)return key1.gold > key2.gold;end) + else end + for k = #copy[i], 1, -1 do + if string.match(copy[i][k].server, " ")then p = string.gsub(copy[i][k].server, " ", "")else p = copy[i][k].server;end + if p ~= test[i]then table.remove(copy[i], k)end + end + end + gold_table = {} + for i = 1, a do + for _, value in pairs(copy[i])do table.insert(gold_table, value)end + end + elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers")then local copy, p = {}, "" + for i = 1, #realmNames do copy[i] = deepcopy(gold_table) + if sort_by == "NameAsc" then table.sort(copy[i], function(key1, key2)return key1.char_name < key2.char_name;end) + elseif sort_by == "GoldAsc" then table.sort(copy[i], function(key1, key2)return key1.gold < key2.gold;end) + elseif sort_by == "GoldDec" then table.sort(copy[i], function(key1, key2)return key1.gold > key2.gold;end) + else end + for k = #copy[i], 1, -1 do + if string.match(copy[i][k].server, " ")then p = string.gsub(copy[i][k].server, " ", "")else p = copy[i][k].server;end + if p ~= realmNames[i]then table.remove(copy[i], k)end + end + end + gold_table = {} + for i = 1, #realmNames do + for _, value in ipairs(copy[i])do table.insert(gold_table, value)end + end + elseif TitanGetVar(TITAN_GOLD_ID, "SeparateServers")then + -- This section will sort the array based on user preference: * by name or by gold amount descending, * grouping by realm if selected + if sort_by == "NameAsc" then table.sort(gold_table, function(key1, key2)return key1.char_name < key2.char_name;end) + -- by gold ascending + elseif sort_by == "GoldAsc" then table.sort(gold_table, function(key1, key2)return key1.gold < key2.gold;end) + -- by gold descending + elseif sort_by == "GoldDec" then table.sort(gold_table, function(key1, key2)return key1.gold > key2.gold;end) + -- should not get here + else end + else end + return gold_table; +end + +---local Generate formatted tooltip text: @return string +local function GetTooltipText() + local GoldSorted = {} + local currentMoneyRichText = "" + local countelements = 0; --(unused outside the next "for"-loop) + local faction = GoldInfo.factionName; + local ignore_faction = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction") + for _ in pairs(realmNames)do countelements = countelements + 1;end + -- insert all keys from hash into the GoldSorted array + if TitanGetVar(TITAN_GOLD_ID, "SeparateServers")then + -- Parse the database and display characters from this server + Titan_Debug.Out('gold', 'tool_tip', "=== SeparateServers") + for index, money in TitanUtils_PlayerIter()do local char = EvalIndexInfo(index) + if char.valid then + if char.same_realm and char.show_toon then + Titan_Debug.Out('gold', 'tool_tip', index.." "..NiceCash(char.gold, false, false)) + table.insert(GoldSorted, char) + end + end + end + elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers")then + -- Parse the database and display characters from merged / connected servers + Titan_Debug.Out('gold', 'tool_tip', "=== MergeServers") + for index, money in TitanUtils_PlayerIter()do local char = EvalIndexInfo(index) + if char.valid then + if char.merge_realm and char.show_toon then + Titan_Debug.Out('gold', 'tool_tip', index.." "..NiceCash(char.gold, false, false)) + table.insert(GoldSorted, char) + end + end + end + elseif TitanGetVar(TITAN_GOLD_ID, "AllServers")then + -- Parse the database and display characters from all servers + Titan_Debug.Out('gold', 'tool_tip', "=== AllServers") + for index, money in TitanUtils_PlayerIter()do local char = EvalIndexInfo(index) + if char.valid then + if char.show_toon then + Titan_Debug.Out('gold', 'tool_tip', index.." "..NiceCash(char.gold, false, false)) + table.insert(GoldSorted, char) + end + end + end + end + local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") + GoldSorted = SortByIndex(GoldSorted) + -- Array holds all characters to display, nicely sorted. + currentMoneyRichText = "" + local coin_str = "" + local faction_text = "" + local curr_realm = "" + local show_dash = false; + local show_realm = true; + local character, charserver, char_faction; + for i = 1, #GoldSorted do + local toon = GoldSorted[i] + character = toon.char_name; + charserver = toon.server; + char_faction = toon.faction; + local t_gold = toon.gold; + coin_str = NiceCash(t_gold, false, false) + show_dash = false; + show_realm = true; + if(TitanGetVar(TITAN_GOLD_ID, "SeparateServers"))then show_realm = false; + elseif(TitanGetVar(TITAN_GOLD_ID, "MergeServers"))then show_dash = true; + elseif(TitanGetVar(TITAN_GOLD_ID, "AllServers"))then show_dash = true;end + if by_realm then + -- Set a realm header + if charserver ~= curr_realm then + currentMoneyRichText = currentMoneyRichText.."\n-- "..charserver; + curr_realm = charserver; + end + show_dash = false; + show_realm = false; + end + if ignore_faction then + if char_faction == TITAN_ALLIANCE then faction_text = " |TInterface/AddOns/TitanGold/Artwork/UI_AllianceIcon-round:"..TitanPanelGetVar("FontSize")..":"..TitanPanelGetVar("FontSize")..":2:0|t" + elseif char_faction == TITAN_HORDE then faction_text = " |TInterface/AddOns/TitanGold/Artwork/UI_HordeIcon-round:"..TitanPanelGetVar("FontSize")..":"..TitanPanelGetVar("FontSize")..":2:0|t" end + end + currentMoneyRichText = currentMoneyRichText.."\n"..character..(show_dash and "-" or "")..(show_realm and charserver or "")..faction_text.."\t"..coin_str; + end + -- === Add Warband Bank + if Warband.Use()then + local cash = NiceCash(Warband.GetSum(), false, false) + local war_name = Warband.GetName() -- localized + currentMoneyRichText = currentMoneyRichText.."\n------\t+\n"..war_name.."\t"..cash; + local msg = war_name.." "..cash; + Titan_Debug.Out('gold', 'tool_tip', msg) + end + -- === Add Total per user options + -- Display total gold + coin_str = NiceCash(TotalGold(), false, false) + currentMoneyRichText = currentMoneyRichText.."\n-------------------------\t----------------------\n"..L["TITAN_GOLD_TTL_GOLD"]..":\t"..coin_str; + -- find session earnings and earning per hour + local sesstotal = Get_Money() - GOLD_STARTINGGOLD; + local negative = false; + if(sesstotal < 0)then + sesstotal = math.abs(sesstotal) + negative = true; + end + local sesslength = GetTime() - GOLD_SESSIONSTART; + local perhour = math.floor(sesstotal / sesslength * 3600) + coin_str = NiceCash(GOLD_STARTINGGOLD, false, false) + local session_status; + local per_hour_status; + local sessionMoneyRichText = "" + if TitanGetVar(TITAN_GOLD_ID, "ShowSessionInfo")then + sessionMoneyRichText = "\n\n"..TitanUtils_GetHighlightText(L["TITAN_GOLD_STATS_TITLE"]).."\n"..L["TITAN_GOLD_START_GOLD"].."\t"..coin_str.."\n" + if(negative)then + session_status = TitanUtils_GetRedText(L["TITAN_GOLD_SESS_LOST"]) + per_hour_status = TitanUtils_GetRedText(L["TITAN_GOLD_PERHOUR_LOST"]) + else + session_status = TitanUtils_GetGreenText(L["TITAN_GOLD_SESS_EARNED"]) + per_hour_status = TitanUtils_GetGreenText(L["TITAN_GOLD_PERHOUR_EARNED"]) + end + coin_str = NiceCash(sesstotal, true, true) + sessionMoneyRichText = sessionMoneyRichText..session_status.."\t"..coin_str.."\n" + if TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour")then + coin_str = NiceCash(perhour, true, true) + sessionMoneyRichText = sessionMoneyRichText..per_hour_status.."\t"..coin_str.."\n" + end + else + -- Do not display session info + end + -- === Add Gold notes and info + local final_tooltip = TitanUtils_GetGoldText(L["TITAN_GOLD_TOOLTIPTEXT"]..": ") + local final_server = "" + if realmNames == nil or TitanGetVar(TITAN_GOLD_ID, "SeparateServers")then final_server = realmName; + elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers")then final_server = L["TITAN_GOLD_MERGED"] + elseif TitanGetVar(TITAN_GOLD_ID, "AllServers")then final_server = ALL;end + final_server = TitanUtils_GetGoldText(final_server.." ") + local final_faction = "" + if ignore_faction then final_faction = TitanUtils_GetGoldText(ALL) + elseif faction == TITAN_ALLIANCE then final_faction = final_server.."("..TitanUtils_GetHexText(FACTION_ALLIANCE, Titan_Global.colors.alliance)..")" + elseif faction == TITAN_HORDE then final_faction = final_server.."("..TitanUtils_GetHexText(FACTION_HORDE, Titan_Global.colors.horde)..")" end + return "\n"..final_tooltip.."\t"..final_faction.."\n-------------------------\t----------------------"..currentMoneyRichText.."\n"..sessionMoneyRichText;--- this is the output what I prefer +end +--]===] + +--[===[ ---Take a table of toons to sort per user settings ---@param gold_table table ---@return table sorted May not be need but it is explicit @@ -659,6 +893,7 @@ print("TG" .. sessionMoneyRichText end -- ====== +--]===] -- ====== Right click menu routines diff --git a/TitanXP/TitanXP.lua b/TitanXP/TitanXP.lua index 35b03a2..ec340a7 100644 --- a/TitanXP/TitanXP.lua +++ b/TitanXP/TitanXP.lua @@ -44,41 +44,6 @@ local txp = { sessionTime = 0, } ---****** overload the 'time played' text to Chat - if XP requested the API call -local requesting - --- Save orignal output to Chat --- somewhere in 11.* (The World Within) this changed -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 - - 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 - -- ******************************** Functions ******************************* ---local Set icon based on faction @@ -163,7 +128,7 @@ end -- Override ChatFrame_DisplayTimePlayed used by RequestTimePlayed(). -- TIME_PLAYED_MSG used to send response. local function RefreshPlayed() - txp.frame:RequestTimePlayed() + TitanUtils_GetTimePlayed() end ---local Display the plugin on selected Titan bar; register events; start timer; and init vars @@ -628,12 +593,6 @@ local function Create_Frames() -- window:SetScript("OnUpdate", function(self, elapsed) -- OnUpdate(self, elapsed) -- end) - - -- Do not output Chat messages when using RequestTimePlayed - function window:RequestTimePlayed() - requesting = true - RequestTimePlayed() - end end end