Thread Tools Display Modes
03-01-11, 02:02 PM   #1
sippeangelo
A Defias Bandit
Join Date: Mar 2011
Posts: 3
Dynamic indicator positioning (Like PitBull)

This is how my playerframe looks right now when the player is both in combat and PvP flagged:



The combat and PvP icons are neatly placed beside each other.

But when the player goes out of combat but are still PvP flagged the combat icon will leave a gap where it was before:



I noticed how you can place PitBull's "indicators" in a stacked order and they shift and fill the empty space when one indicator disappears.
Is there any straight forward way of doing this with oUF or do I have to get dirty with coordinates and event hooks? :S
  Reply With Quote
03-01-11, 03:14 PM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
You would need a function that updates the position on certain events.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
03-01-11, 03:25 PM   #3
sippeangelo
A Defias Bandit
Join Date: Mar 2011
Posts: 3
Originally Posted by Dawn View Post
You would need a function that updates the position on certain events.
Yes, of course.
But the thing is there's a lot of other things I want to fit in there, like the leader icon, the master looter icon, phase icon, role icon, resting icon and the ready check icon. And since oUF is already handling all the conditionals for when to show these I would pretty much have to redo all these things from scratch to make them work like I want them to...
  Reply With Quote
03-01-11, 08:13 PM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
You could use a tag or separate tags instead that handle/s all that. Showing things like "C" for combat, "L" for lead, etc... A text string would handle the position automatically.

Afaik, textures work within tags, too. There was a topic around here about this.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
03-02-11, 04:45 AM   #5
hankthetank
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 64
oUF_Hank does that

Config option:

lua Code:
  1. -- Visibility and order of player status icons (combination of the following placeholders)
  2. -- C: Combat
  3. -- R: Rested
  4. -- P: PvP
  5. -- M: Loot master
  6. -- A: Assistant
  7. -- L: Leader
  8. StatusIcons = "CRAL",

Update function:

lua Code:
  1. -- Manual status icons update
  2. oUF_Hank.UpdateStatus = function(self)
  3.     -- Attach the first icon to the right border of self.power
  4.     local lastElement = {"BOTTOMRIGHT", self.power, "TOPRIGHT"}
  5.  
  6.     -- Status icon texture names and conditions
  7.     local icons = {
  8.         ["C"] = {"Combat", UnitAffectingCombat("player")},
  9.         ["R"] = {"Resting", IsResting()},
  10.         ["L"] = {"Leader", IsPartyLeader()},
  11.         ["M"] = {"MasterLooter", ({GetLootMethod()})[1] == "master" and (
  12.                 (({GetLootMethod()})[2]) == 0 or
  13.                 ((({GetLootMethod()})[2]) and UnitIsUnit("player", "party" .. ({GetLootMethod()})[2])) or
  14.                 ((({GetLootMethod()})[3]) and UnitIsUnit("player", "raid" .. ({GetLootMethod()})[3]))
  15.             )},
  16.         ["P"] = {"PvP", UnitIsPVPFreeForAll("player") or UnitIsPVP("player")},
  17.         ["A"] = {"Assistant", UnitInRaid("player") and UnitIsRaidOfficer("player") and not UnitIsPartyLeader("player")},
  18.     }
  19.    
  20.     for i = -1, -string.len(cfg.StatusIcons), -1 do
  21.         if icons[string.sub(cfg.StatusIcons, i, i)][2] then
  22.             self[icons[string.sub(cfg.StatusIcons, i, i)][1]]:ClearAllPoints()
  23.             self[icons[string.sub(cfg.StatusIcons, i, i)][1]]:SetPoint(unpack(lastElement))
  24.             self[icons[string.sub(cfg.StatusIcons, i, i)][1]]:Show()
  25.             -- Arrange any successive icon to the last one
  26.             lastElement = {"RIGHT", self[icons[string.sub(cfg.StatusIcons, i, i)][1]], "LEFT"}
  27.         else
  28.             -- Condition for displaying the icon not met
  29.             self[icons[string.sub(cfg.StatusIcons, i, i)][1]]:Hide()
  30.         end
  31.     end
  32. end

sharedStyle:

lua Code:
  1. -- Remove invalid or duplicate placeholders
  2. local fixedString = ""
  3.  
  4. for placeholder in string.gmatch(cfg.StatusIcons, "[CRPMAL]") do
  5.     fixedString = fixedString .. (string.match(fixedString, placeholder) and "" or placeholder)
  6. end
  7.  
  8. cfg.StatusIcons = fixedString
  9.  
  10. -- Create the status icons
  11. for i, icon in ipairs({
  12.     {"C", "Combat"},
  13.     {"R", "Resting"},
  14.     {"L", "Leader"},
  15.     {"M", "MasterLooter"},
  16.     {"P", "PvP"},
  17.     {"A", "Assistant"},
  18. }) do
  19.     if string.match(cfg.StatusIcons, icon[1]) then
  20.         self[icon[2]] = self:CreateTexture(nil, "OVERLAY")
  21.         self[icon[2]]:SetSize(24, 24)
  22.         self[icon[2]]:SetTexture("Interface\\AddOns\\oUF_Hank_v3\\textures\\statusicons.blp")
  23.         self[icon[2]]:SetTexCoord((i - 1) * 24 / 256, i * 24 / 256, 0, 24 / 32)
  24.         self[icon[2]].Override = oUF_Hank.UpdateStatus
  25.     end
  26.    
  27. end
  28.  
  29. -- Anchoring handled in UpdateStatus()


Last edited by hankthetank : 03-02-11 at 04:58 AM.
  Reply With Quote
03-03-11, 02:10 AM   #6
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
I believe it's even possible to get the actual icons working via tags:

something like this:

local combaticon = '|TInterface\\path\\to the\\actual\\icon:0:0:0:1|t
  Reply With Quote
03-03-11, 02:43 AM   #7
hankthetank
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 64
It surely is

http://www.wowpedia.org/UI_escape_sequences

I prefered my way so I have more control over the textures. Things like possible future or user edited vertex-coloring, anchoring etc.

The tag solution is easier to maintain as you can rely on the logics offered by oUF. You'd create empty elements like:

lua Code:
  1. self.Leader = self:CreateTexture()
  2. self.Resting = self:CreateTexture()
  3. -- and so on

Then you'd need a tag that updates with already existing standard tags:

lua Code:
  1. oUF.TagEvents["myIcons"] = oUF.TagEvents["resting"] .. " " .. oUF.TagEvents["leader"] -- etc.
  2.  
  3. oUF.Tags["xpRep"] = function(unit)
  4.     local ret = ""
  5.     local frame = _G["SomehowBuildTheUFNameFromThe" .. unit]
  6.  
  7.     ret = ret .. (frame.Leader:IsShown() and "|T.......|t" or "")
  8.     ret = ret .. (frame.Resting:IsShown() and "|T.......|t" or "")
  9.     return ret
  10. end

If you don't want to reference a frame inside a tag it goes down to my attempt just with building a string instead of anchoring elements which is where I would prefer the usage of actual oUF elements / textures.

Anyway, I think he got it now.

Last edited by hankthetank : 03-03-11 at 02:52 AM.
  Reply With Quote
03-05-11, 06:04 AM   #8
sippeangelo
A Defias Bandit
Join Date: Mar 2011
Posts: 3
Awesome, thanks!
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Dynamic indicator positioning (Like PitBull)


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