From acf6b1787ccf858a18e415a2de1fe0fa573873e2 Mon Sep 17 00:00:00 2001 From: MilleXIV Date: Sun, 21 Aug 2016 13:01:14 -0400 Subject: [PATCH] Start of travel module Hearth buttons aren't working yet, no idea why --- core.lua | 25 +++- locales/enUS.lua | 3 + modules/heartstone.lua | 251 --------------------------------- modules/load_modules.xml | 1 + modules/micromenu.lua | 7 +- modules/old/heartstone.lua | 251 +++++++++++++++++++++++++++++++++ modules/travel.lua | 329 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 611 insertions(+), 256 deletions(-) delete mode 100644 modules/heartstone.lua create mode 100644 modules/old/heartstone.lua create mode 100644 modules/travel.lua diff --git a/core.lua b/core.lua index 79ac44f..4198f5d 100644 --- a/core.lua +++ b/core.lua @@ -10,6 +10,7 @@ XIVBar.defaults = { profile = { general = { barPosition = "BOTTOM", + barPadding = 3, }, color = { barColor = { @@ -58,7 +59,9 @@ XIVBar.defaults = { XIVBar.constants = { mediaPath = "Interface\\AddOns\\"..AddOnName.."\\media\\", playerName = UnitName("player"), - playerClass = select(2, UnitClass("player")) + playerClass = select(2, UnitClass("player")), + playerLevel = UnitLevel("player"), + popupPadding = 3 } XIVBar.LSM = LibStub('LibSharedMedia-3.0'); @@ -219,7 +222,7 @@ function XIVBar:CreateMainBar() end function XIVBar:GetHeight() - return (self.db.profile.text.fontSize * 2) + 3 + return (self.db.profile.text.fontSize * 2) + self.db.profile.general.barPadding end function XIVBar:Refresh() @@ -264,6 +267,14 @@ function XIVBar:RGBAToHex(r, g, b, a) return string.format("%02x%02x%02x%02x", r*255, g*255, b*255, a*255) end +function XIVBar:HexToRGBA(hex) + local rhex, ghex, bhex, ahex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6), string.sub(hex, 7, 8) + if not (rhex and ghex and bhex and ahex) then + return 0, 0, 0, 0 + end + return (tonumber(rhex, 16) / 255), (tonumber(ghex, 16) / 255), (tonumber(bhex, 16) / 255), (tonumber(ahex, 16) / 255) +end + function XIVBar:GetGeneralOptions() @@ -300,6 +311,16 @@ function XIVBar:GetGeneralOptions() get = function() return XIVBar:GetColor('barColor') end, disabled = function() return self.db.profile.color.useCC end }, + barPadding = { + name = L['Bar Padding'], + type = 'range', + order = 4, + min = 0, + max = 10, + step = 1, + get = function() return self.db.profile.general.barPadding; end, + set = function(info, val) self.db.profile.general.barPadding = val; self:Refresh(); end + } } } end diff --git a/locales/enUS.lua b/locales/enUS.lua index 3602156..96eb596 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -15,6 +15,7 @@ L['Top'] = true; L['Bottom'] = true; L['Bar Color'] = true; L['Use Class Colors for Bar'] = true; +L['Bar Padding'] = true; -- Media L['Font'] = true; @@ -60,3 +61,5 @@ L['Local Time'] = true; L['Realm Time'] = true; L['Open Calendar'] = true; L['Open Clock'] = true; + +L['Travel'] = true; diff --git a/modules/heartstone.lua b/modules/heartstone.lua deleted file mode 100644 index 322ca4b..0000000 --- a/modules/heartstone.lua +++ /dev/null @@ -1,251 +0,0 @@ -local addon, ns = ... -local cfg = ns.cfg -local unpack = unpack --------------------------------------------------------------- -if not cfg.heartstone.show then return end - -local garrOnHover = false -local hsOnHover = false - -local teleportFrame = CreateFrame("Frame",nil, cfg.SXframe) -teleportFrame:SetPoint("RIGHT",-4,0) -teleportFrame:SetSize(16, 16) ---------------------------------------------------------------------- -local HSFrame = CreateFrame("BUTTON","hsButton", teleportFrame, "SecureActionButtonTemplate") -HSFrame:SetPoint("RIGHT") -HSFrame:SetSize(16, 16) -HSFrame:EnableMouse(true) -HSFrame:RegisterForClicks("AnyUp") -HSFrame:SetAttribute("type", "macro") - -local HSText = HSFrame:CreateFontString(nil, "OVERLAY") -HSText:SetFont(cfg.text.font, cfg.text.normalFontSize) -HSText:SetPoint("RIGHT") -HSText:SetTextColor(unpack(cfg.color.normal)) - -local HSIcon = HSFrame:CreateTexture(nil,"OVERLAY",nil,7) -HSIcon:SetSize(16, 16) -HSIcon:SetPoint("RIGHT", HSText,"LEFT",-2,0) -HSIcon:SetTexture(cfg.mediaFolder.."datatexts\\hearth") -HSIcon:SetVertexColor(unpack(cfg.color.normal)) - -HSFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - HSIcon:SetVertexColor(unpack(cfg.color.hover)) - if not cfg.heartstone.showTooltip then return end - local startTime, duration = GetItemCooldown(6948) - if startTime ~= 0 then - local CDremaining = (startTime+duration)-GetTime() - GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) - GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) - GameTooltip:Show() - end - hsOnHover = true -end) - -HSFrame:SetScript("OnLeave", function() - hsOnHover = false - if IsUsableItem(6948) and GetItemCooldown(6948) == 0 or IsPlayerSpell(556) and GetSpellCooldown(556) == 0 then - HSIcon:SetVertexColor(unpack(cfg.color.normal)) - else - HSIcon:SetVertexColor(unpack(cfg.color.inactive)) - end -end) - --- Change the button action before the click reaches it: -function HSFrame:ChangeAction(action) - if InCombatLockdown() then return end -- can't change attributes in combat - self:SetAttribute("macrotext", action) -end - -HSFrame:SetScript("PreClick", function(self) - if InCombatLockdown() then return end -- can't change attributes in combat - - -- Innkeeper's Daughter - if PlayerHasToy(64488) and GetItemCooldown(64488) == 0 then - local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(64488) - return self:ChangeAction("/use " .. itemName) - - -- Hearthstone - elseif IsUsableItem(6948) and GetItemCooldown(6948) == 0 then - local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(6948) - return self:ChangeAction("/use " .. itemName) - - -- Astral Recall - elseif IsPlayerSpell(556) and GetSpellCooldown(556) == 0 then - local spellName, _, spellIcon = GetSpellInfo(556) - return self:ChangeAction("/cast " .. spellName) - end - - local playerLevel = UnitLevel("player") - - if playerLevel > 70 and IsUsableItem(44315) and GetItemCooldown(44315) == 0 then - return self:SetAttribute("macrotext", "/use Scroll of Recall III") - - elseif playerLevel > 40 and IsUsableItem(44314) and GetItemCooldown(44314) == 0 then - return self:SetAttribute("macrotext", "/use Scroll of Recall II") - - elseif playerLevel <= 39 and IsUsableItem(37118) and GetItemCooldown(37118) == 0 then - return self:SetAttribute("macrotext", "/use Scroll of Recall") - - end -end) ---------------------------------------------------------------------- -local garrisonFrame = CreateFrame("BUTTON","garrisonButton", teleportFrame, "SecureActionButtonTemplate") -garrisonFrame:SetPoint("LEFT") -garrisonFrame:SetSize(16, 16) -garrisonFrame:EnableMouse(true) -garrisonFrame:RegisterForClicks("AnyUp") -garrisonFrame:SetAttribute("*type1", "macro") - --- Change the button action before the click reaches it: -function garrisonFrame:ChangeAction(action) - if InCombatLockdown() then return end -- can't change attributes in combat - self:SetAttribute("macrotext", action) -end - -garrisonFrame:SetScript("PreClick", function(self) - if InCombatLockdown() then return end -- can't change attributes in combat - - if IsShiftKeyDown() then - if IsUsableItem(128353) and GetItemCooldown(128353) == 0 then - local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(128353) - return self:ChangeAction("/use " .. itemName) - end - else - if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then - local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(110560) - return self:ChangeAction("/use " .. itemName) - end - end -end) - - -local garrisonIcon = garrisonFrame:CreateTexture(nil,"OVERLAY",nil,7) -garrisonIcon:SetSize(16, 16) -garrisonIcon:SetPoint("LEFT") -garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garr") -garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) - -local garrisonText = garrisonFrame:CreateFontString(nil, "OVERLAY") -garrisonText:SetFont(cfg.text.font, cfg.text.normalFontSize) -garrisonText:SetPoint("LEFT", garrisonIcon,"RIGHT",2,0) -garrisonText:SetText("GARRISON") -garrisonText:SetTextColor(unpack(cfg.color.normal)) - -garrisonFrame:SetScript("OnEnter", function() - if InCombatLockdown() then return end - local startTime, duration = GetItemCooldown(110560) - if startTime ~= 0 then - local CDremaining = (startTime+duration)-GetTime() - GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) - GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) - GameTooltip:Show() - end - garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) - garrOnHover = true -end) - -garrisonFrame:SetScript("OnLeave", function() - garrOnHover = false - if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then - garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) - else - garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) - end - GameTooltip:Hide() -end) - -local function hsHover() -local startTime, duration = GetItemCooldown(6948) - if startTime ~= 0 then - local CDremaining = (startTime+duration)-GetTime() - GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) - GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) - GameTooltip:Show() - end - HSIcon:SetVertexColor(unpack(cfg.color.hover)) -end - -local function garrHover() -local startTime, duration = GetItemCooldown(110560) - if startTime ~= 0 then - local CDremaining = (startTime+duration)-GetTime() - GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) - GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) - GameTooltip:Show() - end - garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) -end - -local function updateTeleportText() -local playerLevel = UnitLevel("player") - if PlayerHasToy(64488) and GetItemCooldown(64488) == 0 - or IsUsableItem(6948) and GetItemCooldown(6948) == 0 - or IsPlayerSpell(556) and GetSpellCooldown(556) == 0 - or playerLevel > 70 and IsUsableItem(44315) and GetItemCooldown(44315) == 0 - or playerLevel > 40 and IsUsableItem(44314) and GetItemCooldown(44314) == 0 - or playerLevel <= 39 and IsUsableItem(37118) and GetItemCooldown(37118) == 0 - then - HSIcon:SetVertexColor(unpack(cfg.color.normal)) - HSText:SetTextColor(unpack(cfg.color.normal)) - else - HSIcon:SetVertexColor(unpack(cfg.color.inactive)) - HSText:SetTextColor(unpack(cfg.color.inactive)) - end - - if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then - garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) - garrisonText:SetTextColor(unpack(cfg.color.normal)) - else - garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) - garrisonText:SetTextColor(unpack(cfg.color.inactive)) - end -end - -local elapsed = 0 -teleportFrame:SetScript('OnUpdate', function(self, e) - elapsed = elapsed + e - if elapsed >= 1 then - updateTeleportText() - if garrOnHover then garrHover() end - if hsOnHover then hsHover() end - elapsed = 0 - end -end) - -local eventframe = CreateFrame("Frame") -eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") -eventframe:RegisterEvent("BAG_UPDATE") -eventframe:RegisterEvent("HEARTHSTONE_BOUND") -eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") - -eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) -if InCombatLockdown() then return end - -HSText:SetText(strupper(GetBindLocation())) -HSFrame:SetSize(HSText:GetStringWidth()+16, 16) - - -if IsUsableItem(110560) then - garrisonFrame:Show() -else - garrisonFrame:Hide() -end - -if event == "MODIFIER_STATE_CHANGED" then - if arg1 == "LSHIFT" or arg1 == "RSHIFT" then - if arg2 == 1 then - if IsUsableItem(128353) then - garrisonText:SetText("SHIPYARD") - garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\shipcomp") - end - elseif arg2 == 0 then - garrisonText:SetText("GARRISON") - garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garr") - end - end -end - garrisonFrame:SetSize(garrisonText:GetStringWidth()+16, 16) - teleportFrame:SetSize(HSFrame:GetWidth()+garrisonFrame:GetWidth()+8, 16) -end) diff --git a/modules/load_modules.xml b/modules/load_modules.xml index ea97f09..f656a98 100644 --- a/modules/load_modules.xml +++ b/modules/load_modules.xml @@ -3,4 +3,5 @@