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,877
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,877
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
07-08-13, 02:42 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
I can show you what I do with Discord Art which might be addaptable to KgPanels.

For displaying money, in on OnUpdate script
Code:
local m = GetMoney()
local gold = floor(m/10000)
local silver = floor((m - (10000*gold))/100)
self.text:SetText(gold .. "g " .. silver .. "s " .. m - (10000*gold) - (100*silver) .. "c")
For coords:
Code:
In an OnLoad Script:
self:RegisterEvent("MINIMAP_ZONE_CHANGED")
In an OnEvent script:
Code:
if event == "MINIMAP_ZONE_CHANGED" then
    self.needZoneUpdate = true
end
In an OnUpdated script:
Code:
if self.needZoneUpdate and not WorldMapFrame:IsVisible() then
    self.needZoneUpdate = false
    SetMapToCurrentZone()
end
local x,y = GetPlayerMapPosition("player")
x = format("%.1f", x*100)
y = format("%.1f", y*100)
self.text:SetText(25, x .. " " .. y)
Opening bags, in an OnClick script:
Code:
OpenAllBags()
To show/Hide the calendar: in an OnClick script:
Code:
if CalendarFrame:IsVisible() then
    CalendarFrame:Hide()
else
    CalendarFrame:Show()
end
See also reply in other thread. I think that covers them all

Last edited by Fizzlemizz : 07-08-13 at 02:58 PM.
  Reply With Quote
07-08-13, 02:45 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Akatosh View Post
1. How can I do for One click (on kgpanels) open the bags, and one click more close the bags.?
Code:
if pressed then ToggleAllBags() end
Originally Posted by Akatosh View Post
2. how can I do for 1 click (on kgpanels) open the calendar, and one click close the calendar.?
Code:
if pressed then Calendar_Toggle() end
Originally Posted by Akatosh View Post
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?
kgPanels is not really meant for that sort of thing. I'd suggest using a DataBroker display with existing gold and coordinate plugins instead. StatBlocksCore can give you standalone blocks for each plugin if that's the kind of thing you're into, and you can attach a kgPanels background texture if you want. If you want a traditional "info bar" I'd recommend Bazooka.
__________________
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
07-08-13, 03:34 PM   #10
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Ok, Thanks for all the help!!.

I try to aply the changes I said something when I do it.
  Reply With Quote
07-08-13, 03:39 PM   #11
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
For the calendar it would be better to use Calendar_Toggle() than what I posted. I didn't know the function existed as it's not documented at wowprogramming.com or wowpedia.org.

The reason I use DART and not an info bar is because I haven't found one that offers all the colouring options I want. Fussy of me I know but that's the nature of the Fizzle.

Last edited by Fizzlemizz : 07-08-13 at 03:43 PM.
  Reply With Quote
07-08-13, 04:46 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Fizzlemizz View Post
The reason I use DART and not an info bar is because I haven't found one that offers all the colouring options I want. Fussy of me I know but that's the nature of the Fizzle.
Well, I'd have to say that writing a simple Broker plugin that colors the text the way you want would still be a better solution than shoehorning data display into an art panel addon. Plus, there are already Broker plugins to toggle your bags, calendar, and anything else you can imagine, no code-writing required.
__________________
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
07-08-13, 05:08 PM   #13
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Originally Posted by Phanx View Post
Well, I'd have to say that writing a simple Broker plugin that colors the text the way you want would still be a better solution than shoehorning data display into an art panel addon. Plus, there are already Broker plugins to toggle your bags, calendar, and anything else you can imagine, no code-writing required.
It's not really shoehorning as DART is already set up for displaying text as well as art, has the built in scripting points, setup window for easy positioning yada yada yada and as I'm already using it for my background so I'd be duplicating a lot of the plumbing creating yet another addon just to scrape an extra poofteenth of efficiency out of it.

Lua not being my most proficient language, as you have pointed out on several occaisions (thank you), I doubt I would do a better job anyway.

Last edited by Fizzlemizz : 07-08-13 at 05:25 PM.
  Reply With Quote
07-26-13, 06:34 PM   #14
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Thumbs up

Hello all again!!

I was away from the computer for unavoidable causes.
Now I have time .... and questions ...

Sorry if I am very picky ...

1º Make a clock with no military time (aka 12 hours), example: 12:34 am.
2º Can be possible a panel with Zone and Subzone text, with color variation depending of the type of zone (PvP, Sanctuary, City etc.), for example:

