• 0

posted a message on locals, functions and garbage
Quote from egingell
Aside from the syntax error in the second example, it will have significant problems considering you are potentially creating a new function for every FPS.

copy/paste fail... it's early over here ;)

But yeah, as I thought. Keep it clean.

Something else bubbled up though:
I've got a config file, with a global config
config.lua
config = {
["1"] = {
etcetc


Is there a benefit from renaming that to locals? As everything is passed by reference, that local and global (until either changes) point to the same memory location... what is the benefit of using renaming (local x = config.y) as I so often see in addons? Or is that only "should the global change due to outside influence, at least the local has the original value"?
Posted in: Lua Code Discussion
• 0

posted a message on locals, functions and garbage
Hey all!

Consider the 2 following examples:

local a, b, c, d, e
local frame = CreateFrame("Frame")

local function foofoo()
do
stuff
end
end

local function foo()
a, b = wowBarZ()
c = wowBarY()
d, e = wowBarX()
if (a and c) or (e and c) then
foofoo()
print(format("%s%s", b, d))
end
end

frame:SetScript("OnUpdate", foo)

local frame = CreateFrame("Frame")

local function foo()
local a, b = wowBarZ()
local c = wowBarY()
local d, e = wowBarX()
if (a and c) or (e and c) then
local function foofoo()
do
stuff
end
print(format("%s%s", b, d))
end
end

frame:SetScript("OnUpdate", foo)

note: don't mind syntax and all - it's just for the idea

I think you can spot the difference, in the first, all vars are declared and all functions have the file as scope and thus are instantiated. The second, everything that is needed is instantiated on the fly.

Now with the garbage collector in play, I was wondering what was the least intensive way of doing things, aka, what creates the lesser load? Keeping in mind that lua passes by reference...

The first will ofcourse have more initial memory, but having everything at the ready, it only needs to access/read that memory rather then create/write it first.

The second has the benefit of having less constant memory, but higher peak memory. This also needs to be removed again by the garbage collector. Memory jumps a lot more so to say. It is more memory-usage-intensive.

Now the above are only small things with minor impact, however, when doing stuff like tooltips, if on every tooltip-call you have to create roughly 40 locals (random number), when you're mousing through dalaran, you're creating quite a lot of em...

Which would have the lesser impact on a system?
Posted in: Lua Code Discussion
• 0

posted a message on Font Limitations?
Quote from Phanx
Most likely WoW's font rendering engine limits the size of individual glyphs, and the issue is not fixable.

feared as much :( Shame really... should someone know a similar font with less curls..... :cool:
• 0

posted a message on Font Limitations?
Hey peeps!

On my UnitFrames I'm running into a problem (using oUF)

For some specific texts I had my heart set on the font Bleeding Cowboy (safe link, check http://www.dafont.com and search it yourself (right side) if you don't believe me, it just renders a font showcase) --> http://www.dafont.com/bleeding-cowboys.font.

However, it seems the font(string) is limited in size/handling? What I mean is, the n, t and capital R for instance don't render fully, which kinda sucks and destroys the font (they are cut-off about three quarters above the baseline, the bottom part does not show). Initially I thought this was due to the UF, however when testing with




it shows the exact same effect (these are the quest headers in the questlog).

Any ideas what it could be, if it's fixable and if so how?

/salute
• 0

posted a message on "Overwriting" a function
if all you want is the greyscale on non-self buffs, shouldn't it just be something like:
local texture = control.texture
texture:SetTexture(icon)
if db.zoom_aura then
texture:SetTexCoord(0.07, 0.93, 0.07, 0.93)
else
texture:SetTexCoord(0, 1, 0, 1)
end

-- insert this below the above
-- seems is_mine toggles your own or other peeps (de)buffs?
if not control.is_mine then
texture:SetDesaturated(true)
end


seems all there is to it, but this highly depends on what the is_mine actually is...
Posted in: Lua Code Discussion
• 0

posted a message on sUF vs oUF vs Pitbull4
figured that much, but one can never be sure enough eh :)
Posted in: Unit Frames
• 0

posted a message on sUF vs oUF vs Pitbull4
Hey guys,

as the title suggests, which of the 3 should I take?

I've got a new, completely home-coded UI - fully Lua except for some things I think the addons win in addons vs DIY (Omen, Skada).

Note: I didn't use libraries, since I did not need them, the UI is not for distribution and should someone *really* want it, them can alter it via my config.lua.
It is however modular in setup and as much OOP as possible (got a JAVA background)

That about the UI, then why the UF question?

Well, I've always used Pitbull (PB4 atm), I'm accustomed to it, yet there still are some things I'd like more control about (which I might just not know how to do), for instance text positioning. Even though with hours of work you can make it do what you want for 95%, it's the 5% that I can't (or don't know how to) control that annoys me.[1]

I've heard a lot of good stories about sUF, and there is an "advanced" config available. To be honest I have only tried it once for an hour or 2 and then switched back to Pitbull since that just worked better for me, but seeing I want to basicly control everything, perhaps this is more suited for that then Pitbull? No clue, just including it due to the great feedback I got for it.

Then there is ofcourse oUF. This will require a lot of coding, and that is what seems to be the drawback here. Not that I have an issue with that, but why (possibly) try to rediscover the wheel when it has already been done? Besides that, the updates are convenient ofcourse ;)

So what I want:
- pixelperfect control over every aspect of the UF's, for instance the (or my) inability to fully control the placing of text in PB4 as well as for instance (what I could not find/get to work) the inability to separate my debufss from rest-of-the-raid debuffs etc.
- the ability to store 5 separate layouts (solo, party, 10/25 raid, BG's, arena) and LoD the one that I need.

The amount of work is not the issue, I can spare the time at the moment and/or will find the time anyways.

/salute
Posted in: Unit Frames
• 0

posted a message on Frameborder... what am I doing wrong?
Quote from Broes

It's probably something very stupid, silly or a gross mistake, but I can't find what.

gah, can you believe I am overlooking that for about 3 days now? Got both the http://wowprogramming.com/docs/widgets/Frame/SetBackdrop and http://www.wowwiki.com/API_Frame_SetBackdrop open and still didn't see it... :rolleyes:

I'm going to hide in shame. Thanks peeps, much appreciated!
Posted in: Lua Code Discussion
• 0

posted a message on Frameborder... what am I doing wrong?
First off, I'm not really an expert in coding for WoW or anything, but I get everything to work, except this...

I can't get my head round getting borders around my frame...

Settings:
EthenaUIDB["default_backdrop"] = {
["bg"] = "",
["tile"] = false,
["tileSize"] = 0,
["edgeSize"] = 8,
["insets"] = { left = 2, right = 2, top = 2, bottom = 2}
}
EthenaUIDB["color"] =
{
["backdrop"] = {
0.04705882352941176, 0.05098039215686274, 0.05098039215686274, 1
},
["backdropborder"] = {
1, 0, 0, 1
},
0.04705882352941176, 0.05098039215686274, 0.05098039215686274, 1,
0.1137254901960784, 0.1215686274509804, 0.1254901960784314, 1
},

}


Implementation:
--[[
function EthenaUIDB:CreatePanel
creates a new frame with the specified variables.
@param string name		the name of the frame
@param string parent	the parent of the frame
@param int width		the width of the frame
@param int height		the height of the frame
@param enum anchSelf	the point where it anchors
@param enum anchParent	the point where it anchors to
@param int xOff			the x-axis offset
@param int yOff			the y-axis offset
@return Frame panel		the created panel
]]--
function EthenaUIDB:CreatePanel(name, parent, width, height, anchSelf, anchParent, xOff, yOff, alpha)
--determine the parent, UIParent by default
if parent == nil then
parent = UIParent
end

local panel = CreateFrame("Frame", name, parent)

panel:SetWidth(width)
panel:SetHeight(height)

panel.bg = panel:CreateTexture(nil, "PARENT")
panel.bg:SetTexCoord(0,1,0,1)
panel.bg:SetBlendMode("BLEND")
panel.bg:SetAlpha(1)

panel.bg:SetTexture( 1, 1, 1, alpha)

panel:SetBackdrop(EthenaUIDB["default_backdrop"])

panel:SetBackdropColor(unpack(EthenaUIDB["color"]["backdrop"]) )
panel:SetBackdropBorderColor(unpack(EthenaUIDB["color"]["backdropborder"]))

panel.bg:SetPoint("TOPLEFT", panel, "TOPLEFT", 1, -1)
panel.bg:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -1, 1)

