From 84959308aa7705723d59e37652521f3005793d3b Mon Sep 17 00:00:00 2001 From: bernard langham Date: Sat, 5 Oct 2024 17:46:18 +0800 Subject: [PATCH 1/2] new: /gt bank open/show/hide/close/closed (toggle whether to deposit on bank window open or close event) fix: prevent mail deposits from respecting GOLD_CAP debug: output debug info about own, bank and tithe balances before and after DepositGuildBankMoney() new: status info in help chat message new: /gt debug on/true/off/false new: /gt prettyldb on/true/off/false new: /gt chat on/true/off/false (spammy mode toggle) new: additional Locale strings Signed-off-by: bernard langham --- Core.lua | 72 +++++++++++++++++++++++++++++++------- GuildTitheFrameScripts.lua | 3 +- Locale/enUS.lua | 6 +++- 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/Core.lua b/Core.lua index 3d38be3..2d709f5 100644 --- a/Core.lua +++ b/Core.lua @@ -40,7 +40,7 @@ end -- Get a string for the current version of the addon. function E:GetVerString() - CURRENT_REVISION = 129 + CURRENT_REVISION = 130 local v, rev = (C_AddOns.GetAddOnMetadata(addonName, "VERSION") or "???"), CURRENT_REVISION --[===[@debug@ @@ -79,6 +79,7 @@ local SettingsDefaults = { SkinElvUI = true, LDBDisplayTotal = false, PrettyLDB = false, + DepositOnBankOpen = true, } -- Get the coin string for the databroker icon, because it needs to be shorter. @@ -315,6 +316,7 @@ end -- Handles depositing the tithe +-- NB: deposit by mail won't work when mailbox replacement addons are active e.g. Tradeskillmaster function E:DepositTithe(clicked, isMail) self:PrintDebug("DepositTithe(".. self:debugArgs(clicked, isMail) .. ") -- ACTUAL DEPOSIT IS DISABLED IN DEBUG MODE") if not clicked and not GuildTithe_SavedDB.AutoDeposit then @@ -338,7 +340,7 @@ function E:DepositTithe(clicked, isMail) local tithe = GuildTithe_SavedDB.CurrentTithe local bank = GetGuildBankMoney() - if bank + tithe > GOLD_CAP then + if not isMail and (bank + tithe > GOLD_CAP) then tithe = GOLD_CAP - bank end @@ -348,7 +350,7 @@ function E:DepositTithe(clicked, isMail) return end - -- Deposit the money, then reset CurrentTithe and update TotalTithe + -- Deposit the money, then adjust CurrentTithe and update TotalTithe if not E._DebugMode then if isMail then -- postal fix @@ -359,13 +361,18 @@ function E:DepositTithe(clicked, isMail) SendMailMoneySilver:SetText(silverAmount) SendMailMoneyCopper:SetText(copperAmount) else - DepositGuildBankMoney(tithe) - end + -- begin temporary test spam + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Tithe before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)))) + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Guild bank before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetGuildBankMoney())))) + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Own balance before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetMoney())))) + DepositGuildBankMoney(tithe) + -- end temporary test spam + end end if GuildTithe_SavedDB.Spammy or E._DebugMode then if tithe ~= GuildTithe_SavedDB.CurrentTithe then - self:PrintMessage(format(L.ChatDepositToGoldCap, C_CurrencyInfo.GetCoinTextureString(tithe), C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe))) + self:PrintMessage(format(L.ChatDepositToGoldCap, C_CurrencyInfo.GetCoinTextureString(tithe), C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)), false, E._DebugMode) else self:PrintMessage(format(L.ChatDepositTitheAmount, C_CurrencyInfo.GetCoinTextureString(tithe), false, E._DebugMode)) end @@ -374,6 +381,11 @@ function E:DepositTithe(clicked, isMail) if not E._DebugMode then GuildTithe_SavedDB.TotalTithe = GuildTithe_SavedDB.TotalTithe + tithe GuildTithe_SavedDB.CurrentTithe = GuildTithe_SavedDB.CurrentTithe - tithe + -- begin temporary test spam + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Tithe after deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)))) + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Guild bank after deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetGuildBankMoney())))) + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Own balance after deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetMoney())))) + -- end temporary test spam if not GuildTithe_SavedDB.LDBDisplayTotal or not E.ShowTotalTimer then GuildTithe_SavedDB.LDBDisplayTotal = true @@ -382,7 +394,7 @@ function E:DepositTithe(clicked, isMail) end end -local numHelpLines = 12 +local numHelpLines = 15 -- Print Help function E:PrintHelpMessages() for i = 1, numHelpLines do @@ -392,6 +404,10 @@ function E:PrintHelpMessages() self:PrintMessage(L["ChatHelpLine" .. i]) end end + self:PrintMessage("=== Status ===") + self:PrintMessage(format(L.ChatCommandToggleDebug, tostring(E._DebugMode)), false, E._DebugMode ) + self:PrintMessage(format(L.ChatCommandToggleChat, tostring(GuildTithe_SavedDB.Spammy))) + self:PrintMessage(format("Deposit on bank window frame %s.", GREEN_FONT_COLOR:WrapTextInColorCode( tostring(GuildTithe_SavedDB.DepositOnBankOpen and "show" or "hide")))) end -- Handles slash commands @@ -400,7 +416,13 @@ function E:OnChatCommand(msg) -- toggle debug mode without opening the config window if cmd == "debug" then - E._DebugMode = not E._DebugMode + if args == "on" or args == "true" then + E._DebugMode = true + elseif args == "off" or args == "false" then + E._DebugMode = false + else + E._DebugMode = not E._DebugMode + end self:PrintMessage(format(L.ChatCommandToggleDebug, tostring(E._DebugMode)), false, E._DebugMode ) return end @@ -434,9 +456,9 @@ function E:OnChatCommand(msg) -- Toggle pretty LDB display (requires more room on LDB bar than existing basic default) elseif cmd == "prettyldb" then - if args == "on" then + if args == "on" or args == "true" then GuildTithe_SavedDB.PrettyLDB = true - elseif args == "off" then + elseif args == "off" or args == "false" then GuildTithe_SavedDB.PrettyLDB = false else -- No args clause, toggle. GuildTithe_SavedDB.PrettyLDB = not(GuildTithe_SavedDB.PrettyLDB) @@ -491,6 +513,26 @@ function E:OnChatCommand(msg) self:PrintMessage(format(L.ChatOutstandingTithe, C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe))) end + -- taggle chat output + elseif cmd == "chat" then + if args == "on" or args == "true" then + GuildTithe_SavedDB.Spammy = true + elseif args == "off" or args == "false" then + GuildTithe_SavedDB.Spammy = false + else -- No args clause, toggle. + GuildTithe_SavedDB.Spammy = not GuildTithe_SavedDB.Spammy + end + self:PrintMessage(format(L.ChatCommandToggleChat, tostring(GuildTithe_SavedDB.Spammy))) + + -- deposit on bank window open or close (potential fix for server lag) + elseif cmd == "bank" then + if args == "show" or args == "open" then + GuildTithe_SavedDB.DepositOnBankOpen = true + elseif args == "hide" or args == "close" or args == "closed" then + GuildTithe_SavedDB.DepositOnBankOpen = false + end + self:PrintMessage(format("Deposit on bank window frame %s.", GREEN_FONT_COLOR:WrapTextInColorCode(tostring(GuildTithe_SavedDB.DepositOnBankOpen and "show" or "hide")))) + -- This is where we're going to actually print the help info... Later though. else self:PrintMessage(format(L.ChatCommandNotFound, msg), true) @@ -594,9 +636,15 @@ function E.EventHandler(self, event, ...) E.Loaded = true end - -- GUILDBANKFRAME_OPENED: The GB was closed, deposit the outstanding tithe. + -- GUILDBANKFRAME_OPENED: The GB was opened, deposit the outstanding tithe. + elseif event == "PLAYER_INTERACTION_MANAGER_FRAME_SHOW" and tonumber(arg1) == Enum.PlayerInteractionType.GuildBanker then + if GuildTithe_SavedDB.DepositOnBankOpen then + E:DepositTithe() + end elseif event == "PLAYER_INTERACTION_MANAGER_FRAME_HIDE" and tonumber(arg1) == Enum.PlayerInteractionType.GuildBanker then - E:DepositTithe() + if not GuildTithe_SavedDB.DepositOnBankOpen then + E:DepositTithe() + end -- Mail_*: Update outstanding tithe from Mail sources elseif event == "PLAYER_INTERACTION_MANAGER_FRAME_SHOW" and tonumber(arg1) == Enum.PlayerInteractionType.MailInfo then return E:UpdateOutstandingTithe("Mail") diff --git a/GuildTitheFrameScripts.lua b/GuildTitheFrameScripts.lua index bd98e23..67da675 100644 --- a/GuildTitheFrameScripts.lua +++ b/GuildTitheFrameScripts.lua @@ -174,7 +174,8 @@ end function E.FrameScript_MiniTitheFrameOnClick(self, button) E:PrintDebug("MiniFrame OnClick()") - if C_AddOns.IsAddOnLoaded("Blizzard_GuildBankUI") and GuildBankFrame:IsVisible() then + if (C_AddOns.IsAddOnLoaded("Blizzard_GuildBankUI") and GuildBankFrame:IsVisible()) or + (C_AddOns.IsAddOnLoaded("Arkinventory") and ARKINV_Frame4TitleArkBorder:IsVisible()) then E:DepositTithe(1) elseif SendMailFrame:IsVisible() then E:DepositTithe(1,1) diff --git a/Locale/enUS.lua b/Locale/enUS.lua index c45a4d6..a7d64d1 100644 --- a/Locale/enUS.lua +++ b/Locale/enUS.lua @@ -23,7 +23,10 @@ L["ChatHelpLine8"] = "reset config -- Reset this character's config." L["ChatHelpLine9"] = "current/tithe -- Show your current outstanding tithe." L["ChatHelpLine10"] = "mini -- Toggle the Mini-frame." L["ChatHelpLine11"] = "mini lock -- Lock or unlock the Mini-frame." -L["ChatHelpLine12"] = "debug -- Toggle debug mode on and off." +L["ChatHelpLine12"] = "debug (on/off) -- Toggle debug mode on and off." +L["ChatHelpLine13"] = "chat (on/off) -- Toggle chat output on and off." +L["ChatHelpLine14"] = "prettyldb (on/off) -- Toggle LDB text vs graphical display." +L["ChatHelpLine15"] = "bank show/hide -- deposit on bank window show or hide (default show)" L["ChatMiniFrameLock"] = "Mini-Frame locked." @@ -31,6 +34,7 @@ L["ChatCommandSetNegative"] = "Tithe cannot be negative." L["ChatCommandSetOverCap"] = "Tithe cannot exceed gold cap." L["ChatCommandSetSyntax"] = "Syntax: /gt set ." L["ChatCommandToggleDebug"] = "Debug mode §c%s§r." +L["ChatCommandToggleChat"] = "Chat mode §c%s§r." L["ChatMiniFrameUnlock"] = "Mini-frame unlocked." L["ChatNotEnoughFunds"] = "You don't have enough money to do that!" From e7f6317eded0cadf7c0289fc13204822e6055eef Mon Sep 17 00:00:00 2001 From: bernard langham Date: Sat, 5 Oct 2024 18:47:33 +0800 Subject: [PATCH 2/2] changed: support for DepositOnBankHide variable (default false, toggled using /gt bankhide on/true/off/false) added: ChatCommandDepositOnBankHide to Locale/enUS.lua --- Core.lua | 29 ++++++++++++++++++----------- Locale/enUS.lua | 9 +++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Core.lua b/Core.lua index 2d709f5..873aa2a 100644 --- a/Core.lua +++ b/Core.lua @@ -79,7 +79,7 @@ local SettingsDefaults = { SkinElvUI = true, LDBDisplayTotal = false, PrettyLDB = false, - DepositOnBankOpen = true, + DepositOnBankHide = false, } -- Get the coin string for the databroker icon, because it needs to be shorter. @@ -167,7 +167,7 @@ function E:Init() if not GuildTithe_SavedDB or GuildTithe_SavedDB.SettingsVer < SettingsDefaults.SettingsVer then GuildTithe_SavedDB = SettingsDefaults end - + -- Load the frames GT_MiniTitheFrame:EnableMouse(not GuildTithe_SavedDB.MiniFrameLocked) if GuildTithe_SavedDB.MiniFrameShown then @@ -178,6 +178,10 @@ function E:Init() if (GuildTithe_SavedDB.PrettyLDB == nil or GuildTithe_SavedDB.PrettyLDB == '') then GuildTithe_SavedDB.PrettyLDB = false end + + if GuildTithe_SavedDB.DepositOnBankHide == nil then + GuildTithe_SavedDB.DepositOnBankHide = false + end end function E:ResetWindowSettings() @@ -362,6 +366,7 @@ function E:DepositTithe(clicked, isMail) SendMailMoneyCopper:SetText(copperAmount) else -- begin temporary test spam + print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Tithe before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)))) print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Guild bank before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetGuildBankMoney())))) print(LIGHTGRAY_FONT_COLOR:WrapTextInColorCode(format("Own balance before deposit: %s.",C_CurrencyInfo.GetCoinTextureString(GetMoney())))) @@ -407,7 +412,7 @@ function E:PrintHelpMessages() self:PrintMessage("=== Status ===") self:PrintMessage(format(L.ChatCommandToggleDebug, tostring(E._DebugMode)), false, E._DebugMode ) self:PrintMessage(format(L.ChatCommandToggleChat, tostring(GuildTithe_SavedDB.Spammy))) - self:PrintMessage(format("Deposit on bank window frame %s.", GREEN_FONT_COLOR:WrapTextInColorCode( tostring(GuildTithe_SavedDB.DepositOnBankOpen and "show" or "hide")))) + self:PrintMessage(format(L.ChatCommandDepositOnBankHide ,tostring(GuildTithe_SavedDB.DepositOnBankHide))) end -- Handles slash commands @@ -525,13 +530,15 @@ function E:OnChatCommand(msg) self:PrintMessage(format(L.ChatCommandToggleChat, tostring(GuildTithe_SavedDB.Spammy))) -- deposit on bank window open or close (potential fix for server lag) - elseif cmd == "bank" then - if args == "show" or args == "open" then - GuildTithe_SavedDB.DepositOnBankOpen = true - elseif args == "hide" or args == "close" or args == "closed" then - GuildTithe_SavedDB.DepositOnBankOpen = false + elseif cmd == "bankhide" then + if args == "on" or args == "true" then + GuildTithe_SavedDB.DepositOnBankHide = true + elseif args == "off" or args == "false" then + GuildTithe_SavedDB.DepositOnBankHide = false + else + GuildTithe_SavedDB.DepositOnBankHide = not GuildTithe_SavedDB.DepositOnBankHide end - self:PrintMessage(format("Deposit on bank window frame %s.", GREEN_FONT_COLOR:WrapTextInColorCode(tostring(GuildTithe_SavedDB.DepositOnBankOpen and "show" or "hide")))) + self:PrintMessage(format(L.ChatCommandDepositOnBankHide, tostring(GuildTithe_SavedDB.DepositOnBankHide))) -- This is where we're going to actually print the help info... Later though. else @@ -638,11 +645,11 @@ function E.EventHandler(self, event, ...) -- GUILDBANKFRAME_OPENED: The GB was opened, deposit the outstanding tithe. elseif event == "PLAYER_INTERACTION_MANAGER_FRAME_SHOW" and tonumber(arg1) == Enum.PlayerInteractionType.GuildBanker then - if GuildTithe_SavedDB.DepositOnBankOpen then + if not GuildTithe_SavedDB.DepositOnBankHide then E:DepositTithe() end elseif event == "PLAYER_INTERACTION_MANAGER_FRAME_HIDE" and tonumber(arg1) == Enum.PlayerInteractionType.GuildBanker then - if not GuildTithe_SavedDB.DepositOnBankOpen then + if GuildTithe_SavedDB.DepositOnBankHide then E:DepositTithe() end -- Mail_*: Update outstanding tithe from Mail sources diff --git a/Locale/enUS.lua b/Locale/enUS.lua index a7d64d1..a53d1ca 100644 --- a/Locale/enUS.lua +++ b/Locale/enUS.lua @@ -23,10 +23,10 @@ L["ChatHelpLine8"] = "reset config -- Reset this character's config." L["ChatHelpLine9"] = "current/tithe -- Show your current outstanding tithe." L["ChatHelpLine10"] = "mini -- Toggle the Mini-frame." L["ChatHelpLine11"] = "mini lock -- Lock or unlock the Mini-frame." -L["ChatHelpLine12"] = "debug (on/off) -- Toggle debug mode on and off." -L["ChatHelpLine13"] = "chat (on/off) -- Toggle chat output on and off." -L["ChatHelpLine14"] = "prettyldb (on/off) -- Toggle LDB text vs graphical display." -L["ChatHelpLine15"] = "bank show/hide -- deposit on bank window show or hide (default show)" +L["ChatHelpLine12"] = "debug (on/true/off/false) -- Toggle debug mode on and off." +L["ChatHelpLine13"] = "chat (on/true/off/false) -- Toggle chat output on and off." +L["ChatHelpLine14"] = "prettyldb (on/true/off/false) -- Toggle LDB text vs graphical display." +L["ChatHelpLine15"] = "bankhide (on/true/off/false) -- Deposit tithe on bank window hide (default false)" L["ChatMiniFrameLock"] = "Mini-Frame locked." @@ -35,6 +35,7 @@ L["ChatCommandSetOverCap"] = "Tithe cannot exceed gold cap." L["ChatCommandSetSyntax"] = "Syntax: /gt set ." L["ChatCommandToggleDebug"] = "Debug mode §c%s§r." L["ChatCommandToggleChat"] = "Chat mode §c%s§r." +L["ChatCommandDepositOnBankHide"] = "Deposit on bank window frame hide §c%s§r." L["ChatMiniFrameUnlock"] = "Mini-frame unlocked." L["ChatNotEnoughFunds"] = "You don't have enough money to do that!"