Zone, Subzone (hostile)
Zone, Subzone (in sanctuary)
Zone, Subzone (non hostile)

Etc...

3º maybe that be imposible... or very hard:

¿Can be posible a panel that show me the memory usage of the addons?, and when I mouse over it show me a tooltip with a list of the Addons with that format? for example:

________
| 10 MB | <---- Mouseover (tootip)
---------

Kgpanels config 2.8 MB
Kgpanels 711KB.

etc etc


I want to centralize everything I can in the kgpanels.

Thanks!!!
  Reply With Quote
07-26-13, 09:44 PM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Again, I just don't get why you are spending all this time and energy bending kgPanels to this purpose, instead of just using a Broker display addon that already exists, with any of the many Broker plugins that already exist to show you time, memory usage, and zone info.
__________________
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-26-13 at 09:48 PM.
  Reply With Quote
07-27-13, 10:03 AM   #16
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Phanx View Post
Again, I just don't get why you are spending all this time and energy bending kgPanels to this purpose, instead of just using a Broker display addon that already exists, with any of the many Broker plugins that already exist to show you time, memory usage, and zone info.
Sorry if I'm asking is not very logical...

Each addon need 200KB ~, with functions that I dont use, I think that 5 or 6 lines of code, be better in general, for less CPU / Memory usage.

I dont have a lot of idea of lua code...I wish I was able to do it myself ... looking for internet forums, I do not bring any solution, I'm asking here as a last resort trying to disturb as little as possible ... Sorry.
  Reply With Quote
07-27-13, 12:40 PM   #17
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Is your computer running short on memory? Wanting to learn how to code is perfectly fine - though if that were the case we would still encourage you to create standalone addons instead of using kgPanels. But if all you're worried about is saving 1MB in memory? (Which, actually, I'm not even certain the plugins each take 200kb+)
__________________
"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
07-27-13, 01:43 PM   #18
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Personally I've found it quite handy to use Discord Art to do this sort of thing but I'm already using it for other things as well.

Anyway Akatosh if you decide to proceed with KgPanels here's the code for a clock.

Code:
local minutes, hour, minute
local t = date("*t", time())
hour = t.hour
minute = t.min
minutes = (hour*60) + minute
if (minutes > 1440) then
    minutes = minutes - 1440
end
minutes = abs(minutes)
hour = floor(minutes/60)
minute = format("%02d", mod(minutes, 60))
local text
if minutes > 719 then
    if minutes > 779 then
        hour = floor(minutes/60) - 12
    end
    text = hour .. ":" .. minute .. " pm"
else
    if (hour == 0) then
        hour = 12
    end
    text = hour .. ":" .. minute .. " am"
end
-- do whatever KgPanels uses to update the display with text.
About the only thing that would be difficult would be the memory usage.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-27-13 at 02:17 PM.
  Reply With Quote
07-27-13, 02:33 PM   #19
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
Personally I've found it quite handy to use Discord Art to do this sort of thing but I'm already using it for other things as well.

Anyway Akatosh if you decide to proceed with KgPanels here's the code for a clock.

Code:
local minutes, hour, minute
local t = date("*t", time())
hour = t.hour
minute = t.min
minutes = (hour*60) + minute
if (minutes > 1440) then
    minutes = minutes - 1440
end
minutes = abs(minutes)
hour = floor(minutes/60)
minute = format("%02d", mod(minutes, 60))
local text
if minutes > 719 then
    if minutes > 779 then
        hour = floor(minutes/60) - 12
    end
    text = hour .. ":" .. minute .. " pm"
else
    if (hour == 0) then
        hour = 12
    end
    text = hour .. ":" .. minute .. " am"
end
-- do whatever KgPanels uses to update the display with text.
About the only thing that would be difficult would be the memory usage.
Thanks for trusting me! but... I put the code onUpdate section and nothing appear.
  Reply With Quote
07-27-13, 02:44 PM   #20
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Essentially what I've given you is the variable called "text" that contains the information you want.
The following line needs to be replaced using whatever KgPanels does to update the display with the information from this "text" variable.

-- do whatever KgPanels uses to update the display with "text"

if
self.text:SetText(gold .. "g " .. silver .. "s " .. m - (10000*gold) - (100*silver) .. "c")
worked with your gold display then try:

self.text:SetText(text)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-27-13 at 02:46 PM.
  Reply With Quote

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

Thread Tools
Display Modes

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