Thread Tools Display Modes
06-27-10, 08:48 PM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
oUF 1.4 questions

I'm trying to port my layout to 1.4. I decided to rewrite it and to make use of more functions that can be called on every single unit, however.

Anyway, I'm running into an issue with SetAlpha for Portraits. It seems like SetAlpha doesn't work at all on self.Portraits? It always stays at 1.0. Is this intended or am I missing something.


portrait code...
Code:
		local portrait = CreateFrame("PlayerModel", nil, self)
		portrait:SetPoint("TOPLEFT", hp, "TOPLEFT", 0, 0)
		portrait:SetPoint("BOTTOMRIGHT", hp, "BOTTOMRIGHT", 0, 0)	
		portrait:SetAlpha(0.3)	
		self.Portrait = portrait
Edit:

Okay after looking into elements\portraits.lua, I noticed that there is no alpha set for portraits like before. It's missing...
Code:
			local alpha = portrait:GetAlpha()
			portrait:SetAlpha(alpha)
While we are talking about portraits. Why is a portrait Set for
Code:
		if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
			portrait:SetModelScale(4.25)
			portrait:SetPosition(0, 0, -1.5)
			portrait:SetModel"Interface\\Buttons\\talktomequestionmark.mdx"
Why not just hide/don't show the portrait if there is none available? That's pretty much better looking and layout authors don't have to do it via an update function (which was based on SetAlpha *cough*).
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 06-27-10 at 08:55 PM.
  Reply With Quote
06-28-10, 03:30 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Dawn tip from myself. In each function that creates your unit save a variable
Code:
self.style = "player"
That way you can get rid of all the str.find / str.match stuff because you can just do
Code:
if self.style == "player" then
  a
elseif self.style == "target" then
  b
end
I originally did the conditions on unit, but "player" is used in party and raid aswell and not unique.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
06-28-10, 04:53 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
oUF sets .style to the style used to create the frame, so I would have chosen another variable name.

Regarding the portrait: I removed the alpha hack as it was only added to work around the change made to the player model element, without breaking old layouts. It isn't the only function that gets reset when :SetUnit() is called however.

I decided that it was better to let layout authors handle such settings in the PostUpdate, than caching a bunch of variables that might get used or not.

Regarding the question mark model: It's there because most people want it. Complaining about it now is kinda... just too late. 1.4 is already pushed and such a change would only be considered for 1.5, which probably won't happen any time soon.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
06-28-10, 05:09 AM   #4
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
We can do a self.Portrait.PostUpdate so ?

