Thread Tools Display Modes
07-09-12, 01:16 AM   #1
Paopao001
A Fallenroot Satyr
 
Paopao001's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 20
Update max Holypower and Chi

In 5.0 the max number of Holy power and Chi(Harmony Obrs) changes when:
Paladin learned Boundless Conviction;
Monk learned Ascension.

I set the max number by UnitPowerMax("player", SPELL_POWER_HOLY_POWER) and UnitPowerMax("player" , SPELL_POWER_LIGHT_FORCE).
But when my monk changes talent points, the harmony bar don't update it's max chi number and an error will occur if i get one more Chi.
It's hard to test this on a paladin, but i guess it's the same thing.

The width of Holy power bar and Harmony bar are fixed in my layout, so I have to calculate each's width using barwidth/number.

There are two way i can see to avoid this problem.
Give up fixed total width and set the number to 5 Holypower and 5 Chi.
Reload UI when max number update.

You see, the problem are not solved but just avoided.
Anyone has idea on update max number of holy power and Chi?

Here's my code:

Lua Code:
  1. -- Runes, Shards, HolyPower --
  2.         if multicheck(class, "DEATHKNIGHT", "WARLOCK", "PALADIN", "MONK", "SHAMAN", "PRIEST") then
  3.             local count
  4.             if class == "DEATHKNIGHT" then
  5.                 count = 6
  6.             elseif class == "MONK" then
  7.                 count = UnitPowerMax("player" , SPELL_POWER_LIGHT_FORCE)
  8.             elseif class == "SHAMAN" then
  9.                 count = 4
  10.             elseif class == "WARLOCK" then
  11.                 count = UnitPowerMax("player", SPELL_POWER_SOUL_SHARDS)
  12.             elseif class == "PALADIN" then
  13.                 count = UnitPowerMax("player", SPELL_POWER_HOLY_POWER)
  14.             elseif class == "PRIEST" then
  15.                 count = UnitPowerMax("player", SPELL_POWER_SHADOW_ORBS)
  16.             end
  17.  
  18.             local bars = CreateFrame("Frame", nil, self)
  19.  
  20.             if cfg.Ruserplaced and class == "DEATHKNIGHT" then
  21.             bars:SetSize(cfg.Rwidth,cfg.Rheight)
  22.             bars:SetPoint(unpack(cfg.Runesp))
  23.             createBackdrop(bars, bars, 0, 3)
  24.             else
  25.             bars:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, -8)
  26.             bars:SetSize(cfg.width, 10)
  27.             end
  28.  
  29.             local i = count
  30.             for index = 1, count do
  31.                 bars[i] = createStatusbar(bars, cfg.texture, nil, cfg.height*-(cfg.hpheight-1), (cfg.width+3)/count-3, 1, 1, 1, 1)
  32.  
  33.                 if class == "WARLOCK" or class == "PRIEST" then
  34.                     bars[i]:SetStatusBarColor(253/255, 91/255, 176/255)
  35.                 elseif class == "PALADIN" or class == "MONK" then
  36.                     bars[i]:SetStatusBarColor(255/255, 255/255, 53/255)
  37.                 end
  38.                
  39.                 if cfg.Ruserplaced and class == "DEATHKNIGHT" then
  40.                 bars[i]:SetSize((cfg.Rwidth+3)/count-3,cfg.Rheight)
  41.                 end
  42.                
  43.                 if i == count then
  44.                     bars[i]:SetPoint("TOPRIGHT", bars, "TOPRIGHT")
  45.                 else
  46.                     bars[i]:SetPoint("RIGHT", bars[i+1], "LEFT", -3, 0)
  47.                 end
  48.  
  49.                 bars[i].bg = bars[i]:CreateTexture(nil, "BACKGROUND")
  50.                 bars[i].bg:SetAllPoints(bars[i])
  51.                 bars[i].bg:SetTexture(0.3, 0.3, 0.3, 1)
  52.  
  53.                 bars[i].bd = createBackdrop(bars[i], bars[i],1,3)
  54.                 i=i-1
  55.             end
  56.  
  57.             if class == "DEATHKNIGHT" then
  58.                 bars[3], bars[4], bars[5], bars[6] = bars[5], bars[6], bars[3], bars[4]
  59.                 self.Runes = bars
  60.             elseif class == "WARLOCK" then
  61.                 self.SoulShards = bars
  62.                 if cfg.customsp then bars:Hide() end
  63.             elseif class == "PALADIN" then
  64.                 self.HolyPower = bars
  65.                 if cfg.customsp then bars:Hide() end
  66.             elseif class == "MONK" then
  67.                 self.Harmony = bars
  68.                 if cfg.customsp then bars:Hide() end
  69.             elseif class == "SHAMAN" then
  70.                 self.TotemBar = bars
  71.             elseif class == "PRIEST" then
  72.                 self.ShadowOrbs = bars
  73.                 if cfg.customsp then bars:Hide() end
  74.             end
  75.         end
  Reply With Quote
07-09-12, 09:22 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Afaik that stuff is currently being worked on. But you are right. You would need to create the bar with the max number of chi elements possible even if they are not currently displayed.

The API needs to loop over your elements and hide them based on the current value of MAX_CHI etc.

And you always have the possibility to override the default update function for a bar setup and create your own. I would recommend that if you need repositioning/resizing stuff.

To do that just use
Lua Code:
  1. self.barType.Override = myOverrideFunc --where barType is sth like SoulShards or HolyPower etc.
__________________
| 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 : 07-09-12 at 09:28 AM.
  Reply With Quote
07-09-12, 11:13 PM   #3
Coldkil
A Cliff Giant
 
Coldkil's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 70
I made a working chi bar - i didn't know about paladins, i just thought that had 5 holy polwer always; i need to fix that.

