Thread Tools Display Modes
09-25-12, 08:35 PM   #21
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by Phanx View Post
Addons are loaded alphabetically on NTFS filesystems, which, as the filesystem used by Windows, covers the vast majority of users.

I don't know what the Mac filesystem does, or Linux filesystems...
I use a Mac (and a Windows machine btw).
Basically the alphabetical part stands on Mac as well. Since you can't play WoW natively on Linux, you'd be stuck with Wine or a VM with Mac OS X/Windows, you'd end up with the default situation.

And god I need to go to bed NOW. :P
  Reply With Quote
10-02-12, 09:29 AM   #22
Paopao001
A Fallenroot Satyr
 
Paopao001's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 20
Hello.
I would like to change the width of each class icon when the max number of the resource changes.

Lua Code:
  1. local ClassIconsPostUpdate = function(element, cur, max, maxchange)
  2.     for i = 1, 5 do
  3.         if cur == max then
  4.             element[i]:SetStatusBarColor(unpack(classicon_colors[cur]))
  5.         else
  6.             element[i]:SetStatusBarColor(unpack(classicon_colors[i]))
  7.         end
  8.         if maxchange then
  9.             element[i]:SetWidth((oUF_MlightDB.width+3)/max-3)
  10.         end    
  11.     end
  12. end
Lua Code:
  1. local _, class = UnitClass("player")
  2.        
  3.         -- Runes, Shards, HolyPower and so on --
  4.         if multicheck(class, "DEATHKNIGHT", "WARLOCK", "PALADIN", "MONK", "SHAMAN", "PRIEST", "MAGE", "ROGUE", "DRUID") then
  5.             local count
  6.             if class == "DEATHKNIGHT" then
  7.                 count = 6
  8.             elseif class == "WARLOCK" then
  9.                 count = 4
  10.             elseif class == "PALADIN" or class == "PRIEST" or class == "MONK" then
  11.                 count = 5
  12.             elseif class == "SHAMAN" then
  13.                 count = 4
  14.             elseif class == "MAGE" then
  15.                 count = 6
  16.             elseif class == "ROGUE" or class == "DRUID" then
  17.                 count = 5 -- combopoints
  18.             end
  19.  
  20.             local bars = CreateFrame("Frame", nil, self)
  21.             bars:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 3)
  22.             bars:SetSize(oUF_MlightDB.width, 10)
  23.  
  24.             for i = 1, count do
  25.                 bars[i] = createStatusbar(bars, texture, nil, oUF_MlightDB.height*-(oUF_MlightDB.hpheight-1), (oUF_MlightDB.width+2)/count-3, 1, 1, 1, 1)
  26.  
  27.                 if i == 1 then
  28.                     bars[i]:SetPoint("BOTTOMLEFT", bars, "BOTTOMLEFT")
  29.                 else
  30.                     bars[i]:SetPoint("LEFT", bars[i-1], "RIGHT", 3, 0)
  31.                 end
  32.  
  33.                 bars[i].bd = createBackdrop(bars[i], bars[i], 1)
  34.             end
  35.  
  36.             if class == "DEATHKNIGHT" then
  37.                 self.Runes = bars
  38.             elseif class == "WARLOCK" then
  39.                 self.WarlockSpecBars = bars
  40.             elseif class == "PALADIN" or class == "PRIEST" or class == "MONK" then
  41.                 self.ClassIcons = bars
  42.                 self.ClassIcons.UpdateTexture = function() end
  43.                 self.ClassIcons.PostUpdate = ClassIconsPostUpdate
  44.             elseif class == "SHAMAN" then
  45.                 self.TotemBar = bars
  46.             elseif class == "MAGE" then
  47.                 self.ArcaneCharge = bars
  48.             elseif class == "ROGUE" or class == "DRUID" then
  49.                 self.CPoints = bars
  50.                 self.CPoints.PostUpdate = CpointsPostUpdate
  51.             end
  52.         end

