Quantcast

add arena frame

rawoil [08-16-21 - 07:30]
add arena frame
Filename
oUF_Simple/core/functions.lua
oUF_Simple/core/spawn.lua
oUF_Simple/core/style.lua
oUF_Simple/modules/oUF_Trinkets.lua
oUF_Simple/oUF_Simple.toc
oUF_Simple/templates/arena.lua
oUF_SimpleConfig/arena.lua
oUF_SimpleConfig/oUF_SimpleConfig.toc
diff --git a/oUF_Simple/core/functions.lua b/oUF_Simple/core/functions.lua
index 92add3c..15e0ba3 100644
--- a/oUF_Simple/core/functions.lua
+++ b/oUF_Simple/core/functions.lua
@@ -631,4 +631,24 @@ local function ToggleSmooth(self, enabled)
   if self.Power then self.Power.smoothing = enabled end
   if self.HealthPrediction then self.HealthPrediction.smoothing = enabled end
 end
-L.F.ToggleSmooth = ToggleSmooth
\ No newline at end of file
+L.F.ToggleSmooth = ToggleSmooth
+
+--CreateTrinket
+local function CreateTrinket(self)
+  if not self.cfg.trinket or not self.cfg.trinket.enabled then return end
+
+  local s = CreateFrame("Frame", nil, self)
+  s:SetSize(self.cfg.trinket.size, self.cfg.trinket.size)
+  SetPoint(s,self,self.cfg.trinket.point)
+  --backdrop
+  CreateBackdrop(s)
+  --icon
+  local i = s:CreateTexture(nil, "ARTWORK")
+  i:SetAllPoints()
+  i:SetTexture(select(2, UnitFactionGroup("player")) == "Horde" and "Interface\\Icons\\inv_jewelry_trinketpvp_01" or "Interface\\Icons\\inv_jewelry_trinketpvp_02")
+  i:SetTexCoord(0.1, 0.9, 0.1, 0.9)
+  s.Icon = i
+
+  return s
+end
+L.F.CreateTrinket = CreateTrinket
\ No newline at end of file
diff --git a/oUF_Simple/core/spawn.lua b/oUF_Simple/core/spawn.lua
index 7e736a0..5866e91 100644
--- a/oUF_Simple/core/spawn.lua
+++ b/oUF_Simple/core/spawn.lua
@@ -28,6 +28,7 @@ if L.F.CreatePartyStyle then oUF:RegisterStyle(A.."Party", L.F.CreatePartyStyle)
 if L.F.CreateBossStyle then oUF:RegisterStyle(A.."Boss", L.F.CreateBossStyle) end
 if L.F.CreateNamePlateStyle then oUF:RegisterStyle(A.."Nameplate",L.F.CreateNamePlateStyle) end
 if L.F.CreateRaidStyle then oUF:RegisterStyle(A.."Raid", L.F.CreateRaidStyle) end
+if L.F.CreateArenaStyle then oUF:RegisterStyle(A.."Arena", L.F.CreateArenaStyle) end

 -----------------------------
 -- Spawn Units
@@ -163,3 +164,17 @@ if L.F.CreateRaidStyle then
   end
 end

+--spawn arena frames
+if L.F.CreateArenaStyle then
+  oUF:SetActiveStyle(A.."Arena")
+  local arena = {}
+  for i = 1, 5 do
+    arena[i] = oUF:Spawn("arena"..i, A.."Arena"..i)
+    if (i == 1) then
+      arena[i]:SetPoint(unpack(L.C.arena.point))
+    else
+      arena[i]:SetPoint(L.C.arena.setup.point, arena[i-1], L.C.arena.setup.relativePoint, L.C.arena.setup.xOffset, L.C.arena.setup.yOffset)
+    end
+  end
+  SetCVar("showArenaEnemyFrames", 0)
+end
\ No newline at end of file
diff --git a/oUF_Simple/core/style.lua b/oUF_Simple/core/style.lua
index da3920e..1b523eb 100644
--- a/oUF_Simple/core/style.lua
+++ b/oUF_Simple/core/style.lua
@@ -41,5 +41,6 @@ local function CreateStyle(self)
   self.ReadyCheckIndicator = L.F.CreateReadyCheck(self)
   self.RaidDebuffs = L.F.CreateRaidDebuffs(self)
   self.Range = L.F.CreateRange(self)
+  self.Trinket = L.F.CreateTrinket(self)
 end
 L.F.CreateStyle = CreateStyle
