From 2e7eb76d0329a4c0f5f577c3a0ced09132b8690b Mon Sep 17 00:00:00 2001 From: MilleXIV Date: Tue, 23 Aug 2016 23:09:17 -0400 Subject: [PATCH] Few updates, half of currency complete Still need to do XP bar for currency --- embeds.xml | 1 + locales/enUS.lua | 5 + modules/currency.lua | 641 +++++++++++++++++++++++----------------------- modules/load_modules.xml | 1 + modules/micromenu.lua | 10 +- modules/old/currency.lua | 321 +++++++++++++++++++++++ modules/old/social.lua | 272 ++++++++++++++++++++ modules/social.lua | 272 -------------------- modules/travel.lua | 8 +- 9 files changed, 937 insertions(+), 594 deletions(-) create mode 100644 modules/old/currency.lua create mode 100644 modules/old/social.lua delete mode 100644 modules/social.lua diff --git a/embeds.xml b/embeds.xml index 61b51c8..14c0d68 100644 --- a/embeds.xml +++ b/embeds.xml @@ -3,6 +3,7 @@ + diff --git a/locales/enUS.lua b/locales/enUS.lua index b570894..31e2bea 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -77,3 +77,8 @@ L['Currency'] = true; L['Show XP Bar Below Max Level'] = true; L['Show Tooltips'] = true; L['Text on Right'] = true; +L['Toggle Currency Frame'] = true; +L['Currency Select'] = true; +L['First Currency'] = true; +L['Second Currency'] = true; +L['Third Currency'] = true; diff --git a/modules/currency.lua b/modules/currency.lua index 13bbc53..5dc80a9 100644 --- a/modules/currency.lua +++ b/modules/currency.lua @@ -1,321 +1,328 @@ -local addon, ns = ... -local cfg = ns.cfg -local unpack = unpack --------------------------------------------------------------- -if not cfg.currency.show then return end - -local iconPos = "RIGHT" -local textPos = "LEFT" - -if cfg.currency.textOnRight then - iconPos = "LEFT" - textPos = "RIGHT" +local AddOnName, XIVBar = ...; +local _G = _G; +local xb = XIVBar; +local L = XIVBar.L; + +local CurrencyModule = xb:NewModule("CurrencyModule", 'AceEvent-3.0', 'AceHook-3.0') + +function CurrencyModule:GetName() + return L['Currency']; +end + +function CurrencyModule:OnInitialize() + self.rerollItems = { + 697, -- Elder Charm of Good Fortune + 752, -- Mogu Rune of Fate + 776, -- Warforged Seal + 994, -- Seal of Tempered Fate + 1129, -- Seal of Inevitable Fate + 1273, -- Seal of Broken Fate + } + + self.intToOpt = { + [1] = 'currencyOne', + [2] = 'currencyTwo', + [3] = 'currencyThree' + } + + self.curButtons = {} + self.curIcons = {} + self.curText = {} +end + +function CurrencyModule:OnEnable() + if self.currencyFrame == nil then + self.currencyFrame = CreateFrame("FRAME", nil, xb:GetFrame('goldFrame')) + xb:RegisterFrame('currencyFrame', self.currencyFrame) + end + + self:CreateFrames() + self:RegisterFrameEvents() + self:Refresh() +end + +function CurrencyModule:OnDisable() + self.currencyFrame:Hide() + self:UnregisterEvent('CURRENCY_DISPLAY_UPDATE') +end + +function CurrencyModule:Refresh() + local db = xb.db.profile + if self.currencyFrame == nil then return; end + if not db.modules.currency.enabled then return; end + + local iconSize = db.text.fontSize + db.general.barPadding + for i = 1, 3 do + self.curButtons[i]:Hide() + end + + if xb.constants.playerLevel < MAX_PLAYER_LEVEL and db.modules.currency.showXPbar then + else -- show xp bar/show currencies + local iconsWidth = 0 + for i = 1, 3 do + if db.modules.currency[self.intToOpt[i]] ~= '0' then + iconsWidth = iconsWidth + self:StyleCurrencyFrame(tonumber(db.modules.currency[self.intToOpt[i]]), i) + end + end + self.curButtons[1]:SetPoint('LEFT') + self.curButtons[2]:SetPoint('LEFT', self.curButtons[1], 'RIGHT', 5, 0) + self.curButtons[3]:SetPoint('LEFT', self.curButtons[2], 'RIGHT', 5, 0) + self.currencyFrame:SetSize(iconsWidth, xb:GetHeight()) + end -- show currencies + + --self.currencyFrame:SetSize(self.goldButton:GetSize()) + self.currencyFrame:SetPoint('RIGHT', self.currencyFrame:GetParent(), 'LEFT', -(db.general.moduleSpacing), 0) end -local currencyFrame = CreateFrame("Frame",nil, cfg.SXframe) -currencyFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 340,0) -currencyFrame:SetSize(16, 16) - ---------------------------------------------- --- XP BAR ---------------------------------------------- -local xpFrame = CreateFrame("BUTTON",nil, cfg.SXframe) -xpFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 350,0) -xpFrame:SetSize(16, 16) -xpFrame:EnableMouse(true) -xpFrame:RegisterForClicks("AnyUp") - -local xpIcon = xpFrame:CreateTexture(nil,"OVERLAY",nil,7) -xpIcon:SetSize(16, 16) -xpIcon:SetPoint("LEFT") -xpIcon:SetTexture(cfg.mediaFolder.."datatexts\\exp") -xpIcon:SetVertexColor(unpack(cfg.color.normal)) - -local xpText = xpFrame:CreateFontString(nil, "OVERLAY") -xpText:SetFont(cfg.text.font, cfg.text.normalFontSize) -xpText:SetPoint("RIGHT",xpFrame,2,0 ) -xpText:SetTextColor(unpack(cfg.color.normal)) - -local xpStatusbar = CreateFrame("StatusBar", nil, xpFrame) -xpStatusbar:SetStatusBarTexture(1,1,1) -xpStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) -xpStatusbar:SetPoint("TOPLEFT", xpText, "BOTTOMLEFT",0,-2) - -local xpStatusbarBG = xpStatusbar:CreateTexture(nil,"BACKGROUND",nil,7) -xpStatusbarBG:SetPoint("TOPLEFT", xpText, "BOTTOMLEFT",0,-2) -xpStatusbarBG:SetColorTexture(unpack(cfg.color.inactive)) - -xpFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - xpIcon:SetVertexColor(unpack(cfg.color.hover)) - xpStatusbar:SetStatusBarColor(unpack(cfg.color.hover)) - if not cfg.currency.showTooltip then return end - local mxp = UnitXPMax("player") - local xp = UnitXP("player") - local nxp = mxp - xp - local rxp = GetXPExhaustion() - local name, standing, minrep, maxrep, value = GetWatchedFactionInfo() - - if cfg.core.position ~= "BOTTOM" then - GameTooltip:SetOwner(xpStatusbar, cfg.tooltipPos) - else - GameTooltip:SetOwner(xpFrame, cfg.tooltipPos) - end - - GameTooltip:AddLine("[|cff6699FFExperience Bar|r]") - GameTooltip:AddLine(" ") - GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, format(cfg.SVal(xp)).."|cffffd100/|r"..format(cfg.SVal(mxp)).." |cffffd100/|r "..floor((xp/mxp)*1000)/10 .."%",NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) - GameTooltip:AddDoubleLine(NEED, format(cfg.SVal(nxp)).." |cffffd100/|r "..floor((nxp/mxp)*1000)/10 .."%",NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) - if rxp then - GameTooltip:AddDoubleLine(TUTORIAL_TITLE26, format(cfg.SVal(rxp)) .." |cffffd100/|r ".. floor((rxp/mxp)*1000)/10 .."%", NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) - end - GameTooltip:Show() -end) - -xpFrame:SetScript("OnLeave", function() - xpIcon:SetVertexColor(unpack(cfg.color.normal)) - xpStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) - if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end -end) - ---------------------------------------------- --- REROLL ---------------------------------------------- -local rerollFrame = CreateFrame("BUTTON",nil, currencyFrame) -rerollFrame:SetPoint("LEFT") -rerollFrame:SetSize(16, 16) -rerollFrame:EnableMouse(true) -rerollFrame:RegisterForClicks("AnyUp") - -local rerollIcon = rerollFrame:CreateTexture(nil,"OVERLAY",nil,7) -rerollIcon:SetSize(16, 16) -rerollIcon:SetPoint(iconPos) -rerollIcon:SetTexture(cfg.mediaFolder.."datatexts\\reroll") -rerollIcon:SetVertexColor(unpack(cfg.color.inactive)) - -local rerollText = rerollFrame:CreateFontString(nil, "OVERLAY") -rerollText:SetFont(cfg.text.font, cfg.text.normalFontSize) ---rerollText:SetPoint(iconPos,rerollIcon,textPos,-2,0) -rerollText:SetPoint(textPos) -rerollText:SetTextColor(unpack(cfg.color.inactive)) - -rerollFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - rerollIcon:SetVertexColor(unpack(cfg.color.hover)) - if not cfg.currency.showTooltip then return end - GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) - GameTooltip:AddLine("[|cff6699FFReroll|r]") - GameTooltip:AddLine(" ") - local SoIFname, SoIFamount, SoIFicon, SoIFearnedThisWeek, SoIFweeklyMax, SoIFtotalMax, SoIFisDiscovered = GetCurrencyInfo(1129) - if SoIFamount > 0 then - GameTooltip:AddLine(SoIFname,1,1,0) - GameTooltip:AddDoubleLine("|cffffff00Weekly: |cffffffff"..SoIFearnedThisWeek.."|cffffff00/|cffffffff"..SoIFweeklyMax, "|cffffff00Total: |cffffffff"..SoIFamount.."|cffffff00/|cffffffff"..SoIFtotalMax) - else - local SoTFname, SoTFamount, SoTFicon, SoTFearnedThisWeek, SoTFweeklyMax, SoTFtotalMax, SoTFisDiscovered = GetCurrencyInfo(994) - if SoTFamount > 0 then - GameTooltip:AddDoubleLine(SoTFname, "|cffffff00Total: |cffffffff"..SoTFamount.."|cffffff00/|cffffffff"..SoTFtotalMax) - end - end - GameTooltip:Show() -end) - -rerollFrame:SetScript("OnLeave", function() - if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end - rerollIcon:SetVertexColor(unpack(cfg.color.inactive)) -end) - -rerollFrame:SetScript("OnClick", function(self, button, down) - if InCombatLockdown() then return end - if button == "LeftButton" then - ToggleCharacter("TokenFrame") - end -end) - ---------------------------------------------- --- HONOR ---------------------------------------------- - -local honorFrame = CreateFrame("BUTTON",nil, currencyFrame) -honorFrame:SetPoint("LEFT",rerollFrame,"RIGHT",2,0) -honorFrame:SetSize(16, 16) -honorFrame:EnableMouse(true) -honorFrame:RegisterForClicks("AnyUp") - -local honorIcon = honorFrame:CreateTexture(nil,"OVERLAY",nil,7) -honorIcon:SetSize(16, 16) -honorIcon:SetPoint(iconPos) -honorIcon:SetTexture(cfg.mediaFolder.."datatexts\\honor") -honorIcon:SetVertexColor(unpack(cfg.color.inactive)) - -local honorText = honorFrame:CreateFontString(nil, "OVERLAY") -honorText:SetFont(cfg.text.font, cfg.text.normalFontSize) -honorText:SetPoint(textPos) -honorText:SetTextColor(unpack(cfg.color.inactive)) - -honorFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - honorIcon:SetVertexColor(unpack(cfg.color.hover)) - if not cfg.currency.showTooltip then return end - GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) - GameTooltip:AddLine("[|cff6699FFHonor Level:|r"..UnitHonorLevel("player").."]") - GameTooltip:AddLine(" ") - GameTooltip:AddDoubleLine(concName,"|cffffff00Honor: |cffffffff"..UnitHonor("player").."|cffffff00/|cffffffff"..UnitHonorMax("player")) - GameTooltip:Show() -end) - -honorFrame:SetScript("OnLeave", function() - if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end - honorIcon:SetVertexColor(unpack(cfg.color.inactive)) -end) - -honorFrame:SetScript("OnClick", function(self, button, down) - if InCombatLockdown() then return end - if button == "LeftButton" then - ToggleCharacter("TokenFrame") - end -end) - ---------------------------------------------- --- GARRISON RECOURCES ---------------------------------------------- - -local garrisonFrame = CreateFrame("BUTTON",nil, currencyFrame) -garrisonFrame:SetPoint("LEFT",honorFrame,"RIGHT",2,0) -garrisonFrame:SetSize(16, 16) -garrisonFrame:EnableMouse(true) -garrisonFrame:RegisterForClicks("AnyUp") - -local garrisonIcon = garrisonFrame:CreateTexture(nil,"OVERLAY",nil,7) -garrisonIcon:SetSize(16, 16) -garrisonIcon:SetPoint(iconPos) -garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garres") -garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) - -local garrisonText = garrisonFrame:CreateFontString(nil, "OVERLAY") -garrisonText:SetFont(cfg.text.font, cfg.text.normalFontSize) -garrisonText:SetPoint(textPos) -garrisonText:SetTextColor(unpack(cfg.color.inactive)) - -garrisonFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) - if not cfg.currency.showTooltip then return end - GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) - GameTooltip:AddLine("[|cff6699FFGarrison Recources|r]") - GameTooltip:AddLine(" ") - local grName, grAmount, _, _, _, grTotalMax = GetCurrencyInfo(824) - local oilName, oilAmount, _, _, _, oilTotalMax, oilIsDiscovered = GetCurrencyInfo(1101) - local apexisName, apexisAmount = GetCurrencyInfo(823) - local DICName, DICAmount, _, _, _, DICTotalMax = GetCurrencyInfo(980) - - GameTooltip:AddDoubleLine(grName, "|cffffffff"..format(cfg.SVal(grAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(grTotalMax))) - if oilIsDiscovered then - GameTooltip:AddDoubleLine(oilName, "|cffffffff"..format(cfg.SVal(oilAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(oilTotalMax))) - end - GameTooltip:AddDoubleLine(apexisName, "|cffffffff"..format(cfg.SVal(apexisAmount))) - if DICAmount > 0 then - GameTooltip:AddDoubleLine(DICName, "|cffffffff"..format(cfg.SVal(DICAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(DICTotalMax))) - end - GameTooltip:Show() -end) - -garrisonFrame:SetScript("OnLeave", function() - if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end - garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) -end) - -garrisonFrame:SetScript("OnClick", function(self, button, down) - if InCombatLockdown() then return end - if button == "LeftButton" then - ToggleCharacter("TokenFrame") - end -end) - - ---------------------------------------------- --- FUNCTIONS ---------------------------------------------- -local function updateXP(xp, mxp) - if UnitLevel("player") == MAX_PLAYER_LEVEL or not cfg.currency.showXPbar then - xpFrame:Hide() - xpFrame:EnableMouse(false) - currencyFrame:Show() - else - currencyFrame:Hide() - xpFrame:Show() - xpFrame:EnableMouse(true) - xpStatusbar:SetMinMaxValues(0, mxp) - xpStatusbar:SetValue(xp) - xpText:SetText("LEVEL "..UnitLevel("player").." "..cfg.CLASS) - xpFrame:SetSize(xpText:GetStringWidth()+18, 16) - xpStatusbar:SetSize(xpText:GetStringWidth(),3) - xpStatusbarBG:SetSize(xpText:GetStringWidth(),3) - end +function CurrencyModule:StyleCurrencyFrame(curId, i) + local db = xb.db.profile + local iconSize = db.text.fontSize + db.general.barPadding + local icon = xb.constants.mediaPath..'datatexts\\garres' + if tContains(self.rerollItems, curId) then + icon = xb.constants.mediaPath..'datatexts\\reroll' + end + local _, curAmount, _ = GetCurrencyInfo(curId) + + local iconPoint = 'RIGHT' + local textPoint = 'LEFT' + local padding = -5 + + if xb.db.profile.modules.currency.textOnRight then + iconPoint = 'LEFT' + textPoint = 'RIGHT' + padding = -(padding) + end + + self.curIcons[i]:ClearAllPoints() + self.curText[i]:ClearAllPoints() + + self.curIcons[i]:SetTexture(icon) + self.curIcons[i]:SetSize(iconSize, iconSize) + self.curIcons[i]:SetPoint(iconPoint) + self.curIcons[i]:SetVertexColor(db.color.normal.r, db.color.normal.g, db.color.normal.b, db.color.normal.a) + + self.curText[i]:SetFont(xb.LSM:Fetch(xb.LSM.MediaType.FONT, db.text.font), db.text.fontSize) + self.curText[i]:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) + self.curText[i]:SetText(curAmount) + self.curText[i]:SetPoint(iconPoint, self.curIcons[i], textPoint, padding, 0) + + local buttonWidth = iconSize + self.curText[i]:GetStringWidth() + 5 + self.curButtons[i]:SetSize(buttonWidth, xb:GetHeight()) + self.curButtons[i]:Show() + return buttonWidth end ---------------------------------------------- --- EVENT HANDELING ---------------------------------------------- - -local eventframe = CreateFrame("Frame") -eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") -eventframe:RegisterEvent("PLAYER_XP_UPDATE") -eventframe:RegisterEvent("PLAYER_LEVEL_UP") -eventframe:RegisterEvent("CURRENCY_DISPLAY_UPDATE") -eventframe:RegisterEvent("CHAT_MSG_CURRENCY") -eventframe:RegisterEvent("TRADE_CURRENCY_CHANGED") -eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") - -eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) - --if event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then - if UnitLevel("player") ~= MAX_PLAYER_LEVEL and cfg.currency.showXPbar then - mxp = UnitXPMax("player") - xp = UnitXP("player") - updateXP(xp, mxp) - currencyFrame:Hide() - else - xpFrame:Hide() - end - - if event == "MODIFIER_STATE_CHANGED" then - if InCombatLockdown() then return end - if arg1 == "LSHIFT" or arg1 == "RSHIFT" then - if UnitLevel("player") == MAX_PLAYER_LEVEL or not cfg.currency.showXPbar then return end - if arg2 == 1 then - xpFrame:Hide() - xpFrame:EnableMouse(false) - currencyFrame:Show() - elseif arg2 == 0 then - currencyFrame:Hide() - xpFrame:EnableMouse(true) - xpFrame:Show() - end - end - end - - - - - -- reroll currency - local SoIFname, SoIFamount, _, _, _, SoIFtotalMax, SoIFisDiscovered = GetCurrencyInfo(1129) - if SoIFamount > 0 then - rerollText:SetText(SoIFamount) - else - local SoTFname, SoTFamount, _, _, _, SoTFtotalMax, SoTFisDiscovered = GetCurrencyInfo(994) - if SoTFamount > 0 then rerollText:SetText(SoTFamount) end - end - rerollFrame:SetSize(rerollText:GetStringWidth()+18, 16) - - -- honor currency - honorText:SetText(UnitHonor("player")) - honorFrame:SetSize(honorText:GetStringWidth()+18, 16) - - currencyFrame:SetSize(rerollFrame:GetWidth()+honorFrame:GetWidth()+6,16) - - -- garrison currency - local grName, grAmount, _, grEarnedThisWeek, grWeeklyMax, grTotalMax, grIsDiscovered = GetCurrencyInfo(824) - garrisonText:SetText(grAmount) - garrisonFrame:SetSize(garrisonText:GetStringWidth()+18, 16) - - currencyFrame:SetSize(rerollFrame:GetWidth()+honorFrame:GetWidth()+garrisonFrame:GetWidth()+6,16) -end) +function CurrencyModule:CreateFrames() + for i = 1, 3 do + self.curButtons[i] = self.curButtons[i] or CreateFrame("BUTTON", nil, self.currencyFrame) + self.curIcons[i] = self.curIcons[i] or self.curButtons[i]:CreateTexture(nil, 'OVERLAY') + self.curText[i] = self.curText[i] or self.curButtons[i]:CreateFontString(nil, "OVERLAY") + self.curButtons[i]:Hide() + end + + self.xpFrame = self.xpFrame or CreateFrame("BUTTON", nil, self.currencyFrame) + self.xpIcon = self.xpIcon or self.xpFrame:CreateTexture(nil, 'OVERLAY') + self.xpText = self.xpText or self.xpFrame:CreateFontString(nil, 'OVERLAY') + self.xpBar = self.xpBar or CreateFrame('STATUSBAR', nil, self.xpFrame) + self.xpBarBg = self.xpBarBg or self.xpBar:CreateTexture(nil, 'BACKGROUND') + self.xpFrame:Hide() +end + +function CurrencyModule:RegisterFrameEvents() + + for i = 1, 3 do + self.curButtons[i]:EnableMouse(true) + self.curButtons[i]:RegisterForClicks("AnyUp") + self.curButtons[i]:SetScript('OnEnter', function() + if InCombatLockdown() then return; end + self.curText[i]:SetTextColor(unpack(xb:HoverColors())) + if xb.db.profile.modules.currency.showTooltip then + self:ShowTooltip() + end + end) + self.curButtons[i]:SetScript('OnLeave', function() + if InCombatLockdown() then return; end + local db = xb.db.profile + self.curText[i]:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) + if xb.db.profile.modules.currency.showTooltip then + GameTooltip:Hide() + end + end) + self.curButtons[i]:SetScript('OnClick', function() + if InCombatLockdown() then return; end + ToggleCharacter('TokenFrame') + end) + end + self:RegisterEvent('CURRENCY_DISPLAY_UPDATE', 'Refresh') + self:SecureHook('BackpackTokenFrame_Update', 'Refresh') -- Ugh, why is there no event for this? + + self.currencyFrame:EnableMouse(true) + self.currencyFrame:SetScript('OnEnter', function() + if xb.db.profile.modules.currency.showTooltip then + self:ShowTooltip() + end + end) + self.currencyFrame:SetScript('OnLeave', function() + if xb.db.profile.modules.currency.showTooltip then + GameTooltip:Hide() + end + end) + --[[ + self.goldButton:EnableMouse(true) + self.goldButton:RegisterForClicks("AnyUp") + + self.goldButton:SetScript('OnEnter', function() + if InCombatLockdown() then return; end + self.goldText:SetTextColor(unpack(xb:HoverColors())) + self.bagText:SetTextColor(unpack(xb:HoverColors())) + + GameTooltip:SetOwner(CurrencyModule.goldFrame, 'ANCHOR_'..xb.miniTextPosition) + GameTooltip:AddLine("[|cff6699FF"..L['Gold'].."|r - |cff82c5ff"..xb.constants.playerFactionLocal.." "..xb.constants.playerRealm.."|r]") + GameTooltip:AddLine(" ") + + local totalGold = 0 + for charName, goldData in pairs(xb.db.factionrealm) do + GameTooltip:AddDoubleLine(charName, CurrencyModule:FormatCoinText(goldData.currentMoney), 1, 1, 0, 1, 1, 1) + totalGold = totalGold + goldData.currentMoney + end + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine(L['Total'], CurrencyModule:FormatCoinText(totalGold), 1, 1, 0, 1, 1, 1) + GameTooltip:AddDoubleLine('<'..L['Left-Click']..'>', L['Toggle Bags'], 1, 1, 0, 1, 1, 1) + GameTooltip:Show() + end) + + self.goldButton:SetScript('OnLeave', function() + if InCombatLockdown() then return; end + local db = xb.db.profile + self.goldText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) + self.bagText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) + GameTooltip:Hide() + end) + + self.goldButton:SetScript('OnClick', function(_, button) + if InCombatLockdown() then return; end + ToggleAllBags() + end)]]-- +end + +function CurrencyModule:ShowTooltip() + GameTooltip:SetOwner(self.currencyFrame, 'ANCHOR_'..xb.miniTextPosition) + GameTooltip:AddLine("[|cff6699FF"..L['Currency'].."|r]") + GameTooltip:AddLine(" ") + + for i = 1, 3 do + if xb.db.profile.modules.currency[self.intToOpt[i]] ~= '0' then + local curId = tonumber(xb.db.profile.modules.currency[self.intToOpt[i]]) + local name, count, _, _, _, totalMax, _, _ = GetCurrencyInfo(curId) + GameTooltip:AddDoubleLine(name, string.format('%d/%d', count, totalMax), 1, 1, 0, 1, 1, 1) + end + end + + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine('<'..L['Left-Click']..'>', L['Toggle Currency Frame'], 1, 1, 0, 1, 1, 1) + GameTooltip:Show() +end + +function CurrencyModule:GetCurrencyOptions() + local curOpts = { + ['0'] = '' + } + for i = 1, GetCurrencyListSize() do + local _, isHeader, _, isUnused = GetCurrencyListInfo(i) + if not isHeader and not isUnused then + local cL = GetCurrencyListLink(i) + local colon, _ = strfind(cL, ':', 1, true) + local pipeS, _ = strfind(cL, '|h', colon, true) + local itemId = strsub(cL, colon + 1, pipeS - 1) + local name, _ = GetCurrencyInfo(itemId) + curOpts[tostring(itemId)] = name + end + end + return curOpts +end + +function CurrencyModule:GetDefaultOptions() + return 'currency', { + enabled = true, + showXPbar = true, + showTooltip = true, + textOnRight = true, + currencyOne = '0', + currencyTwo = '0', + currencyThree = '0' + } +end + +function CurrencyModule:GetConfig() + return { + name = self:GetName(), + type = "group", + args = { + enable = { + name = ENABLE, + order = 0, + type = "toggle", + get = function() return xb.db.profile.modules.currency.enabled; end, + set = function(_, val) xb.db.profile.modules.currency.enabled = val; self:Refresh(); end, + width = "full" + }, + showXPbar = { + name = L['Show XP Bar Below Max Level'], + order = 1, + type = "toggle", + get = function() return xb.db.profile.modules.currency.showXPbar; end, + set = function(_, val) xb.db.profile.modules.currency.showXPbar = val; self:Refresh(); end, + width = "full" + }, + showTooltip = { + name = L['Show Tooltips'], + order = 2, + type = "toggle", + get = function() return xb.db.profile.modules.currency.showTooltip; end, + set = function(_, val) xb.db.profile.modules.currency.showTooltip = val; self:Refresh(); end + }, + textOnRight = { + name = L['Text on Right'], + order = 3, + type = "toggle", + get = function() return xb.db.profile.modules.currency.textOnRight; end, + set = function(_, val) xb.db.profile.modules.currency.textOnRight = val; self:Refresh(); end + }, + currency = { + type = 'group', + name = L['Currency Select'], + order = 4, + inline = true, + args = { + currencyOne = { + name = L['First Currency'], -- DROPDOWN, GoldModule:GetCurrencyOptions + type = "select", + order = 1, + values = function() return self:GetCurrencyOptions(); end, + style = "dropdown", + get = function() return xb.db.profile.modules.currency.currencyOne; end, + set = function(info, value) xb.db.profile.modules.currency.currencyOne = value; self:Refresh(); end, + }, + currencyTwo = { + name = L['Second Currency'], -- DROPDOWN, GoldModule:GetCurrencyOptions + type = "select", + order = 2, + values = function() return self:GetCurrencyOptions(); end, + style = "dropdown", + get = function() return xb.db.profile.modules.currency.currencyTwo; end, + set = function(info, value) xb.db.profile.modules.currency.currencyTwo = value; self:Refresh(); end, + }, + currencyThree = { + name = L['Third Currency'], -- DROPDOWN, GoldModule:GetCurrencyOptions + type = "select", + order = 3, + values = function() return self:GetCurrencyOptions(); end, + style = "dropdown", + get = function() return xb.db.profile.modules.currency.currencyThree; end, + set = function(info, value) xb.db.profile.modules.currency.currencyThree = value; self:Refresh(); end, + } + } + } + } + } +end diff --git a/modules/load_modules.xml b/modules/load_modules.xml index 32b56ff..9b18e8a 100644 --- a/modules/load_modules.xml +++ b/modules/load_modules.xml @@ -5,4 +5,5 @@