local level = 1
if parent ~= UIParent then
level = parent:GetFrameLevel()
end

panel:SetFrameLevel(level)
panel:SetFrameStrata("BACKGROUND")
panel.bg:SetDrawLayer("BACKGROUND")

panel:SetPoint(anchSelf, parent, anchParent, xOff, yOff)

return panel
end


this, used as following:
-- top menu
"top_location" 	= EthenaUIDB:CreatePanel("top_location", nil, 300, 18, "TOP", "TOP", 0, -37, 0.6)


creates an easy, reusable, stackable panel system for me, with which I can easily adjust panels, settings etc. ( It are all abstracts from the config.lua, core.lua and panels.lua respectively)

Yet those pesky borders... they won't show. I don't get any errors, the code is loaded, everything works, except those borders... The file exists, but even when tested with ["edge"] = [[Interface\Tooltips\UI-Tooltip-Border]], or inline values, it does not work.

It's probably something very stupid, silly or a gross mistake, but I can't find what.

/salute
Posted in: Lua Code Discussion
• 0

posted a message on events not firing?
Quote from egingell
If you're not planing on doing different things for different events, you don't need to check for them, the event handler never fires for events that you don't explicitly register for.

Also, you can lose a tiny amount of overhead by doing this:

frame:SetScript("OnEvent", EthenaUIFunc.GetZoneText)

