Skip to content

Commit

Permalink
Added total pet quests in the status bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Aug 10, 2019
1 parent b5c9d07 commit 67cf662
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
89 changes: 88 additions & 1 deletion WorldQuestTracker_Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ WorldQuestTracker.OnMapHasChanged = function (self)
WorldQuestTracker.WorldMap_GoldIndicator.text = 0
WorldQuestTracker.WorldMap_ResourceIndicator.text = 0
WorldQuestTracker.WorldMap_APowerIndicator.text = 0
WorldQuestTracker.WorldMap_PetIndicator.text = 0
end

--> clear custom map pins
Expand Down Expand Up @@ -1387,6 +1388,7 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
worldSummary.TotalGold = 0
worldSummary.TotalResources = 0
worldSummary.TotalAPower = 0
worldSummary.TotalPet = 0
worldSummary.FactionSelected = 1
worldSummary.FactionSelected_OnInit = 6 --the index 6 is the tortollan faction which has less quests and add less noise
worldSummary.AnchorAmount = 7
Expand Down Expand Up @@ -2300,6 +2302,7 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
worldSummary.TotalGold = 0
worldSummary.TotalResources = 0
worldSummary.TotalAPower = 0
worldSummary.TotalPet = 0

for _, anchor in pairs (worldSummary.Anchors) do
anchor:Hide()
Expand Down Expand Up @@ -2385,6 +2388,10 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
if (resource) then worldSummary.TotalResources = worldSummary.TotalResources + resource end
if (apower) then worldSummary.TotalAPower = worldSummary.TotalAPower + apower end

if (worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE) then
worldSummary.TotalPet = worldSummary.TotalPet + 1
end

if (WorldQuestTracker.WorldMap_GoldIndicator) then
WorldQuestTracker.WorldMap_GoldIndicator.text = floor (worldSummary.TotalGold / 10000)

Expand All @@ -2401,6 +2408,8 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
end

WorldQuestTracker.WorldMap_APowerIndicator.Amount = worldSummary.TotalAPower

WorldQuestTracker.WorldMap_PetIndicator.text = worldSummary.TotalPet
end

if (WorldQuestTracker.db.profile.show_timeleft) then
Expand Down Expand Up @@ -4217,7 +4226,7 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
GameCooltip:CoolTipInject (WorldQuestTracker.OptionsInterfaceMenu.options_button)

local ResourceFontTemplate = DF:GetTemplate ("font", "WQT_RESOURCES_AVAILABLE")

--> party members ~party

-----------
Expand All @@ -4233,6 +4242,9 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
local resource_APowerFrame = CreateFrame ("button", nil, WorldQuestTracker.DoubleTapFrame)
resource_APowerFrame.QuestType = WQT_QUESTTYPE_APOWER

local resource_PetFrame = CreateFrame ("button", nil, WorldQuestTracker.DoubleTapFrame)
resource_PetFrame.QuestType = WQT_QUESTTYPE_PETBATTLE

-- ~resources ~recursos
local resource_GoldIcon = DF:CreateImage (resource_GoldFrame, [[Interface\AddOns\WorldQuestTracker\media\icons_resourcesT]], 16, 16, "overlay", {64/128, 96/128, 0, .25})
resource_GoldIcon:SetDrawLayer ("overlay", 7)
Expand All @@ -4248,6 +4260,11 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
resource_APowerIcon:SetDrawLayer ("overlay", 7)
resource_APowerIcon:SetAlpha (.78)
local resource_APowerText = DF:CreateLabel (resource_APowerFrame, "", ResourceFontTemplate)

local resource_PetIcon = DF:CreateImage (resource_PetFrame, WorldQuestTracker.MapData.QuestTypeIcons [WQT_QUESTTYPE_PETBATTLE].icon, 16, 16, "overlay", {0.05, 0.95, 0.05, 0.95})
resource_PetIcon:SetDrawLayer ("overlay", 7)
resource_PetIcon:SetAlpha (.78)
local resource_PetText = DF:CreateLabel (resource_PetFrame, "", ResourceFontTemplate)

--resource_APowerText:SetPoint ("bottomright", WorldQuestButton, "bottomleft", -10, 2)
--resource_APowerText:SetPoint ("bottomright", AllianceWorldQuestButton, "bottomleft", -10, 3)
Expand All @@ -4258,11 +4275,18 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
resource_ResourcesIcon:SetPoint ("right", resource_ResourcesText, "left", -2, 0)
resource_GoldText:SetPoint ("right", resource_ResourcesIcon, "left", -10, 0)
resource_GoldIcon:SetPoint ("right", resource_GoldText, "left", -2, 0)

resource_PetText:SetPoint ("right", resource_GoldIcon, "left", -2, 0)
resource_PetIcon:SetPoint ("right", resource_PetText, "left", -2, 0)

