diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index c65cc0f..f62e618 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -10,7 +10,7 @@ Created and initially commited on : July 29th, 2008 The spec: https://github.com/tekkub/libdatabroker-1-1 LDB (libdatabroker) is a small library that enables an addon to hook into a 'display' addon such as Titan. -=== Creation +--- Creation The addon dev creates an LDB object which the lib places in storage accessible by lib:DataObjectIterator(). It also fires a "LibDataBroker_DataObjectCreated" callback. @@ -19,21 +19,21 @@ When an LDB addon changes one of its values, the lib fires a callback for the di The LDB addon may declare scripts (tooltip, mouse clicks, etc.) per the spec for the display addon to use. -=== Starting from Titan view +--- Starting from Titan view On PLAYER_ENTERING_WORLD, Titan will use the iterator to wrap each LDB type addon into a Titan plugin. Once done processing the known LDB objects, Titan registers for the callback to handle LDB objects created later or on demand. Titan registers for callbacks on text and icon updates - depending on the LDB type. -=== Running from Titan view +--- Running from Titan view The LDB addon is responsible for setting and changing its text and icon. Titan is responsible for updating the Titan plugin in response. The Titan plugin will use the LDB addon scripts IF declared, again depending on the LDB type. -=== Supported +--- Supported Only LDB types listed in the LDB 1.1 spec are supported by Titan. - "launcher" become "icon" plugins - TitanPanelIconTemplate @@ -149,11 +149,12 @@ end ---Titan Properly anchor tooltips of the Titan (LDB) plugin ---@param parent table Parent frame ---@param anchorPoint string ----@param relativeToFrame table +---@param relativeToFrame table|string ---@param relativePoint string ---@param xOffset number ---@param yOffset number ----@param frame table Tolltip frame +---@param frame table|string Tooltip frame +--- relativeToFrame and frame are really ScriptRegion|string for GameTooltip function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) if frame:GetName() == "GameTooltip" then -- Changes for 9.1.5 Removed the background template from the GameTooltip @@ -177,8 +178,8 @@ end ---Titan Fill in the tooltip for the Titan (LDB) plugin ---@param name string Plugin id name for LDB ---@param frame table Tooltip frame ----@param func function Tooltip function to be run -function LDBToTitan:TitanLDBSetTooltip(name, frame, func) +---@param tt_func function? Tooltip function to be run +function LDBToTitan:TitanLDBSetTooltip(name, frame, tt_func) -- Check to see if we allow tooltips to be shown if not TitanPanelGetVar("ToolTipsShown") or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then @@ -216,7 +217,7 @@ function LDBToTitan:TitanLDBSetTooltip(name, frame, func) else end - if func and If_Show_Tooltip() then func(frame) end; -- TODO: use pcall?? + if tt_func and If_Show_Tooltip() then tt_func(frame) end; -- TODO: use pcall?? frame:Show(); end diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 409fe64..607fe7b 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -764,7 +764,6 @@ end ---@param text string Text to wrap ---@param color any See color:GetRGB() / color:GetRGBA() ---@return string text Custom color encoded string ---- TitanUtils_GetColoredText(GOLD_PERHOUR_STATUS, TITAN_GOLD_GREEN) function TitanUtils_GetColoredText(text, color) local res = "" if (color and text) then @@ -911,9 +910,7 @@ end ---@return integer gold part of value ---@return integer silver part of value ---@return integer copper part of value -function TitanUtils_CashToString(value, thousands_separator, decimal_separator, - only_gold, show_labels, show_icons, - add_color) +function TitanUtils_CashToString(value, thousands_separator, decimal_separator, only_gold, show_labels, show_icons, add_color) local show_zero = true local show_neg = true @@ -999,19 +996,25 @@ function TitanUtils_CashToString(value, thousands_separator, decimal_separator, -- now make the coin strings if gold > 0 then local gnum = TitanUtils_NumToString(gold, thousands_separator, decimal_separator) - gold_str = TitanUtils_GetHexText(gnum..g_lab .. " ", gc) --gc .. (gnum) .. g_lab .. " " .. FONT_COLOR_CODE_CLOSE + gold_str = TitanUtils_GetHexText(gnum..g_lab .. " ", gc) else gold_str = "" end if (silver > 0) then local snum = (string.format("%02d", silver) or "?") - silver_str = TitanUtils_GetHexText(snum..s_lab .. " ", sc) --sc .. (silver or "?") .. s_lab .. " " .. FONT_COLOR_CODE_CLOSE + silver_str = TitanUtils_GetHexText(snum..s_lab .. " ", sc) + elseif (string.len(gold_str) > 0) then -- space if gold present + local snum = (string.format("%02d", 0) or "?") + silver_str = TitanUtils_GetHexText(snum..s_lab .. " ", sc) else silver_str = "" end if (copper > 0) then local cnum = (string.format("%02d", copper) or "?") - copper_str = TitanUtils_GetHexText(cnum..c_lab, cc) --cc .. (copper or "?") .. c_lab .. "" .. FONT_COLOR_CODE_CLOSE + copper_str = TitanUtils_GetHexText(cnum..c_lab, cc) + elseif (string.len(silver_str) > 0) then -- space if silver present + local cnum = (string.format("%02d", 0) or "?") + copper_str = TitanUtils_GetHexText(cnum..c_lab, cc) else copper_str = "" end diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index 04b8ae5..fc2aad4 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -40,16 +40,6 @@ if (GetLocale() == "ruRU") then end local TPC = TITAN_PANEL_CONSTANTS -- shortcut ---[===[ Titan -NAME: Titan bar overview -DESC: --- 3 button frames are used to create a Titan bar: --- the 'display' button frame - the bar itself, --- the 'hider' which is a blank 1/2 height bar to capture the cursor moving to the bar, --- and the 'auto hide' plugin displaying the 'push pin' button. -:DESC ---]===] - --[===[ Var TitanBarData table. The table holds: diff --git a/Titan/_ATitanDoc.lua b/Titan/_ATitanDoc.lua index 9c8221f..6f3eef0 100644 --- a/Titan/_ATitanDoc.lua +++ b/Titan/_ATitanDoc.lua @@ -32,13 +32,6 @@ There are diagnostic annotations used to ignore some warnings. Ignore warning annotations were limited as much as practical to 'this line' to point out usage of Classic routines. === Documentation blocks -Within the document are Titan routines available to a plugin developer. - -There are three files contributing to Titan documentation. -- Titan_API_<time>.lua - for Titan plugin developers -- Titan_Dev_<time>.lua - for Titan developers -- Titan_File_<time>.lua - for Titan developers - These are created from annotations in the Lua files. API : These are routines Titan will keep stable. @@ -49,7 +42,6 @@ These are global routines Tian uses. These may change at any time per Titan need File : Each file has a terse description of its contents. - --]===] --[===[ Titan Start editing @@ -68,7 +60,7 @@ Using a text editor with code folding features will make this file easier to rea For simple changes, install a code / text editor. NotepadPlusPlus is a very popular editor. For more in delpth changes consider using an IDE (Integrated Development Environment). -The file TitanIDE contains details on tools and ammotation. +The file TitanIDE contains details on tools and annotation. Regardless of tools used, please update any annotations and comments as changes are made!!! @@ -162,6 +154,9 @@ When ADDON_LOADED event is received, - Titan registers for event PLAYER_ENTERING_WORLD - Titan ensures its saved variables are whole and known player profiles are read. +NOTE: On ADDON_LOADED is the first time saved variables should be considered loaded and safe!! +EUsing saved variables before is likely to result in nil(s). Such as when WoW parses the addon code as it is loading. + Next: ==== Waiting for WoW WoW fires a bunch of events as this and other addons are loaded. Eventually the game and all addons are loaded and PLAYER_ENTERING_WORLD event is sent @@ -176,7 +171,7 @@ TitanPanel_PlayerEnteringWorld does all the variable and profile setup for the c On first PLAYER_ENTERING_WORLD (not reload) Titan - Sets character profiles - TitanVariables_InitTitanSettings - Sets TitanPanel*Anchor for other addons to adjust for Titan -- Creates all Titan bars - TitanPanelButton_CreateBar - including right click menu and auto hide frames +- Creates all Titan bars including right click menu and auto hide frames. See Frames below. - Registers for events Titan uses - RegisterForEvents On login and reload Titan @@ -196,7 +191,16 @@ If the above failed with an error then - nuke the Titan config tables as cleanup --]===] ---[[ Frame Scripts +--[[ Frames and Frame Scripts +Here we detour into XML. TitanTemplate.xml contains the frames used by Titan. +- TitanPanelBarButton : This "is" Titan in the sense that it has all events attached to it and all the code. +- Titan_Bar__Display_Template : The template (Button) for a Titan bar. +- TitanPanelBarButtonHiderTemplate : The template (Button) paired a full width Titan bar to allow hiding and unhiding the paired Titan Bar. +- TitanPanelTooltip : This or GameTooltip is used for tool tips. + +TitanPanelButton_CreateBar in Titan.lua creates the full width bars and short bars by looping through TitanBarData. +TitanBarData in TitanVariables.lua holds creation data for each bar. +TitanBarDataVars holds the Titan and user settings for each bar. An initial setup (fresh / another install) uses TitanBarVarsDefaults. The frame scripts are how WoW and Titan interact with this addon. @@ -225,12 +229,12 @@ Titan.lua sets the OnEvent stript for TitanPanelBarButton to redirect events to See local function RegisterForEvents for the list of eventsand their usage. --]] ---[[ Plugin registry +--[[ Plugin .registry === Titan plugins The routine - TitanUtils_RegisterPluginList - starts the plugin registry process. -=== LDB objects See LDBTitan.lua for many more details. +=== LDB objects : See LDBTitan.lua for many more details. The OnEvent script of LDBToTitan frame processes the PLAYER_LOGIN event. This starts the process to convert all known LDB objects into Titan plugins. diff --git a/Titan/_TitanIDE.lua b/Titan/_TitanIDE.lua index a6232c6..5a01704 100644 --- a/Titan/_TitanIDE.lua +++ b/Titan/_TitanIDE.lua @@ -98,6 +98,8 @@ end --====== WoW localized globals -- Should be handled by the WoW extension +ACCOUNT_QUEST_LABEL = "" -- 11.0.0 New Warbank - Hopefully WoW API extension will catch up soon +ACCOUNT_BANK_PANEL_TITLE = "" -- 11.0.0 New Warbank - Hopefully WoW API extension will catch up soon --====== WoW frames PetActionBarFrame = {} @@ -116,6 +118,9 @@ FCF_UpdateDockPosition = {} TargetFrame_Update = {} VideoOptionsFrameOkay_OnClick = {} +C_Bank = {} -- 11.0.0 New Warbank - Hopefully WoW API extension will catch up soon + + --====== Convince IDE we know what we are doing -- Lua allows table updates but the IDE complains about 'injecting' a field it does not know about. -- Adding a function or variable to a frame in this case. diff --git a/TitanAmmo/TitanAmmo_Classic.toc b/TitanAmmo/TitanAmmo_Classic.toc index 9825a98..842cd5d 100644 --- a/TitanAmmo/TitanAmmo_Classic.toc +++ b/TitanAmmo/TitanAmmo_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanAmmo/TitanAmmo_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanAmmo/TitanAmmo_Cata.toc ## Notes: Adds an ammo monitor to Titan Panel - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanBag/TitanBag_Classic.toc b/TitanBag/TitanBag_Classic.toc index 3cafe86..a0b3b36 100644 --- a/TitanBag/TitanBag_Classic.toc +++ b/TitanBag/TitanBag_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanBag/TitanBag_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 11503 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanBag/TitanBag_Vanilla.toc ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClassic/TitanClassic_Classic.toc b/TitanClassic/TitanClassic_Classic.toc index 94e0354..7e46520 100644 --- a/TitanClassic/TitanClassic_Classic.toc +++ b/TitanClassic/TitanClassic_Classic.toc @@ -1,12 +1,7 @@ -<<<<<<< HEAD:TitanClassic/TitanClassic_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.15|r -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.16|r ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanClassic/TitanClassic_Cata.toc ## Author: Titan Panel Dev Team -## Version: 8.0.16 +## Version: 8.0.15 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds display bars to show and control information/launcher plugins. diff --git a/TitanClock/TitanClock_Classic.toc b/TitanClock/TitanClock_Classic.toc index a748f95..3ba84e4 100644 --- a/TitanClock/TitanClock_Classic.toc +++ b/TitanClock/TitanClock_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanClock/TitanClock_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 11503 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanClock/TitanClock_Vanilla.toc ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua index 8132cc5..6d94f07 100644 --- a/TitanGold/TitanGold.lua +++ b/TitanGold/TitanGold.lua @@ -10,34 +10,37 @@ -- ******************************** Constants ******************************* local TITAN_GOLD_ID = "Gold"; local TITAN_BUTTON = "TitanPanel" .. TITAN_GOLD_ID .. "Button" -local TITAN_GOLD_COUNT_FORMAT = "%d"; local TITAN_GOLD_VERSION = TITAN_VERSION; local TITAN_GOLD_SPACERBAR = "-----------------------"; -local TITAN_GOLD_BLUE = { r = 0.4, b = 1, g = 0.4 }; -local TITAN_GOLD_RED = { r = 1, b = 0, g = 0 }; -local TITAN_GOLD_GREEN = { r = 0, b = 0, g = 1 }; local updateTable = { TITAN_GOLD_ID, TITAN_PANEL_UPDATE_TOOLTIP }; -- ******************************** Variables ******************************* +GoldSave = {} -- saved vars in TOC local GOLD_INITIALIZED = false; local GOLD_INDEX = ""; -local GOLD_COLOR; -local GOLD_SESS_STATUS; -local GOLD_PERHOUR_STATUS; +local WARBAND_INDEX = "" local GOLD_STARTINGGOLD; local GOLD_SESSIONSTART; -local TitanGold = LibStub("AceAddon-3.0"):NewAddon("TitanGold") local AceTimer = LibStub("AceTimer-3.0") local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local GoldTimer = {}; local GoldTimerRunning = false local _G = getfenv(0); -local realmName = GetRealmName(); -local realmNames = GetAutoCompleteRealms(); +local realmName = "" -- fill on PEW +local realmNames = {} -- fill on PEW +local merged_realms = {} -- fill on PEW -- English faction for indexing and sorting and coloring local TITAN_ALLIANCE = "Alliance" local TITAN_HORDE = "Horde" +local TITAN_WARBAND= "Warband" + +local player_faction, player_faction_locale = UnitFactionGroup("Player") + +-- check for func even though it does not work atm... 2024 Aug (Added 11.0.0) +local warband_active = (C_Bank and C_Bank.CanUseBank) and true or false +local warband_toon = ACCOUNT_BANK_PANEL_TITLE or "WarBand Bank" -- may not be the best... +local warband_server = "WarBandBank" -- may not be the best... --[[ debug local FACTION_ALLIANCE = "Alliance_debug" @@ -45,7 +48,50 @@ local FACTION_HORDE = "Horde_debug" --]] -- ******************************** Functions ******************************* ----local Break apart Gold index <character>_<server>::<faction> +---Take a table of indexes to sort GoldSave +---@param gold_table table +---@return table sorted May not be need but it is explicit +local function SortByIndex(gold_table) + local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") + local by_name = TitanGetVar(TITAN_GOLD_ID, "SortByName") + -- This section will sort the array based on user preference + -- * by name or by gold amount descending + -- * grouping by realm if selected + if by_name then + table.sort(gold_table, function(key1, key2) + if by_realm then + if GoldSave[key1].realm ~= GoldSave[key2].realm then + return GoldSave[key1].realm < GoldSave[key2].realm + end + end + + return GoldSave[key1].name < GoldSave[key2].name + end) + else + table.sort(gold_table, function(key1, key2) + if by_realm then + if GoldSave[key1].realm ~= GoldSave[key2].realm then + return GoldSave[key1].realm < GoldSave[key2].realm + end + end + + return GoldSave[key1].gold > GoldSave[key2].gold + end) + end + + return gold_table +end + +---local Create Gold index <character>_<server>::<faction> +---@param character string +---@param charserver string +---@param char_faction string +local function CreateIndex(character, charserver, char_faction) + local index = character .. "_" .. charserver .. "::" .. char_faction + return index +end + +---local Break apart Gold index ---@param info string ---@return string ---@return string @@ -55,21 +101,63 @@ local function GetIndexInfo(info) return character, charserver, char_faction end ----local Based on user option, add comma or period in the value given, as needed ----@param amount number ----@return string -local function comma_value(amount) - local sep = "" - local dec = "" - if (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma")) then - sep = "," - dec = "." +---@class IndexInfo Index flags +---@field valid boolean Saved toon is valid +---@field char_name string Saved toon name +---@field server string Saved toon server +---@field faction string Saved toon faction +---@field same_faction boolean Saved toon faction is same as player +---@field ignore_faction boolean User selection to ignore faction or not +---@field same_realm boolean Saved realm is same as this server +---@field merge_realm boolean Saved realm is in mergerd server list (connected servers) +---@field show_toon boolean Show server - simple test + +---local Take Gold index and return parts plus various flags +---@param index string +---@return IndexInfo +local function EvalIndexInfo(index) + local res = {valid = false} + local character, charserver, char_faction = GetIndexInfo(index) + + if character then + res.valid = true + + res.char_name = character + res.server = charserver + res.faction = char_faction + + res.ignore_faction = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction") + + if (char_faction == player_faction) or char_faction == TITAN_WARBAND then + res.same_faction = true + else + res.same_faction = false + end + + if (charserver == realmName) or (charserver == warband_server) then + res.same_realm = true + else + res.same_realm = false + end + + local saved_server = string.gsub(charserver, "%s", "") -- GetAutoCompleteRealms removes spaces, idk why... + if merged_realms[saved_server] or (charserver == warband_server) then + res.merge_realm = true + else + res.merge_realm = false + end + + if (res.ignore_faction or res.same_faction) + and GoldSave[index].show then + res.show_toon = true + else + res.show_toon = false + end else - sep = "." - dec = "," + -- do not fill in end - return TitanUtils_NumToString(amount, sep, dec) + return res end ---local Take the total cash and make it into a nice, colorful string of g s c (gold silver copper) @@ -81,115 +169,17 @@ end ---@return integer silver part of value ---@return integer copper part of value local function NiceCash(value, show_zero, show_neg) - --[[ - local neg1 = "" - local neg2 = "" - local agold = 10000; - local asilver = 100; - local outstr = ""; - local gold = 0; - local gold_str = "" - local gc = "|cFFFFFF00" - local silver = 0; - local silver_str = "" - local sc = "|cFFCCCCCC" - local copper = 0; - local copper_str = "" - local cc = "|cFFFF6600" - local amount = (value or 0) - local cash = (amount or 0) - local font_size = TitanPanelGetVar("FontSize") - local icon_pre = "|TInterface\\MoneyFrame\\" - local icon_post = ":" .. font_size .. ":" .. font_size .. ":2:0|t" - local g_icon = icon_pre .. "UI-GoldIcon" .. icon_post - local s_icon = icon_pre .. "UI-SilverIcon" .. icon_post - local c_icon = icon_pre .. "UI-CopperIcon" .. icon_post - -- build the coin label strings based on the user selections - local show_labels = TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels") - local show_icons = TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons") - local c_lab = (show_labels and L["TITAN_GOLD_COPPER"]) or (show_icons and c_icon) or "" - local s_lab = (show_labels and L["TITAN_GOLD_SILVER"]) or (show_icons and s_icon) or "" - local g_lab = (show_labels and L["TITAN_GOLD_GOLD"]) or (show_icons and g_icon) or "" - - -- show the money in highlight or coin color based on user selection - if TitanGetVar(TITAN_GOLD_ID, "ShowColoredText") then - gc = "|cFFFFFF00" - sc = "|cFFCCCCCC" - cc = "|cFFFF6600" - else - gc = _G["HIGHLIGHT_FONT_COLOR_CODE"] - sc = _G["HIGHLIGHT_FONT_COLOR_CODE"] - cc = _G["HIGHLIGHT_FONT_COLOR_CODE"] - end - - if show_neg then - if amount < 0 then - neg1 = "|cFFFF6600" .. "(" .. FONT_COLOR_CODE_CLOSE - neg2 = "|cFFFF6600" .. ")" .. FONT_COLOR_CODE_CLOSE - else - neg2 = " " -- need to pad for other negative numbers - end - end - if amount < 0 then - amount = amount * -1 - end - - if amount == 0 then - if show_zero then - copper_str = cc .. (amount or "?") .. c_lab .. "" .. FONT_COLOR_CODE_CLOSE - end - elseif amount > 0 then - -- figure out the gold - silver - copper components - gold = (math.floor(amount / agold) or 0) - amount = amount - (gold * agold); - silver = (math.floor(amount / asilver) or 0) - copper = amount - (silver * asilver) - -- now make the coin strings - if gold > 0 then - gold_str = gc .. (comma_value(gold) or "?") .. g_lab .. " " .. FONT_COLOR_CODE_CLOSE - silver_str = sc .. (string.format("%02d", silver) or "?") .. s_lab .. " " .. FONT_COLOR_CODE_CLOSE - copper_str = cc .. (string.format("%02d", copper) or "?") .. c_lab .. "" .. FONT_COLOR_CODE_CLOSE - elseif (silver > 0) then - silver_str = sc .. (silver or "?") .. s_lab .. " " .. FONT_COLOR_CODE_CLOSE - copper_str = cc .. (string.format("%02d", copper) or "?") .. c_lab .. "" .. FONT_COLOR_CODE_CLOSE - elseif (copper > 0) then - copper_str = cc .. (copper or "?") .. c_lab .. "" .. FONT_COLOR_CODE_CLOSE - end - end - - if TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly") then - silver_str = "" - copper_str = "" - -- special case for those who want to show only gold - if gold == 0 then - if show_zero then - gold_str = gc .. "0" .. g_lab .. " " .. FONT_COLOR_CODE_CLOSE - end - end - end - - -- build the return string - outstr = outstr - .. neg1 - .. gold_str - .. silver_str - .. copper_str - .. neg2 -print("Acc cash:" -..(gold or "?").."g " -..(silver or "?").."s " -..(copper or "?").."c " -..(outstr or "?") -); ---]] local sep = "" local dec = "" if (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma")) then sep = "," dec = "." - else + elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod")) then sep = "." dec = "," + elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorSpace")) then + sep = " " + dec = "." end local outstr, gold, silver, copper = @@ -203,23 +193,29 @@ end ---local Create Show menu - list of characters in same faction ---@param faction string -local function ShowMenuButtons(faction) +---@param level number +local function ShowMenuButtons(faction, level) + TitanPanelRightClickMenu_AddTitle(L["TITAN_GOLD_SHOW_PLAYER"], level) local info = {}; + -- Sort names for the menu list + local GoldSorted = {}; for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); - if character - and (char_faction == faction) - then + table.insert(GoldSorted, index) + end + GoldSorted = SortByIndex(GoldSorted) + + for i = 1, getn(GoldSorted) do + local index = GoldSorted[i] + local character, charserver, char_faction = GetIndexInfo(index) + if character and (char_faction == faction) then info.text = character .. " - " .. charserver; info.value = character; info.keepShownOnClick = true; info.checked = function() - local rementry = character .. "_" .. charserver .. "::" .. faction; - return GoldSave[rementry].show + return GoldSave[index].show end info.func = function() - local rementry = character .. "_" .. charserver .. "::" .. faction; - GoldSave[rementry].show = not GoldSave[rementry].show; + GoldSave[index].show = not GoldSave[index].show; TitanPanelButton_UpdateButton(TITAN_GOLD_ID) end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); @@ -229,21 +225,38 @@ end ---local Create Delete menu - list of characters in same faction ---@param faction string -local function DeleteMenuButtons(faction) +---@param level number +local function DeleteMenuButtons(faction, level) + TitanPanelRightClickMenu_AddTitle(L["TITAN_GOLD_DELETE_PLAYER"], level) + local info = {}; local name = GetUnitName("player"); local server = realmName; + + -- Sort names for the menu list + local GoldSorted = {}; for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, "(.*)_(.*)::"..faction); + table.insert(GoldSorted, index) + end + GoldSorted = SortByIndex(GoldSorted) + + for i = 1, getn(GoldSorted) do + local index = GoldSorted[i] + local character, charserver, char_faction = GetIndexInfo(index) info.notCheckable = true - if character - and (char_faction == faction) - then + if character and (char_faction == faction) then info.text = character .. " - " .. charserver; info.value = character; info.func = function() - local rementry = character .. "_" .. charserver .. "::" .. faction; - GoldSave[rementry] = nil; + print("Del" + .." "..tostring(index).."" + .." "..tostring(GoldSave[index].gold).."" + ) + GoldSave[index] = {} + GoldSave[index] = nil + print("Del" + .." "..tostring(GoldSave[index]).."" + ) TitanPanelButton_UpdateButton(TITAN_GOLD_ID) end -- cannot delete current character @@ -278,16 +291,23 @@ local function ShowProperLabels(chosen) TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end ----local Based on user Seperator selection set Comma | Period +---local Based on user Seperator selection set Comma | Period | Space ---@param chosen string local function Seperator(chosen) if chosen == "UseSeperatorComma" then TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", true); TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", false); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorSpace", false); end if chosen == "UseSeperatorPeriod" then TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", false); TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", true); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorSpace", false); + end + if chosen == "UseSeperatorSpace" then + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorComma", false); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorPeriod", false); + TitanSetVar(TITAN_GOLD_ID, "UseSeperatorSpace", true); end TitanPanelButton_UpdateButton(TITAN_GOLD_ID); end @@ -349,70 +369,40 @@ end local function TotalGold() local ttlgold = 0; local cnt = 0; - local countelements = 0; local faction = UnitFactionGroup("Player"); local coin_str = "" local character, charserver = "", "" local char_faction = "" local ignore_faction = TitanGetVar(TITAN_GOLD_ID, "IgnoreFaction") - for _ in pairs(realmNames) do - countelements = countelements + 1 - end - if TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then -- Parse the database and display all characters on this server - GoldSave[GOLD_INDEX].gold = GetMoney() - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - if (character) and (charserver == realmName) then - if ignore_faction or (char_faction == faction) then - ttlgold = ToonAdd(GoldSave[index].show, GoldSave[index].gold, ttlgold) - else - -- Do not show per flags - end + local char = EvalIndexInfo(index) + if char.valid and char.same_realm and char.show_toon then + ttlgold = ToonAdd(GoldSave[index].show, GoldSave[index].gold, ttlgold) else - -- Toon is not on connected / merged server + -- Do not show per flags end end elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then -- Parse the database and display characters on merged / connected servers - for ms = 1, countelements do - GoldSave[GOLD_INDEX].gold = GetMoney() - - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - -- GetAutoCompleteRealms removes spaces, idk why... - if (charserver) then - charserver = string.gsub(charserver, "%s", ""); - end - - if (character) and (charserver == realmNames[ms]) then - if ignore_faction or (char_faction == faction) then - ttlgold = ToonAdd(GoldSave[index].show, GoldSave[index].gold, ttlgold) - else - -- Do not show per flags - end - else - -- Toon is not on connected / merged server - end + for index, money in pairs(GoldSave) do + local char = EvalIndexInfo(index) + if char.valid and char.merge_realm and char.show_toon then + ttlgold = ToonAdd(GoldSave[index].show, GoldSave[index].gold, ttlgold) + else + -- Do not show per flags end end elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then -- Parse the database and display characters on all servers - GoldSave[GOLD_INDEX].gold = GetMoney() - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - if (character) then - if ignore_faction or (char_faction == faction) then + local char = EvalIndexInfo(index) + if char.valid and char.show_toon then ttlgold = ToonAdd(GoldSave[index].show, GoldSave[index].gold, ttlgold) - else - -- Do not show per flags - end else - -- Toon is invalid?? + -- Do not show per flags end end end @@ -422,14 +412,10 @@ end -- ====== Tool tip routines -local function GetToonInfo(info) - return info.name, info.realm, info.faction -end - ---local Generate formatted tooltip text ---@return string local function GetTooltipText() - local GoldSaveSorted = {}; + local GoldSorted = {}; local currentMoneyRichText = ""; local countelements = 0; local faction, faction_locale = UnitFactionGroup("Player") -- get localized faction @@ -442,95 +428,37 @@ local function GetTooltipText() -- if countelements == 0 or TitanGetVar(TITAN_GOLD_ID, "SeparateServers") then -- The check for no connected realms was confusing so use the 'merge' format -- if requested. - -- insert all keys from hash into the GoldSaveSorted array + -- 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 - GoldSave[GOLD_INDEX].gold = GetMoney() - local char_faction = "" - local character, charserver = "", "" - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - if (character) then - if (charserver == realmName) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end - end + local char = EvalIndexInfo(index) + if char.valid and char.same_realm and char.show_toon then + table.insert(GoldSorted, index); end end elseif TitanGetVar(TITAN_GOLD_ID, "MergeServers") then -- Parse the database and display characters from merged / connected servers - for ms = 1, countelements do - local server = realmNames[ms] - GoldSave[GOLD_INDEX].gold = GetMoney() - local character, charserver = "", "" - local char_faction = "" - - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetIndexInfo(index) - -- GetAutoCompleteRealms removes spaces, idk why... - if (charserver) then - charserver = string.gsub(charserver, "%s", ""); - end + for index, money in pairs(GoldSave) do + local char = EvalIndexInfo(index) - if (character) then - if (charserver == server) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end - end - end + if char.valid and char.merge_realm and char.show_toon then + table.insert(GoldSorted, index); end end elseif TitanGetVar(TITAN_GOLD_ID, "AllServers") then -- Parse the database and display characters from all servers - GoldSave[GOLD_INDEX].gold = GetMoney() - local character, charserver = "", "" - local char_faction = "" - for index, money in pairs(GoldSave) do - character, charserver, char_faction = GetToonInfo(GoldSave[index]) - if (character) then - if ignore_faction or (char_faction == faction) then - if GoldSave[index].show then - table.insert(GoldSaveSorted, index); - end - end + local char = EvalIndexInfo(index) + if char.valid and char.show_toon then + table.insert(GoldSorted, index); end end end local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") - -- This section will sort the array based on user preference - -- * by name or by gold amount descending - -- * grouping by realm if selected - if TitanGetVar(TITAN_GOLD_ID, "SortByName") then - table.sort(GoldSaveSorted, function(key1, key2) - if by_realm then - if GoldSave[key1].realm ~= GoldSave[key2].realm then - return GoldSave[key1].realm < GoldSave[key2].realm - end - end - - return GoldSave[key1].name < GoldSave[key2].name - end) - else - table.sort(GoldSaveSorted, function(key1, key2) - if by_realm then - if GoldSave[key1].realm ~= GoldSave[key2].realm then - return GoldSave[key1].realm < GoldSave[key2].realm - end - end - - return GoldSave[key1].gold > GoldSave[key2].gold - end) - end + GoldSorted = SortByIndex(GoldSorted) -- Array holds all characters to display, nicely sorted. currentMoneyRichText = "" @@ -540,18 +468,16 @@ local function GetTooltipText() local show_dash = false local show_realm = true local character, charserver, char_faction - for i = 1, getn(GoldSaveSorted) do - character, charserver, char_faction = GetIndexInfo(GoldSaveSorted[i]) --GetToonInfo(GoldSave[GoldSaveSorted[i]]) - coin_str = NiceCash(GoldSave[GoldSaveSorted[i]].gold, false, false) + for i = 1, getn(GoldSorted) do + character, charserver, char_faction = GetIndexInfo(GoldSorted[i]) + coin_str = NiceCash(GoldSave[GoldSorted[i]].gold, false, false) show_dash = false show_realm = true if (TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) then - -- charserver = "" -- do not repeat the server on each line show_realm = false elseif (TitanGetVar(TITAN_GOLD_ID, "MergeServers")) then show_dash = true - -- charserver = "-"..charserver elseif (TitanGetVar(TITAN_GOLD_ID, "AllServers")) then show_dash = true end @@ -564,15 +490,14 @@ local function GetTooltipText() curr_realm = charserver end show_dash = false - -- charserver = "" -- do not repeat the server on each line show_realm = false end if ignore_faction then if char_faction == TITAN_ALLIANCE then - faction_text = TitanUtils_GetHexText(GoldSave[GoldSaveSorted[i]].faction, Titan_Global.colors.alliance) + faction_text = TitanUtils_GetHexText(GoldSave[GoldSorted[i]].faction, Titan_Global.colors.alliance) elseif char_faction == TITAN_HORDE then - faction_text = "-" .. TitanUtils_GetHexText(GoldSave[GoldSaveSorted[i]].faction, Titan_Global.colors.horde) + faction_text = "-" .. TitanUtils_GetHexText(GoldSave[GoldSorted[i]].faction, Titan_Global.colors.horde) end end @@ -589,7 +514,7 @@ print("TG" .." "..tostring(counter) .." "..tostring(x0) .." "..tostring(x1) -.." "..tostring(getn(GoldSaveSorted)) +.." "..tostring(getn(GoldSorted)) .." "..tostring(TitanGetVar(TITAN_GOLD_ID, "SeparateServers")) .." "..tostring(TitanGetVar(TITAN_GOLD_ID, "MergeServers")) .." "..tostring(TitanGetVar(TITAN_GOLD_ID, "AllServers")) @@ -618,31 +543,30 @@ print("TG" coin_str = NiceCash(GOLD_STARTINGGOLD, false, false) - local sessionMoneyRichText = "" + 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 - GOLD_COLOR = TITAN_GOLD_RED; - GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_LOST"]; - GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_LOST"]; + session_status = TitanUtils_GetRedText(L["TITAN_GOLD_SESS_LOST"]) + per_hour_status = TitanUtils_GetRedText(L["TITAN_GOLD_PERHOUR_LOST"]) else - GOLD_COLOR = TITAN_GOLD_GREEN; - GOLD_SESS_STATUS = L["TITAN_GOLD_SESS_EARNED"]; - GOLD_PERHOUR_STATUS = L["TITAN_GOLD_PERHOUR_EARNED"]; + 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) - -- ..TitanUtils_GetColoredText(GOLD_SESS_STATUS,GOLD_COLOR) sessionMoneyRichText = sessionMoneyRichText - .. TitanUtils_GetColoredText(GOLD_SESS_STATUS, GOLD_COLOR) + .. session_status .. "\t" .. coin_str .. "\n"; if TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then coin_str = NiceCash(perhour, true, true) sessionMoneyRichText = sessionMoneyRichText - .. TitanUtils_GetColoredText(GOLD_PERHOUR_STATUS, GOLD_COLOR) + .. per_hour_status .. "\t" .. coin_str .. "\n"; end else @@ -700,53 +624,64 @@ end ---local Build the gold array from saved vars, if any; get current total and session start time ---@param self Button local function Initialize_Array(self) - if (GOLD_INITIALIZED) then return; end + if (GOLD_INITIALIZED) then + -- nlready done + else + self:UnregisterEvent("ADDON_LOADED"); - self:UnregisterEvent("VARIABLES_LOADED"); + -- See if this is a new toon to Gold + if (GoldSave[GOLD_INDEX] == nil) then + GoldSave[GOLD_INDEX] = {} + GoldSave[GOLD_INDEX] = { gold = GetMoney(), name = UnitName("player") } + end - -- See if this is a new to toon to Gold - if (GoldSave[GOLD_INDEX] == nil) then - GoldSave[GOLD_INDEX] = {} - GoldSave[GOLD_INDEX] = { gold = GetMoney(), name = UnitName("player") } - end + if warband_active then + if GoldSave[WARBAND_INDEX] then + -- already exists + else + -- Add a Warband entry with defaults + GoldSave[WARBAND_INDEX] = { + gold = 0, + name = warband_toon, + show = true, + } + end + end - -- Ensure the saved vars are usable - for index, money in pairs(GoldSave) do - local character, charserver, char_faction = GetIndexInfo(index) --string.match(index, '(.*)_(.*)::(.*)') + -- Ensure the saved vars are usable + for index, money in pairs(GoldSave) do + local character, charserver, char_faction = GetIndexInfo(index) - -- Could be a new toon to Gold or an updated Gold - local show_toon = GoldSave[index].show - if show_toon == nil then - show_toon = true - end - GoldSave[index].show = show_toon - GoldSave[index].realm = charserver -- added July 2022 - - -- added Aug 2022 for #1332. - -- Faction in index was not set for display in tool tip. - -- Created localized faction as a field; set every time in case user changes languages - if char_faction == TITAN_ALLIANCE then - GoldSave[index].faction = FACTION_ALLIANCE - elseif char_faction == TITAN_HORDE then - GoldSave[index].faction = FACTION_HORDE - else - GoldSave[index].faction = FACTION_OTHER - end - --[[ - if character == UnitName("player") and charserver == realmName then - local rementry = character.."_"..charserver.."::"..UnitFactionGroup("Player"); - local showCharacter = GoldSave[rementry].show - if showCharacter == nil then showCharacter = true end - GoldSave[GOLD_INDEX] = {gold = GetMoney("player"), show = showCharacter, name = UnitName("player")} + -- Could be a new toon to Gold or an updated Gold + local show_toon = GoldSave[index].show + if show_toon == nil then + show_toon = true + end + GoldSave[index].show = show_toon + GoldSave[index].realm = charserver -- added July 2022 + + -- added Aug 2022 for #1332. + -- Faction in index was not set for display in tool tip. + -- Created localized faction as a field; set every time in case user changes languages + if char_faction == TITAN_ALLIANCE then + GoldSave[index].faction = FACTION_ALLIANCE + elseif char_faction == TITAN_HORDE then + GoldSave[index].faction = FACTION_HORDE + else + GoldSave[index].faction = FACTION_OTHER + end end + GOLD_STARTINGGOLD = GetMoney(); + GOLD_SESSIONSTART = GetTime(); + GOLD_INITIALIZED = true; +---[[ +print("Init" +.." "..tostring(GOLD_STARTINGGOLD).."" +.." "..tostring(GOLD_SESSIONSTART).."" +.." "..tostring(GOLD_INITIALIZED).."" +) --]] end - GOLD_STARTINGGOLD = GetMoney(); - GOLD_SESSIONSTART = GetTime(); - GOLD_INITIALIZED = true; - - -- AFTER we say init is done or we'll never show the gold! - TitanPanelButton_UpdateButton(TITAN_GOLD_ID) end ---local Clear the gold array and rebuild @@ -779,7 +714,6 @@ local function TitanGold_ClearDB() StaticPopup_Show("TITANGOLD_CLEAR_DATABASE"); end - ---local Generate the tooltip display option menu local function DisplayOptions() local info = {}; @@ -833,7 +767,7 @@ local function DisplayOptions() TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - -- What labels to show next to money none / text / icon + -- What labels to show next to money : none / text / icon info = {}; info.text = L["TITAN_GOLD_COIN_NONE"]; info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowCoinNone"); @@ -872,7 +806,7 @@ local function DisplayOptions() TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); - -- Use comma or period as separater on gold + -- Use thousands separater : , . ' ' info = {}; info.text = L["TITAN_PANEL_USE_COMMA"]; info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma"); @@ -889,6 +823,15 @@ local function DisplayOptions() end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + TITAN_PANEL_USE_SPACE = "Use Space" + info = {}; + info.text = TITAN_PANEL_USE_SPACE + info.checked = TitanGetVar(TITAN_GOLD_ID, "UseSeperatorSpace"); + info.func = function() + Seperator("UseSeperatorSpace") + end + TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); + TitanPanelRightClickMenu_AddSeparator(TitanPanelRightClickMenu_GetDropdownLevel()); -- Show session info @@ -1037,13 +980,13 @@ local function CreateMenu() -- Third (3rd) level for the list of characters / toons if TitanPanelRightClickMenu_GetDropdownLevel() == 3 and TitanPanelRightClickMenu_GetDropdMenuValue() == "DeleteAlliance" then - DeleteMenuButtons(TITAN_ALLIANCE) + DeleteMenuButtons(TITAN_ALLIANCE, 3) elseif TitanPanelRightClickMenu_GetDropdownLevel() == 3 and TitanPanelRightClickMenu_GetDropdMenuValue() == "DeleteHorde" then - DeleteMenuButtons(TITAN_HORDE) + DeleteMenuButtons(TITAN_HORDE, 3) elseif TitanPanelRightClickMenu_GetDropdownLevel() == 3 and TitanPanelRightClickMenu_GetDropdMenuValue() == "ShowAlliance" then - ShowMenuButtons(TITAN_ALLIANCE) + ShowMenuButtons(TITAN_ALLIANCE, 3) elseif TitanPanelRightClickMenu_GetDropdownLevel() == 3 and TitanPanelRightClickMenu_GetDropdMenuValue() == "ShowHorde" then - ShowMenuButtons(TITAN_HORDE) + ShowMenuButtons(TITAN_HORDE, 3) end end @@ -1058,12 +1001,10 @@ local function FindGold() local ret_str = "" local ttlgold = 0; - GoldSave[GOLD_INDEX].gold = GetMoney() - if TitanGetVar(TITAN_GOLD_ID, "ViewAll") then ttlgold = TotalGold() else - ttlgold = GetMoney(); + ttlgold = GoldSave[GOLD_INDEX].gold end ret_str = NiceCash(ttlgold, true, false) @@ -1112,6 +1053,7 @@ local function OnLoad(self) DisplayOnRightSide = false, UseSeperatorComma = true, UseSeperatorPeriod = false, + UseSeperatorSpace = false, MergeServers = false, SeparateServers = true, AllServers = false, @@ -1122,20 +1064,16 @@ local function OnLoad(self) } }; + self:RegisterEvent("ADDON_LOADED"); self:RegisterEvent("PLAYER_ENTERING_WORLD"); - - if (not GoldSave) then - GoldSave = {}; - end - - -- Faction is English to use as index NOT display - GOLD_INDEX = UnitName("player") .. "_" .. realmName .. "::" .. UnitFactionGroup("Player"); 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"); + self:RegisterEvent("PLAYER_MONEY") + GoldSave[GOLD_INDEX].gold = GetMoney() + if GoldSave and TitanGetVar(TITAN_GOLD_ID, "DisplayGoldPerHour") then if GoldTimerRunning then -- Do not start a new one @@ -1146,12 +1084,20 @@ local function OnShow(self) else -- timer running or user does not want gold per hour end + + if warband_active then + GoldSave[WARBAND_INDEX].gold = C_Bank.FetchDepositedMoney(Enum.BankType.Account) +---@diagnostic disable-next-line: param-type-mismatch + self:RegisterEvent("ACCOUNT_MONEY") -- register for changes + end end ---local When shown, unregister needed events and stop timer for gold per hour ---@param self Button local function OnHide(self) self:UnregisterEvent("PLAYER_MONEY"); +---@diagnostic disable-next-line: param-type-mismatch + self:UnregisterEvent("ACCOUNT_MONEY"); AceTimer:CancelTimer(GoldTimer) GoldTimerRunning = false end @@ -1166,6 +1112,7 @@ print("_OnEvent" .." "..tostring(event).."" ) --]] + if (event == "PLAYER_MONEY") then if (GOLD_INITIALIZED) then GoldSave[GOLD_INDEX].gold = GetMoney() @@ -1174,10 +1121,34 @@ print("_OnEvent" return; end - if (event == "PLAYER_ENTERING_WORLD") then - if (not GOLD_INITIALIZED) then - Initialize_Array(self); + if (event == "ACCOUNT_MONEY") then + if (GOLD_INITIALIZED) then + GoldSave[WARBAND_INDEX].gold = C_Bank.FetchDepositedMoney(Enum.BankType.Account) + end + return; + end + + if (event == "ADDON_LOADED") then + realmName = GetRealmName() -- this realm + realmNames = GetAutoCompleteRealms() -- connected realms + -- flip to make a simple lookup later rather than a loop + for index, realm in pairs(realmNames) do + merged_realms[realm] = true + end + + -- Faction is English to use as index NOT display + GOLD_INDEX = CreateIndex(UnitName("player"), realmName, UnitFactionGroup("Player")) + + -- New in 11.0.0 (War Within) is Warband Bank Tab + if warband_active then + WARBAND_INDEX = CreateIndex(warband_toon, warband_server, TITAN_WARBAND) end + + return; + end + + if (event == "PLAYER_ENTERING_WORLD") then + Initialize_Array(self); TitanPanelButton_UpdateButton(TITAN_GOLD_ID) return; end diff --git a/TitanGold/TitanGold_Classic.toc b/TitanGold/TitanGold_Classic.toc index d28436d..6d2dd0b 100644 --- a/TitanGold/TitanGold_Classic.toc +++ b/TitanGold/TitanGold_Classic.toc @@ -1,8 +1,4 @@ -<<<<<<< HEAD:TitanGold/TitanGold_Classic.toc ## Interface: 11503, 40400 -======= -## Interface: 40400 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanGold/TitanGold_Cata.toc ## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.16|r ## Version: 8.0.16 ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. diff --git a/TitanLocation/TitanLocation_Classic.toc b/TitanLocation/TitanLocation_Classic.toc index f59ffad..2f3ef9e 100644 --- a/TitanLocation/TitanLocation_Classic.toc +++ b/TitanLocation/TitanLocation_Classic.toc @@ -1,12 +1,7 @@ -<<<<<<< HEAD:TitanLocation/TitanLocation_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 ## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanLocation/TitanLocation_Cata.toc ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLootType/TitanClassicLootType.lua b/TitanLootType/TitanClassicLootType.lua index cb3e1f2..65ccbff 100644 --- a/TitanLootType/TitanClassicLootType.lua +++ b/TitanLootType/TitanClassicLootType.lua @@ -198,6 +198,7 @@ OUT: None --]] ---@class ResizeCursorType ---@field Texture? table +---@diagnostic disable-next-line: missing-fields local ResizeCursor = {} ---@type Frame local SizingStop = function(self, button) self:GetParent():StopMovingOrSizing() diff --git a/TitanLootType/TitanLootType_Classic.toc b/TitanLootType/TitanLootType_Classic.toc index 53c2faa..e34ea60 100644 --- a/TitanLootType/TitanLootType_Classic.toc +++ b/TitanLootType/TitanLootType_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanLootType/TitanLootType_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanLootType/TitanLootType_Cata.toc ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: TitanClassicLootTypeSaved diff --git a/TitanPerformance/TitanPerformance_Classic.toc b/TitanPerformance/TitanPerformance_Classic.toc index 1dc6fe0..27a2644 100644 --- a/TitanPerformance/TitanPerformance_Classic.toc +++ b/TitanPerformance/TitanPerformance_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanPerformance/TitanPerformance_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanPerformance/TitanPerformance_Cata.toc ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRegen/TitanRegen_Classic.toc b/TitanRegen/TitanRegen_Classic.toc index d5eb9b7..1b54847 100644 --- a/TitanRegen/TitanRegen_Classic.toc +++ b/TitanRegen/TitanRegen_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanRegen/TitanRegen_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 11503 -## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanRegen/TitanRegen_Vanilla.toc ## Notes: Adds a regen monitor to Titan Panel to show HP/MANA regen - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRepair/TitanRepair_Classic.toc b/TitanRepair/TitanRepair_Classic.toc index f1664a8..fbcf7b9 100644 --- a/TitanRepair/TitanRepair_Classic.toc +++ b/TitanRepair/TitanRepair_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanRepair/TitanRepair_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanRepair/TitanRepair_Cata.toc ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume_Classic.toc b/TitanVolume/TitanVolume_Classic.toc index 811cdcc..3151e62 100644 --- a/TitanVolume/TitanVolume_Classic.toc +++ b/TitanVolume/TitanVolume_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanVolume/TitanVolume_Classic.toc ## Interface: 11503, 40400 ## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanVolume/TitanVolume_Cata.toc ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP_Classic.toc b/TitanXP/TitanXP_Classic.toc index 98a03f6..195e76e 100644 --- a/TitanXP/TitanXP_Classic.toc +++ b/TitanXP/TitanXP_Classic.toc @@ -1,12 +1,6 @@ -<<<<<<< HEAD:TitanXP/TitanXP_Classic.toc ## Interface: 11503, 40400 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.15|r -## Version: 8.0.15 -======= -## Interface: 40400 ## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.16|r ## Version: 8.0.16 ->>>>>>> 8a735dded11e9609c0f7312294dfb072f859a21e:TitanXP/TitanXP_Cata.toc ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: