WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Helps with Kgpanels! (https://www.wowinterface.com/forums/showthread.php?t=46786)

Akatosh 07-07-13 12:04 PM

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:

Quote:

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

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

Fizzlemizz 07-07-13 02:09 PM

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

Akatosh 07-07-13 02:49 PM

Quote:

Originally Posted by Fizzlemizz (Post 280916)
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!!.

Phanx 07-07-13 07:20 PM

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.

Akatosh 07-08-13 12:15 PM

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.

Fizzlemizz 07-08-13 01:02 PM

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.

Akatosh 07-08-13 01:29 PM

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

Fizzlemizz 07-08-13 02:42 PM

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

Phanx 07-08-13 02:45 PM

Quote:

Originally Posted by Akatosh (Post 280948)
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
Quote:

Originally Posted by Akatosh (Post 280948)
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
Quote:

Originally Posted by Akatosh (Post 280948)
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.

Akatosh 07-08-13 03:34 PM

Ok, Thanks for all the help!!.

I try to aply the changes I said something when I do it.

Fizzlemizz 07-08-13 03:39 PM

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.

Phanx 07-08-13 04:46 PM

Quote:

Originally Posted by Fizzlemizz (Post 280954)
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.

Fizzlemizz 07-08-13 05:08 PM

Quote:

Originally Posted by Phanx (Post 280960)
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.

Akatosh 07-26-13 06:34 PM

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

Phanx 07-26-13 09:44 PM

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.

Akatosh 07-27-13 10:03 AM

Quote:

Originally Posted by Phanx (Post 281614)
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.

Seerah 07-27-13 12:40 PM

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

Fizzlemizz 07-27-13 01:43 PM

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.

Akatosh 07-27-13 02:33 PM

Quote:

Originally Posted by Fizzlemizz (Post 281646)
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.

Fizzlemizz 07-27-13 02:44 PM

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)


All times are GMT -6. The time now is 04:20 AM.

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