Thread Tools Display Modes
01-15-10, 11:07 PM   #1
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Textured combo points w/borders

Hi all. Trying to make some headway on textured combo points. I have the following so far to call the combo points, which results in rectangles for combo points.

Code:
                        self.CPoints = {}
			self.CPoints.unit = PlayerFrame.unit
			for i = 1, 5 do
				self.CPoints[i] = self.Health:CreateTexture(nil, "OVERLAY")
				self.CPoints[i]:SetHeight(10)
				self.CPoints[i]:SetWidth(38)
				self.CPoints[i]:SetTexture(bartex)	
				if i == 1 then
					self.CPoints[i]:SetPoint("LEFT", self.Health, "LEFT", 0, 20)
					self.CPoints[i]:SetVertexColor(0.69, 0.31, 0.31)
				else
					self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 3, 0)
				end
			end
		self.CPoints[2]:SetVertexColor(0.69, 0.31, 0.31)
		self.CPoints[3]:SetVertexColor(0.65, 0.63, 0.35)
		self.CPoints[4]:SetVertexColor(0.65, 0.63, 0.35)
		self.CPoints[5]:SetVertexColor(0.33, 0.59, 0.33)
And the following to put a border around them, but I keep getting an error. I think it's having issues with creating a texture.

Code:
                        local TopLeft = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			TopLeft:SetTexture(frameborder)
			TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
			TopLeft:SetPoint("TOPLEFT", -3, 3)
			TopLeft:SetWidth(14) TopLeft:SetHeight(14)
			TopLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
	
			local TopRight = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			TopRight:SetTexture(frameborder)
			TopRight:SetTexCoord(2/3, 1, 0, 1/3)
			TopRight:SetPoint("TOPRIGHT", 3, 3)
			TopRight:SetWidth(14) TopRight:SetHeight(14)
			TopRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

			local BottomLeft = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			BottomLeft:SetTexture(frameborder)
			BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
			BottomLeft:SetPoint("BOTTOMLEFT", -3, -3)
			BottomLeft:SetWidth(14) BottomLeft:SetHeight(14)
			BottomLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

			local BottomRight = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			BottomRight:SetTexture(frameborder)
			BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
			BottomRight:SetPoint("BOTTOMRIGHT", 3, -3)
			BottomRight:SetWidth(14) BottomRight:SetHeight(14)
			BottomRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

			local TopEdge = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			TopEdge:SetTexture(frameborder)
			TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
			TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
			TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
			TopEdge:SetHeight(14)
			TopEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
			local BottomEdge = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			BottomEdge:SetTexture(frameborder)
			BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
			BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
			BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
			BottomEdge:SetHeight(14)
			BottomEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
			local LeftEdge = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			LeftEdge:SetTexture(frameborder)
			LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
			LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
			LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
			LeftEdge:SetWidth(14)
			LeftEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
			local RightEdge = self.CPoints[i]:CreateTexture(nil, "OVERLAY")
			RightEdge:SetTexture(frameborder)
			RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
			RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
			RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
			RightEdge:SetWidth(14)
			RightEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
For now, I am commenting out the border since it gives me an error:

Code:
layout.lua:931: attempt to call method 'CreateTexture' (a nil value)
Any ideas on how I can get the border to appear around the combo point textures? Thank you!
  Reply With Quote
01-15-10, 11:40 PM   #2
Starinnia
Ninja Code Monkey
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 84
Only Frames (and derivatives) have the :CreateTexture() method. You are trying to call :CreateTexture() on a texture, so the method does not exist.
  Reply With Quote
01-16-10, 03:13 AM   #3
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Starinnia View Post
Only Frames (and derivatives) have the :CreateTexture() method. You are trying to call :CreateTexture() on a texture, so the method does not exist.
If a Method doesn't exist, I would suggest just making a texture in a Paint program with a border?
  Reply With Quote
01-16-10, 09:56 AM   #4
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Ahh ok. So I guess this would have to be built into oUF by Haste like he did for the runebar?

Anyone know of a similar implementation of this that I can refer to? I'm a novice at lua and oUF.
  Reply With Quote
01-16-10, 09:59 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
No.

