-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdisplay.lua
More file actions
191 lines (161 loc) · 6.31 KB
/
Copy pathdisplay.lua
File metadata and controls
191 lines (161 loc) · 6.31 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
-- display.lua
DarkRuneOrder = DarkRuneOrder or {}
local displayFrame = CreateFrame("Frame", "DarkRuneOrderDisplay", UIParent)
displayFrame:SetSize(300, 80)
displayFrame:SetPoint("TOP", UIParent, "TOP", 0, -120)
displayFrame:SetMovable(true)
displayFrame:EnableMouse(true)
displayFrame:RegisterForDrag("LeftButton")
displayFrame:SetScript("OnDragStart", displayFrame.StartMoving)
displayFrame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
-- Save position (C4)
local point, _, relPoint, x, y = self:GetPoint()
DarkRuneOrderDB = DarkRuneOrderDB or {}
DarkRuneOrderDB.displayPos = { point, relPoint, x, y }
end)
displayFrame:SetScript("OnMouseUp", function(self, button)
if button == "RightButton" then
DarkRuneOrderDB.lastOrder = nil
DarkRuneOrder.HideDisplay()
DarkRuneOrder.ResetPicker()
end
end)
displayFrame:Hide()
-- Restore saved position (C4)
local function RestoreDisplayPosition()
DarkRuneOrderDB = DarkRuneOrderDB or {}
local pos = DarkRuneOrderDB.displayPos
if pos then
displayFrame:ClearAllPoints()
displayFrame:SetPoint(pos[1], UIParent, pos[2], pos[3], pos[4])
end
end
-- Defer position restore until SavedVariables are loaded
local posRestoreFrame = CreateFrame("Frame")
posRestoreFrame:RegisterEvent("ADDON_LOADED")
posRestoreFrame:SetScript("OnEvent", function(self, event, name)
if name == "DarkRuneOrder" then
RestoreDisplayPosition()
self:UnregisterEvent("ADDON_LOADED")
end
end)
-- Semi-transparent dark background
local bg = displayFrame:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0, 0, 0, 0.75)
-- Thin border line at top
local border = displayFrame:CreateTexture(nil, "BORDER")
border:SetHeight(2)
border:SetPoint("TOPLEFT", displayFrame, "TOPLEFT")
border:SetPoint("TOPRIGHT", displayFrame, "TOPRIGHT")
border:SetColorTexture(0.5, 0.4, 0.8, 1)
-- Pre-build 5 symbol cells (one per possible symbol slot)
local CELL_WIDTH = 58
local cells = {}
for i = 1, 5 do
local cell = CreateFrame("Frame", nil, displayFrame)
cell:SetSize(CELL_WIDTH, 72)
-- Number above icon
local numLabel = cell:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
numLabel:SetPoint("TOP", cell, "TOP", 0, -4)
numLabel:SetTextColor(1, 1, 1, 1)
cell.numLabel = numLabel
-- Symbol icon
local symLabel = cell:CreateTexture(nil, "OVERLAY")
symLabel:SetSize(40, 40)
symLabel:SetPoint("CENTER", cell, "CENTER", 0, -6)
cell.symLabel = symLabel
cell:Hide()
cells[i] = cell
end
-- ── Cast bar (Death's Dirge, spell 1249620) ──────────────────────────────────
local castEndTime = 0
local castDuration = 1 -- avoid division by zero
-- NOTE: all boss cast information (UnitCastingInfo name/spellID, UNIT_SPELLCAST_*
-- spellID, COMBAT_LOG_EVENT_UNFILTERED) is secret-tainted on this server regardless
-- of execution context. Picker is triggered from marked.lua via player aura detection.
local castBarFrame = CreateFrame("Frame", "DarkRuneOrderCastBar", UIParent)
castBarFrame:SetHeight(18)
castBarFrame:SetPoint("TOP", displayFrame, "BOTTOM", 0, -2)
castBarFrame:SetWidth(300)
local castBarBg = castBarFrame:CreateTexture(nil, "BACKGROUND")
castBarBg:SetAllPoints()
castBarBg:SetColorTexture(0, 0, 0, 0.75)
local castBarBorderLine = castBarFrame:CreateTexture(nil, "BORDER")
castBarBorderLine:SetHeight(1)
castBarBorderLine:SetPoint("BOTTOMLEFT", castBarFrame, "BOTTOMLEFT")
castBarBorderLine:SetPoint("BOTTOMRIGHT", castBarFrame, "BOTTOMRIGHT")
castBarBorderLine:SetColorTexture(0.5, 0.4, 0.8, 1)
local castBarFill = castBarFrame:CreateTexture(nil, "ARTWORK")
castBarFill:SetPoint("TOPLEFT", castBarFrame, "TOPLEFT", 1, -1)
castBarFill:SetPoint("BOTTOMLEFT", castBarFrame, "BOTTOMLEFT", 1, 1)
castBarFill:SetColorTexture(0.85, 0.15, 0.15, 0.9)
local castBarLabel = castBarFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
castBarLabel:SetAllPoints()
castBarLabel:SetJustifyH("CENTER")
castBarLabel:SetTextColor(1, 1, 1, 1)
castBarFrame:Hide()
castBarFrame:SetScript("OnUpdate", function(self)
local remaining = castEndTime - GetTime()
if remaining <= 0 then
self:Hide()
return
end
local frac = math.max(remaining / castDuration, 0)
local fillW = math.max((self:GetWidth() - 2) * frac, 0)
castBarFill:SetWidth(fillW)
castBarLabel:SetText(string.format("Death's Dirge %.1fs", remaining))
end)
-- ── Public API ────────────────────────────────────────────────────────────────
-- Fade-in animation helper (B2)
local function StartFadeIn(frame)
local elapsed = 0
frame:SetAlpha(0)
frame:SetScript("OnUpdate", function(self, dt)
elapsed = elapsed + dt
local alpha = math.min(elapsed / 0.3, 1)
self:SetAlpha(alpha)
if alpha >= 1 then
self:SetScript("OnUpdate", nil)
end
end)
end
-- Shows the display with an ordered list of symbol IDs
function DarkRuneOrder.ShowDisplay(symbolIDs)
local count = #symbolIDs
-- Play sound to alert the player (B1)
PlaySound(SOUNDKIT.RAID_WARNING)
-- Resize frame to fit exactly the number of symbols
displayFrame:SetWidth(count * CELL_WIDTH + 16)
castBarFrame:SetWidth(count * CELL_WIDTH + 16)
-- Hide all cells then populate
for i = 1, 5 do
cells[i]:Hide()
end
for i, id in ipairs(symbolIDs) do
local sym = DarkRuneOrder.SymbolByID[id]
if sym then
local cell = cells[i]
cell:ClearAllPoints()
cell:SetPoint("TOPLEFT", displayFrame, "TOPLEFT", 8 + (i - 1) * CELL_WIDTH, -4)
cell.numLabel:SetText(tostring(i))
cell.symLabel:SetTexture(sym.texture)
cell:Show()
end
end
displayFrame:Show()
StartFadeIn(displayFrame) -- (B2)
end
function DarkRuneOrder.HideDisplay()
displayFrame:Hide()
castBarFrame:Hide()
end
-- Simulates a Death's Dirge cast for testing (duration in seconds)
function DarkRuneOrder.SimulateCast(duration)
duration = duration or 6
castDuration = duration
castEndTime = GetTime() + duration
castBarFrame:SetWidth(displayFrame:GetWidth())
castBarFrame:Show()
end