From 3b94951532b3ed50c8a897e1d17150e7aac3d6db Mon Sep 17 00:00:00 2001 From: Daeymien Date: Sat, 14 Mar 2020 18:07:59 -0400 Subject: [PATCH] backup of local files Initial repo --- Changelog-GuildTithe-release_v2.5.15.txt | 25 + Core.lua | 575 ++++++++++++++++++ GlobalStrings.lua | 55 ++ GuildTithe.toc | 25 + GuildTitheFrameScripts.lua | 339 +++++++++++ GuildTitheFrames.xml | 404 ++++++++++++ .../CallbackHandler-1.0.lua | 238 ++++++++ .../CallbackHandler-1.0.xml | 4 + Libs/LibDataBroker-1.1/LibDataBroker-1.1.lua | 90 +++ Libs/LibStub/LibStub.lua | 51 ++ Libs/LibStub/LibStub.toc | 13 + Libs/LibStub/tests/test.lua | 41 ++ Libs/LibStub/tests/test2.lua | 27 + Libs/LibStub/tests/test3.lua | 14 + Libs/LibStub/tests/test4.lua | 41 ++ Libs/LibVan32-1.0/!LibVan32.toc | 11 + Libs/LibVan32-1.0/LibVan32.lua | 271 +++++++++ Locale/deDE.lua | 59 ++ Locale/enUS.lua | 59 ++ Locale/esES.lua | 59 ++ Locale/esMX.lua | 59 ++ Locale/frFR.lua | 59 ++ Locale/koKR.lua | 59 ++ Locale/loadLocales.xml | 15 + Locale/ptBR.lua | 59 ++ Locale/ruRU.lua | 59 ++ Locale/zhCN.lua | 59 ++ Locale/zhTW.lua | 59 ++ embeds.xml | 9 + 29 files changed, 2838 insertions(+) create mode 100644 Changelog-GuildTithe-release_v2.5.15.txt create mode 100644 Core.lua create mode 100644 GlobalStrings.lua create mode 100644 GuildTithe.toc create mode 100644 GuildTitheFrameScripts.lua create mode 100644 GuildTitheFrames.xml create mode 100644 Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml create mode 100644 Libs/LibDataBroker-1.1/LibDataBroker-1.1.lua create mode 100644 Libs/LibStub/LibStub.lua create mode 100644 Libs/LibStub/LibStub.toc create mode 100644 Libs/LibStub/tests/test.lua create mode 100644 Libs/LibStub/tests/test2.lua create mode 100644 Libs/LibStub/tests/test3.lua create mode 100644 Libs/LibStub/tests/test4.lua create mode 100644 Libs/LibVan32-1.0/!LibVan32.toc create mode 100644 Libs/LibVan32-1.0/LibVan32.lua create mode 100644 Locale/deDE.lua create mode 100644 Locale/enUS.lua create mode 100644 Locale/esES.lua create mode 100644 Locale/esMX.lua create mode 100644 Locale/frFR.lua create mode 100644 Locale/koKR.lua create mode 100644 Locale/loadLocales.xml create mode 100644 Locale/ptBR.lua create mode 100644 Locale/ruRU.lua create mode 100644 Locale/zhCN.lua create mode 100644 Locale/zhTW.lua create mode 100644 embeds.xml diff --git a/Changelog-GuildTithe-release_v2.5.15.txt b/Changelog-GuildTithe-release_v2.5.15.txt new file mode 100644 index 0000000..e562487 --- /dev/null +++ b/Changelog-GuildTithe-release_v2.5.15.txt @@ -0,0 +1,25 @@ +------------------------------------------------------------------------ +r121 | vandesdelca32 | 2014-10-17 03:33:11 +0000 (Fri, 17 Oct 2014) | 1 line +Changed paths: + A /tags/release_v2.5.15 (from /trunk:120) + +Tagging latest build. +------------------------------------------------------------------------ +r120 | vandesdelca32 | 2014-10-17 03:32:15 +0000 (Fri, 17 Oct 2014) | 1 line +Changed paths: + M /trunk/Core.lua + +Fixed an error in the default settings pointed out by Kanegasi +------------------------------------------------------------------------ +r118 | vandesdelca32 | 2014-10-17 00:50:40 +0000 (Fri, 17 Oct 2014) | 1 line +Changed paths: + M /trunk/GuildTitheFrameScripts.lua + +Fixed a bug that caused disabling an option to not be saved correctly. +------------------------------------------------------------------------ +r116 | vandesdelca32 | 2014-10-15 23:49:49 +0000 (Wed, 15 Oct 2014) | 1 line +Changed paths: + M /trunk/GuildTithe.toc + +Bump ToC to 60000 +------------------------------------------------------------------------ diff --git a/Core.lua b/Core.lua new file mode 100644 index 0000000..d70267c --- /dev/null +++ b/Core.lua @@ -0,0 +1,575 @@ +--[[ +------------------------------------------------------------------------ + Project: GuildTithe + File: Core rev. 120 + Date: 2014-10-17T03:32:15Z + Purpose: Core Addon Code + Credits: Code written by Vandesdelca32 + + Copyright (C) 2011 Vandesdelca32 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +------------------------------------------------------------------------ +]] + +-- Import engine and the localization table. +local addonName, _ = ... +local E, L = unpack(select(2, ...)) + +--debugArgs: Returns literal "nil" or the tostring of all of the arguments passed to it. +function E:debugArgs(...) + local tmp = {} + for i = 1, select("#", ...) do + tmp[i] = tostring(select(i, ...)) or "nil" + end + return table.concat(tmp, ", ") +end + +-- Get a string for the current version of the addon. +function E:GetVerString() + local v, rev = (GetAddOnMetadata(addonName, "VERSION") or "???"), (tonumber('120') or "???") + + --[===[@debug@ + -- If this code is run, it's an unpackaged version, show this: + if v == "release_v2.5.15" then v = "DEV_VERSION"; end + --@end-debug@]===] + + if short then + -- Try to discern what release stage: + if strfind(v, "release") then + return "r" .. rev + elseif strfind(v, "beta") then + return "b" .. rev + else + return "a" .. rev + end + end + return v .. "." .. rev +end + +local SettingsDefaults = { + SettingsVer = 2, + CollectSource = { + Quest = -1, + Merchant = -1, + Mail = -1, + Loot = -1, + Trade = -1 + }, + AutoDeposit = true, + Spammy = false, + TotalTithe = 0, + CurrentTithe = 0, + MiniFrameShown = true, + MiniFrameLocked = false, + SkinElvUI = true, + LDBDisplayTotal = false, +} + +-- Get the coin string for the databroker icon, because it needs to be shorter. +local function GetLDBCoinString() + local text = "" + local ct = GuildTithe_SavedDB.CurrentTithe + local tt = GuildTithe_SavedDB.TotalTithe + + if GuildTithe_SavedDB.LDBDisplayTotal then + local gold = floor(tt / COPPER_PER_GOLD) + local silver = floor(tt / SILVER_PER_GOLD) % COPPER_PER_SILVER + local copper = floor(tt % COPPER_PER_SILVER) + if gold ~= 0 then + text = format("%s|cffffd700g|r %s|cffc7c7cfs|r %s|cffeda55fc|r", gold, silver, copper) + elseif silver ~= 0 then + text = format("%s|cffc7c7cfs|r %s|cffeda55fc|r", silver, copper) + else + text = format("%s|cffeda55fc|r", copper) + end + else + local gold = floor(ct / COPPER_PER_GOLD) + local silver = floor(ct / SILVER_PER_GOLD) % COPPER_PER_SILVER + local copper = floor(ct % COPPER_PER_SILVER) + if gold ~= 0 then + text = format("%s|cffffd700g|r %s|cffc7c7cfs|r %s|cffeda55fc|r", gold, silver, copper) + elseif silver ~= 0 then + text = format("%s|cffc7c7cfs|r %s|cffeda55fc|r", silver, copper) + else + text = format("%s|cffeda55fc|r", copper) + end + end + return text +end + +function E:Init() + --[===[@alpha@ + E._DebugMode = true + --@end-alpha@]===] + + E.Info = {} + + -- Set up the LDB datastream + local t = { + type = "data source", + text = "", + icon = "Interface\\ICONS\\inv_misc_coin_17.png", + label = "Tithe", + OnClick = function(frame, button) + GameTooltip:Hide() + if button == "LeftButton" then + E.FrameScript_MiniTitheFrameOnClick() + elseif button == "RightButton" then + if not GuildTithe_SavedDB.LDBDisplayTotal then + GuildTithe_SavedDB.LDBDisplayTotal = true + else + GuildTithe_SavedDB.LDBDisplayTotal = false + end + end + end, + OnTooltipShow = function(tooltip) + if tooltip and tooltip.AddLine then + tooltip:SetText("GuildTithe") + if GuildTithe_SavedDB.LDBDisplayTotal then + tooltip:AddLine(L.TooltipLDBDescriptionTotal, 0.8, 0.8, 0.8, 1) + else + tooltip:AddLine(L.TooltipLDBDescriptionCurrent, 0.8, 0.8, 0.8, 1) + end + tooltip:AddLine("\nHint: Left-Click with the guild bank or a letter open to deposit your tithe! Right-Click to toggle between total and current tithes.", 0, 1, 0, 1) + tooltip:Show() + end + end, + } + E.Info.LDBData = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GuildTithe", t) + + -- Check the settings: + 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 + GT_MiniTitheFrame:Show() + end +end + +function E:ResetWindowSettings() + GT_OptionsFrame:SetUserPlaced(false) + GT_MiniTitheFrame:SetUserPlaced(false) + ReloadUI() +end + +function E:ResetCurrentTithe() + GuildTithe_SavedDB.CurrentTithe = 0 +end + +-- Reset default settings +function E:ResetConfig() + GuildTithe_SavedDB = SettingsDefaults + if GT_OptionsFrame:IsShown() then + self.UpdateOptions(GT_OptionsFrame) + end + return self:ResetWindowSettings() +end + +-- This is used to check the special tithe amounts for merchant/mail/trade. +-- They all need the same function, but have slightly different methods. THis way is faster. +local function CheckSpecialTitheAmounts(source, startGold, finishGold) + + local titheAmount + + -- Get the 'difference' in money + local diff + diff = finishGold - startGold + + -- Check for profit + if diff <= 0 then + diff = 0 + end + + -- Update + titheAmount = diff + + return titheAmount or 0 +end + +-- Quest, Merchant, Mail, Loot, Trade +-- Updates the current tithe, passing update will update the totals. +function E:UpdateOutstandingTithe(source, update, ...) + self:PrintDebug("UpdateOutstandingTithe(" .. self:debugArgs(source, update, ...) .. ")") + + if not update then + self.Info.CurrentGold = GetMoney() + return + else + self.Info.FinishGold = GetMoney() + end + self:PrintDebug(" CurrentGold = " .. self:debugArgs(self.Info.CurrentGold) .. ", FinishGold = " .. self:debugArgs(self.Info.FinishGold)) + + -- Try to extract what GOLD, SILVER, and COPPER are in the client language + local GOLD = strmatch(format(GOLD_AMOUNT, 20), "%d+%s(.+)") -- This will return what's in the brackets, which on enUS would be "Gold" + local SILVER = strmatch(format(SILVER_AMOUNT, 20), "%d+%s(.+)") + local COPPER = strmatch(format(COPPER_AMOUNT, 20), "%d+%s(.+)") + ---self:PrintDebug(self:debugArgs(GOLD, SILVER, COPPER)) + + + -- Make some storage for the tithe amount + local titheAmount + + -- Checking the source of the money event + -- From Loot, Quest + if source == "Loot" or source == "Quest" then + local arg1 = ... + --Try and parse the current amount from the string. + local g = tonumber(arg1:match("(%d+)%s" .. GOLD)) or 0 + local s = tonumber(arg1:match("(%d+)%s" .. SILVER)) or 0 + local c = tonumber(arg1:match("(%d+)%s" .. COPPER)) or 0 + + titheAmount = (g * COPPER_PER_GOLD) + (s * SILVER_PER_GOLD) + c + + -- From Merchants, or Mail, or Trade + elseif source == "Merchant" or source == "Mail" or source == "Trade" then + -- Check and make a table for cooldown info storage + if not E.Info.checkDelays then + E.Info.checkDelays = {} + end + + --Check the cooldown timer, we're gonna hardcode 2s + if (not E.Info.checkDelays[source]) or (GetTime() >= E.Info.checkDelays[source] + 2) then + E.Info.checkDelays[source] = GetTime() + + -- Sanity checks. + if not (self.Info.FinishGold and self.Info.CurrentGold) then + E:PrintDebug("Invalid Type, proper information not available", true) + return + end + + -- Is this a trade? It needs special conditions + if source == "Trade" then + -- Trade is a bit laggy, so we pass the guessed gold amount over through this + -- and assume that the finishgold is == currentgold+ trade amount. + local arg1 = ... + if tonumber(arg1) and tonumber(arg1) >= 0 then + self:PrintDebug(" tradeGold = " .. tonumber(arg1)) + self.Info.FinishGold = self.Info.CurrentGold + tonumber(arg1) + end + end + titheAmount = CheckSpecialTitheAmounts(source, self.Info.CurrentGold, self.Info.FinishGold) + + else + self:PrintDebug("ON ".. source .." CD", true) + return + end + end + self:PrintDebug(" titheAmount = " .. tostring(titheAmount)) + + -- Do some maths + if (GuildTithe_SavedDB.CollectSource[source] + and GuildTithe_SavedDB.CollectSource[source] >= 1) then + -- Collecting from this source, get the actual amount we're taking from this + local actualTithe = floor((titheAmount * (GuildTithe_SavedDB.CollectSource[source] / 100))) + self:PrintDebug(" actualTithe = " .. tostring(actualTithe)) + GuildTithe_SavedDB.CurrentTithe = GuildTithe_SavedDB.CurrentTithe + actualTithe + + -- Clear the info table for the next guy + self.Info.CurrentGold = nil + self.Info.FinishGold = nil + + -- Tell the user what we collected if they want to know + if GuildTithe_SavedDB.Spammy and actualTithe > 0 then + self:PrintMessage(format(L.ChatSpammyCollectedAmount, GetCoinTextureString(actualTithe), strlower(source))) + end + else + self:PrintDebug(" " .. source .. " not collecting", true) + if GuildTithe_SavedDB.Spammy then + self:PrintMessage(format(L.ChatSpammyNotCollectingSource, source)) + end + end +end + + +-- Handles depositing the tithe +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 + if GuildTithe_SavedDB.Spammy then + self:PrintMessage(L.ChatAutoDepositDisabled) + end + self:PrintDebug(" AutoDeposit Disabled") + return + end + + -- Sanity Check, (stop the error speech when trying to deposit 0c) + if GuildTithe_SavedDB.CurrentTithe == 0 then + if GuildTithe_SavedDB.Spammy then + self:PrintMessage(L.ChatNothingToDeposit, true) + end + return + end + + -- Make sure the player has enough money first, then spam them out if they don't! + if GetMoney() < GuildTithe_SavedDB.CurrentTithe then + self:PrintMessage(L["ChatNotEnoughFunds"], true) + return + end + + -- Deposit the money, then reset CurrentTithe and update TotalTithe + if not self.DebugMode then + if isMail then + -- postal fix + local goldAmount = floor(GuildTithe_SavedDB.CurrentTithe / COPPER_PER_GOLD) + local silverAmount = floor((GuildTithe_SavedDB.CurrentTithe % COPPER_PER_GOLD) / COPPER_PER_SILVER) + local copperAmount = floor(GuildTithe_SavedDB.CurrentTithe % COPPER_PER_SILVER) + SendMailMoneyGold:SetText(goldAmount) + SendMailMoneySilver:SetText(silverAmount) + SendMailMoneyCopper:SetText(copperAmount) + else + DepositGuildBankMoney(GuildTithe_SavedDB.CurrentTithe) + end + end + + if GuildTithe_SavedDB.Spammy then + self:PrintMessage(format(L.ChatDepositTitheAmount, GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe))) + end + self:PrintDebug(" Deposit amount = " .. GuildTithe_SavedDB.CurrentTithe) + + GuildTithe_SavedDB.TotalTithe = GuildTithe_SavedDB.TotalTithe + GuildTithe_SavedDB.CurrentTithe + if not GuildTithe_SavedDB.LDBDisplayTotal or not E.ShowTotalTimer then + GuildTithe_SavedDB.LDBDisplayTotal = true + E.ShowTotalTimer = E:SetTimer(10, function() GuildTithe_SavedDB.LDBDisplayTotal = false; end) + end + GuildTithe_SavedDB.CurrentTithe = 0 +end + +local numHelpLines = 10 +-- Print Help +function E:PrintHelpMessages() + for i = 1, numHelpLines do + if i == 1 then + self:PrintMessage(format(L["ChatHelpLine1"], self:GetVerString())) + else + self:PrintMessage(L["ChatHelpLine" .. i]) + end + end +end + + +-- Handles slash commands +function E:OnChatCommand(msg) + self:PrintDebug("OnChatCommand(" .. self:debugArgs(msg) .. ")") + local cmd, args = strsplit(" ", strlower(msg)) + self:PrintDebug("cmd = " .. tostring(cmd) .. ", args = " .. tostring(args)) + if msg == "" or cmd == "help" then + -- Print Help + self:PrintHelpMessages() + + -- want to reset settings? + elseif cmd == "reset" then + if not args or args == "tithe" then + StaticPopup_Show("GUILDTITHE_RESETTITHE") + elseif args == "pos" then + self:ResetWindowSettings() + elseif args == "config" then + StaticPopup_Show("GUILDTITHE_RESETCONFIG") + else + self:PrintMessage(format(L.ChatArgNotFound, args or "", cmd), true) + end + + -- Show the options frame, we don't save this + elseif cmd == "options" or cmd == "config" then + GT_OptionsFrame:Show() + + -- Get the current tithe + elseif cmd == "current" or cmd == "tithe" then + self:PrintMessage(L.ChatOutstandingTithe, GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)) + -- Show/hide or toggle the mini frame. + elseif cmd == "mini" then + -- Show or hide the mini frame, this can be forced, or toggled when passed with no args + if args == "show" then + GT_MiniTitheFrame:Show() + GuildTithe_SavedDB.MiniFrameShown = true + elseif args == "hide" then + GT_MiniTitheFrame:Hide() + GuildTithe_SavedDB.MiniFrameShown = false + -- Lock the mini-frame + elseif args == "lock" then -- This is a toggle + if GuildTithe_SavedDB.MiniFrameLocked then + self:PrintMessage(L.ChatMiniFrameUnlock) + GT_MiniTitheFrame:EnableMouse(true) + GuildTithe_SavedDB.MiniFrameLocked = false + else + self:PrintMessage(L.ChatMiniFrameLock) + GT_MiniTitheFrame:EnableMouse(false) + GuildTithe_SavedDB.MiniFrameLocked = true + end + else -- No args clause, toggle. + if GuildTithe_SavedDB.MiniFrameShown then + GT_MiniTitheFrame:Hide() + GuildTithe_SavedDB.MiniFrameShown = false + else + GT_MiniTitheFrame:Show() + GuildTithe_SavedDB.MiniFrameShown = true + end + end + + + + elseif cmd == "total" then + self:PrintMessage(format(L.OptionsTotalTitheText, GetCoinTextureString(GuildTithe_SavedDB.TotalTithe))) + else + -- This is where we're going to actually print the help info... Later though. + self:PrintMessage(format(L.ChatCommandNotFound, msg), true) + end +end + +function GuildTithe_OnLoad(self) + -- Register events + self:RegisterEvent("ADDON_LOADED") + -- The money events. + self:RegisterEvent("CHAT_MSG_MONEY") + self:RegisterEvent("GUILDBANKFRAME_OPENED") + self:RegisterEvent("MAIL_SHOW") + self:RegisterEvent("MAIL_CLOSED") + self:RegisterEvent("MERCHANT_SHOW") + self:RegisterEvent("MERCHANT_CLOSED") + self:RegisterEvent("TRADE_SHOW") -- Trade Opened + self:RegisterEvent("TRADE_CLOSED") -- Trade closed + self:RegisterEvent("TRADE_MONEY_CHANGED") -- Player's money was updated (used after a trade) + self:RegisterEvent("TRADE_REQUEST_CANCEL") -- Cancelled trade. + + --Other events + self:RegisterEvent("CHAT_MSG_SYSTEM") -- Quest rewards + self:RegisterEvent("PLAYER_LEAVING_WORLD") -- For saving options when we log and the form is closed. + self:RegisterEvent("PLAYER_ENTERING_WORLD") -- For updating the frames and output. + + self:SetScript("OnEvent", E.EventHandler) + + -- Register /commands + SLASH_GUILDTITHE_MAIN1="/gt" + SLASH_GUILDTITHE_MAIN2="/tithe" + SLASH_GUILDTITHE_MAIN3="/guildtithe" + + -- We set up the slash command like this, so we can call the function as a method, instead of a table index. + SlashCmdList["GUILDTITHE_MAIN"] = function(msg, editBox) + E:OnChatCommand(msg) + end + + -- Register dialogs + StaticPopupDialogs["GUILDTITHE_RESETTITHE"] = { + text = L.DialogResetTitheText, + button1 = YES, + button2 = NO, + OnAccept = function() + E:ResetCurrentTithe() + end, + timeout = 0, + whileDead = true, + hideOnEscape = true, + } + + StaticPopupDialogs["GUILDTITHE_RESETCONFIG"] = { + text = E:ParseColorCodedString(L.DialogResetConfigText), + button1 = YES, + button2 = NO, + OnAccept = function() + E:ResetConfig() + end, + timeout = 0, + whileDead = true, + hideOnEscape = true, + showAlert = true, + cancels = "GUILDTITHE_RESETTITHE", + } + + StaticPopupDialogs["GUILDTITHE_SKINRELOADWARNING"] = { + text = L.DialogSkinRequiresReload, + button1 = OKAY, + button2 = NO, + OnAccept = function() + ReloadUI() + end, + OnCancel = function() + GT_OptionsFrame_Seperator_ExtraOption4:SetChecked(GuildTithe_SavedDB.SkinElvUI) + end, + timeout = 0, + whileDead = true, + hideOnEscape = true, + } +end + +function E.EventHandler(self, event, ...) + local arg1, arg2, arg3, arg4 = ... + if event == "ADDON_LOADED" and arg1 == "GuildTithe" then + return E:Init() + + elseif event == "PLAYER_ENTERING_WORLD" then + -- Hide the options frame + GT_OptionsFrame:Hide() + -- Skin the frames + E:SkinFrames() + if not E.Loaded then + + E:PrintMessage(format(L.Loaded, E:GetVerString())) + E:PrintDebug("Loaded in §bDebug Mode§r! This will print a lot of extra, mostly useless information to your chat. You can disable debug mode by unchecking the box marked \"Debug mode\" in the options.") + E:SetTimer(2, function() + GT_MiniTitheFrame.CurrentTithe:SetText(GetCoinTextureString(GuildTithe_SavedDB.CurrentTithe)); + E.Info.LDBData.text = GetLDBCoinString(); + end, true, "GT_CTUPDATE") + E.Loaded = true + end + + -- GUILDBANKFRAME_OPENED: The GB was opened, deposit the outstanding tithe. + elseif event == "GUILDBANKFRAME_OPENED" then + -- WAIT 3 SECONDS FOR GB TO FULLY OPEN + C_Timer.After(3, function() E:DepositTithe() end) + + -- Mail_*: Update outstanding tithe from Mail soruces + elseif event == "MAIL_SHOW" then + return E:UpdateOutstandingTithe("Mail") + elseif event == "MAIL_CLOSED" then + return E:UpdateOutstandingTithe("Mail", true) + + -- Merchant_*: Update outstanding tithe from merchants + elseif event == "MERCHANT_SHOW" then + return E:UpdateOutstandingTithe("Merchant") + elseif event == "MERCHANT_CLOSED" then + return E:UpdateOutstandingTithe("Merchant", true) + + -- TRADE_*: Update trade amounts; + elseif event == "TRADE_SHOW" then + return E:UpdateOutstandingTithe("Trade") + elseif event == "TRADE_REQUEST_CANCEL" then + E.Info.TotalTradeAmount = nil + E:UpdateOutstandingTithe("Trade", true, 0) + elseif event == "TRADE_CLOSED" then + E:UpdateOutstandingTithe("Trade", true, E.Info.TotalTradeAmount or 0) + E.Info.TotalTradeAmount = nil + elseif event == "TRADE_MONEY_CHANGED" then + E.Info.TotalTradeAmount = TradeRecipientMoneyFrame.staticMoney + + -- CHAT_MSG_SYSTEM: Update tithe from Quest rewards + elseif event == "CHAT_MSG_SYSTEM" then + return E:UpdateOutstandingTithe("Quest", true, arg1) + + -- CHAT_MSG_MONEY: Update tithe from Loot + elseif event == "CHAT_MSG_MONEY" then + return E:UpdateOutstandingTithe("Loot", true, arg1) + + -- PLAYER_LEAVING_WORLD + elseif event == "PLAYER_LEAVING_WORLD" then + GT_OptionsFrame:Hide() + -- The options frame doesn't need to remember where it was. + GT_OptionsFrame:SetUserPlaced(false) + end +end + + + diff --git a/GlobalStrings.lua b/GlobalStrings.lua new file mode 100644 index 0000000..7efb7c0 --- /dev/null +++ b/GlobalStrings.lua @@ -0,0 +1,55 @@ +--[[ +------------------------------------------------------------------------ + Project: GuildTithe + File: GlobalStrings rev. 65 + Date: 2012-04-22T23:37:30Z + Purpose: The Global and localizable strings for this addon + Credits: Code written by Vandesdelca32 + + Copyright (C) 2011 Vandesdelca32 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +------------------------------------------------------------------------ +]] + +-- Import the addon table +local addonName, Engine = ... + +-- This is called if a localization can't be found for that key +local function notFound(t,k) + return tostring("§c" .. k .. "§r") +end + +-- Get and load a localization +local function GetL() + -- Store this temporarily + local rv + if not GTLocale["Get_"..GetLocale().."_Strings"] then + rv = GTLocale.Get_enUS_Strings() + else + rv = GTLocale["Get_"..GetLocale().."_Strings"]() + end + return setmetatable(rv, {__index=notFound}) +end + +-- BITCH, WHY DOESN'T THIS FUCKING WORK?! +local L = GetL() + +-- Initialize the addon: +Engine[1] = {} +LibStub:GetLibrary("LibVan32-1.0"):Embed(Engine[1], "GuildTithe") +Engine[2] = L + + +_G[addonName] = Engine diff --git a/GuildTithe.toc b/GuildTithe.toc new file mode 100644 index 0000000..cfb05aa --- /dev/null +++ b/GuildTithe.toc @@ -0,0 +1,25 @@ +## Author: Vandesdelca32 +## Interface: 60000 +## Notes: Implements a guild bank tithe, allowing you to auto-deposit a percentage of your income (from various sources) into the guild bank. Originally written by botono9, this version contains much-needed code updates. +## SavedVariablesPerCharacter: GuildTithe_SavedDB +## Title: GuildTithe +## Version: release_v2.5.15 +## OptionalDeps: ElvUI +## Author: Vandesdelca32 +## X-OriginalAuthor: botono9 +## X-Curse-Packaged-Version: release_v2.5.15 +## X-Curse-Project-Name: Guild Tithe +## X-Curse-Project-ID: guild-tithe +## X-Curse-Repository-ID: wow/guild-tithe/mainline + +#Libraries +embeds.xml + +#Actual Code +Locale\loadLocales.xml +GlobalStrings.lua + +Core.lua +GuildTitheFrames.xml + + diff --git a/GuildTitheFrameScripts.lua b/GuildTitheFrameScripts.lua new file mode 100644 index 0000000..234d87f --- /dev/null +++ b/GuildTitheFrameScripts.lua @@ -0,0 +1,339 @@ +--[[ +------------------------------------------------------------------------ + Project: GuildTithe + File: Frame scripts rev. 118 + Date: 2014-10-17T00:50:40Z + Purpose: Miscellaneous Frame Scripts. + Credits: Code written by Vandesdelca32 + + Copyright (C) 2011 Vandesdelca32 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +------------------------------------------------------------------------ +]] +local E, L = unpack(select(2, ...)) + +-- Skin the frames to look like ElvUI's frames, if it's available +function E:SkinFrames() + if not ElvUI or not GuildTithe_SavedDB.SkinElvUI then return end + local ElvEngine, ElvLocale, ElvProfile, ElvGlobal = unpack(ElvUI) + + local S = ElvEngine:GetModule("Skins") + + local fList = { + "GT_MiniTitheFrame", + "GT_OptionsFrame", + --"GT_OptionsFrame_Title", + "GT_OptionsFrame_Seperator", + } + local chbList = { + "GT_OptionsFrame_QuestOptions_Check", + "GT_OptionsFrame_LootOptions_Check", + "GT_OptionsFrame_MerchantOptions_Check", + "GT_OptionsFrame_MailOptions_Check", + "GT_OptionsFrame_TradeOptions_Check", + "GT_OptionsFrame_Seperator_ExtraOption1", + "GT_OptionsFrame_Seperator_ExtraOption2", + "GT_OptionsFrame_Seperator_ExtraOption3", + "GT_OptionsFrame_Seperator_ExtraOption4", + } + local sbList = { + "GT_OptionsFrame_QuestOptions_Slider", + "GT_OptionsFrame_LootOptions_Slider", + "GT_OptionsFrame_MerchantOptions_Slider", + "GT_OptionsFrame_MailOptions_Slider", + "GT_OptionsFrame_TradeOptions_Slider", + } + local ebList = { + "GT_OptionsFrame_QuestOptions_Text", + "GT_OptionsFrame_LootOptions_Text", + "GT_OptionsFrame_MerchantOptions_Text", + "GT_OptionsFrame_MailOptions_Text", + "GT_OptionsFrame_TradeOptions_Text", + } + + -- Here's where the magic happens + for _, v in pairs(fList) do + _G[v]:SetTemplate("Transparent") + end + -- Tweak the frames + GT_OptionsFrame_Title:StripTextures() + GT_OptionsFrame:SetHeight(292) + GT_OptionsFrame:SetWidth(420) + GT_MiniTitheFrame.CurrentTithe:Point("BOTTOM", GT_MiniTitheFrame, "BOTTOM", 0, -1) + + -- Close button + S:HandleCloseButton(GT_OptionsFrame_CloseButton, GT_OptionsFrame) + S:HandleCloseButton(GT_MiniTitheFrame_Close, GT_MiniTitheFrame) + + -- Check Buttons + for _, v in pairs(chbList) do + S:HandleCheckBox(_G[v]) + _G[v]:SetSize(24, 24) + end + + -- Sliders. These need special handling, they need the thumbs resized or else it will make them HUUUUGE + for _, v in pairs(sbList) do + S:HandleSliderFrame(_G[v]) + _G[v]:SetHeight(12) + _G[v]:GetThumbTexture():SetSize(10, 14) + _G[v .. "Low"]:Point("TOPLEFT", _G[v], "BOTTOMLEFT", 0, -2) + _G[v .. "High"]:Point("TOPRIGHT", _G[v], "BOTTOMRIGHT", 0, -2) + end + + -- EditBoxes: + for _, v in pairs(ebList) do + S:HandleEditBox(_G[v]) + _G[v]:SetHeight(20) + end + + + -- Mark the addon as skinned + E.ElvSkinned = true +end + +-- The script called by the template, used to keep the edit box in check +function E.FrameScript_EditBoxOnEnterPressed(self) + -- Get the text + local num = self:GetText() + + -- Check to see if the user put a % sign in, because the field implies it is there. + if strfind(num, "%%") then return end + + num = tonumber(num) + if not num then return end + if num < 1 then + num = 1 + self:SetText("1") + elseif num > 100 then + num = 100 + self:SetText("100") + end + self:GetParent().Slider:SetValue(num) + self:ClearFocus() +end + +function E.FrameScript_UpdateOptionRow(self) + if not self:GetChecked() then + self:GetParent().Text:Disable(); + self:GetParent().Slider:Disable(); + PlaySound(857) + else + self:GetParent().Slider:Enable(); + self:GetParent().Text:Enable(); + PlaySound(856) + end +end + +function E.FrameScript_OptionRowChangeState(self, state) + if not E.ElvSkinned then + if state == "DISABLE" then + self:GetThumbTexture():SetVertexColor(0.5, 0.5, 0.5) + _G[self:GetName() .. "Low"]:SetFontObject(GameFontDisableSmall) + _G[self:GetName() .. "High"]:SetFontObject(GameFontDisableSmall) + elseif state == "ENABLE" then + self:GetThumbTexture():SetVertexColor(1, 1, 1) + _G[self:GetName() .. "Low"]:SetFontObject(GameFontHighlightSmall) + _G[self:GetName() .. "High"]:SetFontObject(GameFontHighlightSmall) + else + return + end + else + -- Need a different method for this if we're skinning it through ElvUI + if state == "DISABLE" then + self:GetThumbTexture():Hide() + _G[self:GetName() .. "Low"]:SetFontObject(GameFontDisableSmall) + _G[self:GetName() .. "High"]:SetFontObject(GameFontDisableSmall) + elseif state == "ENABLE" then + self:GetThumbTexture():Show() + _G[self:GetName() .. "Low"]:SetFontObject(GameFontHighlightSmall) + _G[self:GetName() .. "High"]:SetFontObject(GameFontHighlightSmall) + end + end +end + +function E.FrameScript_MiniTitheFrameOnLoad(self) + self:RegisterForDrag("LeftButton") + self.Label1:SetText(L.MiniFrameCurrentTitheText) +end + + +function E.FrameScript_MiniTitheFrameOnClick(self, button) + E:PrintDebug("MiniFrame OnClick()") + if IsAddOnLoaded("Blizzard_GuildBankUI") and GuildBankFrame:IsVisible() then + E:DepositTithe(1) + elseif SendMailFrame:IsVisible() then + E:DepositTithe(1,1) + else + if GuildTithe_SavedDB.Spammy then + E:PrintMessage(L.ChatNoValidDeposits, true) + end + end +end + +-- Load the localization-specific strings +function E.LoadOptionsFrame(self) + -- Set the strings + self.Title.Text:SetText(L.OptionsTitle) + self.Info.text:SetText(L.OptionsExtraText) + self.Version.text:SetText(format(L.OptionsVersionText, E:GetVerString())) + + --Set the row's text here. + self.QuestOptions.Check.text:SetText(L.OptionsQuestText) + self.LootOptions.Check.text:SetText(L.OptionsLootText) + self.MerchantOptions.Check.text:SetText(L.OptionsMerchantText) + self.MailOptions.Check.text:SetText(L.OptionsMailText) + self.TradeOptions.Check.text:SetText(L.OptionsTradeText) + + -- Extra Options + self.Extra.AutoDeposit.text:SetText(L.OptionsAutoDeposit) + self.Extra.AutoDeposit.text:SetFontObject(GameFontHighlight) + + self.Extra.Spammy.text:SetText(L.OptionsSpammy) + self.Extra.Spammy.text:SetFontObject(GameFontHighlight) + + self.Extra.Debug.text:SetText(L.OptionsDebug) + + if ElvUI then + self.Extra.SkinElv:Show() + self.Extra.SkinElv.text:SetText(L.OptionsElvSkin) + self.Extra.SkinElv.text:SetFontObject(GameFontHighlight) + else + self.Extra.SkinElv:Hide() + end +end + +-- Show the user thier options when they open the form. +function E.UpdateOptions(self) + -- load options + -- Quests? + if (GuildTithe_SavedDB.CollectSource.Quest + and GuildTithe_SavedDB.CollectSource.Quest ~= -1) then + self.QuestOptions.Check:SetChecked(1) + self.QuestOptions.Slider:SetValue(GuildTithe_SavedDB.CollectSource.Quest) + else + self.QuestOptions.Check:SetChecked(false) + self.QuestOptions.Slider:SetValue(20) + end + + -- Loot? + if (GuildTithe_SavedDB.CollectSource.Loot + and GuildTithe_SavedDB.CollectSource.Loot ~= -1) then + self.LootOptions.Check:SetChecked(true) + self.LootOptions.Slider:SetValue(GuildTithe_SavedDB.CollectSource.Loot) + else + self.LootOptions.Check:SetChecked(false) + self.LootOptions.Slider:SetValue(20) + end + + -- Merchant? + if (GuildTithe_SavedDB.CollectSource.Merchant + and GuildTithe_SavedDB.CollectSource.Merchant ~= -1) then + self.MerchantOptions.Check:SetChecked(true) + self.MerchantOptions.Slider:SetValue(GuildTithe_SavedDB.CollectSource.Merchant) + else + self.MerchantOptions.Check:SetChecked(false) + self.MerchantOptions.Slider:SetValue(20) + end + + -- Mail? + if (GuildTithe_SavedDB.CollectSource.Mail + and GuildTithe_SavedDB.CollectSource.Mail ~= -1) then + self.MailOptions.Check:SetChecked(true) + self.MailOptions.Slider:SetValue(GuildTithe_SavedDB.CollectSource.Mail) + else + self.MailOptions.Check:SetChecked(false) + self.MailOptions.Slider:SetValue(20) + end + + -- Trade? + if (GuildTithe_SavedDB.CollectSource.Trade + and GuildTithe_SavedDB.CollectSource.Trade ~= -1) then + self.TradeOptions.Check:SetChecked(true) + self.TradeOptions.Slider:SetValue(GuildTithe_SavedDB.CollectSource.Trade) + else + self.TradeOptions.Check:SetChecked(false) + self.TradeOptions.Slider:SetValue(20) + end + + -- Misc options + self.Extra.AutoDeposit:SetChecked(GuildTithe_SavedDB.AutoDeposit) + self.Extra.Spammy:SetChecked(GuildTithe_SavedDB.Spammy) + self.Extra.Debug:SetChecked(E._DebugMode) + self.Extra.SkinElv:SetChecked(GuildTithe_SavedDB.SkinElvUI) + + -- Total Tithe + self.TotalTithe.text:SetFormattedText(L.OptionsTotalTitheText, GetCoinTextureString(GuildTithe_SavedDB.TotalTithe)) + + -- Force the frame to properly update state. + E.FrameScript_UpdateOptionRow(self.QuestOptions.Check) + E.FrameScript_UpdateOptionRow(self.LootOptions.Check) + E.FrameScript_UpdateOptionRow(self.MerchantOptions.Check) + E.FrameScript_UpdateOptionRow(self.MailOptions.Check) + E.FrameScript_UpdateOptionRow(self.TradeOptions.Check) + PlaySound(850) +end + +-- Save the config when the user closes the form. +function E.SaveOptions(self) + local GuildTithe_SavedDB = GuildTithe_SavedDB + + -- Inc tedium, we're setting the option to the value, or -1 if the check isn't set. + -- Quest + if self.QuestOptions.Check:GetChecked() then + GuildTithe_SavedDB["CollectSource"]["Quest"] = self.QuestOptions.Slider:GetValue() + else + GuildTithe_SavedDB["CollectSource"]["Quest"] = -1 + end + + -- Loot + if self.LootOptions.Check:GetChecked() then + GuildTithe_SavedDB["CollectSource"]["Loot"] = self.LootOptions.Slider:GetValue() + else + GuildTithe_SavedDB["CollectSource"]["Loot"] = -1 + end + + -- Mail + if self.MailOptions.Check:GetChecked() then + GuildTithe_SavedDB["CollectSource"]["Mail"] = self.MailOptions.Slider:GetValue() + else + GuildTithe_SavedDB["CollectSource"]["Mail"] = -1 + end + + -- Merchant + if self.MerchantOptions.Check:GetChecked() then + GuildTithe_SavedDB["CollectSource"]["Merchant"] = self.MerchantOptions.Slider:GetValue() + else + GuildTithe_SavedDB["CollectSource"]["Merchant"] = -1 + end + + -- Trade + if self.TradeOptions.Check:GetChecked() then + GuildTithe_SavedDB["CollectSource"]["Trade"] = self.TradeOptions.Slider:GetValue() + else + GuildTithe_SavedDB["CollectSource"]["Trade"] = -1 + end + + GuildTithe_SavedDB["AutoDeposit"] = self.Extra.AutoDeposit:GetChecked() + GuildTithe_SavedDB["Spammy"] = self.Extra.Spammy:GetChecked() + GuildTithe_SavedDB["SkinElvUI"] = self.Extra.SkinElv:GetChecked() + -- DebugMode is never saved, but update the user's choice: + if self.Extra.Debug:GetChecked() then + E._DebugMode = true + else + E._DebugMode = false + end + PlaySound(851) +end + diff --git a/GuildTitheFrames.xml b/GuildTitheFrames.xml new file mode 100644 index 0000000..e4e723f --- /dev/null +++ b/GuildTitheFrames.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + self.text:SetFontObject(GameFontHighlight) + GuildTithe[1].FrameScript_UpdateOptionRow(self, button) + + + + + + + + + + + + EditBox_HighlightText(self); + self:SetNumber(self:GetParent().Slider:GetValue()) + + + EditBox_ClearHighlight(self); + if not strfind(self:GetText(), "%%") then + self:SetText(self:GetText() .. "%") + end + + GuildTithe[1].FrameScript_EditBoxOnEnterPressed(self) + self:ClearFocus() + self:SetFontObject(ChatFontDisable) + self:SetFontObject(ChatFontNormal) + + + + + + + + + + + + + _G[self:GetName() .. "Low"]:SetText("1%") + _G[self:GetName() .. "High"]:SetText("100%") + + + self:GetParent().Text:ClearFocus() + self:GetParent().Text:SetText(tostring(value) .. "%") + + + GuildTithe[1].FrameScript_OptionRowChangeState(self, "DISABLE") + + + GuildTithe[1].FrameScript_OptionRowChangeState(self, "ENABLE") + + + + + + + +