frame:RegisterEvent("ZONE_CHANGED")
frame:RegisterEvent("ZONE_CHANGED_INDOORS")
frame:RegisterEvent("ZONE_CHANGED_NEW_AREA")


However, if you use self in EthenaUIFunc:GetZoneText() and it's not the same table as frame, then this won't work.

It was just an excerpt, it is registered to several other events as well. Thanks for the tips though! Every optimization is good!
Posted in: Lua Code Discussion
• 0

posted a message on events not firing?
Gah, silly me...

forgot to actually add the onEvent....

working as intended with:
frame:SetScript("OnEvent", function(self, event, ...)
if( event == "ZONE_CHANGED" or
event == "ZONE_CHANGED_INDOORS" or
event == "ZONE_CHANGED_NEW_AREA") then
EthenaUIFunc:GetZoneText()
end
end)

frame:RegisterEvent("ZONE_CHANGED")
frame:RegisterEvent("ZONE_CHANGED_INDOORS")
frame:RegisterEvent("ZONE_CHANGED_NEW_AREA")

Posted in: Lua Code Discussion
• 0

posted a message on events not firing?
Heya,

I've finally ran into a brick wall... I wanted to add a panel with the name of the zone on it, however it does not seem to be willing to update on the events listed, better yet, it does not fire any of these events when changing (sub)zone, only on first load...

local frame = EthenaUICore:CreatePanel("locationtext", EthenaUIDB["panels"]["top_location"],300,19, "CENTER", "CENTER", 0, 0, 0)
frame:EnableMouse(true)

-- function EthenaUIFunc:GetZoneText()
--...
--this works
--...
--end

frame:RegisterEvent("ZONE_CHANGED", "EthenaUIFunc:GetZoneText")
frame:RegisterEvent("ZONE_CHANGED_INDOORS", "EthenaUIFunc:GetZoneText")
frame:RegisterEvent("ZONE_CHANGED_NEW_AREA", "EthenaUIFunc:GetZoneText")


N.B.: EthenaUIFunc:CreatePanel is a custom function to easily add generic frames with a default or customized layout to the UIstack, on the proper strata, level, size, location etc etc.

I've tested the firing with
frame:RegisterEvent("ZONE_CHANGED_NEW_AREA", ChatFrame1:AddMessage("|cFF91C9E8ZCNA event called|r"))


but this only fires once, onload...

Now I could have it update every sec - like the clock I have - but that is kinda pointless most of the time, thus a waste of resources.

I have no clue why the events don't fire... if needed I am more then willing to post the function code as well, but that works just fine, the initial display works like a charm (incl. tooltip)

Any ideas what it could be or what I'm doing wrong?