Thread Tools Display Modes
11-23-13, 01:38 PM   #1
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Mana/Power level

like this:
  Reply With Quote
11-23-13, 02:04 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I'm sorry, are you requesting something? Or...
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-23-13, 04:28 PM   #3
humfras
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 131
Nice idea. If you want a tip on how to do this, see below:

Create the background texture (the scale) and a (square) texture for the indicator.
Create a ScrollFrame (like in the Questlog) with the size of the background texture (e.g. ScrollFrame:SetAllPoints(background)) and create the indicator texture as a child of the ScrollFrame.
The indicator will be visible in the ScrollFrame area only.
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker
  Reply With Quote
11-23-13, 06:21 PM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Actually you can do sth like this easily with the animation system or by just rotating a texture. Just think of the accelerometer as a circle and the needle is a texture that you rotate around the center of that circle. That and using texture alpha layers properly. To rotate a texture without the animation system around its center you can do:
Lua Code:
  1. --needle texture rotate
  2.   local texture = frame:CreateTexture(nil,"BACKGROUND",nil,-6)
  3.   texture:SetTexture(PATH_TO_TEXTURE)
  4.   texture:SetSize(sqrt(2)*frame:GetWidth(),sqrt(2)*frame:GetHeight())
  5.   texture:SetPoint("CENTER")
  6.   texture:SetRotation(math.rad(30))



Using a texture alpha layer you can show/hide whatever part of the background.

If you need to crop stuff...just use a ScrollFrame. ScrollFrames crop any content inside.
http://www.wowinterface.com/forums/s...ad.php?t=45810
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-23-13 at 06:40 PM.
  Reply With Quote
11-24-13, 02:10 AM   #5
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by humfras View Post
Nice idea. If you want a tip on how to do this, see below:

Create the background texture (the scale) and a (square) texture for the indicator.
Create a ScrollFrame (like in the Questlog) with the size of the background texture (e.g. ScrollFrame:SetAllPoints(background)) and create the indicator texture as a child of the ScrollFrame.
The indicator will be visible in the ScrollFrame area only.
too hard lol.
I like this way:

Lua Code:
  1. local holder = CreateFrame("ScrollFrame", "Holder", UIParent); -- holder
  2. holder:SetSize(w, h);
  3. holder:SetPoint(...);
  4.  
  5. local parent = CreateFrame("Frame", "Parent", holder) -- parent of our elements
  6. holder:SetScrollChild(parent);
  7.  
  8. local anytexture = parent:CreateTexture(...);
  9. anytexture:SetPoint(..., holder, ...); -- point to holder, not to parent
  10.  
  11. ...

Last edited by AlleyKat : 11-24-13 at 03:35 AM.
  Reply With Quote
11-24-13, 04:41 AM   #6
pelf
Sentient Plasmoid
 
pelf's Avatar
Premium Member
Join Date: May 2008
Posts: 133
Sorry, I couldn't hear that code over the sound of Holder and Parent being added to (or having their values replaced in) the global environment.
  Reply With Quote
11-24-13, 07:09 AM   #7
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by pelf View Post
Sorry, I couldn't hear that code over the sound of Holder and Parent being added to (or having their values replaced in) the global environment.
this is example

Lua Code:
  1. local title, M = ...;
  2. local holder = CreateFrame("ScrollFrame", title.."Holder", UIParent);

Last edited by AlleyKat : 11-24-13 at 07:11 AM.
  Reply With Quote
11-24-13, 07:18 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's better, but there's really no reason to give your frame a global name at all, unless you're using a Blizzard template that requires a name.

Code:
local holder = CreateFrame("ScrollFrame", nil, UIParent)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-24-13, 08:08 AM   #9
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by Phanx View Post
That's better, but there's really no reason to give your frame a global name at all, unless you're using a Blizzard template that requires a name.

Code:
local holder = CreateFrame("ScrollFrame", nil, UIParent)
I like to give names for static frames, you can easily access via plugins and it costs almost nothing in memory usage.
  Reply With Quote
11-24-13, 08:39 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, for one, what is the likelihood that anyone is actually going to write a plugin for a simple mana display addon? I'd have to go with the probability of that being pretty much zero.

For another, you don't need to give everything a global name in order for it to be accessible. Give your main object a global name, and add references to everything else to it as table members:

Code:
local mainFrame = CreateFrame("Frame", "MyAddon", UIParent)

local otherFrame = CreateFrame("Button", nil, mainFrame)
mainFrame.Button = otherFrame

-- now other addons can access "otherFrame" as "MyAddon.Button"
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-24-13, 09:46 AM   #11
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by Phanx View Post
Well, for one, what is the likelihood that anyone is actually going to write a plugin for a simple mana display addon? I'd have to go with the probability of that being pretty much zero.