\ No newline at end of file
diff --git a/oUF_Simple/modules/oUF_Trinkets.lua b/oUF_Simple/modules/oUF_Trinkets.lua
new file mode 100644
index 0000000..ac406d7
--- /dev/null
+++ b/oUF_Simple/modules/oUF_Trinkets.lua
@@ -0,0 +1,78 @@
+local _, ns = ...
+local oUF = ns.oUF or oUF
+assert(oUF, 'oUF not loaded')
+
+local Update = function(self, event, ...)
+	local _, instanceType = IsInInstance()
+
+	if instanceType ~= 'arena' then
+		self.Trinket.Icon:SetTexture(select(2, UnitFactionGroup("player")) == "Horde" and "Interface\\Icons\\inv_jewelry_trinketpvp_01" or "Interface\\Icons\\inv_jewelry_trinketpvp_02")
+		self.Trinket:Hide()
+
+		return
+	else
+		self.Trinket:Show()
+	end
+
+	if(self.Trinket.PreUpdate) then self.Trinket:PreUpdate(event, ...) end
+
+	if event == "ARENA_COOLDOWNS_UPDATE" then
+		local unit = ...
+		local tunit = self.unit
+
+		if self.unit == unit then
+			C_PvP.RequestCrowdControlSpell(unit)
+
+			local spellID, startTime, duration = C_PvP.GetArenaCrowdControlInfo(unit)
+
+			if spellID and startTime ~= 0 and duration ~= 0 then
+				CooldownFrame_Set(self.Trinket.cooldownFrame, startTime / 1000, duration / 1000, 1)
+			end
+		end
+	elseif event == "ARENA_CROWD_CONTROL_SPELL_UPDATE" then
+		local unit, spellID = ...
+
+		if self.unit == unit then
+			local _, _, spellTexture = GetSpellInfo(spellID)
+
+			self.Trinket.Icon:SetTexture(spellTexture)
+		end
+	elseif event == 'PLAYER_ENTERING_WORLD' then
+		CooldownFrame_Set(self.Trinket.cooldownFrame, 1, 1, 1)
+	end
+
+	if(self.Trinket.PostUpdate) then self.Trinket:PostUpdate(event, ...) end
+end
+
+local Enable = function(self)
+	if self.Trinket then
+		self:RegisterEvent("ARENA_COOLDOWNS_UPDATE", Update, true)
+		self:RegisterEvent("PLAYER_ENTERING_WORLD", Update, true)
+		self:RegisterEvent("ARENA_CROWD_CONTROL_SPELL_UPDATE", Update, true)
+
+		if not self.Trinket.cooldownFrame then
+			self.Trinket.cooldownFrame = CreateFrame("Cooldown", nil, self.Trinket)
+			self.Trinket.cooldownFrame:SetAllPoints(self.Trinket)
+		end
+
+		if not self.Trinket.Icon then
+			self.Trinket.Icon = self.Trinket:CreateTexture(nil, "BORDER")
+			self.Trinket.Icon:SetAllPoints(self.Trinket)
+			self.Trinket.Icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+			self.Trinket.Icon:SetTexture(select(2, UnitFactionGroup("player")) == "Horde" and "Interface\\Icons\\inv_jewelry_trinketpvp_01" or "Interface\\Icons\\inv_jewelry_trinketpvp_02")
+		end
+
+		return true
+	end
+end
+
+local Disable = function(self)
+	if self.Trinket then
+		self:UnregisterEvent("ARENA_COOLDOWNS_UPDATE", Update)
+		self:UnregisterEvent("PLAYER_ENTERING_WORLD", Update)
+		self:UnregisterEvent("ARENA_CROWD_CONTROL_SPELL_UPDATE", Update)
+		self.Trinket:Hide()
+	end
+end
+
+oUF:AddElement('Trinket', Update, Enable, Disable)
\ No newline at end of file
diff --git a/oUF_Simple/oUF_Simple.toc b/oUF_Simple/oUF_Simple.toc
index 8f93888..25fafc2 100644
--- a/oUF_Simple/oUF_Simple.toc
+++ b/oUF_Simple/oUF_Simple.toc
@@ -9,6 +9,7 @@ modules\rClassBar.lua
 modules\oUF_DebuffHighlight.lua
 modules\oUF_Swing.lua
 modules\oUF_RaidDebuffs.lua
+modules\oUF_Trinkets.lua

 core\init.lua
 core\functions.lua
@@ -25,5 +26,6 @@ templates\party.lua
 templates\boss.lua
 templates\nameplate.lua
 templates\raid.lua
+templates\arena.lua

 core\spawn.lua