resource_PetText.text = 996


WorldQuestTracker.IndicatorsAnchor = resource_APowerText
WorldQuestTracker.WorldMap_GoldIndicator = resource_GoldText
WorldQuestTracker.WorldMap_ResourceIndicator = resource_ResourcesText
WorldQuestTracker.WorldMap_APowerIndicator = resource_APowerText
WorldQuestTracker.WorldMap_PetIndicator = resource_PetText

local track_all_quests_thread = function (tickerObject)
local questsToTrack = tickerObject.questsToTrack
Expand Down Expand Up @@ -4331,6 +4355,9 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
elseif (qType == "apower") then
qType = QUESTTYPE_ARTIFACTPOWER

elseif (qType == "petbattle") then
qType = QUESTTYPE_PET

end

local widgets = WorldQuestTracker.Cache_ShownWidgetsOnZoneMap
Expand Down Expand Up @@ -4360,10 +4387,15 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
local qType = self.QuestType
if (qType == "gold") then
qType = QUESTTYPE_GOLD

elseif (qType == "resource") then
qType = QUESTTYPE_RESOURCE

elseif (qType == "apower") then
qType = QUESTTYPE_ARTIFACTPOWER

elseif (qType == "petbattle") then
qType = QUESTTYPE_PET
end

for _, widget in pairs (WorldQuestTracker.WorldMapSmallWidgets) do
Expand Down Expand Up @@ -4412,6 +4444,7 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
resource_GoldFrame:SetScript ("OnClick", TrackAllFromType)
resource_ResourcesFrame:SetScript ("OnClick", TrackAllFromType)
resource_APowerFrame:SetScript ("OnClick", TrackAllFromType)
resource_PetFrame:SetScript ("OnClick", TrackAllFromType)

