diff --git a/Buttons/Housing.lua b/Buttons/Housing.lua index dba782d..14ca390 100644 --- a/Buttons/Housing.lua +++ b/Buttons/Housing.lua @@ -3,6 +3,10 @@ local _, tpm = ... local Housing = {} tpm.Housing = Housing +local L = LibStub("AceLocale-3.0"):GetLocale("TeleportMenu") +local MSQ = LibStub("Masque", true) +local MasqueGroup = MSQ and MSQ:Group(L["ADDON_NAME"]) + local housingButtonsPool = {} local activeHousingButtons = {} @@ -52,6 +56,8 @@ local function createCooldownFrame(frame) end function Housing:CreateSecureHousingButton(tpInfo) + local db = tpm:GetOptions() + local size = db["Button:Size"] or 40 local button, houseInfo = nil, nil if #houseData == 1 or tpInfo.faction == "alliance" then @@ -64,8 +70,11 @@ function Housing:CreateSecureHousingButton(tpInfo) button = table.remove(housingButtonsPool) else button = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate") + button:SetSize(size, size) button.text = button:CreateFontString(nil, "OVERLAY") + button.Icon = button:CreateTexture(nil, "BACKGROUND") + button.Icon:SetAllPoints() button.text:SetPoint("BOTTOM", button, "BOTTOM", 0, 5) button.cooldownFrame = createCooldownFrame(button) @@ -99,11 +108,15 @@ function Housing:CreateSecureHousingButton(tpInfo) end -- Textures + if button:GetNormalTexture() then + button:GetNormalTexture():SetTexture(nil) + end + if self:CanReturn() then - button:SetNormalAtlas("dashboard-panel-homestone-teleport-out-button") + button.Icon:SetAtlas("dashboard-panel-homestone-teleport-out-button") else local spellTexture = C_Spell.GetSpellTexture(1263273) - button:SetNormalTexture(spellTexture) + button.Icon:SetTexture(spellTexture) end -- Attributes @@ -118,6 +131,11 @@ function Housing:CreateSecureHousingButton(tpInfo) button.cooldownFrame:CheckCooldown() table.insert(activeHousingButtons, button) + + if MasqueGroup then + MasqueGroup:AddButton(button, { Icon = button.Icon }) + end + return button end diff --git a/Locales/zhTW.lua b/Locales/zhTW.lua index 2d44528..927c822 100644 --- a/Locales/zhTW.lua +++ b/Locales/zhTW.lua @@ -1,7 +1,7 @@ local L = LibStub("AceLocale-3.0"):NewLocale("TeleportMenu", "zhTW") if not L then return end -L["AddonNamePrint"] = "\124cFFFF0000TeleportMenu:\124r " -- 1 space after the : +L["AddonNamePrint"] = "\124cFFFF0000傳送選單:\124r " -- 1 space after the : L["Common:Loading"] = "載入中" L["Not In Combat Tooltip"] = "\124cFFFF0000<戰鬥中不可用>\124r" L["Random Hearthstone"] = "隨機爐石" @@ -82,17 +82,17 @@ L["Eco-Dome Al'dani"] = "秘境" L["Manaforge Omega"] = "歐美加" -- expansion abreviated Text -L["Cataclysm"] = "浩劫重生" -L["Mists of Pandaria"] = "潘達利亞" +L["Cataclysm"] = "浩劫" +L["Mists of Pandaria"] = "潘達" L["Warlords of Draenor"] = "德拉諾" L["Legion"] = "軍臨" L["Battle for Azeroth"] = "決戰" L["Shadowlands"] = "暗影" -L["Shadowlands Raids"] = "暗影 團" +L["Shadowlands Raids"] = "暗影團本" L["Dragonflight"] = "巨龍" -L["Dragonflight Raids"] = "巨龍 團" +L["Dragonflight Raids"] = "巨龍團本" L["The War Within"] = "地心" -L["The War Within Raids"] = "地心 團" +L["The War Within Raids"] = "地心團本" L["Season 1"] = "賽季1" L["Season 2"] = "賽季2" L["Season 3"] = "賽季3" @@ -134,7 +134,7 @@ L["Opening Options Menu"] = "開啟設定選單" L["Enabled"] = "啟用" L["Enable Tooltip"] = "啟用/停用 此傳送選單。" L["Auto Close"] = "自動關閉" -L["Auto Close Tooltip"] = "在點擊使用爐石后自動關閉游戲主菜單界面" +L["Auto Close Tooltip"] = "在點擊使用爐石後自動關閉遊戲主選單介面" L["Hearthstone Toy"] = "爐石玩具" L["Hearthstone Toy Tooltip"] = "設置首選的爐石玩具。\n\n如果設置為隨機,則每次打開遊戲選單時都會選擇一個隨機的爐石玩具。" L["None"] = "無" @@ -159,8 +159,8 @@ L["Teleports:Items:Filters:Held_Items"] = "您擁有的物品" L["Teleports:Items:Filters:Items_To_Be_Obtained"] = "不可用的物品" -- Settings -L["ADDON_NAME"] = "TeleportMenu" -L["TITLE"] = "TeleportMenu設定" +L["ADDON_NAME"] = "傳送選單" +L["TITLE"] = "傳送選單設定" L["GENERAL"] = "一般設定" L["BUTTON_SETTINGS"] = "按鈕設定" L["TELEPORT_SETTINGS"] = "傳送設定" diff --git a/TeleportMenu.lua b/TeleportMenu.lua index 4a14970..0bb72ba 100644 --- a/TeleportMenu.lua +++ b/TeleportMenu.lua @@ -5,6 +5,8 @@ local _, tpm = ... -------------------------------------- local L = LibStub("AceLocale-3.0"):GetLocale("TeleportMenu") +local MSQ = LibStub("Masque", true) +local MasqueGroup = MSQ and MSQ:Group(L["ADDON_NAME"]) -------------------------------------- -- Locales @@ -14,6 +16,7 @@ local db = {} local APPEND = L["AddonNamePrint"] local DEFAULT_ICON = "Interface\\Icons\\INV_Misc_QuestionMark" local globalWidth, globalHeight = 40, 40 -- defaults +local SPACING = 3 local IsSpellKnown = C_SpellBook.IsSpellKnown @@ -214,11 +217,14 @@ local GetItemCount = C_Item.GetItemCount -------------------------------------- local function SetTextureByItemId(frame, itemId) - frame:SetNormalTexture(DEFAULT_ICON) -- Temp while loading + if frame:GetNormalTexture() then + frame:GetNormalTexture():SetTexture(nil) + end + frame.Icon:SetTexture(DEFAULT_ICON) -- Temp while loading local item = Item:CreateFromItemID(tonumber(itemId)) item:ContinueOnItemLoad(function() local icon = item:GetItemIcon() - frame:SetNormalTexture(icon) + frame.Icon:SetTexture(icon) end) end @@ -353,6 +359,8 @@ local function createFlyOutButton(flyOutFrame, flyoutData, tooltipData, side) -- flyOutButton = table.remove(flyOutButtonsPool) else flyOutButton = CreateFrame("Button", nil, side == "LEFT" and TeleportMeButtonsFrameLeft or TeleportMeButtonsFrameRight, "SecureActionButtonTemplate") + flyOutButton.Icon = flyOutButton:CreateTexture(nil, "BACKGROUND") + flyOutButton.Icon:SetAllPoints() flyOutButton.text = flyOutButton:CreateFontString(nil, "OVERLAY") flyOutButton.text:SetPoint("BOTTOM", flyOutButton, "BOTTOM", 0, 5) @@ -408,7 +416,10 @@ local function createFlyOutButton(flyOutFrame, flyoutData, tooltipData, side) -- end -- Texture - flyOutButton:SetNormalTexture(flyoutData.iconId) + if flyOutButton:GetNormalTexture() then + flyOutButton:GetNormalTexture():SetTexture(nil) + end + flyOutButton.Icon:SetTexture(flyoutData.iconId) -- Positioning/Size flyOutButton:SetFrameStrata("HIGH") @@ -416,6 +427,9 @@ local function createFlyOutButton(flyOutFrame, flyoutData, tooltipData, side) -- flyOutButton:SetSize(globalWidth, globalHeight) flyOutButton:Show() + if MasqueGroup then + MasqueGroup:AddButton(flyOutButton, { Icon = flyOutButton.Icon }) + end return flyOutButton end @@ -487,6 +501,8 @@ local function CreateSecureButton(frame, buttonType, text, id, hearthstone) button.text = button:CreateFontString(nil, "OVERLAY") button:LockHighlight() button.text:SetPoint("BOTTOM", button, "BOTTOM", 0, 5) + button.Icon = button:CreateTexture(nil, "BACKGROUND") + button.Icon:SetAllPoints() table.insert(secureButtons, button) end @@ -546,9 +562,12 @@ local function CreateSecureButton(frame, buttonType, text, id, hearthstone) button.cooldownFrame:CheckCooldown(id, buttonType) -- Textures + if button:GetNormalTexture() then + button:GetNormalTexture():SetTexture(nil) + end if buttonType == "spell" then local spellTexture = C_Spell.GetSpellTexture(id) - button:SetNormalTexture(spellTexture) + button.Icon:SetTexture(spellTexture) else -- item or toy SetTextureByItemId(button, id) end @@ -571,6 +590,9 @@ local function CreateSecureButton(frame, buttonType, text, id, hearthstone) button:SetFrameLevel(102) -- This needs to be lower than the flyout frame button:Show() + if MasqueGroup then + MasqueGroup:AddButton(button, { Icon = button.Icon }) + end return button end @@ -664,7 +686,7 @@ function tpm:CreateFlyout(flyoutData, side) return end - local yOffset = -globalHeight * ButtonFrame:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * ButtonFrame:GetButtonAmount() local flyOutFrame = createFlyOutFrame(side) flyOutFrame:SetPoint(side == "LEFT" and "RIGHT" or "LEFT", ButtonFrame, side == "LEFT" and "TOPLEFT" or "TOPRIGHT", side == "LEFT" and globalWidth or 0, yOffset) @@ -689,10 +711,10 @@ function tpm:CreateFlyout(flyoutData, side) end flyoutsCreated = flyoutsCreated + 1 local flyOutButton = CreateSecureButton(flyOutFrame, "spell", shortNames[spellId], spellId) - local offsetY = (rowNr - 1) * - globalHeight - local offsetX = globalWidth * flyoutsCreated + local offsetY = (rowNr - 1) * -(globalHeight + SPACING) + local offsetX = (globalWidth + SPACING) * flyoutsCreated if side == "LEFT" then - offsetX = -globalWidth * flyoutsCreated + offsetX = -(globalWidth + SPACING) * flyoutsCreated end flyOutButton:SetPoint(side == "LEFT" and "TOPRIGHT" or "TOPLEFT", flyOutFrame, side == "LEFT" and "TOPRIGHT" or "TOPLEFT", offsetX, offsetY) table.insert(childButtons, flyOutButton) @@ -700,7 +722,7 @@ function tpm:CreateFlyout(flyoutData, side) end local frameWidth = rowNr > 1 and globalWidth * (db["Flyout:Max_Per_Row"] + 1) or globalWidth * (flyoutsCreated + 1) - flyOutFrame:SetSize(frameWidth, globalHeight * rowNr) + flyOutFrame:SetSize(frameWidth, (globalHeight + SPACING) * rowNr) button.childButtons = childButtons return button end @@ -712,7 +734,7 @@ function tpm:CreateSeasonalTeleportFlyout() local tooltipData = { type = "seasonalteleport" } local seasonalFlyOutData = { id = -1, name = L["Season " .. tpm.settings.current_season], iconId = 5927657 } - local yOffset = -globalHeight * TeleportMeButtonsFrameRight:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * TeleportMeButtonsFrameRight:GetButtonAmount() local flyOutFrame = createFlyOutFrame() flyOutFrame:SetPoint("LEFT", TeleportMeButtonsFrameRight, "TOPRIGHT", 0, yOffset) @@ -731,11 +753,11 @@ function tpm:CreateSeasonalTeleportFlyout() flyoutsCreated = flyoutsCreated + 1 local text = tpm:GetIconText(spellId) local flyOutButton = CreateSecureButton(flyOutFrame, "spell", text, spellId) - flyOutButton:SetPoint("TOPLEFT", flyOutFrame, "TOPLEFT", globalWidth * flyoutsCreated, (rowNr - 1) * - globalHeight) + flyOutButton:SetPoint("TOPLEFT", flyOutFrame, "TOPLEFT", (globalWidth + SPACING) * flyoutsCreated, (rowNr - 1) * -(globalHeight + SPACING)) end end local frameWidth = rowNr > 1 and globalWidth * (db["Flyout:Max_Per_Row"] + 1) or globalWidth * (flyoutsCreated + 1) - flyOutFrame:SetSize(frameWidth, globalHeight * rowNr) + flyOutFrame:SetSize(frameWidth, (globalHeight + SPACING) * rowNr) return button end @@ -746,7 +768,7 @@ function tpm:CreateWormholeFlyout(flyoutData) return end - local yOffset = -globalHeight * TeleportMeButtonsFrameLeft:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * TeleportMeButtonsFrameLeft:GetButtonAmount() local flyOutFrame = createFlyOutFrame("LEFT") flyOutFrame:SetPoint("RIGHT", TeleportMeButtonsFrameLeft, "TOPLEFT", globalWidth, yOffset) @@ -763,10 +785,10 @@ function tpm:CreateWormholeFlyout(flyoutData) end flyoutsCreated = flyoutsCreated + 1 local flyOutButton = CreateSecureButton(flyOutFrame, "toy", nil, wormholeId) - flyOutButton:SetPoint("TOPRIGHT", flyOutFrame, "TOPRIGHT", -globalWidth * flyoutsCreated, (rowNr - 1) * - globalHeight) + flyOutButton:SetPoint("TOPRIGHT", flyOutFrame, "TOPRIGHT", -(globalWidth + SPACING) * flyoutsCreated, (rowNr - 1) * -(globalHeight + SPACING)) end local frameWidth = rowNr > 1 and globalWidth * (db["Flyout:Max_Per_Row"] + 1) or globalWidth * (flyoutsCreated + 1) - flyOutFrame:SetSize(frameWidth, globalHeight * rowNr) + flyOutFrame:SetSize(frameWidth, (globalHeight + SPACING) * rowNr) return button end @@ -776,10 +798,10 @@ function tpm:CreateItemTeleportsFlyout(flyoutData) return end - local yOffset = -globalHeight * TeleportMeButtonsFrameLeft:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * TeleportMeButtonsFrameLeft:GetButtonAmount() local flyOutFrame = createFlyOutFrame("LEFT") - flyOutFrame:SetPoint("RIGHT", TeleportMeButtonsFrameLeft, "TOPLEFT", 0, yOffset) + flyOutFrame:SetPoint("RIGHT", TeleportMeButtonsFrameLeft, "TOPLEFT", globalWidth, yOffset) local button = createFlyOutButton(flyOutFrame, flyoutData, { type = "item_teleports" }, "LEFT") button:SetPoint("LEFT", TeleportMeButtonsFrameLeft, "TOPRIGHT", 0, yOffset) @@ -794,11 +816,11 @@ function tpm:CreateItemTeleportsFlyout(flyoutData) flyoutsCreated = flyoutsCreated + 1 local isToy = tpm:IsToyTeleport(itemTeleportId) local flyOutButton = CreateSecureButton(flyOutFrame, isToy and "toy" or "item", nil, itemTeleportId) - flyOutButton:SetPoint("TOPLEFT", flyOutFrame, "TOPLEFT", globalWidth * flyoutsCreated, (rowNr - 1) * - globalHeight) + flyOutButton:SetPoint("TOPRIGHT", flyOutFrame, "TOPRIGHT", -(globalWidth + SPACING) * flyoutsCreated, (rowNr - 1) * -(globalHeight + SPACING)) end local frameWidth = rowNr > 1 and globalWidth * (db["Flyout:Max_Per_Row"] + 1) or globalWidth * (flyoutsCreated + 1) - flyOutFrame:SetSize(frameWidth, globalHeight * rowNr) + flyOutFrame:SetSize(frameWidth, (globalHeight + SPACING) * rowNr) return button end @@ -811,7 +833,10 @@ function tpm:updateHearthstone() if db["Teleports:Hearthstone"] == "rng" then local rng = math.random(#tpm.AvailableHearthstones) - hearthstoneButton:SetNormalTexture(1669494) -- misc_rune_pvp_random + if hearthstoneButton:GetNormalTexture() then + hearthstoneButton:GetNormalTexture():SetTexture(nil) + end + hearthstoneButton.Icon:SetTexture(1669494) -- misc_rune_pvp_random hearthstoneButton:SetAttribute("type", "toy") hearthstoneButton:SetAttribute("toy", tpm.AvailableHearthstones[rng]) elseif db["Teleports:Hearthstone"] == "disabled" then @@ -925,7 +950,7 @@ local function createAnchors() if known and (teleport.type == "toy" or teleport.type == "item" or teleport.type == "spell" or (showHearthstone and teleport.hearthstone)) then tpm:DebugPrint(teleport.hearthstone) local button = CreateSecureButton(buttonsFrameLeft, teleport.type, nil, teleport.id --[[@as integer]], teleport.hearthstone) - local yOffset = -globalHeight * buttonsFrameLeft:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * buttonsFrameLeft:GetButtonAmount() button:SetPoint("LEFT", buttonsFrameLeft, "TOPRIGHT", 0, yOffset) if teleport.hearthstone then -- store to replace item later buttonsFrameLeft.hearthstoneButton = button @@ -938,7 +963,7 @@ local function createAnchors() button:SetParent(buttonsFrameLeft) button:SetSize(globalWidth, globalHeight) button:Show() - local yOffset = -globalHeight * buttonsFrameLeft:GetButtonAmount() + local yOffset = -(globalHeight + SPACING) * buttonsFrameLeft:GetButtonAmount() button:SetPoint("LEFT", buttonsFrameLeft, "TOPRIGHT", 0, yOffset) buttonsFrameLeft:IncrementButtons() end diff --git a/TeleportMenu.toc b/TeleportMenu.toc index 8f84f36..20ec93c 100644 --- a/TeleportMenu.toc +++ b/TeleportMenu.toc @@ -19,6 +19,7 @@ ## Author: Justwait ## Version: @project-version@ ## SavedVariables: TeleportMenuDB +## OptionalDeps: Masque ## X-Curse-Project-ID: 1087836