Code:
local PostUpdatePortrait = function(portrait, unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
      portrait:Hide()
   end
end
  Reply With Quote
06-28-10, 07:01 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Originally Posted by haste View Post
oUF sets .style to the style used to create the frame, so I would have chosen another variable name.
Wth...it does that already?! Didn't know. >_<
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
06-28-10, 07:56 AM   #6
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Rostok View Post
We can do a self.Portrait.PostUpdate so ?

Code:
local PostUpdatePortrait = function(portrait, unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
      portrait:Hide()
   end
end
Add an else to :Show() it again and it's all fine.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
06-28-10, 08:10 AM   #7
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Code:
Regarding the question mark model: It's there because most people want it. Complaining about it now is kinda... just too late. 1.4 is already pushed and such a change would only be considered for 1.5, which probably won't happen any time soon.
It wasn't a complaint, just a question. And I don't think it would be such a big change, neither. But it's ok if we can do something like portraits:Hide() for those condititons, somewhere.

Anyway, I'm still not quite sure how to set an alpha for portraits, now. I tried to set the alpha via the function I was using to update the alpha in 1.3.28 and to hide the portraits, if not available (disconnected, etc.). Mhm, I keep trying...

That's what I used in 1.3.28
Code:
	local updatePortrait = function(self, event, unit)
		if (not UnitExists(self.unit) or not UnitIsConnected(self.unit) or not UnitIsVisible(self.unit)) then
			self.Portrait:SetAlpha(0)
		else
			self.Portrait:SetAlpha(cfgs.pAlpha)
		end
	end
and this for "if (unit == "player") or ... etc."

Code:
table.insert(self.__elements, updatePortrait)
Not quite sure where to put this now (putting the insert table thing into the unit specific function resulted in an error).

I want to use a "Shared" function, that contains the shared stuff (what's used on every unit, like health, power, ...). And a "UnitSpecific" function that contains the unit specific stuff.

And finally functions that contain stuff like castbar, portrait, whatever.

Something like that ...

NOTE: I did put the portrait code in the shared style, because I "hacked" the portraits.lua and put in the alpha. What I really want is to put the portrait code into it's own function, like I did it with the castbar code. This way I can include the functions for every unit I want them to use for in the UnitSpecific function.


Code:
-- shared style 
local Shared = function(self, unit)
	self.menu = menu

	self:SetScript("OnEnter", UnitFrame_OnEnter)
	self:SetScript("OnLeave", UnitFrame_OnLeave)

	self:RegisterForClicks"anyup"
	self:SetAttribute("*type2", "menu")
	
	-- hp
	local hp = CreateFrame("StatusBar", nil, self)
	hp:SetHeight(Ncfgfs.height.L)	
	hp:SetStatusBarTexture(Ncfgm.HPtex)
	hp:SetPoint"TOP"
	hp:SetPoint"LEFT"
	hp:SetPoint"RIGHT"
	hp:SetStatusBarColor(unpack(Ncfgc.maincolor))
	
	hp.frequentUpdates = true
	self.Health = hp
	
	-- hp border
	self.Glow = CreateFrame("Frame", nil, hp)
	self.Glow:SetPoint("TOPLEFT", hp, "TOPLEFT", -2, 2)
	self.Glow:SetPoint("BOTTOMRIGHT", hp, "BOTTOMRIGHT", 2, -2)
	self.Glow:SetBackdrop{edgeFile = Ncfgm.glowtex, edgeSize = 8, insets = {left = 0, right = 0, top = 0, bottom = 0}}
	self.Glow:SetBackdropColor(0, 0, 0, 0)
	self.Glow:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))
	
	-- hp bg
	local hpBG = hp:CreateTexture(nil, "BORDER")
	hpBG:SetAllPoints(hp)
	hpBG:SetAlpha(.5)
	hpBG:SetTexture(Ncfgm.Itex)
	hp.bg = hpBG
	
	-- pp
	local pp = CreateFrame("StatusBar", nil, self)
	pp:SetWidth(Ncfgfs.width.L)			
	pp:SetHeight(4)
	pp:SetStatusBarTexture(Ncfgm.PPtex)
	pp:SetPoint("TOP", hp, "BOTTOM", 0, -4)

	pp.frequentUpdates = true
	pp.colorPower = true	
	self.Power = pp	
	
	-- pp border
	self.Glow.pp = CreateFrame("Frame", nil, pp)
	self.Glow.pp:SetPoint("TOPLEFT", pp, "TOPLEFT", -1.75, 2)
	self.Glow.pp:SetPoint("BOTTOMRIGHT", pp, "BOTTOMRIGHT", 2, -1.75)
	self.Glow.pp:SetBackdrop{edgeFile = Ncfgm.glowtex2, edgeSize = 6, insets = {left = -2, right = -2, top = -2, bottom = -2}}
	self.Glow.pp:SetBackdropColor(0, 0, 0, 0)
	self.Glow.pp:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))	
	
	-- pp bg
	local ppBG = pp:CreateTexture(nil, 'BORDER')
	ppBG:SetAllPoints()	
	ppBG:SetTexture(Ncfgm.Itex)
	ppBG:SetAlpha(.5)	
	ppBG.multiplier = 0.4
	pp.bg = ppBG	
	
	-- portraits
		local portrait = CreateFrame("PlayerModel", nil, hp)
		portrait:SetPoint("TOPLEFT", hp, "TOPLEFT", 0, 0)
		portrait:SetPoint("BOTTOMRIGHT", hp, "BOTTOMRIGHT", 0, 0)	
		portrait:SetAlpha(Ncfgs.pAlpha)	
		self.Portrait = portrait	
	
	-- enable colors
	self.colors = colors
	
end

