diff --git a/.luacheckrc b/.luacheckrc index 5bd56ca1..3d378bf4 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -36,6 +36,7 @@ globals = { "PlumberLandingPageMinimapButtonMixin", "PlumberLootUIFont", "PlumberOutfitSelectOutfitEntryMixin", + "PlumberReloadHelperMixin", "PlumberStorage", "PlumberSuperTrackingMixin", "PlumberWorldMapPinMixin", @@ -90,6 +91,7 @@ stds.wow = { "GossipFrame", "SlashCmdList", "StaticPopupDialogs", + "UnitPopupViewHousesButtonMixin", "WardrobeItemModelMixin", "WardrobeItemsCollectionSlotButtonMixin", @@ -780,6 +782,7 @@ stds.wow = { "GetCurrentHouseLevelFavor", "GetCurrentNeighborhoodGUID", "GetHouseLevelFavorForLevel", + "GetOthersOwnedHouses", "GetPlayerOwnedHouses", "GetUIMapIDForNeighborhood", "GetVisitCooldownInfo", @@ -1318,6 +1321,12 @@ stds.wow = { }, }, + C_UI = { + fields = { + "Reload", + }, + }, + C_UIWidgetManager = { fields = { "GetAllWidgetsBySetID", @@ -1704,6 +1713,8 @@ stds.wow = { UnitPopupSharedUtil = { fields = { + "GetFullPlayerName", + "GetGUID", "HasLFGRestrictions", }, }, @@ -1776,6 +1787,7 @@ stds.wow = { "EQUIPMENTFLYOUT_FIRST_SPECIAL_LOCATION", "ERR_ACHIEVEMENT_WATCH_COMPLETED", "ERR_COSMETIC_KNOWN", + "ERR_HOUSING_RESULT_LOCKED_BY_COMBAT", "ERR_ITEM_NOT_FOUND", "ERR_LFG_PROPOSAL_FAILED", "EXPANSION_NAME10", @@ -1891,6 +1903,7 @@ stds.wow = { "UNIT_SKINNABLE_HERB", "UNIT_YOU", "UNUSED", + "VIEW_HOUSES_TITLE", "WEEKLY_REWARDS_CLICK_TO_PREVIEW_INSTRUCTIONS", "WEEKLY_REWARDS_COMPLETE_WORLD", "WEEKLY_REWARDS_CURRENT_REWARD", diff --git a/API.lua b/API.lua index 20370416..2185147d 100644 --- a/API.lua +++ b/API.lua @@ -2514,7 +2514,7 @@ do -- System end - function API.TriggerExpansionMinimapButtonAlert(text) + function API.TriggerExpansionMinimapButtonAlert(text) -- unused if ExpansionLandingPageMinimapButton then ExpansionLandingPageMinimapButton:TriggerAlert(text); end @@ -4039,6 +4039,11 @@ do -- Custom Hyperlink ItemRef local args = {...}; local link = "|Haddon:plumber:"..typeName; + if #args == 0 then + -- There must be at least 1 arg + args = {0}; + end + for i, v in ipairs(args) do link = link..":"..v; end @@ -4048,6 +4053,8 @@ do -- Custom Hyperlink ItemRef return link end end + + API.AddCustomLinkType("ReloadUI", C_UI.Reload); end do -- 11.0 Menu Formatter diff --git a/Art/ControlCenter/Changelog_Housing_HouseList.jpg b/Art/ControlCenter/Changelog_Housing_HouseList.jpg new file mode 100644 index 00000000..d46ad668 Binary files /dev/null and b/Art/ControlCenter/Changelog_Housing_HouseList.jpg differ diff --git a/Art/ControlCenter/Preview_Housing_HouseList.jpg b/Art/ControlCenter/Preview_Housing_HouseList.jpg new file mode 100644 index 00000000..14630776 Binary files /dev/null and b/Art/ControlCenter/Preview_Housing_HouseList.jpg differ diff --git a/Art/Housing/HouseListFrame.png b/Art/Housing/HouseListFrame.png new file mode 100644 index 00000000..c2472cad Binary files /dev/null and b/Art/Housing/HouseListFrame.png differ diff --git a/Initialization.lua b/Initialization.lua index 95d45c22..0794ecfc 100644 --- a/Initialization.lua +++ b/Initialization.lua @@ -1,5 +1,5 @@ -local VERSION_TEXT = "1.9.2 f"; -local VERSION_DATE = 1781900000; +local VERSION_TEXT = "1.9.3"; +local VERSION_DATE = 1782600000; local addonName, addon = ... @@ -379,6 +379,7 @@ local DefaultValues = { TooltipDyeDeez = true, --Show dyes on pigment tooltip Housing_CatalogSearch = false, Housing_ItemAcquiredAlert = true, --Click AlertFrame to view decor model + Housing_HouseList = true, --Namaplte: Quest Indicator diff --git a/Locales/enUS.lua b/Locales/enUS.lua index fbfe85fb..36abbedb 100755 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -47,6 +47,9 @@ L["Return To Module List"] = "Return to List"; L["Generic Addon Conflict"] = "This module might be incompatible with addons of similar functionalities:"; L["Work In Progress Tag"] = "[WIP]"; L["Colon With Space"] = ": "; +L["Disabled Module Requires Reload Format"] = "You must %s to apply the changes."; --We'll replace %s with a clickable "reload the UI" +L["Reload The UI"] = "reload the UI"; +L["Click To Reload UI"] = "Click to reload the UI."; --Settings Category @@ -918,6 +921,11 @@ L["ModuleName BlizzFixActionBarArt"] = "Blitz Fix: Action Bar Art"; L["ModuleDescription BlizzFixActionBarArt"] = "Fixed an issue where Action Bar Art (gryphons and wyverns) reappears unexpectedly after Hiding/Showing UI or exiting House Editor."; +--HouseList +L["ModuleName Housing_HouseList"] = "House List"; +L["ModuleDescription Housing_HouseList"] = "Improve the House List UI:\n\n- Indicate the house's faction with an image on the right.\n\n- Show both Visit House buttons if the player has two houses."; + + --Generic L["Total Colon"] = FROM_TOTAL or "Total:"; L["Reposition Button Horizontal"] = "Move Horizontally"; --Move the window horizontally diff --git a/Locales/zhCN.lua b/Locales/zhCN.lua index a703da67..4271072b 100755 --- a/Locales/zhCN.lua +++ b/Locales/zhCN.lua @@ -47,6 +47,9 @@ L["Return To Module List"] = "返回模块列表"; L["LootUI Addon Conflict"] = "此模块可能与以下功能类似的插件不兼容:"; L["Work In Progress Tag"] = "[施工中]"; L["Colon With Space"] = ":"; +L["Disabled Module Requires Reload Format"] = "你必须%s才能使改变生效。"; --We'll replace %s with a clickable "reload the UI" +L["Reload The UI"] = "重载界面"; +L["Click To Reload UI"] = "左键单击以重载界面。"; --Settings Category @@ -886,6 +889,11 @@ L["ModuleName BlizzFixActionBarArt"] = "动作条装饰修复"; L["ModuleDescription BlizzFixActionBarArt"] = "修复被你隐藏的动作条装饰在隐藏/显示游戏界面或退出住宅编辑器后重现的问题。"; +--HouseList +L["ModuleName Housing_HouseList"] = "房屋列表"; +L["ModuleDescription Housing_HouseList"] = "改进房屋列表界面:\n\n- 用图片展示房屋所属的阵营。\n\n- 如果玩家有两栋房子,直接显示两个“访问住宅”按钮。"; + + --Generic L["Total Colon"] = "总计:"; L["Reposition Button Horizontal"] = "水平方向移动"; --Move the window horizontally diff --git a/Modules/ControlCenter/Changelog/enUS.lua b/Modules/ControlCenter/Changelog/enUS.lua index 73ef6faf..c187b15d 100644 --- a/Modules/ControlCenter/Changelog/enUS.lua +++ b/Modules/ControlCenter/Changelog/enUS.lua @@ -7,6 +7,71 @@ local _, addon = ... local L = addon.L; local changelogs = addon.ControlCenter.changelogs; +changelogs[10903] = { + { + type = "date", + versionText = "1.9.3", + timestamp = 1782600000, + }, + + { + type = "h1", + text = L["ModuleName Housing_HouseList"], + dbKey = "Housing_HouseList", + }, + + { + type = "Checkbox", + dbKey = "Housing_HouseList", + }, + + { + type = "p", + text = "Improve the House List UI.", + }, + + { + type = "p", + bullet = true, + text = "Indicate the house's faction with an image on the right.", + }, + + { + type = "p", + bullet = true, + text = "Show both Visit House buttons if the player has two houses.", + }, + + { + type = "img", + fileName = "Changelog_Housing_HouseList", + canvasWidth = 512, + canvasHeight = 256, + imageRight = 394, + }, + + { + type = "br", + }, + + { + type = "h1", + text = MISCELLANEOUS, + }, + + { + type = "p", + bullet = true, + text = "Expansion Summary UI: If you have enabled the minimap button, it will display a notification when you have unclaimed Paragon reward chests.", + }, + + { + type = "p", + bullet = true, + text = "Expansion Summary UI: Added Field Accolade to the Resources List and Sporefall to the Raids Tab.", + }, +}; + changelogs[10902] = { { diff --git a/Modules/ControlCenter/SettingsPanelNew.lua b/Modules/ControlCenter/SettingsPanelNew.lua index 926fa87b..66f49da0 100644 --- a/Modules/ControlCenter/SettingsPanelNew.lua +++ b/Modules/ControlCenter/SettingsPanelNew.lua @@ -1794,6 +1794,8 @@ do --ChangelogTab elseif info.type == "img" then if info.dbKey or info.fileName then local file; + local l, r, t, b; + if info.dbKey then file = "Interface/AddOns/Plumber/Art/ControlCenter/Preview_"..info.dbKey; else @@ -1809,6 +1811,16 @@ do --ChangelogTab height = Def.ChangelogImageSize; end + if info.canvasWidth and info.canvasHeight and info.imageRight then + l = 0; + r = info.imageRight / info.canvasWidth; + t = 0; + b = (info.imageBottom and info.imageBottom / info.canvasHeight) or 1; + width = height / info.canvasHeight * info.imageRight; + else + l, r, t, b = 0, 1, 0, 1; + end + n = n + 1; bottom = top + height + Def.ChangelogParagraphSpacing; content[n] = { @@ -1821,7 +1833,7 @@ do --ChangelogTab offsetX = leftOffset, setupFunc = function(obj) obj:SetSize(width, height); - obj:SetTexCoord(0, 1, 0, 1); + obj:SetTexCoord(l, r, t, b); obj:SetVertexColor(1, 1, 1); obj:SetTexture(file); end; diff --git a/Modules/ExpansionLandingPage/Basic.lua b/Modules/ExpansionLandingPage/Basic.lua index 104cdac1..14947437 100644 --- a/Modules/ExpansionLandingPage/Basic.lua +++ b/Modules/ExpansionLandingPage/Basic.lua @@ -1737,6 +1737,16 @@ do --Expansion Select ExpansionData[expansionID][field] = data; end + function LandingPageUtil.GetExpansionData(expansionID, field) + if ExpansionData[expansionID] then + if field then + return ExpansionData[expansionID][field]; + else + return ExpansionData[expansionID]; + end + end + end + function LandingPageUtil.GetCurrentExpansionInfo() if CurrentExpansionID then local name = ExpansionData[CurrentExpansionID].name or "Unknown Expansion"; diff --git a/Modules/ExpansionLandingPage/EncounterData.lua b/Modules/ExpansionLandingPage/EncounterData.lua index 362b3a04..91af02af 100644 --- a/Modules/ExpansionLandingPage/EncounterData.lua +++ b/Modules/ExpansionLandingPage/EncounterData.lua @@ -18,6 +18,8 @@ local EncounterData = { --https://wago.tools/db2/JournalEncounter?page=1 --/dump GetMouseFoci()[1].icon:GetTexture() + [2711] = {icon = 7448202, achv = {63237, 63240, 63241}}, --Rotmire + [2795] = {icon = 7448202, achv = {61487, 61488, 61489, 61454}}, --Chimaerus [2733] = {icon = 7448209, achv = {61372, 62106}}, --Imperator Averzian @@ -271,6 +273,7 @@ do local MID_EncounterTabInfo = { JournalInstanceIDs = { + 1305, --Sporefall 1314, --The Dreamrift 1307, --The Voidspire 1308, --March on Quel'Danas diff --git a/Modules/ExpansionLandingPage/ExpansionLandingPage.lua b/Modules/ExpansionLandingPage/ExpansionLandingPage.lua index abdac2b7..1b500732 100644 --- a/Modules/ExpansionLandingPage/ExpansionLandingPage.lua +++ b/Modules/ExpansionLandingPage/ExpansionLandingPage.lua @@ -522,8 +522,9 @@ do end -do --12.0.7 Only +do --Open to Tab function PlumberExpansionLandingPageMixin:ShowTraitTab() + -- 12.0.7 Only? if not self:IsShown() then self:Show(); end @@ -534,6 +535,21 @@ do --12.0.7 Only end LandingPageUtil.SelectExpansion(12); end + + function PlumberExpansionLandingPageMixin:ShowFactionTabWithPendingReward() + if not self:IsShown() then + self:Show(); + end + local selectedTab = LandingPageUtil.GetSelectedTabKey(); + if selectedTab ~= "faction" then + LandingPageUtil.SelectTab("faction"); + MainFrame:UpdateTabs(); + end + local expansionID = addon.FactionUtil:GetBestExpansionIDWithRewardPending(); + if expansionID then + LandingPageUtil.SelectExpansion(expansionID); + end + end end diff --git a/Modules/ExpansionLandingPage/FactionUtil.lua b/Modules/ExpansionLandingPage/FactionUtil.lua index 3591c130..024b275c 100644 --- a/Modules/ExpansionLandingPage/FactionUtil.lua +++ b/Modules/ExpansionLandingPage/FactionUtil.lua @@ -293,10 +293,46 @@ function FactionUtil:GetFactionsWithRewardPending(viewedExpansionOnly) return tbl end +function FactionUtil:GetBestExpansionIDWithRewardPending() + local IsOnQuest = C_QuestLog.IsOnQuest; + local expansionIDs = {12, 11}; -- newer expansion first + + for _, expansionID in ipairs(expansionIDs) do + local factionLayout = LandingPageUtil.GetExpansionData(expansionID, "factionLayout"); + if factionLayout then + local questID; + for row, rowInfo in ipairs(factionLayout) do + for _, factionInfo in ipairs(rowInfo) do + if OverrideFactionInfo[factionInfo.factionID] then + questID = OverrideFactionInfo[factionInfo.factionID].rewardQuestID; + if questID and IsOnQuest(questID) then + return expansionID; + end + end + end + end + end + end +end + function FactionUtil:IsAnyParagonRewardPending(viewedExpansionOnly) return self:GetFactionsWithRewardPending(viewedExpansionOnly) ~= nil end +function FactionUtil:GetRewardPendingFactioName() + local factions = self:GetFactionsWithRewardPending(); + if factions then + local firstFactionName = self:GetFactionName(factions[1]); + if firstFactionName then + if #factions == 1 then + return firstFactionName; + else + return firstFactionName.." ..."; + end + end + end +end + function FactionUtil:GetParagonRewardQuestFaction(questID) return questID and RewardQuestXFaction[questID] or nil end diff --git a/Modules/ExpansionLandingPage/MinimapButton.lua b/Modules/ExpansionLandingPage/MinimapButton.lua index bce43f29..93c03cd3 100644 --- a/Modules/ExpansionLandingPage/MinimapButton.lua +++ b/Modules/ExpansionLandingPage/MinimapButton.lua @@ -780,6 +780,18 @@ end do --Notification / Alert / Banner + local MinimapAlertType = { + Generic = {autoHide = true}, + + ParagonReward = {autoHide = true, onClickFunc = function() + PlumberExpansionLandingPage:ShowFactionTabWithPendingReward(); + end}, + + TraitSystem = {autoHide = false, onClickFunc = function() + PlumberExpansionLandingPage:ShowTraitTab(); + end}, + }; + function ButtonMixin:AlertFrame_Init() local f = self.AlertFrame; @@ -816,17 +828,35 @@ do --Notification / Alert / Banner local easingFunc = addon.EasingFunctions.outSine; local duration = 0.5; local alertFrameFromWidth = 32; + local shouldAutoHide = self.alertInfo and self.alertInfo.autoHide; f:SetHeight(f.alertFrameHeight); f:SetAlpha(0); f.Text:SetAlpha(0); + local function AlertFrame_AnimOut_OnUpdate(_self, elapsed) + _self.t = _self.t + elapsed; + if _self.t >= 5 then -- auto hide after 5 second + _self.alpha = _self.alpha - 4 * elapsed; + if _self.alpha <= 0 then + _self.alpha = 0; + _self:SetScript("OnUpdate", nil); + _self:Hide(); + end + _self:SetAlpha(_self.alpha); + end + end + local function AlertFrame_Text_OnUpdate(_self, elapsed) _self.t = _self.t + elapsed; local alpha = 4 * _self.t - 1; if alpha > 1 then _self:SetScript("OnUpdate", nil); alpha = 1; + if shouldAutoHide then + _self.alpha = self:GetAlpha(); + _self:SetScript("OnUpdate", AlertFrame_AnimOut_OnUpdate); + end elseif alpha < 0 then alpha = 0; end @@ -855,7 +885,9 @@ do --Notification / Alert / Banner f:SetScript("OnMouseDown", function(_, button) if button == "LeftButton" then - PlumberExpansionLandingPage:ShowTraitTab(); + if self.alertInfo and self.alertInfo.onClickFunc then + self.alertInfo.onClickFunc(button); + end end end); end @@ -867,9 +899,15 @@ do --Notification / Alert / Banner end end - function LandingPageUtil.ShowMinimapButtonAlert(text) + function LandingPageUtil.ShowMinimapButtonAlert(text, alertType) if text and text ~= "" then if MiniButton and MiniButton:IsVisible() and (not MiniButton.AlertFrame:IsShown()) then + if not (alertType and MinimapAlertType[alertType]) then + alertType = "Generic"; + end + MiniButton.alertType = alertType; + MiniButton.alertInfo = MinimapAlertType[alertType]; + MiniButton:AlertFrame_Init(); MiniButton:AlertFrame_ShowText(text); end @@ -882,10 +920,12 @@ do --Notification / Alert / Banner CallbackRegistry:RegisterCallback("LandingPage.HasPurchasableTrait", function(hasPurchasableTrait) if hasPurchasableTrait and (not InCombatLockdown()) then if not PlumberExpansionLandingPage:IsShown() then - LandingPageUtil.ShowMinimapButtonAlert(OMNIUM_FOLIO_UNSPENT_POINTS) + LandingPageUtil.ShowMinimapButtonAlert(OMNIUM_FOLIO_UNSPENT_POINTS, "TraitSystem"); end else - LandingPageUtil.HideMinimapButtonAlert(); + if MiniButton and MiniButton.MiniButton and MiniButton.MiniButton == "TraitSystem" then + LandingPageUtil.HideMinimapButtonAlert(); + end end end); end diff --git a/Modules/ExpansionLandingPage/ModuleRegistry.lua b/Modules/ExpansionLandingPage/ModuleRegistry.lua index 8e14c688..cf25bedf 100644 --- a/Modules/ExpansionLandingPage/ModuleRegistry.lua +++ b/Modules/ExpansionLandingPage/ModuleRegistry.lua @@ -6,13 +6,8 @@ local L = addon.L; local CallbackRegistry = addon.CallbackRegistry; local FactionUtil = addon.FactionUtil; local LandingPageUtil = addon.LandingPageUtil; -local IsExpansionLandingPageUnlockedForPlayer = C_PlayerInfo.IsExpansionLandingPageUnlockedForPlayer or API.Nop; -local function ShouldShowWarWithinLandingPage() - return IsExpansionLandingPageUnlockedForPlayer(10) -end - local function Plumber_ToggleLandingPage() PlumberExpansionLandingPage:ToggleUI(); end @@ -63,8 +58,9 @@ EL:SetScript("OnEvent", function(self, event, ...) self:UnregisterEvent(event); if EL.enabled then C_Timer.After(3, function() - if ShouldShowWarWithinLandingPage() and FactionUtil:IsAnyParagonRewardPending() then - API.TriggerExpansionMinimapButtonAlert(L["Paragon Reward Available"]); + local factionName = FactionUtil:GetRewardPendingFactioName(); + if factionName then + LandingPageUtil.ShowMinimapButtonAlert(L["Paragon Reward Available"].."\n"..factionName, "ParagonReward"); end LandingPageUtil.HandleTraitTreeCurrencyChanged(1186); end); @@ -73,14 +69,15 @@ EL:SetScript("OnEvent", function(self, event, ...) local questID = ... local factionID = FactionUtil:GetParagonRewardQuestFaction(questID); if factionID then - API.TriggerExpansionMinimapButtonAlert(L["Paragon Reward Available"]); - CallbackRegistry:Trigger("ParagonRewardReady", factionID); + local factionName = FactionUtil:GetFactionName(factionID); + if factionName then + LandingPageUtil.ShowMinimapButtonAlert(L["Paragon Reward Available"].."\n"..factionName, "ParagonReward"); + end CallbackRegistry:Trigger("LandingPage.UpdateNotification"); end elseif event == "QUEST_TURNED_IN" then local questID = ... if FactionUtil:IsParagonRewardQuest(questID) then - CallbackRegistry:Trigger("ParagonRewardQuestTurnedIn", questID); CallbackRegistry:Trigger("LandingPage.UpdateNotification"); end elseif event == "TRAIT_TREE_CURRENCY_INFO_UPDATED" then diff --git a/Modules/ExpansionLandingPage/Retail/ResourceList.lua b/Modules/ExpansionLandingPage/Retail/ResourceList.lua index d3c36ca5..b2800477 100644 --- a/Modules/ExpansionLandingPage/Retail/ResourceList.lua +++ b/Modules/ExpansionLandingPage/Retail/ResourceList.lua @@ -51,6 +51,7 @@ end do --MID local ResourceList = { {currencyID = 3418, hasWeeklyCap = true}, --Nebulous Voidcore (Bonus Rolls) + {currencyID = 3405}, --Field Accolade {currencyID = 3028}, --Restored Coffer Key {currencyID = 3310, hasWeeklyCap = true}, --Coffer Key Shard {currencyID = 3316}, --Voidlight Marl diff --git a/Modules/Housing/HouseList.lua b/Modules/Housing/HouseList.lua new file mode 100644 index 00000000..e824ae6a --- /dev/null +++ b/Modules/Housing/HouseList.lua @@ -0,0 +1,302 @@ +local _, addon = ... + + +local Def = { + CardWidth = 480, + CardHeight = 120, + BackgroundWidth = 512, + BackgroundHeight = 152, + CardTextPadding = 22, + CardSpacing = 10, + TextureFile = "Interface/AddOns/Plumber/Art/Housing/HouseListFrame.png", + + CardEffectiveWidth = 368, + CardEffectiveHeight = 92, +}; + + +local Module = {}; + + +do -- HouseListEntry + local HouseListEntryMixin = {}; + + function HouseListEntryMixin:SetHouseInfo(houseInfo) + if houseInfo then + self.HouseNameText:SetText(houseInfo.houseName); + self.HouseOwnerText:SetText(houseInfo.ownerName); + if addon.Housing.IsAllianceNeighborhood(houseInfo.neighborhoodGUID) then + self.Background:SetTexCoord(0, 1, 152/512, 304/512); + else + self.Background:SetTexCoord(0, 1, 0, 152/512); + end + self.VisitHouseButton:Show(); + self.VisitHouseButton:SetupAction(houseInfo.neighborhoodGUID, houseInfo.houseGUID, houseInfo.plotID); + else + self.VisitHouseButton:Hide(); + end + end + + + local VisitHouseButtonMixin = {}; + + function VisitHouseButtonMixin:OnEvent(event) + if event == "PLAYER_REGEN_ENABLED" then + self:Enable(); + elseif event == "PLAYER_REGEN_DISABLED" then + self:Disable(); + end + + if self:IsMouseMotionFocus() then + self:OnEnter(); + end + end + + function VisitHouseButtonMixin:OnShow() + self:RegisterEvent("PLAYER_REGEN_ENABLED"); + self:RegisterEvent("PLAYER_REGEN_DISABLED"); + if InCombatLockdown() then + self:Disable(); + else + self:Enable(); + end + end + + function VisitHouseButtonMixin:OnHide() + self:UnregisterEvent("PLAYER_REGEN_ENABLED"); + self:UnregisterEvent("PLAYER_REGEN_DISABLED"); + end + + function VisitHouseButtonMixin:OnEnter() + GameTooltip:Hide(); + local tooltipText; + + if InCombatLockdown() then + tooltipText = ERR_HOUSING_RESULT_LOCKED_BY_COMBAT; + else + local propagateMouseMotion = true; + local propagateMouseClicks = true; + local actionButton = addon.AcquireSecureActionButton("HouseList", propagateMouseMotion, propagateMouseClicks); + if actionButton then + actionButton:SetParent(self); + actionButton:CoverParent(); + actionButton:SetVisitHouse(self.neighborhoodGUID, self.houseGUID, self.plotID); + actionButton:Show(); + end + end + + if tooltipText then + GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); + GameTooltip:SetText(tooltipText, 1.000, 0.125, 0.125, 1, true); + GameTooltip:Show(); + end + end + + function VisitHouseButtonMixin:OnLeave() + GameTooltip:Hide(); + end + + function VisitHouseButtonMixin:SetupAction(neighborhoodGUID, houseGUID, plotID) + self.neighborhoodGUID = neighborhoodGUID; + self.houseGUID = houseGUID; + self.plotID = plotID; + end + + function VisitHouseButtonMixin:OnLoad() + self:SetScript("OnShow", self.OnShow); + self:SetScript("OnHide", self.OnHide); + self:SetScript("OnEnter", self.OnEnter); + self:SetScript("OnLeave", self.OnLeave); + self:SetScript("OnEvent", self.OnEvent); + end + + + function Module.CreateEntry(parent) + local f = CreateFrame("Frame", nil, parent, "PlumberHouseListFrameEntryTemplate"); + Mixin(f, HouseListEntryMixin); + + local effectiveWidth = Def.CardEffectiveWidth; + local scale = effectiveWidth / Def.CardWidth; + + f:SetSize(effectiveWidth, scale * Def.CardHeight); + f.Background:SetTexture(Def.TextureFile); + f.Background:SetSize(scale * Def.BackgroundWidth, scale * Def.BackgroundHeight); + local offset = 12; + f.HouseNameText:SetPoint("TOPLEFT", f, "TOPLEFT", offset + 1, -offset); + f.VisitHouseButton:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", offset, offset); + + Mixin(f.VisitHouseButton, VisitHouseButtonMixin); + f.VisitHouseButton:OnLoad(); + + return f + end +end + + +do + local MainFrame; + local MainFrameMixin = {}; + + function MainFrameMixin:Release() + for _, card in ipairs(self.cards) do + card:Hide(); + end + end + + function MainFrameMixin:InitWithContextData(name, guid, bnetID, isGuildMember) + self.Title:SetText(string.format(VIEW_HOUSES_TITLE, name)); + self:OnHouseListUpdated(nil); + self.LoadingSpinner:Show(); + self.NoHousesText:Hide(); + C_Housing.GetOthersOwnedHouses(guid, bnetID, isGuildMember or false); + end + + function MainFrameMixin:OnShow() + self:RegisterEvent("VIEW_HOUSES_LIST_RECIEVED"); + self.ReloadHelper:SetShown(not Module.enabled); + end + + function MainFrameMixin:OnHide() + self:UnregisterEvent("VIEW_HOUSES_LIST_RECIEVED"); + self.LoadingSpinner:Hide(); + end + + function MainFrameMixin:OnEvent(event, ...) + if event == "VIEW_HOUSES_LIST_RECIEVED" then + local houseInfoList = ...; + self:OnHouseListUpdated(houseInfoList); + self.LoadingSpinner:Hide(); + end + end + + function MainFrameMixin:OnHouseListUpdated(houseInfoList) + local numEntries = 2; + local headerHeight = 32; + + if houseInfoList and #houseInfoList > 0 then + --Always show 2 + for i = 1, 2 do + if houseInfoList[i] then + local card = self.cards[i]; + if not card then + card = Module.CreateEntry(self); + self.cards[i] = card; + if i == 1 then + card:SetPoint("TOP", self, "TOP", 0, -headerHeight -Def.CardSpacing); + else + card:SetPoint("TOP", self.cards[i - 1], "BOTTOM", 0, -Def.CardSpacing); + end + end + card:SetHouseInfo(houseInfoList[i]); + card:Show(); + end + end + self.NoHousesText:Hide(); + else + self:Release(); + self.NoHousesText:Show(); + end + + local extraHeight = 0; + if self.ReloadHelper:IsShown() then + extraHeight = self.ReloadHelper:GetHeight() + 14; + end + + self:SetHeight(headerHeight + numEntries * (Def.CardEffectiveHeight + Def.CardSpacing) + Def.CardSpacing + 7 + extraHeight); + self:UpdatePosition(); + self:Raise(); + end + + + local FrameCandidates = { + FriendsListFrame = 16, + CommunitiesFrame = 36, -- Leave room for tab buttons + }; + + function MainFrameMixin:UpdatePosition() + local relativeTo, offset; + for frameName, offsetX in pairs(FrameCandidates) do + if _G[frameName] and _G[frameName]:IsShown() then + relativeTo = _G[frameName]; + offset = offsetX; + break; + end + end + self:ClearAllPoints(); + if relativeTo then + self:SetPoint("TOPLEFT", relativeTo, "TOPRIGHT", offset, 0); + else + self:SetPoint("CENTER", UIParent, "CENTER", 0, 0); + end + end + + + function Module.InitMainFrame() + if not MainFrame then + local frameName = "PlumberHouseListFrame"; + MainFrame = CreateFrame("Frame", frameName, UIParent, "PlumberHouseListFrameTemplate"); + table.insert(UISpecialFrames, frameName); + Mixin(MainFrame, MainFrameMixin); + MainFrame.cards = {}; + MainFrame:SetScript("OnShow", MainFrame.OnShow); + MainFrame:SetScript("OnHide", MainFrame.OnHide); + MainFrame:SetScript("OnEvent", MainFrame.OnEvent); + + if MainFrame:IsShown() then + MainFrame:OnShow(); + end + end + end + + function Module.RemoveMainFrame() + if MainFrame then + MainFrame:Hide(); + MainFrame:Release(); + end + end + + function Module.InitWithContextData(...) + Module.InitMainFrame(); + MainFrame:Show(); + MainFrame:InitWithContextData(...); + end +end + + +do -- Module Control + local function OverrideOnClick(self, contextData) + local name = UnitPopupSharedUtil.GetFullPlayerName(contextData); + local guid = UnitPopupSharedUtil.GetGUID(contextData); + local bnetID = contextData.bnetIDAccount; + local isGuildMember = contextData.isGuildMember; + + Module.InitWithContextData(name, guid, bnetID, isGuildMember); + end + + local function EnableModule(state) + if state then + Module.enabled = true; + UnitPopupViewHousesButtonMixin.OnClick = OverrideOnClick; + elseif Module.enabled then + Module.enabled = false; + -- Once tainted, it's irreversible and we ask the user to /reload + --UnitPopupViewHousesButtonMixin.OnClick = OriginalOnClick; + end + end + + local moduleData = { + name = addon.L["ModuleName Housing_HouseList"], + dbKey = "Housing_HouseList", + description = addon.L["ModuleDescription Housing_HouseList"], + toggleFunc = EnableModule, + moduleAddedTime = 1782400000, + categoryKeys = { + "Housing", + }, + searchTags = { + "Housing", + }, + }; + + addon.ControlCenter:AddModule(moduleData); +end diff --git a/Modules/Housing/Housing.xml b/Modules/Housing/Housing.xml index 3599d2f9..32b955b5 100644 --- a/Modules/Housing/Housing.xml +++ b/Modules/Housing/Housing.xml @@ -7,6 +7,7 @@