Thread Tools Display Modes
12-18-17, 09:30 AM   #1
sirpucna
An Aku'mai Servant
Join Date: Nov 2016
Posts: 33
latency texture on castbar

i'm trying to figure out why i'm getting odd occurrences with the below code, hopefully someone can help me fix it up.
originally CreateTexture's strata was set to BACKGROUND, but i wanted to overlap when channeling so i set it to LOW, seems to work if I do a regular cast 1st on a fresh /reload ui, but if i start off with a channeling spell, the texture goes over top of everything till i /reload ui


Code:
local lagmeter = CastingBarFrame:CreateTexture(nil, "LOW") 
lagmeter:SetHeight(CastingBarFrame:GetHeight()) 
lagmeter:SetWidth(0) 
lagmeter:SetPoint("RIGHT", CastingBarFrame, "RIGHT", 0, 0) 
lagmeter:SetColorTexture(1, 0, 0, 1)

hooksecurefunc(CastingBarFrame, "Show", function() 
	local _, _, _, lag = GetNetStats() 
	local castingmin, castingmax = CastingBarFrame:GetMinMaxValues() 
	local lagvalue = ( lag / 1000 ) / ( castingmax - castingmin ) 
	local channeling = CastingBarFrame.channeling
	
	if ( lagvalue < 0 ) then 
		lagvalue = 0 
	elseif ( lagvalue > 1 ) then 
		lagvalue = 1 
	end
	lagmeter:ClearAllPoints()
	lagmeter:SetWidth(CastingBarFrame:GetWidth() * lagvalue)
	
	if channeling then
		lagmeter:SetPoint("LEFT")
	else
		lagmeter:SetPoint("RIGHT")
	end	
end)

Last edited by sirpucna : 12-18-17 at 09:39 AM.
  Reply With Quote
12-18-17, 09:39 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
For Layers see:
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-18-17, 09:48 AM   #3
sirpucna
An Aku'mai Servant
Join Date: Nov 2016
Posts: 33
Originally Posted by Fizzlemizz View Post
For Layers see:
appreciate the reply, but wasn't helpful
i seem to be missing something else.
  Reply With Quote
12-18-17, 09:50 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
LOW (on your CreateTexture) is a frame strata not a region layer. You didn't say wether you tried setting it to say ARTWORK or OVERLAY.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-18-17 at 10:58 AM.
  Reply With Quote
12-18-17, 10:03 PM   #5
sirpucna
An Aku'mai Servant
Join Date: Nov 2016
Posts: 33
solved it with SetDrawLayer, "BORDER" during channeling, "BACKGROUND" during regular cast

Code:
local lagmeter = CastingBarFrame:CreateTexture(nil, "BACKGROUND") 
local cblag = CreateFrame("Frame")
cblag:SetScript("OnEvent", function(self, event, ...)
	if event == "PLAYER_ENTERING_WORLD" then
		lagmeter:SetHeight(CastingBarFrame:GetHeight()) 
		lagmeter:SetWidth(0) 
		lagmeter:SetPoint("RIGHT") 
		lagmeter:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
		lagmeter:SetVertexColor(1, 0, 0)
		self:UnregisterEvent("PLAYER_ENTERING_WORLD")
	end
end)
cblag:RegisterEvent("PLAYER_ENTERING_WORLD")


hooksecurefunc(CastingBarFrame, "Show", function() 
	local _, _, _, lag = GetNetStats() 
	local castingmin, castingmax = CastingBarFrame:GetMinMaxValues() 
	local lagvalue = ( lag / 1000 ) / ( castingmax - castingmin ) 
	local channeling = CastingBarFrame.channeling
	
	if ( lagvalue < 0 ) then 
		lagvalue = 0 
	elseif ( lagvalue > 1 ) then 
		lagvalue = 1 
	end
	lagmeter:ClearAllPoints()
	lagmeter:SetWidth(CastingBarFrame:GetWidth() * lagvalue)
	
	if channeling then
		lagmeter:SetDrawLayer("BORDER", 0)
		lagmeter:SetPoint("LEFT")
	else
		lagmeter:SetDrawLayer("BACKGROUND", 0)
		lagmeter:SetPoint("RIGHT")
	end	
end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » latency texture on castbar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off