Skip to content

Commit

Permalink
Updating to TWW prepatch and syncing changes from mainstream gathermate
Browse files Browse the repository at this point in the history
  • Loading branch information
ynazar1 committed Aug 12, 2024
1 parent 8a28b4e commit 7a4f4a8
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 71 deletions.
60 changes: 24 additions & 36 deletions Collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@ local Collector = GatherMateTreasures:NewModule("Collector", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("GatherMate2Treasures",true)
local NL = LibStub("AceLocale-3.0"):GetLocale("GatherMate2TreasuresNodes") -- for get the local name of Gas Cloud´s

local WoW10 = select(4, GetBuildInfo()) >= 100000

local Display = nil
-- prevSpell, curSpell are markers for what has been cast now and the lastcast
-- gatherevents if a flag for wether we are listening to events
local prevSpell, curSpell, foundTarget, gatherEvents, ga
local prevSpell, curSpell, foundTarget, ga

local GetSpellName = C_Spell and C_Spell.GetSpellName or GetSpellInfo

--[[
Convert for 2.4 spell IDs
]]
local miningSpell = (GetSpellInfo(2575))
local miningSpell2 = (GetSpellInfo(195122))
local herbSpell = (GetSpellInfo(2366))
local herbSkill = ((GetSpellInfo(170691)) or (string.gsub((GetSpellInfo(9134)),"%A","")))
local fishSpell = (GetSpellInfo(7620)) or (GetSpellInfo(131476))
local gasSpell = (GetSpellInfo(30427))
--local gasSpell = (GetSpellInfo(48929)) --other gasspell
local openSpell = (GetSpellInfo(3365))
local openNoTextSpell = (GetSpellInfo(22810))
local pickSpell = (GetSpellInfo(1804))
local archSpell = (GetSpellInfo(73979)) -- Searching for Artifacts spell
local sandStormSpell = (GetSpellInfo(93473)) -- Sandstorm spell cast by the camel
local loggingSpell = (GetSpellInfo(167895))
local digDisturbedDirt = (GetSpellInfo(370349))
local miningSpell = (GetSpellName(2575))
local miningSpell2 = (GetSpellName(195122))
local herbSpell = (GetSpellName(2366))
local herbSkill = ((GetSpellName(170691)) or (string.gsub((GetSpellName(9134)),"%A","")))
local fishSpell = (GetSpellName(7620)) or (GetSpellName(131476))
local gasSpell = (GetSpellName(30427))
--local gasSpell = (GetSpellName(48929)) --other gasspell
local openSpell = (GetSpellName(3365))
local openNoTextSpell = (GetSpellName(22810))
local pickSpell = (GetSpellName(1804))
local archSpell = (GetSpellName(73979)) -- Searching for Artifacts spell
local sandStormSpell = (GetSpellName(93473)) -- Sandstorm spell cast by the camel
local loggingSpell = (GetSpellName(167895))
local digDisturbedDirt = (GetSpellName(370349))

local spells =
{ -- spellname to "database name"
Expand All @@ -45,12 +44,11 @@ local spells =
[digDisturbedDirt] = "Treasure",
}
local tooltipLeftText1 = _G["GameTooltipTextLeft1"]
local strfind, stringmatch = string.find, string.match
local strfind = string.find
local pii = math.pi
local sin = math.sin
local cos = math.cos
local gsub = gsub
local strtrim = strtrim

--[[
This search string code no longer needed since we use CombatEvent to detect gas clouds harvesting
]]
Expand All @@ -74,16 +72,11 @@ function Collector:RegisterGatherEvents()
self:RegisterEvent("UNIT_SPELLCAST_STOP","SpellStopped")
self:RegisterEvent("UNIT_SPELLCAST_FAILED","SpellFailed")
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED","SpellFailed")
if WoW10 then
self:RegisterEvent("CURSOR_CHANGED","CursorChange")
else
self:RegisterEvent("CURSOR_UPDATE","CursorChange")
end
self:RegisterEvent("CURSOR_CHANGED","CursorChange")
self:RegisterEvent("UI_ERROR_MESSAGE","UIError")
--self:RegisterEvent("LOOT_CLOSED","GatherCompleted")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", "GasBuffDetector")
self:RegisterEvent("CHAT_MSG_LOOT","SecondaryGasCheck") -- for Storm Clouds
gatherEvents = true
end

--[[
Expand All @@ -95,19 +88,14 @@ function Collector:UnregisterGatherEvents()
self:UnregisterEvent("UNIT_SPELLCAST_STOP")
self:UnregisterEvent("UNIT_SPELLCAST_FAILED")
self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED")
if WoW10 then
self:UnregisterEvent("CURSOR_CHANGED")
else
self:UnregisterEvent("CURSOR_UPDATE")
end
self:UnregisterEvent("CURSOR_CHANGED")
self:UnregisterEvent("UI_ERROR_MESSAGE")
--self:UnregisterEvent("LOOT_CLOSED")
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
gatherEvents = false
end

local CrystalizedWater = (GetItemInfo(37705)) or ""
local MoteOfAir = (GetItemInfo(22572)) or ""
local CrystalizedWater = (C_Item.GetItemNameByID(37705)) or ""
local MoteOfAir = (C_Item.GetItemNameByID(22572)) or ""

function Collector:SecondaryGasCheck(event,msg)
if ga ~= gasSpell then return end
Expand Down Expand Up @@ -214,7 +202,7 @@ function Collector:SpellStarted(event,unit,target,guid,spellcast)
if unit ~= "player" then return end
foundTarget = false
ga ="No"
local spellname = GetSpellInfo(spellcast)
local spellname = GetSpellName(spellcast)
if spellname and (spells[spellname] or spells[spellcast]) then
if spells[spellname] then
curSpell = spellname
Expand Down
3 changes: 1 addition & 2 deletions Config.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local GatherMateTreasures = LibStub("AceAddon-3.0"):GetAddon("GatherMate2Treasures")
local Config = GatherMateTreasures:NewModule("Config","AceEvent-3.0")
local Display = GatherMateTreasures:GetModule("Display")
local L = LibStub("AceLocale-3.0"):GetLocale("GatherMate2Treasures", false)

-- Databroker support
Expand Down Expand Up @@ -1019,7 +1018,7 @@ importOptions.args.GatherMateData = {
local enabled = GetAddOnEnableState(UnitName("player"), "GatherMate2T_Data") > 0
-- disable if the addon is not enabled, or
-- disable if there is a reason why it can't be loaded ("MISSING" or "DISABLED")
return not enabled or (reason ~= nil and reason ~= "DEMAND_LOADED")
return not enabled or (reason ~= nil and reason ~= "" and reason ~= "DEMAND_LOADED")
end,
args = {
desc = {
Expand Down
74 changes: 45 additions & 29 deletions Display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local L = LibStub("AceLocale-3.0"):GetLocale("GatherMate2Treasures")
-- WoW 10.0 tracking API compat
local GetNumTrackingTypes = GetNumTrackingTypes or C_Minimap.GetNumTrackingTypes
local GetTrackingInfo = GetTrackingInfo or C_Minimap.GetTrackingInfo
local GetSpellName = C_Spell and C_Spell.GetSpellName or GetSpellInfo


-- Current minimap pin set
local minimapPins, minimapPinCount = {}, 0
Expand All @@ -22,27 +24,23 @@ local pinClickedOn
-- our current zone
local zone = -1
-- cache of table insert functions
local tinsert, tremove, next, pairs = tinsert, tremove, next, pairs
local next, pairs = next, pairs
-- minimap rotation
local rotateMinimap = GetCVar("rotateMinimap") == "1"
-- shape of the minimap
local minimapShape
-- is the minimap indoors or outdoors
local indoors = GetCVar("minimapZoom")+0 == Minimap:GetZoom() and "outdoor" or "indoor"
-- diameter of the minimap
local mapRadius, minimapWidth, minimapHeight, minimapScale, lastFacing, lastZoom
local minimapStrata, minimapFrameLevel
-- math function cache
local math_sin, math_cos, abs, max = math.sin, math.cos, math.abs, math.max
local math_sin, math_cos, max = math.sin, math.cos, math.max
local sin, cos
-- API function cache
local GetRealZoneText = GetRealZoneText
local GetProfessionInfo = GetProfessionInfo
local strfind, format = string.find, string.format
local format = string.format
local trackingCircle, nodeTextures
local db
local Minimap = Minimap
local inInstance
local nodeRange = 2
local forceNextUpdate
local trackShow = {}
Expand Down Expand Up @@ -100,29 +98,43 @@ end
Pin OnEnter
]]
local tooltip_template = "|c%02x%02x%02x%02x%s|r"
local mouseoveredPins = {}
local checkMoused = false
local function showPin(self)
if (self.title) then
local pinset
if self.worldmap then
pinset = worldmapPins
else
pinset = minimapPins
end
local x, y = self:GetCenter()
local parentX, parentY = UIParent:GetCenter()
if ( x > parentX ) then
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
else
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
end

local t = db.trackColors
local text = format(tooltip_template, t[self.nodeType].Alpha*255, t[self.nodeType].Red*255, t[self.nodeType].Green*255, t[self.nodeType].Blue*255, self.title)
for id, pin in pairs(pinset) do
if pin:IsMouseOver() and pin.title and pin ~= self then
text = text .. "\n" .. format(tooltip_template, t[pin.nodeType].Alpha*255, t[pin.nodeType].Red*255, t[pin.nodeType].Green*255, t[pin.nodeType].Blue*255, pin.title)
local dbtable
if not checkMoused then
local pinset
if self.worldmap then
pinset = worldmapPins
else
pinset = minimapPins
end
for id, pin in pairs(pinset) do --Cache mouseovered pins to improve tooltip perf
if pin.title and pin:IsMouseOver() then
dbtable = t[pin.nodeType]
mouseoveredPins[pin] = format(tooltip_template, dbtable.Alpha*255, dbtable.Red*255, dbtable.Green*255, dbtable.Blue*255, pin.title)
end
end
checkMoused = true
end
dbtable = t[self.nodeType]
local text = format(tooltip_template, dbtable.Alpha*255, dbtable.Red*255, dbtable.Green*255, dbtable.Blue*255, self.title)

for pin, pin_text in pairs(mouseoveredPins) do
if pin ~= self then
text = text .. "\n" .. pin_text
end
end

GameTooltip:SetText(text)
GameTooltip:Show()
end
Expand All @@ -132,6 +144,8 @@ end
]]
local function hidePin(self)
GameTooltip:Hide()
wipe(mouseoveredPins)
checkMoused = false
end
--[[
Pin click handler
Expand Down Expand Up @@ -180,14 +194,12 @@ local function generatePinMenu(self,level)
info.disabled = nil
info.isTitle = nil
info.notCheckable = nil
for id, pin in pairs(worldmapPins) do
if pin:IsMouseOver() and pin.title then
info.text = L["Delete"] .. " :" ..pin.title
info.icon = nodeTextures[pin.nodeType][GatherMateTreasures:GetIDForNode(pin.nodeType, pin.title)]
info.func = deletePin
info.arg1 = pin
UIDropDownMenu_AddButton(info, level);
end
for pin, pin_text in pairs(mouseoveredPins) do --Reuse here, not as significant since this is ran occasionally
info.text = L["Delete"] .. " :" ..pin.title
info.icon = nodeTextures[pin.nodeType][GatherMate:GetIDForNode(pin.nodeType, pin.title)]
info.func = deletePin
info.arg1 = pin
UIDropDownMenu_AddButton(info, level);
end

if TomTom then
Expand Down Expand Up @@ -387,7 +399,7 @@ function Display:UpdateVisibility()
end

function Display:SetTrackingSpell(skill,spell)
local spellName, _, texture = GetSpellInfo(spell)
local spellName = GetSpellName(spell)
if not spellName then return end
tracking_spells[spellName] = skill
if fullInit then self:MINIMAP_UPDATE_TRACKING() end
Expand Down Expand Up @@ -748,7 +760,8 @@ function Display.WorldMapDataProvider:RefreshAllData(fromOnShow)
-- update visibility for archaeology blobs
Display:UpdateVisibility()

local uiMapID = self:GetMap():GetMapID()
local map = self:GetMap()
local uiMapID = map:GetMapID()
if not uiMapID then return end

if GatherMateTreasures.phasing[uiMapID] then uiMapID = GatherMateTreasures.phasing[uiMapID] end
Expand All @@ -757,7 +770,7 @@ function Display.WorldMapDataProvider:RefreshAllData(fromOnShow)
for i,db_type in pairs(GatherMateTreasures.db_types) do
if GatherMateTreasures.Visible[db_type] then
for coord, nodeID in GatherMateTreasures:GetNodesForZone(uiMapID, db_type) do
local pin = self:GetMap():AcquirePin("GatherMate2TreasuresWorldMapPinTemplate", coord, nodeID, db_type, uiMapID)
local pin = map:AcquirePin("GatherMate2TreasuresWorldMapPinTemplate", coord, nodeID, db_type, uiMapID)
table.insert(worldmapPins, pin)
end
end
Expand Down Expand Up @@ -809,6 +822,9 @@ function GatherMate2TreasuresWorldMapPinMixin:OnClick(button)
return pinClick(self, button)
end

-- hack to avoid error in combat in 10.1.5
GatherMate2WorldMapPinMixin.SetPassThroughButtons = function() end

function Display:UpdateWorldMap()
self.WorldMapDataProvider:RefreshAllData()
end
Expand Down
2 changes: 0 additions & 2 deletions GatherMate2Treasures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ local defaults = {
}
},
}
local floor = floor
local next = next

--[[
Setup a few databases, we sub divide namespaces for resetting/importing
Expand Down
4 changes: 2 additions & 2 deletions GatherMate2Treasures.toc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Interface: 100105
## Interface: 100207, 110000, 110002
## Title: Gathermate2Treasures
## Notes: Collects Treasure locations and adds them to the worldmap and minimap
## Author: ynazar1
## X-Credits: OttoDeFe for the launher icon.
## SavedVariables: GatherMate2TreasuresDB, GatherMate2TreasuresHerbDB, GatherMate2TreasuresMineDB, GatherMate2TreasuresFishDB, GatherMate2TreasuresGasDB, GatherMate2TreasuresTreasureDB, GatherMate2TreasuresArchaeologyDB, GatherMate2TreasuresLoggingDB
## X-Category: Map
## Version: 1.0.0-105
## Version: 1.0.1-1102
## X-License: ARR
## OptionalDeps: Ace3, LibDataBroker-1.1, HereBeDragons
## LoadManagers: AddonLoader
Expand Down

0 comments on commit 7a4f4a8

Please sign in to comment.