diff --git a/oUF_Simple/templates/arena.lua b/oUF_Simple/templates/arena.lua
new file mode 100644
index 0000000..7adbe17
--- /dev/null
+++ b/oUF_Simple/templates/arena.lua
@@ -0,0 +1,29 @@
+
+-- oUF_Simple: templates/arena
+-- rawoil, 2021
+
+-----------------------------
+-- Variables
+-----------------------------
+
+local A, L = ...
+
+-----------------------------
+-- CreateArenaStyle
+-----------------------------
+
+if not L.C.arena or not L.C.arena.enabled then return end
+
+local function CreateArenaStyle(self)
+  --config
+  self.cfg = L.C.arena
+  --settings
+  self.settings = {}
+  self.settings.template = "arena"
+  self.settings.setupFrame = true
+  self.settings.setupHeader = true
+  self.settings.createDrag = true
+  --style
+  L.F.CreateStyle(self)
+end
+L.F.CreateArenaStyle = CreateArenaStyle
\ No newline at end of file
diff --git a/oUF_SimpleConfig/arena.lua b/oUF_SimpleConfig/arena.lua
new file mode 100644
index 0000000..5997dd6
--- /dev/null
+++ b/oUF_SimpleConfig/arena.lua
@@ -0,0 +1,121 @@
+
+-- oUF_SimpleConfig: party
+-- zork, 2016
+
+-----------------------------
+-- Variables
+-----------------------------
+
+local A, L = ...
+
+-----------------------------
+-- Arena Config
+-----------------------------
+
+L.C.arena = {
+  enabled = true,
+  size = {180,26},
+  point = {"TOP",Minimap,"BOTTOM",0,-35}, --point of first arena frame
+  scale = 1*L.C.globalscale,
+  --healthbar
+  healthbar = {
+    --health and absorb bar cannot be disabled, they match the size of the frame
+    colorDisconnected = true,
+    colorClass = true,
+    colorReaction = true,
+    colorHealth = true,
+    name = {
+      enabled = true,
+      points = {
+        {"TOPLEFT",2,10},
+        {"TOPRIGHT",-2,10},
+      },
+      size = 17,
+      tag = "[name]",
+    },
+    health = {
+      enabled = true,
+      point = {"RIGHT",-2,0},
+      size = 14,
+      tag = "[oUF_Simple:health]",
+      font = L.C.fonts.expressway,
+    },
+    debuffHighlight = true,
+  },
+  --powerbar
+  powerbar = {
+    enabled = true,
+    size = {180,5},
+    point = {"TOP","BOTTOM",0,-4}, --if no relativeTo is given the frame base will be the relativeTo reference
+    colorPower = true,
+    power = {
+      font = L.C.fonts.expressway,
+    },
+  },
+  --raidmark
+  raidmark = {
+    enabled = false,
+    size = {18,18},
+    point = {"CENTER","TOP",0,0},
+  },
+  --castbar
+  castbar = {
+    enabled = true,
+    size = {180,26},
+    point = {"TOP","BOTTOM",0,-14},
+    name = {
+      enabled = true,
+      points = {
+        {"LEFT",2,0},
+        {"RIGHT",-2,0},
+      },
+      size = 16,
+    },
+    icon = {
+      enabled = true,
+      size = {26,26},
+      point = {"RIGHT","LEFT",-6,0},
+    },
+  },
+  --buffs
+  buffs = {
+    enabled = true,
+    point = {"BOTTOMLEFT","RIGHT",5,5},
+    num = 3,
+    cols = 8,
+    size = 22,
+    spacing = 5,
+    initialAnchor = "BOTTOMLEFT",
+    growthX = "RIGHT",
+    growthY = "UP",
+    disableCooldown = false,
+    stealable = true,
+  },
+  --debuffs
+  debuffs = {
+    enabled = true,
+    point = {"TOPLEFT","RIGHT",5,-5},
+    num = 4,
+    cols = 8,
+    size = 22,
+    spacing = 5,
+    initialAnchor = "TOPLEFT",
+    growthX = "RIGHT",
+    growthY = "DOWN",
+    disableCooldown = false,
+    desaturate = false,
+  },
+  --trinket
+  trinket = {
+    enabled = true,
+    point = {"RIGHT","LEFT",-5,0},
+    size = 26,
+    disableCooldown = true,
+  },
+  setup = {
+    point = "TOP",
+    relativePoint = "BOTTOM", --relativeTo will be the arena frame preceding
+    xOffset = 0,
+    yOffset = -50,
+  },
+}
diff --git a/oUF_SimpleConfig/oUF_SimpleConfig.toc b/oUF_SimpleConfig/oUF_SimpleConfig.toc
index a103a94..f94e606 100644
--- a/oUF_SimpleConfig/oUF_SimpleConfig.toc
+++ b/oUF_SimpleConfig/oUF_SimpleConfig.toc
@@ -15,6 +15,7 @@ focus.lua
 mouseover.lua
 party.lua
 boss.lua
+arena.lua
 nameplate.lua
 raid.lua
 debuffs.lua
\ No newline at end of file