Code:
Regarding the question mark model: It's there because most people want it. Complaining about it now is kinda... just too late. 1.4 is already pushed and such a change would only be considered for 1.5, which probably won't happen any time soon.
It wasn't a complaint, just a question.
And I don't think it would be such a big change, neither. But it's ok if we can do something like portraits:Hide() for those condititons, somewhere.
Anyway, I'm still not quite sure how to set an alpha for portraits, now. I tried to set the alpha via the function I was using to update the alpha in 1.3.28 and to hide the portraits, if not available (disconnected, etc.). Mhm, I keep trying...
That's what I used in 1.3.28
Code:
local updatePortrait = function(self, event, unit)
if (not UnitExists(self.unit) or not UnitIsConnected(self.unit) or not UnitIsVisible(self.unit)) then
self.Portrait:SetAlpha(0)
else
self.Portrait:SetAlpha(cfgs.pAlpha)
end
end
and this for "if (unit == "player") or ... etc."
Code:
table.insert(self.__elements, updatePortrait)
Not quite sure where to put this now (putting the insert table thing into the unit specific function resulted in an error).
I want to use a "Shared" function, that contains the shared stuff (what's used on every unit, like health, power, ...). And a "UnitSpecific" function that contains the unit specific stuff.
And finally functions that contain stuff like castbar, portrait, whatever.
Something like that ...
NOTE: I did put the portrait code in the shared style, because I "hacked" the portraits.lua and put in the alpha. What I really want is to put the portrait code into it's own function, like I did it with the castbar code. This way I can include the functions for every unit I want them to use for in the UnitSpecific function.
Code:
-- shared style
local Shared = function(self, unit)
self.menu = menu
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
self:RegisterForClicks"anyup"
self:SetAttribute("*type2", "menu")
-- hp
local hp = CreateFrame("StatusBar", nil, self)
hp:SetHeight(Ncfgfs.height.L)
hp:SetStatusBarTexture(Ncfgm.HPtex)
hp:SetPoint"TOP"
hp:SetPoint"LEFT"
hp:SetPoint"RIGHT"
hp:SetStatusBarColor(unpack(Ncfgc.maincolor))
hp.frequentUpdates = true
self.Health = hp
-- hp border
self.Glow = CreateFrame("Frame", nil, hp)
self.Glow:SetPoint("TOPLEFT", hp, "TOPLEFT", -2, 2)
self.Glow:SetPoint("BOTTOMRIGHT", hp, "BOTTOMRIGHT", 2, -2)
self.Glow:SetBackdrop{edgeFile = Ncfgm.glowtex, edgeSize = 8, insets = {left = 0, right = 0, top = 0, bottom = 0}}
self.Glow:SetBackdropColor(0, 0, 0, 0)
self.Glow:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))
-- hp bg
local hpBG = hp:CreateTexture(nil, "BORDER")
hpBG:SetAllPoints(hp)
hpBG:SetAlpha(.5)
hpBG:SetTexture(Ncfgm.Itex)
hp.bg = hpBG
-- pp
local pp = CreateFrame("StatusBar", nil, self)
pp:SetWidth(Ncfgfs.width.L)
pp:SetHeight(4)
pp:SetStatusBarTexture(Ncfgm.PPtex)
pp:SetPoint("TOP", hp, "BOTTOM", 0, -4)
pp.frequentUpdates = true
pp.colorPower = true
self.Power = pp
-- pp border
self.Glow.pp = CreateFrame("Frame", nil, pp)
self.Glow.pp:SetPoint("TOPLEFT", pp, "TOPLEFT", -1.75, 2)
self.Glow.pp:SetPoint("BOTTOMRIGHT", pp, "BOTTOMRIGHT", 2, -1.75)
self.Glow.pp:SetBackdrop{edgeFile = Ncfgm.glowtex2, edgeSize = 6, insets = {left = -2, right = -2, top = -2, bottom = -2}}
self.Glow.pp:SetBackdropColor(0, 0, 0, 0)
self.Glow.pp:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))
-- pp bg
local ppBG = pp:CreateTexture(nil, 'BORDER')
ppBG:SetAllPoints()
ppBG:SetTexture(Ncfgm.Itex)
ppBG:SetAlpha(.5)
ppBG.multiplier = 0.4
pp.bg = ppBG
-- portraits
local portrait = CreateFrame("PlayerModel", nil, hp)
portrait:SetPoint("TOPLEFT", hp, "TOPLEFT", 0, 0)
portrait:SetPoint("BOTTOMRIGHT", hp, "BOTTOMRIGHT", 0, 0)
portrait:SetAlpha(Ncfgs.pAlpha)
self.Portrait = portrait
-- enable colors
self.colors = colors
end
-- castbar
local createCastbar = function(self, unit)
local cb = CreateFrame("StatusBar", nil, self)
cb:SetStatusBarTexture(Ncfgm.CBtex)
cb:SetStatusBarColor(unpack(Ncfgc.trdcolor))
--cb:SetAllPoints(self.Health)
cb:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 1.75, -2)
cb:SetPoint("BOTTOMRIGHT", self.Health, "BOTTOMRIGHT", -2, 1.75)
cb:SetToplevel(true)
self.Castbar = cb
cb.Text = cb:CreateFontString(nil, 'ARTWORK')
cb.Text:SetPoint("LEFT", cb, "LEFT", 6, 0)
cb.Text:SetJustifyH("LEFT")
cb.Text:SetFont(Ncfgm.NameFont, Ncfgm.CastFS, Ncfgm.FontF)
cb.Text:SetTextColor(unpack(Ncfgc.sndcolor))
cb.Time = cb:CreateFontString(nil, 'ARTWORK')
cb.Time:SetPoint("RIGHT", cb, "RIGHT", -22, 0)
cb.Time:SetFont(Ncfgm.NumbFont, Ncfgm.CastFS, Ncfgm.fontFNum)
cb.Time:SetJustifyH('RIGHT')
cb.Time:SetTextColor(unpack(Ncfgc.sndcolor))
cb.Time2 = cb:CreateFontString(nil, 'ARTWORK')
cb.Time2:SetPoint("TOPLEFT", cb.Time, "TOPRIGHT", -4, 0)
cb.Time2:SetFont(Ncfgm.NumbFont, Ncfgm.CastFS, Ncfgm.fontFNum)
cb.Time2:SetJustifyH('RIGHT')
cb.Time2:SetTextColor(unpack(Ncfgc.sndcolor))
cb.CustomTimeText = CustomTimeText
if Ncfgs.useSpellIcon == true then
cb.Icon = cb:CreateTexture(nil, 'BACKGROUND')
cb.Icon:SetHeight(Ncfgfs.height.L+8)
cb.Icon:SetWidth(Ncfgfs.height.L+8)
cb.Icon:SetTexCoord(0.1,0.9,0.1,0.9)
cb.Icon:SetPoint("TOPRIGHT", self, "TOPLEFT", -8, 0)
cb.IconGlow = CreateFrame("Frame", nil, cb)
cb.IconGlow:SetPoint("TOPLEFT", cb.Icon, "TOPLEFT", -2, 2)
cb.IconGlow:SetPoint("BOTTOMRIGHT", cb.Icon, "BOTTOMRIGHT", 2, -2)
cb.IconGlow:SetBackdrop{edgeFile = Ncfgm.glowtex, edgeSize = 8, insets = {left = 0, right = 0, top = 0, bottom = 0}}
cb.IconGlow:SetBackdropColor(0, 0, 0, 0)
cb.IconGlow:SetBackdropBorderColor(unpack(Ncfgc.brdcolor))
end
cb.bg1 = cb:CreateTexture(nil, "BORDER")
cb.bg1:SetAllPoints(cb)
cb.bg1:SetTexture(Ncfgm.Itex)
cb.bg1:SetVertexColor(44/255, 40/255, 67/255)
cb.bg1:SetAlpha(0.6)
end
-- unit specific style
local UnitSpecific = {
player = function(self)
Shared(self)
createCastbar(self)
self:SetAttribute('initial-height', Ncfgfs.height.L)
self:SetAttribute('initial-width', Ncfgfs.width.L)
end,
target = function(self)
Shared(self)
createCastbar(self)
self:SetAttribute('initial-height', Ncfgfs.height.L)
self:SetAttribute('initial-width', Ncfgfs.width.L)
end,
focus = function(self)
Shared(self)
createCastbar(self)
self:SetAttribute('initial-height', Ncfgfs.height.L)
self:SetAttribute('initial-width', Ncfgfs.width.L)
end,
pet = function(self)
Shared(self)
self.Power:SetWidth(Ncfgfs.width.S)
self:SetAttribute('initial-height', Ncfgfs.height.S)
self:SetAttribute('initial-width', Ncfgfs.width.S)
end,
targettarget = function(self)
Shared(self)
self.Power:SetWidth(Ncfgfs.width.S)
self:SetAttribute('initial-height', Ncfgfs.height.S)
self:SetAttribute('initial-width', Ncfgfs.width.S)
end,
focustarget = function(self)
Shared(self)
self.Power:SetWidth(Ncfgfs.width.S)
self:SetAttribute('initial-height', Ncfgfs.height.S)
self:SetAttribute('initial-width', Ncfgfs.width.S)
end,
boss = function(self)
Shared(self)
self.Power:SetWidth(Ncfgfs.width.M)
self:SetAttribute('initial-height', Ncfgfs.height.M)
self:SetAttribute('initial-width', Ncfgfs.width.M)
end,
MainTank = function(self)
Shared(self)
self.Power:SetWidth(Ncfgfs.width.M)
self:SetAttribute('initial-height', Ncfgfs.height.M)
self:SetAttribute('initial-width', Ncfgfs.width.M)
end,
}
I really need that alpha, because I want to put portraits on top of other things ...
Edit: Would this work ?
Code:
local PostUpdatePortrait = function(portrait, unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
portrait:Hide()
else
portrait:Show()
portrait:SetAlpha(myAlpha)
end
end