WoWInterface SVN TidyPlatesBeta

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 603 to Rev 604
    Reverse comparison

Rev 603 → Rev 604

trunk/TidyPlates/TidyPlatesCore.lua
10,12 → 10,12
local massQueue, targetQueue, functionQueue = {}, {}, {} -- Queue Lists
local ForEachPlate -- Allocated for Function (Defined later in file)
local EMPTY_TEXTURE = "Interface\\Addons\\TidyPlates\\Media\\Empty"
local select, pairs, tostring = select, pairs, tostring -- Local function copies
local select, pairs, tostring, wipe = select, pairs, tostring, wipe -- Local function copies
local CreateTidyPlatesStatusbar = CreateTidyPlatesStatusbar -- Local function copy
local InCombat, HasTarget, EnableFadeIn = false, false, true
local Plates, PlatesVisible, PlatesFading, GUID = {}, {}, {}, {} -- Plate Lists
local PlatesScaling = {} -- ScaleFade
local nameplate, extended, bars, regions, visual -- Temp References
local nameplate, extended, bars, regions, visual -- Temp/Local/Current References
local unit, unitcache, style, stylename, unitchanged -- Temp References
local currentTarget -- Stores current target plate pointer
local extendedSetAlpha, HighlightIsShown, HighlightSetAlpha -- Local copies of methods; faster than table lookups
225,11 → 225,14
-- UpdateIndicator_CustomAlpha: Calls the alpha delegate to get the requested alpha
function UpdateIndicator_CustomAlpha()
if activetheme.SetAlpha then
local previousAlpha = extended.requestedAlpha
extended.requestedAlpha = activetheme.SetAlpha(unit) or previousAlpha or unit.alpha or 1
extended.requestedAlpha = activetheme.SetAlpha(unit) or unit.alpha or 1
 
else extended.requestedAlpha = unit.alpha or 1 end
 
if EnableFadeIn then
if extended.requestedAlpha == 0 then print(nameplate, extended, unit.name) end
 
if EnableFadeIn then
extended.visibleAlpha = extended:GetAlpha() -- Just to be sure the values haven't been messed up
if extended.requestedAlpha ~= extended.visibleAlpha then
PlatesFading[nameplate] = true
end
256,6 → 259,7
extended.requestedScale = tonumber(activetheme.SetScale(unit)) or 0
 
if EnableFadeIn then
extended.visibleScale = extended:GetScale() -- Just to be sure!
if extended.visibleScale ~= extended.requestedScale then -- ScaleFade
PlatesScaling[nameplate] = true
end
497,17 → 501,20
unit.alpha = 1
unit.isTarget = false
unit.isMouseover = false
extended.unitcache = ClearIndices(extended.unitcache)
extended.unit = wipe(extended.unit)
--extended.unitcache = ClearIndices(extended.unitcache)
extended.unitcache = wipe(extended.unitcache) -- Gonna try the native 'wipe' function
extended.stylename = ""
 
-- For Fading In
PlatesFading[plate] = EnableFadeIn
extended.requestedAlpha = 0
extended.visibleAlpha = 0
PlatesScaling[plate] = EnableFadeIn -- ScaleFade
extended.requestedScale = 1
extended.visibleScale = 1 -- Inital scale
extended:SetAlpha(0)
 
PlatesScaling[plate] = EnableFadeIn -- ScaleFade
extended.requestedScale = 1
extended.visibleScale = 1 -- Inital scale
extended:SetScale(1)
 
-- Graphics
515,11 → 522,13
bars.castbar:Hide()
visual.highlight:Hide()
regions.highlight:Hide()
 
visual.raidicon:Hide()
visual.target:Hide()
 
-- Widgets/Extensions -- Moved to OnEchoNewNameplate
if activetheme.OnInitialize then activetheme.OnInitialize(extended) end
end
 
 
--------------------------------
-- Individual Gather/Entry-Point Functions
--------------------------------
544,33 → 553,42
This function takes care of the full update after the TidyP lates plate has
been prepared, and the parent plate has been fully populated with data.
--]]
 
 
 
local function OnEchoNewNameplate(plate)
if not plate:IsShown() then return end
UpdateReferences(plate)
UpdateReferences(plate)
local health, cast = bars.health, bars.cast
health:HookScript("OnShow", OnShowNameplate )
health:HookScript("OnHide", OnHideNameplate)
health:HookScript("OnValueChanged", OnUpdateHealth)
health:HookScript("OnMinMaxChanged", OnUpdateHealthRange)
extended.isHooked = true
 