For another, you don't need to give everything a global name in order for it to be accessible. Give your main object a global name, and add references to everything else to it as table members:

Code:
local mainFrame = CreateFrame("Frame", "MyAddon", UIParent)

local otherFrame = CreateFrame("Button", nil, mainFrame)
mainFrame.Button = otherFrame

-- now other addons can access "otherFrame" as "MyAddon.Button"
Frames must have names for framestack function and OnUpdate/OnEvent tracking.
You can drop textures and fontstrings names, but, i think, you must keep frame`s name.
  Reply With Quote
11-24-13, 09:50 AM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by AlleyKat View Post
Frames must have names for framestack function and OnUpdate/OnEvent tracking.
You can drop textures and fontstrings names, but, i think, you must keep frame`s name.
Frames don't have names, they can have a global reference, which means other addons can use/change that frame too. And if a frame has a global reference then you will see that name as the frames name.

Last edited by Resike : 11-24-13 at 09:54 AM.
  Reply With Quote
11-24-13, 10:09 AM   #13
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by Resike View Post
Frames don't have names, they can have a global reference, which means other addons can use/change that frame too. And if a frame has a global reference then you will see that name as the frames name.
That s Blizzard problem, thas why i use addon title before frame name, to protect random global variable.
And i don`t care about memory, lua has a lot of memory leaks with table rehash and everyone run game in 64bit mode.

Last edited by AlleyKat : 11-24-13 at 10:16 AM.
  Reply With Quote
11-24-13, 10:10 AM   #14
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by zork View Post
Actually you can do sth like this easily with the animation system or by just rotating a texture. Just think of the accelerometer as a circle and the needle is a texture that you rotate around the center of that circle. That and using texture alpha layers properly.
first steps, looks funny
http://www.youtube.com/watch?v=wA-Qspt7W-U
  Reply With Quote
11-24-13, 12:46 PM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by AlleyKat View Post
That s Blizzard problem, thas why i use addon title before frame name, to protect random global variable.
And i don`t care about memory, lua has a lot of memory leaks with table rehash and everyone run game in 64bit mode.
It's still going to be global. You just merging the string's name which is going to be the global reference's "name".
  Reply With Quote
11-24-13, 12:50 PM   #16
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by Resike View Post
It's still going to be global. You just merging the string's name which is going to be the global reference's "name".
This is not good? It slows down system?

Last edited by AlleyKat : 11-24-13 at 12:52 PM.
  Reply With Quote
11-24-13, 01:21 PM   #17
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by AlleyKat View Post
This is not good? It slows down system?
No but it's pointless if you don't need it as a global too, and could cause taints, if it's not named properly.

If you use it like this:

Lua Code:
  1. local holder = CreateFrame("ScrollFrame", "holder", UIParent)

Then it's overwrites your local holder, aka it becomes global, and then you can reach that variable sligtly slower. That can slow down your functions, since it takes more time to find that var.
  Reply With Quote
11-24-13, 02:20 PM   #18
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Resike View Post
If you use it like this:

Lua Code:
  1. local holder = CreateFrame("ScrollFrame", "holder", UIParent)

Then it's overwrites your local holder, aka it becomes global, and then you can reach that variable slightly slower. That can slow down your functions, since it takes more time to find that var.
That would not overwrite the local. There would be both a local and a global reference, with the local superseding the global. Also, any "slow down" would be negligible outside of an OnUpdate script or an extremely frequently called OnEvent handler.

I'm all for advocating less pollution of _G but not at the expense of misinformation.
  Reply With Quote
11-24-13, 03:32 PM   #19
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by Resike View Post
No but it's pointless if you don't need it as a global too, and could cause taints, if it's not named properly.

If you use it like this:

Lua Code:
  1. local holder = CreateFrame("ScrollFrame", "holder", UIParent)

Then it's overwrites your local holder, aka it becomes global, and then you can reach that variable sligtly slower. That can slow down your functions, since it takes more time to find that var.
It is not pointless, frame is like base of your ui elements and it must has name.
There are two types of variables: local and upvalue, if you are anonced local variable, you no longer can get upvalue from function environment, only via direct call from env table, like _G.
to avoid tains and etc you can put addon name before frame name
  Reply With Quote
11-24-13, 04:41 PM   #20
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Vrul View Post
That would not overwrite the local. There would be both a local and a global reference, with the local superseding the global. Also, any "slow down" would be negligible outside of an OnUpdate script or an extremely frequently called OnEvent handler.

I'm all for advocating less pollution of _G but not at the expense of misinformation.
I still had some issues with the code above.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Mana/Power level


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