Combo points are just shown/hidden. They can be whatever type of frame objects you want them to be.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
01-16-10, 10:08 AM   #6
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Thanks. Since I already have textures spawned in the above code, how can I put a border around them? Again, they appear as rectangles above the target frame. All I need to do is put the border around them to match the rest of the unitframes.
  Reply With Quote
01-16-10, 12:48 PM   #7
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
I think what various people are trying to say is you should be doing something like this psudocode:

Code:
cpoints = CreateFrame(blah blah)
cpoints:Set location and size
for i = 1,5 do
  cpoints[i] = CreateFrame("Frame", nil, cpoints)
  cpoints[i]:set location and size

  cpoints[i].tex = CreateTexture(whatever main texture you want)
  cpoints[i].bg = CreateTexture(appropriate background)
  cpoints[i].top = CreateTexture(some other texture that is needed)
end
  Reply With Quote
01-16-10, 01:04 PM   #8
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Code:
local CreateBorder = function(self)
local TopLeft = self:CreateTexture(nil, "OVERLAY")
TopLeft:SetParent(self)
TopLeft:SetTexture(frameborder)
TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
TopLeft:SetPoint("TOPLEFT", -3, 3)
TopLeft:SetWidth(14) TopLeft:SetHeight(14)

TopLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
	
local TopRight = self:CreateTexture(nil, "OVERLAY")
TopRight:SetParent(self)
TopRight:SetTexture(frameborder)
TopRight:SetTexCoord(2/3, 1, 0, 1/3)
TopRight:SetPoint("TOPRIGHT", 3, 3)
TopRight:SetWidth(14) TopRight:SetHeight(14)

TopRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

local BottomLeft = self:CreateTexture(nil, "OVERLAY")
BottomLeft:SetParent(self)
BottomLeft:SetTexture(frameborder)
BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
BottomLeft:SetPoint("BOTTOMLEFT", -3, -3)
BottomLeft:SetWidth(14) BottomLeft:SetHeight(14)

BottomLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

local BottomRight = self:CreateTexture(nil, "OVERLAY")
BottomRight:SetParent(self)
BottomRight:SetTexture(frameborder)
BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
BottomRight:SetPoint("BOTTOMRIGHT", 3, -3)
BottomRight:SetWidth(14) BottomRight:SetHeight(14)

BottomRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)

local TopEdge = self:CreateTexture(nil, "OVERLAY")
TopEdge:SetParent(self)
TopEdge:SetTexture(frameborder)
TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
TopEdge:SetHeight(14)

TopEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
local BottomEdge = self:CreateTexture(nil, "OVERLAY")
BottomEdge:SetParent(self)
BottomEdge:SetTexture(frameborder)
BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
BottomEdge:SetHeight(14)

BottomEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
local LeftEdge = self:CreateTexture(nil, "OVERLAY")
LeftEdge:SetParent(self)
LeftEdge:SetTexture(frameborder)
LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
LeftEdge:SetWidth(14)

LeftEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
		
local RightEdge = self:CreateTexture(nil, "OVERLAY")
RightEdge:SetParent(self)
RightEdge:SetTexture(frameborder)
RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
RightEdge:SetWidth(14)

RightEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
end
Code:
for i = 1, 5 do
self.CPoints[i] = CreateFrame('Frame', nil, self)
self.CPoints[i]:SetHeight(10)
self.CPoints[i]:SetWidth(38)
self.CPoints[i]:SetBackdrop(backdrop)
self.CPoints[i]:SetBackdropColor(0,0,0)
self.CPoints[i].bg = self.CPoints[i]:CreateTexture(nil, 'LOW')
self.CPoints[i].bg:SetTexture(bartex)
self.CPoints[i].bg:SetAllPoints(self.CPoints[i])
if i == 1 then
self.CPoints[i]:SetPoint("LEFT", self.Health, "LEFT", 0, 20)
else
self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 3, 0)
end
end
self.CPoints[1].bg:SetVertexColor(0.69, 0.31, 0.31)
self.CPoints[2].bg:SetVertexColor(0.69, 0.31, 0.31)
self.CPoints[3].bg:SetVertexColor(0.65, 0.63, 0.35)
self.CPoints[4].bg:SetVertexColor(0.65, 0.63, 0.35)
self.CPoints[5].bg:SetVertexColor(0.33, 0.59, 0.33)
CreateBorder(self.CPoints[i])
end
Copy&Paste the first part before your layout function and the second part where you have your CP code.
Totaly untested though