--animations
local animaSettings = {
Expand Down Expand Up @@ -4447,6 +4480,16 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
local anim = WorldQuestTracker:CreateAnimation (resource_APowerFrame.OnLeaveAnimation, "Scale", 2, animaSettings.speed, animaSettings.scaleMax, animaSettings.scaleMax, 1, 1, "center", 0, 0)
anim:SetSmoothing ("OUT")
end
--
do
resource_PetFrame.OnEnterAnimation = DF:CreateAnimationHub (resource_PetFrame, function() end, function() end)
local anim = WorldQuestTracker:CreateAnimation (resource_PetFrame.OnEnterAnimation, "Scale", 1, animaSettings.speed, 1, 1, animaSettings.scaleMax, animaSettings.scaleMax, "center", 0, 0)
anim:SetEndDelay (60) --this fixes the animation going back to 1 after it finishes
anim:SetSmoothing ("IN")
resource_PetFrame.OnLeaveAnimation = DF:CreateAnimationHub (resource_PetFrame, function() end, function() end)
local anim = WorldQuestTracker:CreateAnimation (resource_PetFrame.OnLeaveAnimation, "Scale", 2, animaSettings.speed, animaSettings.scaleMax, animaSettings.scaleMax, 1, 1, "center", 0, 0)
anim:SetSmoothing ("OUT")
end

--this function is called when the mouse enters the indicator area, here it handles only the animation
local indicatorsAnimationOnEnter = function (self, questType)
Expand All @@ -4463,6 +4506,7 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
local mapType = WorldQuestTrackerAddon.GetCurrentZoneType()

if (mapType == "world") then

for _, widget in ipairs (WorldQuestTracker.WorldSummaryQuestsSquares) do
if (widget.QuestType == questType and widget:IsShown()) then
widget.LoopFlash:Play()
Expand Down Expand Up @@ -4532,13 +4576,21 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
shadow:SetSize (58, 10)
shadow:SetAlpha (.3)

local shadow = WorldQuestTracker.DoubleTapFrame:CreateTexture (nil, "background")
shadow:SetPoint ("left", resource_PetIcon.widget, "left", 2, 0)
shadow:SetTexture ([[Interface\AddOns\WorldQuestTracker\media\background_blackgradientT]])
shadow:SetSize (58, 10)
shadow:SetAlpha (.3)

resource_GoldFrame:SetSize (55, 20)
resource_ResourcesFrame:SetSize (55, 20)
resource_APowerFrame:SetSize (55, 20)
resource_PetFrame:SetSize (55, 20)

resource_GoldFrame:SetPoint ("left", resource_GoldIcon.widget, "left", -2, 0)
resource_ResourcesFrame:SetPoint ("left", resource_ResourcesIcon.widget, "left", -2, 0)
resource_APowerFrame:SetPoint ("left", resource_APowerIcon.widget, "left", -2, 0)
resource_PetFrame:SetPoint ("left", resource_PetIcon.widget, "left", -2, 0)

resource_GoldFrame:SetScript ("OnEnter", function (self)
resource_GoldText.textcolor = "WQT_ORANGE_ON_ENTER"
Expand Down Expand Up @@ -4637,18 +4689,53 @@ WorldQuestTracker.OnToggleWorldMap = function (self)
GameCooltip:Show(self)
end)

resource_PetFrame:SetScript ("OnEnter", function (self)
resource_PetText.textcolor = "WQT_ORANGE_ON_ENTER"

indicatorsAnimationOnEnter (self, QUESTTYPE_PET)

GameCooltip:Preset (2)
GameCooltip:SetType ("tooltipbar")
GameCooltip:SetOption ("TextSize", 10)
GameCooltip:SetOption ("FixedWidth", 220)
GameCooltip:SetOption ("StatusBarTexture", [[Interface\RaidFrame\Raid-Bar-Hp-Fill]])

if (WorldQuestTracker.db.profile.bar_anchor == "top") then
GameCooltip:SetOption ("MyAnchor", "top")
GameCooltip:SetOption ("RelativeAnchor", "bottom")
GameCooltip:SetOption ("WidthAnchorMod", 0)
GameCooltip:SetOption ("HeightAnchorMod", -29)
else
GameCooltip:SetOption ("MyAnchor", "bottom")
GameCooltip:SetOption ("RelativeAnchor", "top")
GameCooltip:SetOption ("WidthAnchorMod", 0)
GameCooltip:SetOption ("HeightAnchorMod", 0)
end

GameCooltip:AddLine ("Pet Battle")
GameCooltip:AddIcon (WorldQuestTracker.MapData.QuestTypeIcons [WQT_QUESTTYPE_PETBATTLE].icon, 1, 1, 20, 20)

GameCooltip:AddLine ("", "", 1, "green", _, 10)
GameCooltip:AddLine (format (L["S_MAPBAR_RESOURCES_TOOLTIP_TRACKALL"], "Pet Battles"), "", 1, "green", _, 10)
GameCooltip:SetOption ("LeftTextHeight", 22)
GameCooltip:SetOwner (self)
GameCooltip:Show(self)
end)

local resource_IconsOnLeave = function (self)
GameCooltip:Hide()
resource_GoldText.textcolor = "WQT_ORANGE_RESOURCES_AVAILABLE"
resource_ResourcesText.textcolor = "WQT_ORANGE_RESOURCES_AVAILABLE"
resource_APowerText.textcolor = "WQT_ORANGE_RESOURCES_AVAILABLE"
resource_PetText.textcolor = "WQT_ORANGE_RESOURCES_AVAILABLE"

indicatorsAnimationOnLeave (self)
end

resource_GoldFrame:SetScript ("OnLeave", resource_IconsOnLeave)
resource_ResourcesFrame:SetScript ("OnLeave", resource_IconsOnLeave)
resource_APowerFrame:SetScript ("OnLeave", resource_IconsOnLeave)
resource_PetFrame:SetScript ("OnLeave", resource_IconsOnLeave)

--------------

Expand Down
1 change: 1 addition & 0 deletions WorldQuestTracker_Initialize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ do
QUESTTYPE_RESOURCE = 0x2
QUESTTYPE_ITEM = 0x4
QUESTTYPE_ARTIFACTPOWER = 0x8
QUESTTYPE_PET = 0x16

--todo: rename or put these into a table
FILTER_TYPE_PET_BATTLES = "pet_battles"
Expand Down
8 changes: 7 additions & 1 deletion WorldQuestTracker_ZoneMap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ function WorldQuestTracker.UpdateZoneWidgets (forceUpdate)
wipe (WorldQuestTracker.Cache_ShownQuestOnZoneMap)
wipe (WorldQuestTracker.Cache_ShownWidgetsOnZoneMap)

local total_Gold, total_Resources, total_APower = 0, 0, 0
local total_Gold, total_Resources, total_APower, total_Pet = 0, 0, 0, 0
local scale = WorldQuestTracker.db.profile.zone_map_config.scale

local questFailed = false
Expand Down Expand Up @@ -659,6 +659,10 @@ function WorldQuestTracker.UpdateZoneWidgets (forceUpdate)

local isSpellTarget = SpellCanTargetQuest() and IsQuestIDValidSpellTarget (questID)

if (worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE) then
total_Pet = total_Pet + 1
end

widget.mapID = mapID
widget.questID = questID
widget.numObjectives = info.numObjectives
Expand Down Expand Up @@ -855,6 +859,8 @@ function WorldQuestTracker.UpdateZoneWidgets (forceUpdate)
end

WorldQuestTracker.WorldMap_APowerIndicator.Amount = total_APower

WorldQuestTracker.WorldMap_PetIndicator.text = total_Pet
end

WorldQuestTracker.UpdateZoneSummaryFrame()
Expand Down

0 comments on commit 67cf662

Please sign in to comment.