From 40ec6839fabc7786af713e5ed9af6944c87ab26e Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 30 Aug 2024 12:34:42 -0300 Subject: [PATCH] Added Special Assignment quests into the world map --- .gitignore | 1 + WorldQuestTrackerMixin.xml | 1 + WorldQuestTracker_Core.lua | 3 ++ WorldQuestTracker_Initialize.lua | 4 ++ WorldQuestTracker_WorldMap.lua | 70 +++++++++++++++++++++++---- WorldQuestTracker_ZoneMap.lua | 82 ++++++++++++++++++++++++++++---- 6 files changed, 144 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index a58570b3..bd092169 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ api.lua media/options_visibility_context.afphoto~lock~ luac.out *.afphoto~lock~ +annotations.txt diff --git a/WorldQuestTrackerMixin.xml b/WorldQuestTrackerMixin.xml index e437a284..cbad9bd2 100644 --- a/WorldQuestTrackerMixin.xml +++ b/WorldQuestTrackerMixin.xml @@ -13,5 +13,6 @@ + diff --git a/WorldQuestTracker_Core.lua b/WorldQuestTracker_Core.lua index 7dfb1e9f..97b95477 100644 --- a/WorldQuestTracker_Core.lua +++ b/WorldQuestTracker_Core.lua @@ -114,6 +114,9 @@ end WorldQuestTracker.OnMapHasChanged = function(self) WorldQuestTracker.AdjustThatThingInTheBottomLeftCorner() + WorldQuestTrackerDataProvider:GetMap():RemoveAllPinsByTemplate("WorldQuestTrackerPOIPinTemplate") + WorldQuestTracker.HideAllPOIPins() + local mapID = WorldMapFrame.mapID WorldQuestTracker.InitializeWorldWidgets() diff --git a/WorldQuestTracker_Initialize.lua b/WorldQuestTracker_Initialize.lua index 5fa17891..67571085 100644 --- a/WorldQuestTracker_Initialize.lua +++ b/WorldQuestTracker_Initialize.lua @@ -271,6 +271,10 @@ do quest_summary_minimized = false, show_summary_minimize_button = true, + pins_discovered = { + ["worldquest-Capstone-questmarker-epic-Locked"] = {}, + }, + zone_map_config = { summary_show = true, quest_summary_scale = 1.2, diff --git a/WorldQuestTracker_WorldMap.lua b/WorldQuestTracker_WorldMap.lua index bc9afaaf..eeee3b5e 100644 --- a/WorldQuestTracker_WorldMap.lua +++ b/WorldQuestTracker_WorldMap.lua @@ -1176,14 +1176,14 @@ function WorldQuestTracker.BuildMapChildrenTable(parentMap, t) t = t or {} local newChildren = {} for mapID, mapTable in pairs(WorldQuestTracker.mapTables) do - if (mapTable.show_on_map [parentMap]) then - t [mapID] = true - newChildren [mapID] = true + if (mapTable.show_on_map[parentMap]) then + t[mapID] = true + newChildren[mapID] = true end end if (next(newChildren)) then - for newMapChildren, _ in pairs(newChildren) do + for newMapChildren in pairs(newChildren) do WorldQuestTracker.BuildMapChildrenTable(newMapChildren, t) end end @@ -1191,6 +1191,15 @@ function WorldQuestTracker.BuildMapChildrenTable(parentMap, t) return t end +WorldQuestTracker.POIPins = {} +--hide all poi pins +function WorldQuestTracker.HideAllPOIPins() + for i = 1, #WorldQuestTracker.POIPins do + WorldQuestTracker.POIPins[i]:Hide() + end +end + +local worldQuestLockedIndex = 1 -- ~world -- ~update function WorldQuestTracker.UpdateWorldQuestsOnWorldMap(noCache, showFade, isQuestFlaggedRecheck, forceCriteriaAnimation, questList) if (UnitLevel("player") < 50) then --this has to be improved @@ -1204,6 +1213,51 @@ function WorldQuestTracker.UpdateWorldQuestsOnWorldMap(noCache, showFade, isQues return end + WorldQuestTrackerDataProvider:GetMap():RemoveAllPinsByTemplate("WorldQuestTrackerPOIPinTemplate") + + for poiId, poiInfo in pairs(WorldQuestTracker.db.profile.pins_discovered["worldquest-Capstone-questmarker-epic-Locked"]) do + ---@cast poiInfo wqt_poidata + + --double check if the quest is on the map + if (C_AreaPoiInfo.GetAreaPOIInfo(poiInfo.mapID, poiInfo.poiID)) then + local pin = WorldQuestTrackerDataProvider:GetMap():AcquirePin("WorldQuestTrackerPOIPinTemplate") + + if (not pin.widget) then + local button = WorldQuestTracker.CreateZoneWidget(worldQuestLockedIndex, "WorldQuestTrackerLockedQuestButton", worldFramePOIs) --, "WorldQuestTrackerPOIPinTemplate" + button.IsWorldZoneQuestButton = true + button:SetPoint("center", pin, "center", 0, 0) + worldQuestLockedIndex = worldQuestLockedIndex + 1 + pin.button = button + pin.widget = button + pin:SetSize(20, 20) + + button:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") + if (poiInfo.tooltipSetId) then + GameTooltip_AddWidgetSet(GameTooltip, poiInfo.tooltipSetId, 0) + end + GameTooltip:Show() + end) + + button:SetScript("OnHide", function(self) + GameTooltip:Hide() + end) + + button.UpdateTooltip = nil + + WorldQuestTracker.POIPins[#WorldQuestTracker.POIPins+1] = button + end + + WorldQuestTracker.ResetWorldQuestZoneButton(pin.button) + pin:SetPosition(poiInfo.worldX, poiInfo.worldY) + pin.button.Texture:SetMask("") + pin.button.Texture:SetAtlas("worldquest-Capstone-questmarker-epic-Locked") + pin.button.Texture:SetSize(32, 32) + pin.button.poiInfo = poiInfo + pin.button:Show() + end + end + WorldQuestTracker.RefreshStatusBarVisibility() WorldQuestTracker.ClearZoneSummaryButtons() @@ -1388,14 +1442,14 @@ function WorldQuestTracker.UpdateWorldQuestsOnWorldMap(noCache, showFade, isQues end --quantidade de quest para a faccao - configTable.factionFrame.amount = factionAmountForEachMap [mapId] + configTable.factionFrame.amount = factionAmountForEachMap[mapId] end --force retry in case the game just opened and the server might not has sent all quests - forceRetryForHub [WorldMapFrame.mapID] = forceRetryForHub [WorldMapFrame.mapID] or forceRetryForHubAmount - if (forceRetryForHub [WorldMapFrame.mapID] > 0) then + forceRetryForHub[WorldMapFrame.mapID] = forceRetryForHub[WorldMapFrame.mapID] or forceRetryForHubAmount + if (forceRetryForHub[WorldMapFrame.mapID] > 0) then needAnotherUpdate = true - forceRetryForHub [WorldMapFrame.mapID] = forceRetryForHub [WorldMapFrame.mapID] - 1 + forceRetryForHub[WorldMapFrame.mapID] = forceRetryForHub[WorldMapFrame.mapID] - 1 end if (needAnotherUpdate) then diff --git a/WorldQuestTracker_ZoneMap.lua b/WorldQuestTracker_ZoneMap.lua index 5ce6112c..027a1447 100644 --- a/WorldQuestTracker_ZoneMap.lua +++ b/WorldQuestTracker_ZoneMap.lua @@ -187,7 +187,6 @@ function WorldQuestTracker.CreateZoneWidget(index, name, parent, pinTemplate) -- button:SetFrameLevel(button.OriginalFrameLevel + 50) if (self.OnEnterAnimation) then - if (not WorldQuestTracker.db.profile.hoverover_animations) then return end @@ -220,12 +219,10 @@ function WorldQuestTracker.CreateZoneWidget(index, name, parent, pinTemplate) -- end self.OnEnterAnimation:Play() end - end end) button:HookScript("OnLeave", function(self) - if (button.OriginalFrameLevel) then button:SetFrameLevel(button.OriginalFrameLevel) end @@ -730,6 +727,75 @@ function WorldQuestTracker.UpdateZoneWidgets(forceUpdate) --pin.Texture:SetScale(0.7) --end + ---@class poiinfo : table + ---@field areaPoiID number + ---@field description string + ---@field addPaddingAboveTooltipWidgets boolean + ---@field isAlwaysOnFlightmap boolean + ---@field isPrimaryMapForPOI boolean + ---@field tooltipWidgetSet number + ---@field highlightVignettesOnHover boolean + ---@field name string + ---@field position table + ---@field shouldGlow boolean + ---@field isCurrentEvent boolean + ---@field highlightWorldQuestsOnHover boolean + ---@field atlasName string + + WorldQuestTrackerDataProvider:GetMap():RemoveAllPinsByTemplate("WorldQuestTrackerPOIPinTemplate") + WorldQuestTracker.HideAllPOIPins() + + for pin in map:EnumeratePinsByTemplate("AreaPOIPinTemplate") do + local atlasName = pin.Texture:GetAtlas() + pin.Texture:SetAlpha(0.934) + if (atlasName == "worldquest-Capstone-questmarker-epic-Locked") then + --how to identify the point of interest? + if (not WorldQuestTracker.db.profile.pins_discovered["worldquest-Capstone-questmarker-epic-Locked"][pin.areaPoiID]) then + local poiInfo = pin:GetPoiInfo() --table + local mapData = pin:GetMap() --function + + local poiId = poiInfo.areaPoiID + local mapId = mapData:GetMapID() + local position = poiInfo.position + local mapInfo = C_Map.GetMapInfo(mapId) + local parentMapInfo = C_Map.GetMapInfo(mapInfo.parentMapID) + + --need check if a waypoint already exists + local mapPoint = UiMapPoint.CreateFromCoordinates(mapId, position.x, position.y) + C_Map.SetUserWaypoint(mapPoint) + local worldPosition = C_Map.GetUserWaypointPositionForMap(parentMapInfo.mapID) + C_Map.ClearUserWaypoint() + + ---@class wqt_poidata + ---@field poiID number + ---@field mapID number + ---@field zoneX number + ---@field zoneY number + ---@field continentID number + ---@field worldX number + ---@field worldY number + ---@field tooltipSetId number + + local pointOfInterestData = { + ["poiID"] = poiId, + ["mapID"] = mapId, + ["zoneX"] = pin.normalizedX, + ["zoneY"] = pin.normalizedY, + ["continentID"] = parentMapInfo.mapID, + ["worldX"] = worldPosition.x, + ["worldY"] = worldPosition.y, + ["tooltipSetId"] = poiInfo.tooltipWidgetSet, + } + + WorldQuestTracker.db.profile.pins_discovered["worldquest-Capstone-questmarker-epic-Locked"][poiId] = pointOfInterestData + end + + pin.Texture:SetScale(1.2) + else + pin.Texture:SetScale(1) + end + end + for pin in map:EnumeratePinsByTemplate("QuestPinTemplate") do pin:SetAlpha(0.923) end @@ -1073,7 +1139,6 @@ function WorldQuestTracker.UpdateZoneWidgets(forceUpdate) end if (WorldQuestTracker.WorldMap_GoldIndicator) then - WorldQuestTracker.WorldMap_GoldIndicator.text = floor(total_Gold / 10000) if (total_Resources >= 1000) then @@ -1164,7 +1229,6 @@ function WorldQuestTracker.UpdateZonePOIs(forceUpdate) end end end - --elseif (iconData.dataType == "icon") then end end @@ -1521,6 +1585,7 @@ function WorldQuestTracker.ScheduleZoneMapUpdate(seconds, isForceUpdate) end WorldQuestTracker.ScheduledZoneUpdate:Cancel() end + WorldQuestTracker.ScheduledZoneUpdate = C_Timer.NewTimer(seconds or 1, do_zonemap_update) WorldQuestTracker.ScheduledZoneUpdate.IsForceUpdate = isForceUpdate end @@ -1657,14 +1722,14 @@ function WorldQuestTracker.GetOrCreateZoneSummaryWidget(index, parent, pool) local on_enter_animation = DF:CreateAnimationHub(button, nil, function() --button:SetScale(1.1, 1.1) end) - on_enter_animation.Step1 = DF:CreateAnimation(on_enter_animation, "scale", 1, 0.05, 1, 1, 1.05, 1.05) - on_enter_animation.Step2 = DF:CreateAnimation(on_enter_animation, "scale", 2, 0.05, 1.05, 1.05, 1.0, 1.0) + on_enter_animation.Step1 = DF:CreateAnimation(on_enter_animation, "Scale", 1, 0.05, 1, 1, 1.05, 1.05) + on_enter_animation.Step2 = DF:CreateAnimation(on_enter_animation, "Scale", 2, 0.05, 1.05, 1.05, 1.0, 1.0) button.OnEnterAnimation = on_enter_animation local on_leave_animation = DF:CreateAnimationHub(button, nil, function() --button:SetScale(1.0, 1.0) end) - on_leave_animation.Step1 = DF:CreateAnimation(on_leave_animation, "scale", 1, 0.1, 1.1, 1.1, 1, 1) + on_leave_animation.Step1 = DF:CreateAnimation(on_leave_animation, "Scale", 1, 0.1, 1.1, 1.1, 1, 1) button.OnLeaveAnimation = on_leave_animation local mouseoverHighlight = WorldQuestTracker.AnchoringFrame:CreateTexture(nil, "overlay") @@ -1836,7 +1901,6 @@ end -- ~summary function WorldQuestTracker.UpdateZoneSummaryToggleButton(canShow) - if (not WorldQuestTracker.ZoneSummaryToogleButton) then local button = CreateFrame("button", nil, ZoneSumaryFrame, "BackdropTemplate") button:SetSize(12, 12)