unitframes: option to use fallback 2d portrait

This commit is contained in:
shagu
2017-01-06 19:56:38 +01:00
parent 18fca002ae
commit 4cf5fddb47
3 changed files with 29 additions and 8 deletions
+27 -8
View File
@@ -314,13 +314,21 @@ function pfUI.uf:CreatePortrait(frame, pos, spacing)
local id = frame.id or ""
local unitstr = unit .. id
frame.portrait = CreateFrame("PlayerModel", "pfPortrait" .. unitstr, frame)
frame.portrait = CreateFrame("Frame", "pfPortrait" .. unitstr, frame)
frame.portrait:RegisterEvent("UNIT_PORTRAIT_UPDATE")
frame.portrait:RegisterEvent("UNIT_MODEL_CHANGED")
frame.portrait:RegisterEvent("PLAYER_ENTERING_WORLD")
frame.portrait:RegisterEvent("PLAYER_TARGET_CHANGED")
frame.portrait.base = frame
frame.portrait.pos = pos
frame.portrait.tex = frame.portrait:CreateTexture("pfPortraitTexture" .. unitstr, "OVERLAY")
frame.portrait.tex:SetAllPoints(frame.portrait)
frame.portrait.tex:SetTexCoord(.1, .9, .1, .9)
frame.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. unitstr, frame.portrait)
frame.portrait.model:SetAllPoints(frame.portrait)
frame.portrait:SetScript("OnEvent", function()
local unit = this.base.label
@@ -380,18 +388,29 @@ function pfUI.uf:UpdatePortrait()
local unitstr = unit .. id
local name = UnitName(unitstr) or ""
if this.name then this:SetCamera(0) end
if this.name == name then return end
if not UnitIsVisible(unitstr) or not UnitIsConnected(unitstr) then
this:SetModelScale(4.25)
this:SetPosition(0, 0, -1.0)
this:SetModel("Interface\\Buttons\\talktomequestionmark.mdx")
if this.pos == "bar" then
this.tex:Hide()
this.model:Hide()
elseif pfUI_config.unitframes.portraittexture == "1" then
this.tex:Show()
this.model:Hide()
SetPortraitTexture(this.tex, unitstr)
else
this.tex:Hide()
this.model:Show()
this.model:SetModelScale(4.25)
this.model:SetPosition(0, 0, -1)
this.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx")
end
this.name = nil
else
this:SetUnit(unitstr)
this:SetCamera(0)
this.tex:Hide()
this.model:Show()
this.model:SetUnit(unitstr)
this.model:SetCamera(0)
this.name = name
end
end