PS : Thanks Neal

EDIT : Wurmfood is just too fast.

Last edited by Rostok : 01-16-10 at 01:07 PM.
  Reply With Quote
01-16-10, 02:28 PM   #9
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
But, can't you achieve your border effect with a simple backdrop?
  Reply With Quote
01-16-10, 02:34 PM   #10
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
@Bruners Dunno but can't seem to get anything to work now.

If someone finds a solution to this please post. It will take me a while to figure this out I think. Thanks for the help so far!

(has no one implemented textured combo points w/borders yet?)

@Rostok No dice, but thanks for the try!
  Reply With Quote
01-16-10, 02:48 PM   #11
acapela
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 241
Originally Posted by Toran View Post
@Bruners Dunno but can't seem to get anything to work now.
i don't see a way (on the Wiki) to specify any sort of texture as background or fill for a FontString.

colors and alpha gradients, yes, but not a texture.

i looked at Button as well... but from the API i have the impression that consists basically of a FontString laid over a background texture (all of which can be configured to fiddle as the user clicks on the button, etc).

is there any "generic" way to do masking overlays (i.e. have the user choose a fill texture, then overlay with custom/hand-crafted masks in the shape of numbers, to form the on-screen graphics, analogous to changing the shape of the minimap)? this wouldn't actually be "text" any more, at the API level, and borders/shadows might be hard to automate (that would take more custom art), but it would look like text on the screen. heh, seems like lots of work for a single digit of text.
__________________
Retired author/maintainer of Aloft (the nameplate addon)
http://www.wowinterface.com/download...AloftBeta.html
-----
Zippy said it best: "All life is a BLUR of Republicans and Meat!"
  Reply With Quote
01-16-10, 03:10 PM   #12
tyeni
A Deviate Faerie Dragon
 
tyeni's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 19
From oUF_Caellian

Code:
			self.CPoints = {}
			self.CPoints.unit = PlayerFrame.unit
			for i = 1, 5 do
				self.CPoints[i] = self.Power:CreateTexture(nil, "OVERLAY")
				self.CPoints[i]:SetHeight(12)
				self.CPoints[i]:SetWidth(12)
				self.CPoints[i]:SetTexture(bubbleTex)
				if i == 1 then
					self.CPoints[i]:SetPoint("LEFT")
					self.CPoints[i]:SetVertexColor(0.69, 0.31, 0.31)
				else
					self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 1)
				end
			end
			self.CPoints[2]:SetVertexColor(0.69, 0.31, 0.31)
			self.CPoints[3]:SetVertexColor(0.65, 0.63, 0.35)
			self.CPoints[4]:SetVertexColor(0.65, 0.63, 0.35)
			self.CPoints[5]:SetVertexColor(0.33, 0.59, 0.33)
			self:RegisterEvent("UNIT_COMBO_POINTS", UpdateCPoints)
		end
Why not do something like this but instead of the texture use the backdrop?
__________________
  Reply With Quote
01-16-10, 03:34 PM   #13
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
@tyeni yup, that's exactly what i'm doing. Tried creating a new .tga for the texture, call it as

local cptexture = "Interface\\AddOns\\oUF_Lyn\\textures\\combotex"

However it doesn't appear. Not sure why. I replaced "bartex" (or "bubbletex" as you show above) with "cptexture" - no go.

I'm modifying Lyn's old layout as a base to update it a bit. Added some borders to the unitframes with some help from Rufio UI and others. Thought having the same for the CPs would be cool.

Here's how I have it now, code borrowed from Caellian. Actually, it's nice and simple. Just spawns a background color, as shown in the code below, and in the screenshot below.

