forked from shrekin/DarkRuneOrder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarked.lua
More file actions
160 lines (133 loc) · 5.19 KB
/
Copy pathmarked.lua
File metadata and controls
160 lines (133 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
-- marked.lua
-- Tracks players marked by Dark Rune (1249609) via combat log
CoxisDarkRuneOrder = CoxisDarkRuneOrder or {}
local DARK_RUNE_ID = 1249609
local MAX_MARKED = 5
local ROW_H = 20
local ROUND_TIMEOUT = 15 -- seconds between rounds
-- Resolve spell name once at load time (name is public, spellId is secret)
local DARK_RUNE_NAME = C_Spell and C_Spell.GetSpellName(DARK_RUNE_ID)
if not DARK_RUNE_NAME then
DARK_RUNE_NAME = GetSpellInfo and GetSpellInfo(DARK_RUNE_ID)
end
if not DARK_RUNE_NAME then
DARK_RUNE_NAME = "Dark Rune" -- hardcoded fallback (D2)
end
local markedPlayers = {}
local lastMarkTime = 0
-- ── UI ───────────────────────────────────────────────────────────────────────
local markedFrame = CreateFrame("Frame", "CoxisDarkRuneOrderMarked", UIParent, "BackdropTemplate")
markedFrame:SetSize(160, 36)
markedFrame:SetPoint("LEFT", "CoxisDarkRuneOrderPicker", "RIGHT", 8, 0)
markedFrame:SetMovable(true)
markedFrame:EnableMouse(true)
markedFrame:RegisterForDrag("LeftButton")
markedFrame:SetScript("OnDragStart", markedFrame.StartMoving)
markedFrame:SetScript("OnDragStop", markedFrame.StopMovingOrSizing)
markedFrame:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\Buttons\\WHITE8X8",
tile = true, tileSize = 32, edgeSize = 2,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
markedFrame:SetBackdropBorderColor(0.408, 0.227, 0.651, 1)
markedFrame:SetScript("OnMouseUp", function(self, button)
if button == "RightButton" then markedFrame:Hide() end
end)
markedFrame:Hide()
-- Border line at top
local markedBorder = markedFrame:CreateTexture(nil, "BORDER")
markedBorder:SetHeight(2)
markedBorder:SetPoint("TOPLEFT", markedFrame, "TOPLEFT")
markedBorder:SetPoint("TOPRIGHT", markedFrame, "TOPRIGHT")
markedBorder:SetColorTexture(0.5, 0.4, 0.8, 1)
-- Title
local markedTitle = markedFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
markedTitle:SetFont("Interface\\AddOns\\CoxisDarkRuneOrder\\fonts\\Expressway.ttf", 12, "OUTLINE")
markedTitle:SetPoint("TOP", markedFrame, "TOP", 0, -10)
markedTitle:SetText("Dark Rune")
markedTitle:SetTextColor(0.8, 0.55, 1, 1)
-- Pre-build player rows
local rows = {}
for i = 1, MAX_MARKED do
local row = CreateFrame("Frame", nil, markedFrame)
row:SetHeight(ROW_H)
row:SetPoint("TOPLEFT", markedFrame, "TOPLEFT", 6, -(26 + (i - 1) * ROW_H))
row:SetPoint("TOPRIGHT", markedFrame, "TOPRIGHT", -6, -(26 + (i - 1) * ROW_H))
-- Alternating background
local rowBg = row:CreateTexture(nil, "BACKGROUND")
rowBg:SetAllPoints()
rowBg:SetColorTexture(1, 1, 1, i % 2 == 0 and 0.04 or 0)
local numLabel = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
numLabel:SetPoint("LEFT", row, "LEFT", 2, 0)
numLabel:SetWidth(18)
numLabel:SetJustifyH("LEFT")
numLabel:SetTextColor(0.6, 0.6, 0.6, 1)
row.numLabel = numLabel
local nameLabel = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
nameLabel:SetPoint("LEFT", row, "LEFT", 20, 0)
nameLabel:SetPoint("RIGHT", row, "RIGHT", 0, 0)
nameLabel:SetJustifyH("LEFT")
nameLabel:SetTextColor(1, 1, 1, 1)
row.nameLabel = nameLabel
row:Hide()
rows[i] = row
end
local function RefreshMarked()
local count = #markedPlayers
for i = 1, MAX_MARKED do rows[i]:Hide() end
for i, name in ipairs(markedPlayers) do
rows[i].numLabel:SetText(i .. ".")
rows[i].nameLabel:SetText(name)
rows[i]:Show()
end
if count > 0 then
markedFrame:SetHeight(28 + count * ROW_H + 6)
markedFrame:Show()
else
markedFrame:Hide()
end
end
local function ClearMarked()
markedPlayers = {}
lastMarkTime = 0
markedFrame:Hide()
end
-- ── Polling (avoids UNIT_AURA taint in Midnight raid context) ────────────────
local function CheckUnit(unitID)
if not UnitExists(unitID) then return end
if not DARK_RUNE_NAME then return end
if not AuraUtil.FindAuraByName(DARK_RUNE_NAME, unitID, "HARMFUL") then return end
local name = UnitName(unitID)
if not name then return end
local shortName = name:match("^([^%-]+)") or name
-- Already in list?
for _, n in ipairs(markedPlayers) do
if n == shortName then return end
end
-- New round if enough time has passed
local now = GetTime()
if now - lastMarkTime > ROUND_TIMEOUT then
markedPlayers = {}
end
lastMarkTime = now
table.insert(markedPlayers, shortName)
RefreshMarked()
end
local function ScanGroupForDarkRune()
CheckUnit("player")
if IsInRaid() then
for i = 1, GetNumGroupMembers() do
CheckUnit("raid" .. i)
end
elseif IsInGroup() then
for i = 1, GetNumSubgroupMembers() do
CheckUnit("party" .. i)
end
end
end
C_Timer.NewTicker(0.5, ScanGroupForDarkRune)
-- ── Callbacks called from core.lua's single event frame ──────────────────────
function CoxisDarkRuneOrder.OnEncounterReset()
ClearMarked()
end