Skip to content

Commit

Permalink
Merge pull request #69 from GurliGebis/feature/fix-taints
Browse files Browse the repository at this point in the history
Added workarounds for World Map taints
  • Loading branch information
GurliGebis authored Sep 10, 2024
2 parents 29781d7 + c3431e2 commit b252aa8
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 11.0.2-20240910-2

* Added workarounds for World Map taints.

## 11.0.2-20240910-1

* Complete refactor and code cleanup.
Expand Down
1 change: 1 addition & 0 deletions Modules/Config/ConfigModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ do
"hideQuestList",
"showHoveredPOI",
"lootFilterUpgrades",
"enableTaintWorkarounds",
"enableDebugging"
}

Expand Down
1 change: 1 addition & 0 deletions Modules/DB/DBModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ local defaultOptions = {
hideQuestList = false,
showContinentPOI = true,
enableDebugging = false,
enableTaintWorkarounds = false,
sortMethod = 2,
extendedInfo = false,
saveFilters = false
Expand Down
16 changes: 8 additions & 8 deletions Modules/QuestFrame/QuestFrameModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -903,31 +903,31 @@ do
if self:IsQuestSuppressed(info.questId) then
return false;
end

if self.focusedQuestID then
return C_QuestLog.IsQuestCalling(self.focusedQuestID) and self:ShouldSupertrackHighlightInfo(info.questId);
end

local mapID = self:GetMap():GetMapID()

if ConfigModule:Get("showHoveredPOI") and hoveredQuestID == info.questId then
return true
end

if ConfigModule:Get("hideFilteredPOI") then
if DataModule:IsQuestFiltered(info, mapID) then
return false
end
end

if ConfigModule:Get("hideUntrackedPOI") then
if not (WorldMap_IsWorldQuestEffectivelyTracked(info.questId)) then
return false
end
end

local mapInfo = C_Map.GetMapInfo(mapID)

if ConfigModule:Get("showContinentPOI") and mapInfo.mapType == Enum.UIMapType.Continent then
return mapID == info.mapID or (DataModule:GetContentMapIDFromMapID(info.mapID) == mapID)
else
Expand Down Expand Up @@ -973,4 +973,4 @@ do
self:RegisterCallbacks()
end
end
--endregion
--endregion
125 changes: 125 additions & 0 deletions Modules/Workarounds/WorkaroundsModule.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
--[[
Copyright (C) 2024 GurliGebis
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1: Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2: Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3: Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
]]

local addonName, _ = ...
local AngrierWorldQuests = LibStub("AceAddon-3.0"):GetAddon(addonName)
local WorkaroundsModule = AngrierWorldQuests:NewModule("WorkaroundsModule")
local ConfigModule = AngrierWorldQuests:GetModule("ConfigModule")

local function WorkaroundMapTaints()
-- Code copied from hack from Kalies Tracker, which is based on the original Blizzard_MapCanvas.lua code.
local function OnPinReleased(pinPool, pin)
Pool_HideAndClearAnchors(pinPool, pin);
pin:OnReleased();
pin.pinTemplate = nil;
pin.owningMap = nil;
end

local function OnPinMouseUp(pin, button, upInside)
pin:OnMouseUp(button, upInside);
if upInside then
pin:OnClick(button);
end
end

function WorldMapFrame:AcquirePin(pinTemplate, ...)
if not self.pinPools[pinTemplate] then
local pinTemplateType = self.pinTemplateTypes[pinTemplate] or "FRAME";
self.pinPools[pinTemplate] = CreateFramePool(pinTemplateType, self:GetCanvas(), pinTemplate, OnPinReleased);
end

local pin, newPin = self.pinPools[pinTemplate]:Acquire();

pin.pinTemplate = pinTemplate;
pin.owningMap = self;

if newPin then
local isMouseClickEnabled = pin:IsMouseClickEnabled();
local isMouseMotionEnabled = pin:IsMouseMotionEnabled();

if isMouseClickEnabled then
pin:SetScript("OnMouseUp", OnPinMouseUp);
pin:SetScript("OnMouseDown", pin.OnMouseDown);

-- Prevent OnClick handlers from being run twice, once a frame is in the mapCanvas ecosystem it needs
-- to process mouse events only via the map system.
if pin:IsObjectType("Button") then
pin:SetScript("OnClick", nil);
end
end

if isMouseMotionEnabled then
if newPin and not pin:DisableInheritedMotionScriptsWarning() then
-- These will never be called, just define a OnMouseEnter and OnMouseLeave on the pin mixin and it'll be called when appropriate
assert(pin:GetScript("OnEnter") == nil);
assert(pin:GetScript("OnLeave") == nil);
end
pin:SetScript("OnEnter", pin.OnMouseEnter);
pin:SetScript("OnLeave", pin.OnMouseLeave);
end

pin:SetMouseClickEnabled(isMouseClickEnabled);
pin:SetMouseMotionEnabled(isMouseMotionEnabled);
end

if newPin then
pin:OnLoad();
pin.CheckMouseButtonPassthrough = function() end
pin.UpdateMousePropagation = function() end
end

self.ScrollContainer:MarkCanvasDirty();
pin:Show();
pin:OnAcquired(...);

return pin;
end
end

function WorkaroundsModule:LoadWorkarounds(callback)
if ConfigModule:Get("enableTaintWorkarounds") then
WorkaroundMapTaints()
end

if callback then
ReloadUI()
end
end

function WorkaroundsModule:RegisterCallbacks()
ConfigModule:RegisterCallback("enableTaintWorkarounds", function()
self:LoadWorkarounds(true)
end)
end

function WorkaroundsModule:OnEnable()
self:RegisterCallbacks()

self:LoadWorkarounds(false)
end
3 changes: 3 additions & 0 deletions Modules/Workarounds/WorkaroundsModule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="WorkaroundsModule.lua" />
</Ui>
1 change: 1 addition & 0 deletions Modules/modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<Include file="DB\DBModule.xml" />
<Include file="Config\ConfigModule.xml" />
<Include file="Data\DataModule.xml" />
<Include file="Workarounds\WorkaroundsModule.xml" />
<Include file="QuestFrame\QuestFrameModule.xml" />
</Ui>

0 comments on commit b252aa8

Please sign in to comment.