mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
Compare commits
3 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 daycolor = {strsplit(",", C.appearance.cd.daycolor)}
|
||||
|
||||
local parent, parent_name
|
||||
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
|
||||
parent_name = parent:GetName()
|
||||
|
||||
-- avoid to set cooldowns on invalid frames
|
||||
if parent_name and _G[parent_name .. "Cooldown"] then
|
||||
if not _G[parent_name .. "Cooldown"]:IsShown() then
|
||||
this:Hide()
|
||||
end
|
||||
-- avoid to set cooldowns on invalid frames. The cooldown frame is stashed
|
||||
-- at creation: resolving it as _G[parent:GetName() .. "Cooldown"] built and
|
||||
-- interned that string twice per call, and this is the hottest path in the
|
||||
-- UI. The stashed reference is also the frame itself rather than a guess
|
||||
-- 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
|
||||
|
||||
-- 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)
|
||||
if this:GetAlpha() ~= parent:GetAlpha() then
|
||||
this:SetAlpha(parent:GetAlpha())
|
||||
end
|
||||
|
||||
if this.start < GetTime() then
|
||||
if this.start < now then
|
||||
-- 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
|
||||
this.text:SetText(GetColoredTimeString(remaining))
|
||||
else
|
||||
@@ -38,13 +43,13 @@ pfUI:RegisterModule("cooldown", function ()
|
||||
else
|
||||
-- I have absolutely no idea, but it works:
|
||||
-- https://github.com/Stanzilla/WoWUIBugs/issues/47
|
||||
local time = time()
|
||||
local startupTime = time - GetTime()
|
||||
local currentTime = time()
|
||||
local startupTime = currentTime - now
|
||||
-- just a simplification of: ((2^32) - (start * 1000)) / 1000
|
||||
local cdTime = (2 ^ 32) / 1000 - this.start
|
||||
local cdStartTime = startupTime - cdTime
|
||||
local cdEndTime = cdStartTime + this.duration
|
||||
local remaining = cdEndTime - time
|
||||
local remaining = cdEndTime - currentTime
|
||||
|
||||
if remaining >= 0 then
|
||||
this.text:SetText(GetColoredTimeString(remaining))
|
||||
@@ -55,11 +60,16 @@ pfUI:RegisterModule("cooldown", function ()
|
||||
end
|
||||
|
||||
local height, size
|
||||
local textcount = 0
|
||||
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: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
|
||||
size = tonumber(C.appearance.cd.font_size_foreign)
|
||||
|
||||
+6
-17
@@ -104,7 +104,6 @@ pfUI:RegisterModule("loothistory", function ()
|
||||
-- Frame pools
|
||||
-- ==========================================================================
|
||||
local itemFrames = {}
|
||||
local usedPlayers, freePlayers = {}, {}
|
||||
|
||||
local FullUpdate -- forward declaration (toggle handlers call it)
|
||||
|
||||
@@ -204,20 +203,10 @@ pfUI:RegisterModule("loothistory", function ()
|
||||
return f
|
||||
end
|
||||
|
||||
local function RecycleAllPlayers()
|
||||
for i = 1, table.getn(usedPlayers) do
|
||||
local pf = usedPlayers[i]
|
||||
pf:Hide()
|
||||
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 playerPool = CreateObjectPool(CreatePlayerFrame, function(_, pf)
|
||||
pf:Hide()
|
||||
pf:ClearAllPoints()
|
||||
end)
|
||||
|
||||
local function SetToggleTexture(toggle, isExpanded)
|
||||
if isExpanded then
|
||||
@@ -309,7 +298,7 @@ pfUI:RegisterModule("loothistory", function ()
|
||||
|
||||
function FullUpdate()
|
||||
if not pfUI.loothistory:IsShown() then return end
|
||||
RecycleAllPlayers()
|
||||
playerPool:ReleaseAll()
|
||||
|
||||
local num = C_LootHistory.GetNumItems()
|
||||
local y = -2
|
||||
@@ -327,7 +316,7 @@ pfUI:RegisterModule("loothistory", function ()
|
||||
for p = 1, f.numPlayers do
|
||||
local name, class, rollType, roll, isWinner, isMe = C_LootHistory.GetPlayerInfo(i, p)
|
||||
if ShouldDisplayPlayer(f.isDone, roll, isMe) then
|
||||
local pf = GetPlayerFrame()
|
||||
local pf = playerPool:Acquire()
|
||||
RenderPlayerFrame(pf, name, class, rollType, roll, isWinner)
|
||||
pf:ClearAllPoints()
|
||||
pf:SetPoint("TOPLEFT", list, "TOPLEFT", 22, y)
|
||||
|
||||
+42
-44
@@ -30,20 +30,14 @@ pfUI:RegisterModule("mapreveal", function ()
|
||||
pfUI.mapreveal:UpdateConfig()
|
||||
end)
|
||||
|
||||
local explores = {}
|
||||
local explorecaches = {}
|
||||
local alreadyknown = {} -- per-zone accumulator: { [zone] = { [texName] = true } }
|
||||
|
||||
-- Own texture pool - separate from Blizzard's WorldMapOverlay textures
|
||||
local pfOverlays = {}
|
||||
local pfOverlayMax = 0
|
||||
|
||||
local function pfGetOverlay(idx)
|
||||
if not pfOverlays[idx] then
|
||||
pfOverlays[idx] = WorldMapDetailFrame:CreateTexture("pfReveal"..idx, "BORDER")
|
||||
end
|
||||
return pfOverlays[idx]
|
||||
end
|
||||
local overlayPool = CreateTexturePool(WorldMapDetailFrame, "BORDER", nil, nil, function(_, tex)
|
||||
tex:Hide()
|
||||
tex:ClearAllPoints()
|
||||
end)
|
||||
|
||||
local exploreEnter = function()
|
||||
WorldMapTooltip:ClearLines()
|
||||
@@ -69,14 +63,38 @@ pfUI:RegisterModule("mapreveal", function ()
|
||||
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()
|
||||
-- clear stale caches
|
||||
for k in pairs(explorecaches) do explorecaches[k] = nil end
|
||||
|
||||
-- hide all our textures from last frame
|
||||
for i = 1, pfOverlayMax do
|
||||
pfOverlays[i]:Hide()
|
||||
end
|
||||
overlayPool:ReleaseAll()
|
||||
|
||||
local r,g,b,a = GetStringColor(C.appearance.worldmap.mapreveal_color)
|
||||
local mapFileName = GetMapInfo()
|
||||
@@ -94,14 +112,13 @@ pfUI:RegisterModule("mapreveal", function ()
|
||||
local zoneKnown = alreadyknown[mapFileName]
|
||||
|
||||
-- hide explore icons
|
||||
for _, frame in pairs(explores) do frame:Hide() end
|
||||
explorePool:ReleaseAll()
|
||||
|
||||
-- ClassicAPI: full overlay list for the viewed zone (explored + unexplored),
|
||||
-- read straight from WorldMapOverlay.dbc. Replaces the hand-measured pfMapOverlayData.
|
||||
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 textureName = overlay.texturePath -- full engine path (for SetTexture)
|
||||
local textureWidth = overlay.textureWidth
|
||||
@@ -109,30 +126,15 @@ pfUI:RegisterModule("mapreveal", function ()
|
||||
local offsetX = overlay.offsetX
|
||||
local offsetY = overlay.offsetY
|
||||
|
||||
-- explore magnifying glass icon
|
||||
explores[i] = explores[i] or CreateFrame("Frame", nil, WorldMapDetailFrame)
|
||||
local explore = explores[i]
|
||||
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.
|
||||
-- explore magnifying glass icon. `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
|
||||
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()
|
||||
else
|
||||
explore:Hide()
|
||||
end
|
||||
|
||||
-- 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).
|
||||
if C.appearance.worldmap.mapreveal == "1" then
|
||||
for _, tile in ipairs(overlay.tiles) do
|
||||
textureCount = textureCount + 1
|
||||
local tex = pfGetOverlay(textureCount)
|
||||
local tex = overlayPool:Acquire()
|
||||
|
||||
tex:SetWidth(tile.width)
|
||||
tex:SetHeight(tile.height)
|
||||
tex:SetSize(tile.width, tile.height)
|
||||
tex:SetTexCoord(0, tile.texCoordX, 0, tile.texCoordY)
|
||||
tex:ClearAllPoints()
|
||||
tex:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", tile.offsetX, -tile.offsetY)
|
||||
@@ -165,8 +165,6 @@ pfUI:RegisterModule("mapreveal", function ()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pfOverlayMax = math.max(pfOverlayMax, textureCount)
|
||||
end
|
||||
|
||||
-- hook WorldMapFrame_Update
|
||||
|
||||
Reference in New Issue
Block a user