When the max number of power changes, it works properly. But there's a problem when log-in.
If the player is shadow priest. The width of each element is 1/5 of the width of player frame.
I would like it to be 1/3. A paladin under lvl 85 ,a warlock with 3 soul shards and a monk with 4 chis got the same problem.
The solution I found is to change element.__max to 5 in oUF\elements\classicons.lua(because I can't find a right place to make it in my layout).
This means: when I create the frames/textures for the element, I set the width of each icon suppose the player got 5 class icons. When PLAYER_TALENT_UPDATE fires, oUF update the element and oldMax ~= max is true in element:PostUpdate(cur, max, oldMax ~= max). So the layout can change the width of each icon when log-in.

Haste, I really appreciate if you could set element.__max to 5 in oUF\elements\classicons.lua or make it easier to change element.__max in layout.
__________________

I hope you could understand my broken English.
If I offended you it was unwitting.
  Reply With Quote
10-02-12, 04:28 PM   #23
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, the obvious problem in your login code is that you are dividing the total width by 5, not by 3...
__________________
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
10-02-12, 09:06 PM   #24
Paopao001
A Fallenroot Satyr
 
Paopao001's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 20
Originally Posted by Phanx View Post
Well, the obvious problem in your login code is that you are dividing the total width by 5, not by 3...
Then should I divided it by PRIEST_BAR_NUM_ORBS for shadow priest, by 4 for monk, by 3 for warlock, by HOLY_POWER_FULL for paladin? I think that's different from the intent of combine them together in some way.
__________________

I hope you could understand my broken English.
If I offended you it was unwitting.
  Reply With Quote
10-02-12, 11:55 PM   #25
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Paopao001 View Post
Then should I divided it by PRIEST_BAR_NUM_ORBS for shadow priest, by 4 for monk, by 3 for warlock, by HOLY_POWER_FULL for paladin? I think that's different from the intent of combine them together in some way.
They're only combined into one element so Haste isn't copy/pasting the same code 3+ times and just changing the name. You don't have to treat them all exactly the same, all the time. ShadowOrbs isn't going to get upset if you pick HolyPower first for the team.

Simply updating the width in your PostUpdate should work, though you may need to set some kind of flag on the element, and update the width if it's set even if oUF didn't think the max changed, to catch that initial update:
Code:
self.ClassIcons.PostUpdate = ClassIconsPostUpdate
self.ClassIcons.forceUpdate = true
Then, in your ClassIconsPostUpdate function:
Code:
if maxchange or element.forceUpdate then
     element.forceUpdate = nil
     element[i]:SetWidth((oUF_MlightDB.width+3)/max-3)
__________________
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
10-03-12, 04:30 PM   #26
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You both missed the last argument of the ClassIcons' PostUpdate function, which tells you whether the number of bars changed. Here is what I use for reference:

Register the element:
lua Code:
  1. local AddClassPowerIcons = function(self, width, height, spacing)
  2.     self.ClassIcons = {}
  3.  
  4.     self.ClassIcons.width  = width
  5.     self.ClassIcons.height = height
  6.     self.ClassIcons.spacing = spacing
  7.  
  8.     local maxPower = 5
  9.  
  10.     for i = 1, maxPower do
  11.         self.ClassIcons[i] = self.Overlay:CreateTexture("oUF_Rain_ComboPoint_"..i, "OVERLAY")
  12.         self.ClassIcons[i]:SetSize((width - spacing * (maxPower - 1)) / maxPower, height)
  13.         self.ClassIcons[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * self.ClassIcons[i]:GetWidth() + i * spacing, 1)
  14.         self.ClassIcons[i]:SetTexture(ns.media.TEXTURE)
  15.     end
  16.  
  17.     self.ClassIcons.PostUpdate = ns.PostUpdateClassPowerIcons
  18. end
  19. ns.AddClassPowerIcons = AddClassPowerIcons

The PostUpdate function:
lua Code:
  1. local PostUpdateClassPowerIcons = function(element, power, maxPower, maxPowerChanged)
  2.     if (not maxPowerChanged) then return end
  3.  
  4.     local self = element.__owner
  5.     local width = element.width
  6.     local height = element.height
  7.     local spacing = element.spacing
  8.  
  9.     for i = 1, maxPower do
  10.         element[i]:SetSize((width - spacing * (maxPower - 1)) / maxPower, height)
  11.         element[i]:SetPoint("BOTTOMLEFT", self.Overlay, (i - 1) * element[i]:GetWidth() + i * spacing, 1)
  12.     end
  13. end
  14. ns.PostUpdateClassPowerIcons = PostUpdateClassPowerIcons

Add the element to the frame appropriate unit frames:
lua Code:
  1. if (playerClass == "DEATHKNIGHT") then
  2.     ns.AddRuneBar(self, 215, 5, 1)
  3.     ns.AddTotems(self, 60, 5)
  4. elseif (playerClass == "DRUID") then
  5.     ns.AddEclipseBar(self, 230, 7)
  6.     ns.AddTotems(self, 30, 5)
  7. elseif (playerClass == "HUNTER") then
  8.     ns.AddFocusHelper(self)
  9. elseif (playerClass == "MONK") then
  10.     ns.AddClassPowerIcons(self, 215, 5, 1)
  11. elseif (playerClass == "PALADIN") then
  12.     ns.AddClassPowerIcons(self, 215, 5, 1)
  13. elseif (playerClass == "PRIEST") then
  14.     ns.AddClassPowerIcons(self, 215, 5, 1)
  15. elseif (playerClass == "SHAMAN") then
  16.     ns.AddTotems(self, nil, 5)
  17. elseif (playerClass == "WARLOCK") then
  18.     ns.AddWarlockPowerBar(self, 215, 5, 1)
  19. end

Apart from that, adding combo points only for druid and rogue is a bad idea, as other classes can use them too when in vehicle (Aces High! comes to mind)

EDIT: Ouch, Phanx got it right of course, I kind of have the annoying habit of reading too fast and thinking to slow. I don't think the call to ForceUpdate is needed, as oUF does this for you when it sets up the unit frame. But I would trust Phanx more than me, so you'd better check.

Last edited by Rainrider : 10-03-12 at 04:36 PM.
  Reply With Quote
10-03-12, 06:50 PM   #27
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Rainrider View Post
You both missed the last argument of the ClassIcons' PostUpdate function, which tells you whether the number of bars changed.
No, I didn't. The problem is that oUF does not consider the number to have changed the first time it updates the element, so you need to set your own flag if you want to run some code when the value changes or if the element is being updated for the first time.

Also, I'm not sure what "call to ForceUpdate" you're referring to. My code never calls the element's ForceUpdate method. Remember that Lua is case-sensitive; "forceUpdate" is not the same as "ForceUpdate", and so both keys -- the former containing my boolean flag, the latter containing oUF's function -- will coexist the same table without any conflicts or any relation to each other.

You're right, though, that combo points should be created for all classes. Many vehicles use them. I don't know about current content since I'm not really playing the game 99% of the time I'm logged in, but there have been encounters in the past (eg. Malygos) where vehicle combo points were critical to being able to use the vehicle successfully.
__________________
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
10-04-12, 05:16 PM   #28
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You are right, Phanx.

Wouldn't it be better to just set element.__max = 5 in the ClassIcons' Enable function and not individually in ClassPowerEnable? This way oUF will pick the correct max values on it's initial update and inform the user about the change through PostUpdate.

Code:
@@ -155,11 +155,10 @@ do
 			DARK_FORCE = true,
 		}
 
 		ClassPowerEnable = function(self)
 			local element = self.ClassIcons