--[[
Hook for Updates Note:
This used to be done in OnNewNameplate. It has been moved because
the event handler would sometimes call for events right after the
nameplate was created, but before the data was populated.
nameplate was created, but before the data was populated.
 
This hooking function has been placed prior to the IsShown check
because sometimes the nameplate gets created and hidden in a single
frame.
--]]
 
-- Hook for Updates
local health, cast = bars.health, bars.cast
health:HookScript("OnShow", OnShowNameplate )
health:HookScript("OnHide", OnHideNameplate)
health:HookScript("OnValueChanged", OnUpdateHealth)
health:HookScript("OnMinMaxChanged", OnUpdateHealthRange)
--if not plate:IsShown() then print("Hook would have Failed", plate); return else print("Hook suceeded", plate) end
if not plate:IsShown() then return else end
PlatesVisible[plate] = true
 
-- Gather Information
GatherData_BasicInfo()
GatherData_Alpha(plate)
ProcessUnitChanges(true) -- Forces an update
ProcessUnitChanges(true) -- Forces an update
end
 
-- OnNewNameplate:
--[[
When a nameplate is created, this function prepares the textures
When a nameplate is created, this function prepares the conditions
and queues the plate for a more complete update. Why? On the
cycle that the nameplate is created, its data hasn't been
completely populated by Blizzard's client. The data is complete
578,37 → 596,11
--]]
function OnNewNameplate(plate)
UpdateReferences(plate)
PrepareNameplate(plate)
--GatherData_BasicInfo() -- in PrepareNameplate... no need to call twice
 
--[[
Notes:
If I comment these lines out, and let the Echo take care of everything, that should solve a few issues, right?
No, because OnUpdateHealth can be triggered between updates, in rare conditions.
Ok, so, move the hooks to the OnEchoNewNameplate.
--]]
 
--[[
local health, cast = bars.health, bars.cast
 
-- Alternative to reduce initial CPU load
CheckNameplateStyle()
UpdateIndicator_CustomAlpha()
 
-- Hook for Updates
health:HookScript("OnShow", OnShowNameplate)
health:HookScript("OnHide", OnHideNameplate)
health:HookScript("OnValueChanged", OnUpdateHealth)
health:HookScript("OnMinMaxChanged", OnUpdateHealthRange)
 
-- Activates nameplate visibility
PlatesVisible[plate] = true
--]]
 
PrepareNameplate(plate)
SetTargetQueue(plate, OnEchoNewNameplate) -- Echo for a full update (alpha only)
end
 
-- OnShowNameplate
-- OnShowNameplate: This occurs when a nameplate is Reused
function OnShowNameplate(source)
local plate = source.parentPlate
-- Activate Plate
915,7 → 907,8
end
 
function ApplyPlateExtension(plate)
Plates[plate] = true
Plates[plate] = GetTime()
--Plates[plate] = true
plate.extended = CreateFrame("Frame", nil, plate)
local extended = plate.extended
platelevels = platelevels - 1; if platelevels < 1 then platelevels = 1 end
1092,11 → 1085,10
end
 
-- Fade Function
local FadeRate = .15
local function UpdateFade(frame, func, visible, requested)
local function UpdateFade(frame, func, visible, requested, rate)
if visible == requested then return nil, requested end
 
local scaledRate = FadeRate * (30/FrameRate)
local scaledRate = rate * (30/FrameRate)
if visible < requested then
visible = min(visible + scaledRate, requested)
elseif visible > requested then
1142,13 → 1134,13
-- Fade/Scale Transition Loops
for plate in pairs(PlatesFading) do
local extended = plate.extended
PlatesFading[plate] , extended.visibleAlpha = UpdateFade(extended, extendedSetAlpha, extended.visibleAlpha, extended.requestedAlpha)
PlatesFading[plate] , extended.visibleAlpha = UpdateFade(extended, extendedSetAlpha, extended.visibleAlpha, extended.requestedAlpha, .15)
end
 
-- [[ Disabled
for plate in pairs(PlatesScaling) do
local extended = plate.extended
PlatesScaling[plate], extended.visibleScale = UpdateFade(extended, extendedSetScale, extended.visibleScale, extended.requestedScale)
PlatesScaling[plate], extended.visibleScale = UpdateFade(extended, extendedSetScale, extended.visibleScale, extended.requestedScale, .15)
end
--]]