The solution is to store the current chi/holypower/shard/embers in a variable just after creation, then make a check in the update function to show/hode the additional frame and/or reposition/resize the other ones.

Here's a pastebin of my harmonybar http://pastebin.com/zNh2XbpC

in the Create() function i make all the frames and set chinum to 5 - this because i still don't know if the player has the talent or not , so i need all the frames ready, then force an Update().

Then the Update() checks the number i stored with UnitPowerMax("player", SPELL_POWER_LIGHT_FORCE), and toggles the the 5th frame as needed. Then saves the new chinum for next Update() calls.

This can be used for any of the bars above - as a side not, i'm having really odd behaviours with lock bars, just because i sticked into using only one container then make fancy thing with the widgets inside. I'm dropping that and just create three separate bars, toggling between them based on spec and updateing only the shown one (since every bar will have a very different style/behaviour).
  Reply With Quote
07-10-12, 01:03 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Exactly the way it should be done. Afaik you could just always create 10 elements for a bar and the update function just hides all elements that are currently not being used. 10 is just for being safe.

I know that we currently know the values but what happens if they change the abilities to have more/less. I don't want to change the code all the time. Thus checking MAX_POWER in the update function and hiding non-existent bars is a good thing imo.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
07-10-12, 01:25 AM   #5
Coldkil
A Cliff Giant
 
Coldkil's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 70
Yeah, i set the num to 5 at creation because it's the minimum required, so no need to make additional checks.

Unfortunately sometimes (like player xp) at login isn't still stored/loaded so it can return 0 or nil. It happens the same for holy power - using the standard oUF plugin just returns an error on the for cycle because MAX_HOLY_POWER (or whatever is called) is nil at start.

After the first update the game returns me the correct value, but the error makes the frame not load at all.
  Reply With Quote
07-10-12, 05:46 PM   #6
Paopao001
A Fallenroot Satyr
 
Paopao001's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 20
The same goes to soul shards.I edit it a little to avoid the error.

UnitPowerMax(unit, SPELL_POWER_HOLY_POWER)
UnitPowerMax(unit, SPELL_POWER_SOUL_SHARDS)

BTW,It seems that the max number of shadow orbs are change in certain conditions,TOO.
  Reply With Quote
07-18-12, 08:52 AM   #7
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Why hasn't this been posted yet?

For the time being tukz posted plugins for ShadowOrbs, WarlockSpec and that monk thingy.

Monk (Harmony)
http://www.wowinterface.com/download...armonyBar.html

Warlock
http://www.wowinterface.com/download...SpecsBars.html

Shadow Orbs
http://www.wowinterface.com/download...owOrbsBar.html

Just for notice.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
07-18-12, 02:50 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The oUF GitHub repo already has working chi and shadow orbs support, and holy power works with an .Override set (the default Update function references a global that doesn't exist).

On the topic of holy power, you can actually get up to 5 according to the API, but the default UI only shows up to 3. If you have 5, the UI shows 3, and then if you spend 1 or 2, the UI still shows 3. I'm showing all 5 in my layout, but was wondering what other people thought about this? Should I follow the default UI's lead and only show 3 at a time, or should I show all 5?
__________________
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-19-12, 03:34 AM   #9
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
The default UI shows 5 for me - 3 normal indicators like in Cata, and then 2 smaller horizontal indicators below them for 4 and 5.
  Reply With Quote
07-19-12, 05:39 AM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Okay, I'll stick with showing all 5. I haven't actually looked at the default UI in MoP... just its source code, and not very thoroughly.
__________________
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-19-12, 07:36 AM   #11
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Is anyone working on the new warlock spec bars? They're different for each spec so it's a mess to code.

Tukz has a plugin for it uploaded here but it doesn't work for me as demonology, showing bars instead of just one for demonic fury - it works for him though.

Could have a go at it myself if nobody else is bothered, but I don't actually play a warlock so testing would be pretty limited.
  Reply With Quote
07-19-12, 11:46 AM   #12
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
I've been fiddling with it a bit, but since it's 3 different types of powers, I am pretty sure you'd have to do them seperately to avoid cluttered code.
  Reply With Quote
07-19-12, 04:47 PM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Haleth View Post
Is anyone working on the new warlock spec bars? They're different for each spec so it's a mess to code.

Tukz has a plugin for it uploaded here but it doesn't work for me as demonology, showing bars instead of just one for demonic fury - it works for him though.

Could have a go at it myself if nobody else is bothered, but I don't actually play a warlock so testing would be pretty limited.
Beta versions of oUF_Phanx has a fully functioning single element that works for all three warlock power types.

It does not switch to a single bar for demonic fury, though; it just splits the total into 5 parts and fills up each orb in sequence as if they were all part of a single bar. If you're using statusbars instead of custom orb things, it would be trivial to expand the first statusbar and hide the others, though. Even easier if you're using a single statusbar for the whole thing. I've only tested the element with my orbs, but I coded it to work -- in theory -- with single statusbar elements and multi-statusbar elements. Feel free to try it out.
__________________
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-21-12, 07:12 AM   #14
Coldkil
A Cliff Giant
 
Coldkil's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 70
I made a code for warlock bars that uses 3 different widgets - i found this the best solution to avoid resize/movement bugs due to different shards/ember/fury behaviour.

When the events for updating fires, a check for the spec hides/show the frames needed. Also having 3 widgets lets me design them in different ways while keeping them work pretty good.

Code is here: http://pastebin.com/XZ7ANESK

I'm not totally sure it's perfect, but i haven't got any issue so far. Some other testing would be awesome. The lib functions are only for getting the class and some font/textures, just replace them with yours.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Update max Holypower and Chi

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