-- castbar
local createCastbar = function(self, unit)
	local cb = CreateFrame("StatusBar", nil, self)
	cb:SetStatusBarTexture(Ncfgm.CBtex)
	cb:SetStatusBarColor(unpack(Ncfgc.trdcolor))
	--cb:SetAllPoints(self.Health)
	cb:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 1.75, -2)
	cb:SetPoint("BOTTOMRIGHT", self.Health, "BOTTOMRIGHT", -2, 1.75)	
	cb:SetToplevel(true)

	self.Castbar = cb

	cb.Text = cb:CreateFontString(nil, 'ARTWORK')
	cb.Text:SetPoint("LEFT", cb, "LEFT", 6, 0)
	cb.Text:SetJustifyH("LEFT")		
	cb.Text:SetFont(Ncfgm.NameFont, Ncfgm.CastFS, Ncfgm.FontF)
	cb.Text:SetTextColor(unpack(Ncfgc.sndcolor)) 
		
	cb.Time = cb:CreateFontString(nil, 'ARTWORK')
	cb.Time:SetPoint("RIGHT", cb, "RIGHT", -22, 0)
	cb.Time:SetFont(Ncfgm.NumbFont, Ncfgm.CastFS, Ncfgm.fontFNum)
	cb.Time:SetJustifyH('RIGHT')		
	cb.Time:SetTextColor(unpack(Ncfgc.sndcolor))	

	cb.Time2 = cb:CreateFontString(nil, 'ARTWORK')
	cb.Time2:SetPoint("TOPLEFT", cb.Time, "TOPRIGHT", -4, 0)
	cb.Time2:SetFont(Ncfgm.NumbFont, Ncfgm.CastFS, Ncfgm.fontFNum)
	cb.Time2:SetJustifyH('RIGHT')		
	cb.Time2:SetTextColor(unpack(Ncfgc.sndcolor))
	
	cb.CustomTimeText = CustomTimeText	
	
	if Ncfgs.useSpellIcon == true then 	
		cb.Icon = cb:CreateTexture(nil, 'BACKGROUND')
		cb.Icon:SetHeight(Ncfgfs.height.L+8)
		cb.Icon:SetWidth(Ncfgfs.height.L+8)
		cb.Icon:SetTexCoord(0.1,0.9,0.1,0.9)
		cb.Icon:SetPoint("TOPRIGHT", self, "TOPLEFT", -8, 0)
		
		cb.IconGlow = CreateFrame("Frame", nil, cb)
		cb.IconGlow:SetPoint("TOPLEFT", cb.Icon, "TOPLEFT", -2, 2)
		cb.IconGlow:SetPoint("BOTTOMRIGHT", cb.Icon, "BOTTOMRIGHT", 2, -2)
		cb.IconGlow:SetBackdrop{edgeFile = Ncfgm.glowtex, edgeSize = 8, insets = {left = 0, right = 0, top = 0, bottom = 0}}
		cb.IconGlow:SetBackdropColor(0, 0, 0, 0)
		cb.IconGlow:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))			
	end
		
	cb.bg1 = cb:CreateTexture(nil, "BORDER")
	cb.bg1:SetAllPoints(cb)
	cb.bg1:SetTexture(Ncfgm.Itex)
	cb.bg1:SetVertexColor(44/255, 40/255, 67/255)	
	cb.bg1:SetAlpha(0.6)
	
end
	
-- unit specific style
local UnitSpecific = {
	player = function(self)
		Shared(self)
		createCastbar(self)

		self:SetAttribute('initial-height', Ncfgfs.height.L)
		self:SetAttribute('initial-width', Ncfgfs.width.L)
	end,
		
	target = function(self)
		Shared(self)
		createCastbar(self)

		self:SetAttribute('initial-height', Ncfgfs.height.L)
		self:SetAttribute('initial-width', Ncfgfs.width.L)		
	end,
	
	focus = function(self)
		Shared(self)
		createCastbar(self)

		self:SetAttribute('initial-height', Ncfgfs.height.L)
		self:SetAttribute('initial-width', Ncfgfs.width.L)		
	end,	

	pet = function(self)
		Shared(self)
			
		self.Power:SetWidth(Ncfgfs.width.S)	
		self:SetAttribute('initial-height', Ncfgfs.height.S)
		self:SetAttribute('initial-width', Ncfgfs.width.S)		
	end,
	
	targettarget = function(self)
		Shared(self)

		self.Power:SetWidth(Ncfgfs.width.S)			
		self:SetAttribute('initial-height', Ncfgfs.height.S)
		self:SetAttribute('initial-width', Ncfgfs.width.S)		
	end,

	focustarget = function(self)
		Shared(self)
		
		self.Power:SetWidth(Ncfgfs.width.S)			
		self:SetAttribute('initial-height', Ncfgfs.height.S)
		self:SetAttribute('initial-width', Ncfgfs.width.S)		
	end,

	boss = function(self)
		Shared(self)
		
		self.Power:SetWidth(Ncfgfs.width.M)			
		self:SetAttribute('initial-height', Ncfgfs.height.M)
		self:SetAttribute('initial-width', Ncfgfs.width.M)		
	end,
	
	MainTank = function(self)
		Shared(self)
		
		self.Power:SetWidth(Ncfgfs.width.M)			
		self:SetAttribute('initial-height', Ncfgfs.height.M)
		self:SetAttribute('initial-width', Ncfgfs.width.M)		
	end,	
		
}

I really need that alpha, because I want to put portraits on top of other things ...


Edit: Would this work ?

Code:
local PostUpdatePortrait = function(portrait, unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
      portrait:Hide()
else
      portrait:Show()
      portrait:SetAlpha(myAlpha)
   end
end
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 06-28-10 at 08:13 AM.
  Reply With Quote
06-28-10, 08:18 AM   #8
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
self.Portrait:PostUpdate() should work fine for both alpha and hiding/showing. Injecting your portrait update function into self.__elements is quite error prone however. The functions in self.__elements are executed in a undefined order.

lua Code:
  1. local Portrait_PostUpdate = function(Portrait, unit)
  2.    if(someCondition) then
  3.       Portrait:Hide()
  4.    else
  5.       Portrait:SetAlpha(.5)
  6.       Portrait:Show()
  7.    end
  8. end
__________________
「貴方は1人じゃないよ」
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF 1.4 questions


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