Thread Tools Display Modes
07-07-13, 12:04 PM   #1
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Helps with Kgpanels!

Hi all!.

I am trying to remove databroker addons and use kgpanels with scrpts for my interface.

I want put a part of the text in class colored, and the other in white.

At this point I have that cripts.

On load:

local font, size, flags = self.text:GetFont()
self.text:SetFont(font, size, "OUTLINE," .. flags)
local _, Class = UnitClass("player")
local Color = RAID_CLASS_COLORS[Class]
self.text:SetTextColor(Color.r,Color.g,Color.b)

self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")
FPS_UPDATE = 0
FPS_RATE = 1
OnUpdate:
FPS_UPDATE = FPS_UPDATE + elapsed
if FPS_UPDATE > FPS_RATE then
local fps = GetFramerate()
self.text:SetText(string.format("%0.i fps",fps))
FPS_UPDATE = 0.1
end
Result:




¿Can be posible text color like the example?:




Thx to all!!
  Reply With Quote
07-07-13, 02:09 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
In OnUpdate:
local fps = "|c00FFFFFF".. string.format("%0.i", GetFramerate()) .. " |rfps"
self.text:SetText(fps)

Edit: A description of escape sequences: http://www.wowpedia.org/UI_escape_sequences

Last edited by Fizzlemizz : 07-07-13 at 02:19 PM.
  Reply With Quote
07-07-13, 02:49 PM   #3
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
In OnUpdate:
local fps = "|c00FFFFFF".. string.format("%0.i", GetFramerate()) .. " |rfps"
self.text:SetText(fps)

Edit: A description of escape sequences: http://www.wowpedia.org/UI_escape_sequences
Work ok, very thanks!!!, now I aply to all elements!!.
  Reply With Quote
07-07-13, 07:20 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Instead of:

Code:
local fps = "|c00FFFFFF".. string.format("%0.i", GetFramerate()) .. " |rfps"
self.text:SetText(fps)
Use:

Code:
self.text:SetFormattedText("|cffffffff%0.i|r fps", GetFramerate())
This passes the string.format operation to the C code backend instead of doing it in Lua, so it's faster, and creates less string garbage.

Also, string.format can handle plain text, so you should just put all your text in the format string, instead of performing multiple concatenation operations and creating more strings.

Finally, in your original code, FPS_UPDATE and FPS_RATE are defined global variables. You should avoid putting anything into the global namespace unless it's absolutely necessary, and when you do, make sure the names are unique (so, not FPS_RATE which is very generic and likely to collide with other addons leaking globals) and clearly identify them as belonging to your addon. In this case, it's not necessary, so you should not make them globals:

Code:
local font, size, flags = self.text:GetFont()
self.text:SetFont(font, size, "OUTLINE")

local _, class = UnitClass("player")
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
self.text:SetTextColor(color.r, color.g, color.b)

self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")

self.update = 0
self.rate = 1
Code:
self.update = self.update + elapsed
if self.update >= self.rate then
   self.text:SetFormattedText("|cffffffff%0.i|r fps", GetFramerate())
   self.update = 0
end
Oh, and in color codes, you should always begin with "|cff", not "|c00". That first hex pair represents the opacity of the contained text. 00 represents 0% opacity, which is invisible. You want ff, which represents 100% opacity. In practice it isn't important because the opacity is ignored in most (if not all) contexts in WoW, but that's not an excuse for passing the wrong value. You want visible text, so you shouldn't specify that you want invisible text and rely on the value being ignored -- just specify the value you actually want.
__________________
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.

Last edited by Phanx : 07-07-13 at 07:22 PM.
  Reply With Quote
07-08-13, 12:15 PM   #5
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Thx!, its very frustrating... I want do a lot of modificatons in my interface.... but I dont have no Idea of lua... I have a lot of questions... If maybe Someone can help me via skype voice client program or chat or something... I would be very grateful

Thanks for the help.
  Reply With Quote
07-08-13, 01:02 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
Posting questions here should get you all the help you need and it will be available to help others as well as Phanxs correction of my interpretaion of your problem has helped me find a more efficient way of doing things.
  Reply With Quote
07-08-13, 01:29 PM   #7
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Okok, I understand.

can someone help me with that question?¿

http://www.wowinterface.com/forums/s...92&postcount=4

I have a lot of questions more:

1. How can I do for One click (on kgpanels) open the bags, and one click more close the bags.?

2. how can I do for 1 click (on kgpanels) open the calendar, and one click close the calendar.?

3. how can I do for a panel that show me the gold in that format?: 111g 111s 111c?

4. how can i do for panel of cords with xx, yy format?

I have a lot of more questions but for now is enought, I think that be usefull for me and a lot of people too.

Thanks!!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Helps with Kgpanels!


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