Skip to content

Commit

Permalink
Added new feature "Faction icon in BG".
Browse files Browse the repository at this point in the history
  • Loading branch information
Wetxius committed Nov 6, 2013
1 parent b73c9df commit 6ed3e62
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
60 changes: 60 additions & 0 deletions ShestakUI/Libs/oUF/Modules/FactionIcon.lua
@@ -0,0 +1,60 @@
local T, C, L = unpack(select(2, ...))
if C.unitframe.enable ~= true or C.unitframe.show_arena ~= true then return end

----------------------------------------------------------------------------------------
-- Based on oUF_PVPSpecIcons
----------------------------------------------------------------------------------------

local _, ns = ...
local oUF = ns.oUF or oUF

local Update = function(self, event, unit)
if event == 'ARENA_OPPONENT_UPDATE' and unit ~= self.unit then return; end
local specIcon = self.FactionIcon

local _, instanceType = IsInInstance();
specIcon.instanceType = instanceType

if(specIcon.PreUpdate) then specIcon:PreUpdate(event) end

if instanceType == 'pvp' then
local faction = UnitFactionGroup(self.unit)
if faction == "Horde" then
specIcon.Icon:SetTexture([[Interface\Icons\INV_BannerPVP_01]])
elseif faction == "Alliance" then
specIcon.Icon:SetTexture([[Interface\Icons\INV_BannerPVP_02]])
else
specIcon.Icon:SetTexture([[INTERFACE\ICONS\INV_MISC_QUESTIONMARK]])
end
end

if(specIcon.PostUpdate) then specIcon:PostUpdate(event) end
end

local Enable = function(self)
local specIcon = self.FactionIcon
if specIcon then
self:RegisterEvent("ARENA_OPPONENT_UPDATE", Update, true)
self:RegisterEvent("PLAYER_ENTERING_WORLD", Update, true)

if not specIcon.Icon then
specIcon.Icon = specIcon:CreateTexture(nil, "BORDER")
specIcon.Icon:SetPoint("TOPLEFT", specIcon, 2, -2)
specIcon.Icon:SetPoint("BOTTOMRIGHT", specIcon, -2, 2)
specIcon.Icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
end
specIcon:Show()
return true
end
end

local Disable = function(self)
local specIcon = self.FactionIcon
if specIcon then
self:UnregisterEvent("ARENA_OPPONENT_UPDATE", Update)
self:UnregisterEvent("PLAYER_ENTERING_WORLD", Update)
specIcon:Hide()
end
end

oUF:AddElement('FactionIcon', Update, Enable, Disable)
1 change: 1 addition & 0 deletions ShestakUI/Libs/oUF/oUF.xml
Expand Up @@ -44,6 +44,7 @@
<Script file="Modules\CombatFeedback.lua"/>
<Script file="Modules\DebuffHighlight.lua"/>
<Script file="Modules\Experience.lua"/>
<Script file="Modules\FactionIcon.lua"/>
<Script file="Modules\Fader.lua"/>
<Script file="Modules\Friendship.lua"/>
<Script file="Modules\GCD.lua"/>
Expand Down
7 changes: 7 additions & 0 deletions ShestakUI/Modules/UnitFrames/Layout.lua
Expand Up @@ -950,12 +950,19 @@ local function Shared(self, unit)
if C.unitframe.show_arena and unit == "arena" then
self.Trinket = CreateFrame("Frame", self:GetName().."_Trinket", self)
self.Trinket:SetSize(31, 31)

self.FactionIcon = CreateFrame("Frame", nil, self)
self.FactionIcon:SetSize(31, 31)

if C.unitframe.arena_on_right == true then
self.Trinket:SetPoint("TOPRIGHT", self, "TOPLEFT", -5, 2)
self.FactionIcon:SetPoint("TOPRIGHT", self, "TOPLEFT", -5, 2)
else
self.Trinket:SetPoint("TOPLEFT", self, "TOPRIGHT", 5, 2)
self.FactionIcon:SetPoint("TOPLEFT", self, "TOPRIGHT", 5, 2)
end
self.Trinket:SetTemplate("Default")
self.FactionIcon:SetTemplate("Default")

self.AuraTracker = CreateFrame("Frame", nil, self)
self.AuraTracker:SetWidth(self.Trinket:GetWidth())
Expand Down

0 comments on commit 6ed3e62

Please sign in to comment.