-			element.__max = 4
 
 			self:RegisterEvent('UNIT_DISPLAYPOWER', Update)
 			self:RegisterEvent('UNIT_POWER_FREQUENT', Update)
 		end
 
@@ -173,11 +172,10 @@ do
 			HOLY_POWER = true,
 		}
 
 		ClassPowerEnable = function(self)
 			local element = self.ClassIcons
-			element.__max = HOLY_POWER_FULL
 
 			self:RegisterEvent('UNIT_DISPLAYPOWER', Update)
 			self:RegisterEvent('UNIT_POWER', Update)
 		end
 
@@ -192,11 +190,10 @@ do
 		}
 		RequireSpec = SPEC_PRIEST_SHADOW
 
 		ClassPowerEnable = function(self)
 			local element = self.ClassIcons
-			element.__max = PRIEST_BAR_NUM_ORBS
 
 			self:RegisterEvent('UNIT_DISPLAYPOWER', Update)
 			self:RegisterEvent('UNIT_POWER_FREQUENT', Update)
 		end
 
@@ -211,11 +208,10 @@ do
 		}
 		RequireSpell = WARLOCK_SOULBURN
 
 		ClassPowerEnable = function(self)
 			local element = self.ClassIcons
-			element.__max = 3
 
 			self:RegisterEvent('UNIT_DISPLAYPOWER', Update)
 			self:RegisterEvent('UNIT_POWER_FREQUENT', Update)
 		end
 
@@ -229,10 +225,11 @@ end
 local Enable = function(self, unit)
 	local element = self.ClassIcons
 	if(not element) then return end
 
 	element.__owner = self
+	element.__max = 5
 	element.ForceUpdate = ForceUpdate
 
 	if(ClassPowerEnable) then
 		if(PlayerClass == 'PRIEST') then
 			self:RegisterEvent('PLAYER_TALENT_UPDATE', Visibility, true)
I could push this to oUF's github repo if you think it would be a better way.
  Reply With Quote
10-04-12, 05:26 PM   #29
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Maybe, but you'd want to set the initial value to 0 (or some other unlikely value) so that the initial update would also report a change for classes who do actually have 5 icons.
__________________
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
10-05-12, 09:28 AM   #30
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Why would that be needed? The layout should create 5 ui widgets and if maxPower happens to be that, than we are good to go and don't have to change anything. Or am I missing something?
  Reply With Quote
10-05-12, 06:09 PM   #31
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Because if you do that, then you have to duplicate code by setting the widths in two places: once where you create the element, and again in the PostUpdate. If oUF reports a change on the first update, then you only need the code in one place: in the PostUpdate.
__________________
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
10-05-12, 07:47 PM   #32
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
https://github.com/haste/oUF/pull/156
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Combo Points (and related class powers)

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