WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Textured combo points w/borders (https://www.wowinterface.com/forums/showthread.php?t=30040)

Toran 01-15-10 11:07 PM

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!

Starinnia 01-15-10 11:40 PM

Only Frames (and derivatives) have the :CreateTexture() method. You are trying to call :CreateTexture() on a texture, so the method does not exist.

Ferous 01-16-10 03:13 AM

Quote:

Originally Posted by Starinnia (Post 174802)
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? :)

Toran 01-16-10 09:56 AM

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.

haste 01-16-10 09:59 AM

No.

Combo points are just shown/hidden. They can be whatever type of frame objects you want them to be.

Toran 01-16-10 10:08 AM

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.

wurmfood 01-16-10 12:48 PM

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


Rostok 01-16-10 01:04 PM

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 :o

PS : Thanks Neal :p

EDIT : Wurmfood is just too fast.

Bruners 01-16-10 02:28 PM

But, can't you achieve your border effect with a simple backdrop?

Toran 01-16-10 02:34 PM

@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!

acapela 01-16-10 02:48 PM

Quote:

Originally Posted by Toran (Post 174866)
@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.

tyeni 01-16-10 03:10 PM

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?

Toran 01-16-10 03:34 PM

@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)


Rostok 01-16-10 05:10 PM

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.

Toran 01-16-10 05:37 PM

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")

Rostok 01-17-10 12:41 AM

Code:

self.CPoints = {}
self.CPoints.unit = PlayerFrame.unit

forgot to put this on the top of the code. My bad.

zork 01-17-10 04:22 AM

I did this for oUF_Simple

http://www.wowinterface.com/forums/s...ad.php?t=27704

Toran 01-17-10 07:51 PM

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...


All times are GMT -6. The time now is 10:29 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI