mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-12 16:40:00 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
863d99647d | ||
|
|
06b3ae8d22 | ||
|
|
879d7afe83 |
+28
-18
@@ -6,30 +6,35 @@ pfUI:RegisterModule("cooldown", function ()
|
|||||||
-- local hourcolor = {strsplit(",", C.appearance.cd.hourcolor)}
|
-- local hourcolor = {strsplit(",", C.appearance.cd.hourcolor)}
|
||||||
-- local daycolor = {strsplit(",", C.appearance.cd.daycolor)}
|
-- local daycolor = {strsplit(",", C.appearance.cd.daycolor)}
|
||||||
|
|
||||||
local parent, parent_name
|
|
||||||
local function pfCooldownOnUpdate()
|
local function pfCooldownOnUpdate()
|
||||||
parent = this:GetParent()
|
-- Throttle FIRST. One of these runs per visible cooldown text, every frame,
|
||||||
|
-- so anything above this gate is multiplied by the frame rate and by how
|
||||||
|
-- many cooldowns are ticking.
|
||||||
|
local now = GetTime()
|
||||||
|
if (this.tick or 0) > now then return end
|
||||||
|
this.tick = now + .1
|
||||||
|
|
||||||
|
local parent = this:GetParent()
|
||||||
if not parent then this:Hide() return end
|
if not parent then this:Hide() return end
|
||||||
parent_name = parent:GetName()
|
|
||||||
|
|
||||||
-- avoid to set cooldowns on invalid frames
|
-- avoid to set cooldowns on invalid frames. The cooldown frame is stashed
|
||||||
if parent_name and _G[parent_name .. "Cooldown"] then
|
-- at creation: resolving it as _G[parent:GetName() .. "Cooldown"] built and
|
||||||
if not _G[parent_name .. "Cooldown"]:IsShown() then
|
-- interned that string twice per call, and this is the hottest path in the
|
||||||
this:Hide()
|
-- UI. The stashed reference is also the frame itself rather than a guess
|
||||||
end
|
-- from its parent's name, so it holds for cooldowns named anything else.
|
||||||
|
if this.cooldown and not this.cooldown:IsShown() then
|
||||||
|
this:Hide()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- only run every 0.1 seconds from here on
|
|
||||||
if ( this.tick or .1) > GetTime() then return else this.tick = GetTime() + .1 end
|
|
||||||
|
|
||||||
-- fix own alpha value (should be inherited, but somehow isn't always)
|
-- fix own alpha value (should be inherited, but somehow isn't always)
|
||||||
if this:GetAlpha() ~= parent:GetAlpha() then
|
if this:GetAlpha() ~= parent:GetAlpha() then
|
||||||
this:SetAlpha(parent:GetAlpha())
|
this:SetAlpha(parent:GetAlpha())
|
||||||
end
|
end
|
||||||
|
|
||||||
if this.start < GetTime() then
|
if this.start < now then
|
||||||
-- calculating remaining time as it should be
|
-- calculating remaining time as it should be
|
||||||
local remaining = this.duration - (GetTime() - this.start)
|
local remaining = this.duration - (now - this.start)
|
||||||
if remaining >= 0 then
|
if remaining >= 0 then
|
||||||
this.text:SetText(GetColoredTimeString(remaining))
|
this.text:SetText(GetColoredTimeString(remaining))
|
||||||
else
|
else
|
||||||
@@ -38,13 +43,13 @@ pfUI:RegisterModule("cooldown", function ()
|
|||||||
else
|
else
|
||||||
-- I have absolutely no idea, but it works:
|
-- I have absolutely no idea, but it works:
|
||||||
-- https://github.com/Stanzilla/WoWUIBugs/issues/47
|
-- https://github.com/Stanzilla/WoWUIBugs/issues/47
|
||||||
local time = time()
|
local currentTime = time()
|
||||||
local startupTime = time - GetTime()
|
local startupTime = currentTime - now
|
||||||
-- just a simplification of: ((2^32) - (start * 1000)) / 1000
|
-- just a simplification of: ((2^32) - (start * 1000)) / 1000
|
||||||
local cdTime = (2 ^ 32) / 1000 - this.start
|
local cdTime = (2 ^ 32) / 1000 - this.start
|
||||||
local cdStartTime = startupTime - cdTime
|
local cdStartTime = startupTime - cdTime
|
||||||
local cdEndTime = cdStartTime + this.duration
|
local cdEndTime = cdStartTime + this.duration
|
||||||
local remaining = cdEndTime - time
|
local remaining = cdEndTime - currentTime
|
||||||
|
|
||||||
if remaining >= 0 then
|
if remaining >= 0 then
|
||||||
this.text:SetText(GetColoredTimeString(remaining))
|
this.text:SetText(GetColoredTimeString(remaining))
|
||||||
@@ -55,11 +60,16 @@ pfUI:RegisterModule("cooldown", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local height, size
|
local height, size
|
||||||
|
local textcount = 0
|
||||||
local function pfCreateCoolDown(cooldown, start, duration)
|
local function pfCreateCoolDown(cooldown, start, duration)
|
||||||
cooldown.pfCooldownText = CreateFrame("Frame", "pfCooldownFrame", cooldown:GetParent())
|
textcount = textcount + 1
|
||||||
|
local name = cooldown.GetName and cooldown:GetName() or "pfCooldown" .. textcount
|
||||||
|
|
||||||
|
cooldown.pfCooldownText = CreateFrame("Frame", name .. "Text", cooldown:GetParent())
|
||||||
|
cooldown.pfCooldownText.cooldown = cooldown
|
||||||
cooldown.pfCooldownText:SetAllPoints(cooldown)
|
cooldown.pfCooldownText:SetAllPoints(cooldown)
|
||||||
cooldown.pfCooldownText:SetFrameLevel(cooldown:GetParent():GetFrameLevel() + 2)
|
cooldown.pfCooldownText:SetFrameLevel(cooldown:GetParent():GetFrameLevel() + 2)
|
||||||
cooldown.pfCooldownText.text = cooldown.pfCooldownText:CreateFontString("pfCooldownFrameText", "OVERLAY")
|
cooldown.pfCooldownText.text = cooldown.pfCooldownText:CreateFontString(name .. "TextString", "OVERLAY")
|
||||||
|
|
||||||
if not cooldown.pfCooldownType then
|
if not cooldown.pfCooldownType then
|
||||||
size = tonumber(C.appearance.cd.font_size_foreign)
|
size = tonumber(C.appearance.cd.font_size_foreign)
|
||||||
|
|||||||
+6
-17
@@ -104,7 +104,6 @@ pfUI:RegisterModule("loothistory", function ()
|
|||||||
-- Frame pools
|
-- Frame pools
|
||||||
-- ==========================================================================
|
-- ==========================================================================
|
||||||
local itemFrames = {}
|
local itemFrames = {}
|
||||||
local usedPlayers, freePlayers = {}, {}
|
|
||||||
|
|
||||||
local FullUpdate -- forward declaration (toggle handlers call it)
|
local FullUpdate -- forward declaration (toggle handlers call it)
|
||||||
|
|
||||||
@@ -204,20 +203,10 @@ pfUI:RegisterModule("loothistory", function ()
|
|||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
|
|
||||||
local function RecycleAllPlayers()
|
local playerPool = CreateObjectPool(CreatePlayerFrame, function(_, pf)
|
||||||
for i = 1, table.getn(usedPlayers) do
|
pf:Hide()
|
||||||
local pf = usedPlayers[i]
|
pf:ClearAllPoints()
|
||||||
pf:Hide()
|
end)
|
||||||
table.insert(freePlayers, pf)
|
|
||||||
end
|
|
||||||
usedPlayers = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function GetPlayerFrame()
|
|
||||||
local pf = table.remove(freePlayers) or CreatePlayerFrame()
|
|
||||||
table.insert(usedPlayers, pf)
|
|
||||||
return pf
|
|
||||||
end
|
|
||||||
|
|
||||||
local function SetToggleTexture(toggle, isExpanded)
|
local function SetToggleTexture(toggle, isExpanded)
|
||||||
if isExpanded then
|
if isExpanded then
|
||||||
@@ -309,7 +298,7 @@ pfUI:RegisterModule("loothistory", function ()
|
|||||||
|
|
||||||
function FullUpdate()
|
function FullUpdate()
|
||||||
if not pfUI.loothistory:IsShown() then return end
|
if not pfUI.loothistory:IsShown() then return end
|
||||||
RecycleAllPlayers()
|
playerPool:ReleaseAll()
|
||||||
|
|
||||||
local num = C_LootHistory.GetNumItems()
|
local num = C_LootHistory.GetNumItems()
|
||||||
local y = -2
|
local y = -2
|
||||||
@@ -327,7 +316,7 @@ pfUI:RegisterModule("loothistory", function ()
|
|||||||
for p = 1, f.numPlayers do
|
for p = 1, f.numPlayers do
|
||||||
local name, class, rollType, roll, isWinner, isMe = C_LootHistory.GetPlayerInfo(i, p)
|
local name, class, rollType, roll, isWinner, isMe = C_LootHistory.GetPlayerInfo(i, p)
|
||||||
if ShouldDisplayPlayer(f.isDone, roll, isMe) then
|
if ShouldDisplayPlayer(f.isDone, roll, isMe) then
|
||||||
local pf = GetPlayerFrame()
|
local pf = playerPool:Acquire()
|
||||||
RenderPlayerFrame(pf, name, class, rollType, roll, isWinner)
|
RenderPlayerFrame(pf, name, class, rollType, roll, isWinner)
|
||||||
pf:ClearAllPoints()
|
pf:ClearAllPoints()
|
||||||
pf:SetPoint("TOPLEFT", list, "TOPLEFT", 22, y)
|
pf:SetPoint("TOPLEFT", list, "TOPLEFT", 22, y)
|
||||||
|
|||||||
+42
-44
@@ -30,20 +30,14 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
pfUI.mapreveal:UpdateConfig()
|
pfUI.mapreveal:UpdateConfig()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local explores = {}
|
|
||||||
local explorecaches = {}
|
local explorecaches = {}
|
||||||
local alreadyknown = {} -- per-zone accumulator: { [zone] = { [texName] = true } }
|
local alreadyknown = {} -- per-zone accumulator: { [zone] = { [texName] = true } }
|
||||||
|
|
||||||
-- Own texture pool - separate from Blizzard's WorldMapOverlay textures
|
-- Own texture pool - separate from Blizzard's WorldMapOverlay textures
|
||||||
local pfOverlays = {}
|
local overlayPool = CreateTexturePool(WorldMapDetailFrame, "BORDER", nil, nil, function(_, tex)
|
||||||
local pfOverlayMax = 0
|
tex:Hide()
|
||||||
|
tex:ClearAllPoints()
|
||||||
local function pfGetOverlay(idx)
|
end)
|
||||||
if not pfOverlays[idx] then
|
|
||||||
pfOverlays[idx] = WorldMapDetailFrame:CreateTexture("pfReveal"..idx, "BORDER")
|
|
||||||
end
|
|
||||||
return pfOverlays[idx]
|
|
||||||
end
|
|
||||||
|
|
||||||
local exploreEnter = function()
|
local exploreEnter = function()
|
||||||
WorldMapTooltip:ClearLines()
|
WorldMapTooltip:ClearLines()
|
||||||
@@ -69,14 +63,38 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Magnifying-glass icons for unexplored overlays. Everything constant lives
|
||||||
|
-- in the creator; the update only anchors and labels what it acquires -- and
|
||||||
|
-- it only acquires the ones it is going to show, where the old table grew an
|
||||||
|
-- icon for every overlay in the zone and hid most of them again.
|
||||||
|
local function CreateExplore()
|
||||||
|
local explore = CreateFrame("Frame", nil, WorldMapDetailFrame)
|
||||||
|
explore:SetSize(16, 16)
|
||||||
|
explore:SetScript("OnEnter", exploreEnter)
|
||||||
|
explore:SetScript("OnLeave", exploreLeave)
|
||||||
|
explore:EnableMouse(true)
|
||||||
|
explore:SetFrameLevel(255)
|
||||||
|
|
||||||
|
explore.tex = explore:CreateTexture(nil, "OVERLAY")
|
||||||
|
explore.tex:SetTexture("Interface\\WorldMap\\WorldMap-MagnifyingGlass")
|
||||||
|
explore.tex:SetBlendMode("ADD")
|
||||||
|
explore.tex:SetTexCoord(.08, .92, .08, .92)
|
||||||
|
explore.tex:SetAllPoints()
|
||||||
|
|
||||||
|
return explore
|
||||||
|
end
|
||||||
|
|
||||||
|
local explorePool = CreateObjectPool(CreateExplore, function(_, explore)
|
||||||
|
explore:Hide()
|
||||||
|
explore:ClearAllPoints()
|
||||||
|
end)
|
||||||
|
|
||||||
local function pfWorldMapFrame_Update()
|
local function pfWorldMapFrame_Update()
|
||||||
-- clear stale caches
|
-- clear stale caches
|
||||||
for k in pairs(explorecaches) do explorecaches[k] = nil end
|
for k in pairs(explorecaches) do explorecaches[k] = nil end
|
||||||
|
|
||||||
-- hide all our textures from last frame
|
-- hide all our textures from last frame
|
||||||
for i = 1, pfOverlayMax do
|
overlayPool:ReleaseAll()
|
||||||
pfOverlays[i]:Hide()
|
|
||||||
end
|
|
||||||
|
|
||||||
local r,g,b,a = GetStringColor(C.appearance.worldmap.mapreveal_color)
|
local r,g,b,a = GetStringColor(C.appearance.worldmap.mapreveal_color)
|
||||||
local mapFileName = GetMapInfo()
|
local mapFileName = GetMapInfo()
|
||||||
@@ -94,14 +112,13 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
local zoneKnown = alreadyknown[mapFileName]
|
local zoneKnown = alreadyknown[mapFileName]
|
||||||
|
|
||||||
-- hide explore icons
|
-- hide explore icons
|
||||||
for _, frame in pairs(explores) do frame:Hide() end
|
explorePool:ReleaseAll()
|
||||||
|
|
||||||
-- ClassicAPI: full overlay list for the viewed zone (explored + unexplored),
|
-- ClassicAPI: full overlay list for the viewed zone (explored + unexplored),
|
||||||
-- read straight from WorldMapOverlay.dbc. Replaces the hand-measured pfMapOverlayData.
|
-- read straight from WorldMapOverlay.dbc. Replaces the hand-measured pfMapOverlayData.
|
||||||
local zoneData = C_Map.GetMapOverlays() or {}
|
local zoneData = C_Map.GetMapOverlays() or {}
|
||||||
local textureCount = 0
|
|
||||||
|
|
||||||
for i, overlay in ipairs(zoneData) do
|
for _, overlay in ipairs(zoneData) do
|
||||||
local name = overlay.textureName -- bare, e.g. "DRYGULCHRAVINE"
|
local name = overlay.textureName -- bare, e.g. "DRYGULCHRAVINE"
|
||||||
local textureName = overlay.texturePath -- full engine path (for SetTexture)
|
local textureName = overlay.texturePath -- full engine path (for SetTexture)
|
||||||
local textureWidth = overlay.textureWidth
|
local textureWidth = overlay.textureWidth
|
||||||
@@ -109,30 +126,15 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
local offsetX = overlay.offsetX
|
local offsetX = overlay.offsetX
|
||||||
local offsetY = overlay.offsetY
|
local offsetY = overlay.offsetY
|
||||||
|
|
||||||
-- explore magnifying glass icon
|
-- explore magnifying glass icon. `alreadyknown` stores the FULL paths
|
||||||
explores[i] = explores[i] or CreateFrame("Frame", nil, WorldMapDetailFrame)
|
-- GetMapOverlayInfo returns, so compare with the full path, not the bare
|
||||||
local explore = explores[i]
|
-- name.
|
||||||
explore:SetWidth(16)
|
|
||||||
explore:SetHeight(16)
|
|
||||||
explore:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", offsetX + textureWidth/2, -offsetY - textureHeight/2)
|
|
||||||
explore:SetScript("OnEnter", exploreEnter)
|
|
||||||
explore:SetScript("OnLeave", exploreLeave)
|
|
||||||
explore:EnableMouse(true)
|
|
||||||
explore:SetFrameLevel(255)
|
|
||||||
explore.name = mapFileName .. " (" .. name .. ")"
|
|
||||||
explore.area = name -- cache key: explorecaches is keyed by the plain area name
|
|
||||||
explore.tex = explore.tex or explore:CreateTexture("", "OVERLAY")
|
|
||||||
explore.tex:SetBlendMode("ADD")
|
|
||||||
explore.tex:SetTexCoord(.08, .92, .08, .92)
|
|
||||||
explore.tex:SetAllPoints()
|
|
||||||
|
|
||||||
-- `alreadyknown` stores the FULL paths GetMapOverlayInfo returns,
|
|
||||||
-- so compare with the full path, not the bare name.
|
|
||||||
if C.appearance.worldmap.mapexploration == "1" and not zoneKnown[string.upper(textureName)] then
|
if C.appearance.worldmap.mapexploration == "1" and not zoneKnown[string.upper(textureName)] then
|
||||||
explore.tex:SetTexture("Interface\\WorldMap\\WorldMap-MagnifyingGlass")
|
local explore = explorePool:Acquire()
|
||||||
|
explore:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", offsetX + textureWidth/2, -offsetY - textureHeight/2)
|
||||||
|
explore.name = mapFileName .. " (" .. name .. ")"
|
||||||
|
explore.area = name -- cache key: explorecaches is keyed by the plain area name
|
||||||
explore:Show()
|
explore:Show()
|
||||||
else
|
|
||||||
explore:Hide()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- render overlay texture tiles on BORDER draw layer
|
-- render overlay texture tiles on BORDER draw layer
|
||||||
@@ -147,11 +149,9 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
-- exactly what shears quirky overlays (e.g. Icepoint's Kaneq'nuun).
|
-- exactly what shears quirky overlays (e.g. Icepoint's Kaneq'nuun).
|
||||||
if C.appearance.worldmap.mapreveal == "1" then
|
if C.appearance.worldmap.mapreveal == "1" then
|
||||||
for _, tile in ipairs(overlay.tiles) do
|
for _, tile in ipairs(overlay.tiles) do
|
||||||
textureCount = textureCount + 1
|
local tex = overlayPool:Acquire()
|
||||||
local tex = pfGetOverlay(textureCount)
|
|
||||||
|
|
||||||
tex:SetWidth(tile.width)
|
tex:SetSize(tile.width, tile.height)
|
||||||
tex:SetHeight(tile.height)
|
|
||||||
tex:SetTexCoord(0, tile.texCoordX, 0, tile.texCoordY)
|
tex:SetTexCoord(0, tile.texCoordX, 0, tile.texCoordY)
|
||||||
tex:ClearAllPoints()
|
tex:ClearAllPoints()
|
||||||
tex:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", tile.offsetX, -tile.offsetY)
|
tex:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", tile.offsetX, -tile.offsetY)
|
||||||
@@ -165,8 +165,6 @@ pfUI:RegisterModule("mapreveal", function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pfOverlayMax = math.max(pfOverlayMax, textureCount)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hook WorldMapFrame_Update
|
-- hook WorldMapFrame_Update
|
||||||
|
|||||||
Reference in New Issue
Block a user