09-11-12, 09:06 PM | #1 |
oUF help - again
Hello fellow UI enthusiasts,
Need some help with oUF/unit frame LUA again. http://i.imgur.com/WZnf6.jpg First, as you can see, on mobs with long names the name extends over the health numbers. Same thing happens on focus/target of target except those will just extend over the length of the bar. Is there any way to limit the number of characters shown, or something? Second, my pet bar shows as dark reddish brown no matter what I do... I want it to be the same hunter green as my focus bar. http://i.imgur.com/n8xIo.jpg Code for target frame: Code:
local function CreateTargetStyle(self, unit, isSingle) self.mystyle = "target" lib.init(self) self:SetScale(cfg.scale) self.width = 210 self.height = 34 self:SetSize(self.width,self.height) lib.gen_hpbar(self) lib.gen_tagcontainer(self) lib.gen_hpstrings(self) lib.gen_highlight(self) lib.gen_ppbar(self) lib.gen_RaidMark(self) self.Health.frequentUpdates = false self.Health.Smooth = true if cfg.HealthcolorClass then self.Health.colorClass = true self.Health.colorHealth = true end self.Power.colorTapping = true self.Power.colorDisconnected = true if cfg.Powercolor then self.Power.colorClass = true else self.Power.colorPower = true end self.Power.colorReaction = true self.Power.Smooth = true lib.gen_castbar(self) lib.addQuestIcon(self) lib.createAuras(self) lib.genCPoints(self) if cfg.showPortrait then lib.gen_portrait(self) end end Code:
local function CreatePetStyle(self, unit, isSingle) local _, playerClass = UnitClass("player") self.mystyle = "pet" lib.init(self) self:SetScale(cfg.scale) self.width = 105 self.height = 12 self:SetSize(self.width,self.height) lib.gen_hpbar(self) lib.gen_hpstrings(self) lib.gen_highlight(self) lib.gen_RaidMark(self) self.Health.frequentUpdates = false self.Health.Smooth = true if cfg.HealthcolorClass then self.Health.colorClass = true self.Health.colorHealth = true end Code:
cfg.HealthcolorClass = false -- health color class, false to color health the default color cfg.Powercolor = true -- power color class, false to color power type I cannot thank you all enough for the help, my UI has come a long way in the past few weeks! EDIT: Crap, forgot this one: what is the coding to show a white border around dispellable (purge/tranq) buffs on my target? Last edited by eponine : 09-11-12 at 10:33 PM. |
|
09-11-12, 11:59 PM | #2 |
This is the relevant part from ouf/health.lua
Code:
elseif(health.colorClass and UnitIsPlayer(unit)) or (health.colorClassNPC and not UnitIsPlayer(unit)) or (health.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then local _, class = UnitClass(unit) t = self.colors.class[class] Code:
self.Health.colorClassPet = true |
|
09-12-12, 12:13 AM | #3 | |
I added that line to the pet style so it now looks like this:
Code:
if PlayerClass == "HUNTER" then self.Power.colorReaction = false self.Power.colorClass = false self.Health.colorClassPet = true end
|
||
09-12-12, 12:22 AM | #4 |
playerClass shouldn't start with a capital p. That condition always evaluates to false, the original code has that error too. Just stick it in the main function, not inside that condition. Also seems kind of pointless tbh, colorClass should do nothing with pet frames anyway unless you are in a vehicle when you reload and oUF sends real unitID to style functions not just "pet".
Regarding name strings, make a backup of lib.lua, then under lib.gen_hpstrings, replace this: Code:
local name = lib.gen_fontstring(f.Health, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetJustifyH("LEFT") if f.mystyle == "player" then local name = lib.gen_fontstring(f.Tagcontainer, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetPoint("BOTTOMLEFT", f.Tagcontainer) f:Tag(name, "[color][name][afk]") elseif f.mystyle == "target" then name:SetPoint("BOTTOMLEFT", f.Tagcontainer) f:Tag(name, "[level] [color][name][afk]") elseif f.mystyle == "focus" then name:SetPoint("LEFT", f.Health) f:Tag(name, "[color][name]") elseif f.mystyle == "raidfordps" then name:SetAllPoints(f) f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "partyforhealer" or f.mystyle == "raid25" or f.mystyle == "raid40" then name:SetPoint("CENTER") f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") else name:SetPoint("LEFT") f:Tag(name, "[color][name]") end Code:
local name = lib.gen_fontstring(f.Health, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetJustifyH("LEFT") if f.mystyle == "player" then local name = lib.gen_fontstring(f.Tagcontainer, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name][afk]") elseif f.mystyle == "target" then name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) f:Tag(name, "[level] [color][name][afk]") elseif f.mystyle == "focus" then name:SetPoint("LEFT", f.Health) name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name]") elseif f.mystyle == "raidfordps" then name:SetPoint("center", f, "center") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "partyforhealer" or f.mystyle == "raid25" or f.mystyle == "raid40" then name:SetPoint("CENTER") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") else name:SetPoint("LEFT") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name]") end I'll get back to you on the rest in a couple of hours, servers are down in Europe. Last edited by nailertn : 09-12-12 at 02:26 AM. Reason: set height to cfg.fontsize |
|
09-12-12, 02:19 AM | #5 |
One thing to note about pet frame colour is that pets have their own class. Most of them are considered warriors or paladins IIRC. If you want it green, you should just set it directly in the CreatePetStyle function.
Replace this: Code:
if PlayerClass == "HUNTER" then self.Power.colorReaction = false self.Power.colorClass = false self.Health.colorClassPet = true end Code:
if playerClass == "HUNTER" then local t = self.colors.class[playerClass] self.Health:SetStatusBarColor(t[1], t[2], t[3]) end |
|
09-12-12, 03:38 AM | #6 |
And lastly here is the aura border code. Again, make a backup of lib.lua first.
Delete these: Code:
CreateBorder = function(f,x) h = CreateFrame("Frame", nil, f) h:SetFrameLevel(1) h:SetFrameStrata(f:GetFrameStrata()) h:SetPoint("TOPLEFT", -x, x) h:SetPoint("BOTTOMRIGHT", x, -x) h:SetBackdrop(borders) h:SetBackdropColor(0.1,0.1,0.1,0.6) h:SetBackdropBorderColor(65/255, 74/255, 79/255) end local postUpdateIcon = function(element, unit, button, index) local _, _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, button.filter) if duration and duration > 0 then button.time:Show() button.timeLeft = expirationTime button:SetScript("OnUpdate", setTimer) else button.time:Hide() button.timeLeft = math.huge button:SetScript("OnUpdate", nil) end if(button.debuff) then if(unit == "target") then if (unitCaster == "player" or unitCaster == "vehicle") then button.icon:SetDesaturated(false) elseif(not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don"t desaturate debuffs button:SetBackdropColor(0, 0, 0) button.overlay:SetVertexColor(0.3, 0.3, 0.3) button.icon:SetDesaturated(true) end end end button:SetScript('OnMouseUp', function(self, mouseButton) if mouseButton == 'RightButton' then CancelUnitBuff('player', index) end end) button.first = true end Code:
CreateBorder = function(f,x) h = CreateFrame("Frame", nil, f) h:SetFrameLevel(1) h:SetFrameStrata(f:GetFrameStrata()) h:SetPoint("TOPLEFT", -x, x) h:SetPoint("BOTTOMRIGHT", x, -x) h:SetBackdrop(borders) h:SetBackdropColor(0.1,0.1,0.1,0.6) h:SetBackdropBorderColor(65/255, 74/255, 79/255) f.something_unique = h end local dispell_lists = { DRUID = { Curse = true, Poison = true }, MAGE = { Curse = true }, PALADIN = { Disease = true, Magic = true, Poison = true }, PRIEST = { Disease = true, Magic = true }, SHAMAN = { Curse = true, Disease = true, Poison = true } } local dispell_list = dispell_lists[select(2, UnitClass("player"))] local postUpdateIcon = function(element, unit, button, index) local _, _, _, _, debuff_type, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, button.filter) if duration and duration > 0 then button.time:Show() button.timeLeft = expirationTime button:SetScript("OnUpdate", setTimer) else button.time:Hide() button.timeLeft = math.huge button:SetScript("OnUpdate", nil) end if(button.debuff) then if(unit == "target") then if (unitCaster == "player" or unitCaster == "vehicle") then button.icon:SetDesaturated(false) elseif(not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don"t desaturate debuffs button:SetBackdropColor(0, 0, 0) button.overlay:SetVertexColor(0.3, 0.3, 0.3) button.icon:SetDesaturated(true) end end end button:SetScript('OnMouseUp', function(self, mouseButton) if mouseButton == 'RightButton' then CancelUnitBuff('player', index) end end) button.first = true if unit == "target" and UnitCanAssist("player", "target") and button.debuff and debuff_type and dispell_list and dispell_list[debuff_type] then button.something_unique:SetBackdropBorderColor(1,0,0) else button.something_unique:SetBackdropBorderColor(65/255, 74/255, 79/255) end end Last edited by nailertn : 09-12-12 at 03:46 AM. |
|
09-12-12, 05:44 AM | #7 | |
Code:
local health = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") health:SetPoint("RIGHT", frame, "RIGHT", -4, 0) local name = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") name:SetPoint("LEFT", frame, "LEFT", 4, 0) name:SetPoint("RIGHT", health, "LEFT", -4, 0)
__________________
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. |
||
09-12-12, 07:47 AM | #8 |
Sorry guys, I went to bed. But I am checking all of these suggestions out right now. Thanks, will update
Also, thank you for moving this to the oUF forum. I did not even know there was one. edit: Nailertn, what you suggested for truncating the name worked perfectly. It now says RAIDER'S TRAINING DU... - except for some reason it messed up my player/pet/target frames and I don't know how to fix it. See: http://i.imgur.com/KvVDu.jpg Have not tried the aura coding yet because I'll need somebody to have dispellable buffs to test it with first, but will try when I can. I also tried what you said for pet frame color, and while it worked I decided I don't like it, lol it now looks like this: http://i.imgur.com/BGWb0.jpg So new question, could you tell me what I'd need to change to make my pet frame look like my ToT frame? ie the greyish color and hunter-green text? @Phanx, will that code stretch the text so it looks narrower, or will it shrink the font to fit? I don't want bunched up text when my target has a super long name, but smaller would be fine. Thanks guys! Last edited by eponine : 09-12-12 at 08:39 AM. |
|
09-12-12, 02:33 PM | #9 | |
If you wanted to make the text size smaller for units with really long names, you could register for the UNIT_NAME event on your frame, and handle setting the text yourself, instead of using a tag: Code:
local playerRealm = GetRealmName() local function UpdateName(frame, event, unit) local name, realm = UnitName(unit) if realm and realm ~= "" and realm ~= playerRealm then name = format("%s-%s", name, realm) end local font, _, outline = frame.Name:GetFont() if strlen(name) > 20 then -- change 20 to however many characters usually fit frame.Name:SetFont(font, 14, outline) -- small size for long names else frame.Name:SetFont(font, 18, outline) -- normal size for short names end frame.Name:SetText(name) end local function Spawn(frame, unit, single) -- do stuff here frame.Name = frame:CreateFontString() -- configure name font string here -- register your name update function: frame:RegisterEvent("UNIT_NAME_UPDATE", UpdateName) -- do more stuff here end
__________________
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. |
||
09-12-12, 03:48 PM | #10 | |||
Code:
lib.updateHealth = function(bar, unit, min, max) local color, t = {1, 0, 0} if(UnitIsPlayer(unit)) then local _, class = UnitClass(unit) t = bar:GetParent().colors.class[class] end if(t) then r, g, b = t[1], t[2], t[3] elseif unit == "pet" then t = oUF.colors.class[select(2, UnitClass("player"))] r, g, b = t[1], t[2], t[3] else r, g, b = 1, 0, 0 end if not cfg.HealthcolorClass then bar.bg:SetVertexColor(r, g, b, 0.35) else bar.bg:SetVertexColor(1, 0.2, 0.2, 0.15) end end Code:
local name = lib.gen_fontstring(f.Health, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetJustifyH("LEFT") if f.mystyle == "player" then local name = lib.gen_fontstring(f.Tagcontainer, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) name:SetJustifyH("LEFT") f:Tag(name, "[color][name][afk]") elseif f.mystyle == "target" then name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) f:Tag(name, "[level] [color][name][afk]") elseif f.mystyle == "focus" then name:SetPoint("LEFT", f.Health) name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name]") elseif f.mystyle == "raidfordps" then name:SetPoint("center", f, "center") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "partyforhealer" or f.mystyle == "raid25" or f.mystyle == "raid40" then name:SetPoint("CENTER") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "pet" then name:SetPoint("LEFT") name:SetSize(50, cfg.fontsize) name:SetVertexColor(unpack(f.colors.class[select(2, UnitClass("player"))])) f:Tag(name, "[name]") else name:SetPoint("LEFT") name:SetSize(50, cfg.fontsize) f:Tag(name, "[color][name]") end
Frankly if you don't know Lua you have to use layouts as they are. People are generally willing to help with basic stuff but you have to make very sure you know exactly what you want. When you ask for multiple implementations just because you don't fancy the first, it is time to learn Lua or switch to more user friendly unit frames. Last edited by nailertn : 09-12-12 at 06:12 PM. |
||||
09-12-12, 04:54 PM | #11 | ||
Thanks Phanx, I'll try that when I get home.
Also I do have the justify code in there but my player name is still appearing in the center, for some reason. Code:
local name = lib.gen_fontstring(f.Health, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetJustifyH("LEFT") if f.mystyle == "player" then local name = lib.gen_fontstring(f.Tagcontainer, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(155, cfg.fontsize) f:Tag(name, "[color][name][afk]")
Last edited by eponine : 09-12-12 at 05:10 PM. |
|||
09-12-12, 06:17 PM | #12 |
I know how daunting it is, a few years ago I was exactly where you are now: staring at an oUF layout with zero coding knowledge.
Code:
local name = lib.gen_fontstring(f.Health, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetJustifyH("LEFT") -- this line aligns name to the left on all frames except for player frame if f.mystyle == "player" then local name = lib.gen_fontstring(f.Tagcontainer, cfg.font, cfg.fontsize, cfg.fontstyle) name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) -- this line sets name width for player frame name:SetJustifyH("LEFT") -- this line aligns name to the left on the player frame f:Tag(name, "[color][name][afk]") elseif f.mystyle == "target" then name:SetPoint("BOTTOMLEFT", f.Tagcontainer) name:SetSize(50, cfg.fontsize) -- this line sets name width for target frame f:Tag(name, "[level] [color][name][afk]") elseif f.mystyle == "focus" then name:SetPoint("LEFT", f.Health) name:SetSize(50, cfg.fontsize) -- this line sets name width for focus frame f:Tag(name, "[color][name]") elseif f.mystyle == "raidfordps" then name:SetPoint("center", f, "center") name:SetSize(50, cfg.fontsize) -- this line sets name width for raid frames f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "partyforhealer" or f.mystyle == "raid25" or f.mystyle == "raid40" then name:SetPoint("CENTER") name:SetSize(50, cfg.fontsize) -- this line sets name width for party frames f:Tag(name, "[color][name][afk]") name:SetJustifyH("CENTER") elseif f.mystyle == "pet" then name:SetPoint("LEFT") name:SetSize(50, cfg.fontsize) -- this line sets name width for pet frames name:SetVertexColor(unpack(f.colors.class[select(2, UnitClass("player"))])) -- this line f:Tag(name, "[name]") else name:SetPoint("LEFT") name:SetSize(50, cfg.fontsize) -- this line sets name width for any frames not specified above, including target of target frame f:Tag(name, "[color][name]") end Last edited by nailertn : 09-12-12 at 06:25 PM. |
|
09-12-12, 06:41 PM | #13 | |
If you're using anchors to control the width, you can anchor the font string to the whole frame to make sure it doesn't spill out of the frame, but not cut it off as long as it's not wider than the frame: Code:
elseif f.mystyle == "pet" then name:SetPoint("LEFT") -- this is already there name:SetPoint("RIGHT") -- add this
__________________
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. |
||
09-12-12, 08:09 PM | #14 |
Okay, that last bit of code worked perfectly.
Only problem I have now is my pet's name doesn't seem to be showing, OR it is hunter-green so it's not showing on the bar. I replaced that "Change lib.updateHealth to this" code but it didn't change anything. I realize this are very specific requests, as I'm quite nitpicky about small things, so just let me know if I'm asking too much. Every explanation helps me understand LUA more so eventually I won't have to ask (hopefully) Thank you so much. edit: here's what I'm talking about regarding the pet frames: http://i.imgur.com/MNtbo.png Seems like the font and the bar color are both class-color for my hunter only edit again: removed the "if hunter" lines from core.lua and that fixed it. See, I'm learning already. Last edited by eponine : 09-12-12 at 08:33 PM. |
|
09-12-12, 11:44 PM | #15 |
After my second post the servers went live and I have tested everything since then with the version that's available right here on Wowinterface. If you don't get the expected results some other modification you made is interfering or you did not undo the original change you asked for, which it sounds like.
|
|
09-13-12, 08:07 AM | #16 |
Everything is working perfectly now
Thank you so much for your help. |
|
WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF help - again |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|