Code:
		
                        self.CPoints = {}
			self.CPoints.unit = PlayerFrame.unit
			for i = 1, 5 do
				self.CPoints[i] = self.Health:CreateTexture(nil, "OVERLAY")
				self.CPoints[i]:SetHeight(8)
				self.CPoints[i]:SetWidth(38)
				self.CPoints[i]:SetTexture(bartex)	
				if i == 1 then
					self.CPoints[i]:SetPoint("LEFT", self.Health, "LEFT", 0, 17)
					self.CPoints[i]:SetVertexColor(1, 0.94, 0.32)
				else
					self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 3, 0)
				end
			end
		self.CPoints[2]:SetVertexColor(1, 0.94, 0.32)
		self.CPoints[3]:SetVertexColor(1, 0.49, 0.04)
		self.CPoints[4]:SetVertexColor(1, 0.49, 0.04)
		self.CPoints[5]:SetVertexColor(0.76, .11, 0.23)

Last edited by Toran : 01-16-10 at 04:51 PM.
  Reply With Quote
01-16-10, 05:10 PM   #14
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
I don't know what you're doing wrong, but the piece of code i put works just fine.
I stole the border texture from Neal's UI :


The only thing i didn't do was define the color code you have in your layout, so the border is all black.

Last edited by Rostok : 01-16-10 at 05:13 PM.
  Reply With Quote
01-16-10, 05:37 PM   #15
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
You know, I think I figured out what I may have been doing wrong. Will try this again later. Thanks everybody.

Edit:

I keep getting this error:

Code:
layout.lua:1006: attempt to index field 'CPoints' (a nil value)
It references this line:

Code:
self.CPoints[i] = CreateFrame("Frame", nil, self)
and this one:

Code:
local TopLeft = self:CreateTexture(nil, "OVERLAY")

Last edited by Toran : 01-16-10 at 09:33 PM.
  Reply With Quote
01-17-10, 12:41 AM   #16
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Code:
self.CPoints = {}
self.CPoints.unit = PlayerFrame.unit
forgot to put this on the top of the code. My bad.
  Reply With Quote
01-17-10, 04:22 AM   #17
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I did this for oUF_Simple

http://www.wowinterface.com/forums/s...ad.php?t=27704
__________________
| 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
01-17-10, 07:51 PM   #18
Toran
A Nerdscale Dorkin
 
Toran's Avatar
Premium Member
Join Date: May 2006
Posts: 143
Thanks Zork. I used portions of your code and came up with the following, which does the trick...

For anyone else wondering, this part goes in the beginning, pre-layout:

Code:
local function kiss_set_me_a_backdrop(f)
    f:SetBackdrop( { 
      bgFile = bartex, 
      edgeFile = "", tile = false, tileSize = 0, edgeSize = 32, 
      insets = { left = -2, right = -2, top = -2, bottom = -2 }
    })
    f:SetBackdropColor(0,0,0,1)
  end


local function updateCPoints(self, event, unit)
	if unit == PlayerFrame.unit and unit ~= self.CPoints.unit then
		self.CPoints.unit = unit
	end
end
This goes in the "target" section of the layout:

Code:
self.CPoints = {}
		self.CPoints.unit = PlayerFrame.unit
		for i = 1, 5 do
			self.CPoints[i] = CreateFrame("Frame", nil, self.Health)
			self.CPoints[i]:SetHeight(6)
			self.CPoints[i]:SetWidth(39)
			kiss_set_me_a_backdrop(self.CPoints[i])
			self.CPoints[i].bg = self.CPoints[i]:CreateTexture(nil, "LOW")
			self.CPoints[i].bg:SetTexture(bartex)
			self.CPoints[i].bg:SetAllPoints(self.CPoints[i])
			if i == 1 then
				self.CPoints[i]:SetPoint("LEFT", self.Health, "LEFT", 0, 17)
			else
				self.CPoints[i]:SetPoint("LEFT", self.CPoints[i-1], "RIGHT", 2, 0)
			end
		end

		self.CPoints[1].bg:SetVertexColor(1,1,0)
		self.CPoints[2].bg:SetVertexColor(1,0.75,0)
		self.CPoints[3].bg:SetVertexColor(1,0.5,0)
		self.CPoints[4].bg:SetVertexColor(1,0.25,0)
		self.CPoints[5].bg:SetVertexColor(1,0,0)
		self:RegisterEvent("UNIT_COMBO_POINTS", updateCPoints)
Good stuff. Learned a ton, but still a noob. Thanks all. Now to implement the runes...
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Textured combo points w/borders


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