-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathInterruptDisplay.lua
More file actions
172 lines (161 loc) · 7.49 KB
/
Copy pathInterruptDisplay.lua
File metadata and controls
172 lines (161 loc) · 7.49 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
local _, NSI = ... -- Internal namespace
function NSI:CreateInterruptDisplay()
if not self.InterruptDisplay then
self.InterruptDisplay = CreateFrame("Frame", "NSIInterruptDisplay", NSI.NSRTFrame)
self.InterruptDisplay.Box = self.InterruptDisplay:CreateTexture(nil, "ARTWORK")
self.InterruptDisplay.Box:SetColorTexture(0, 0, 0, 1)
self.InterruptDisplay.Box:SetAllPoints()
self.InterruptDisplay.Border = self.InterruptDisplay:CreateTexture(nil, "BACKGROUND")
self.InterruptDisplay.Border:SetColorTexture(0, 0, 0, 1)
self.InterruptDisplay.Border:SetPoint("TOPLEFT", self.InterruptDisplay, "TOPLEFT", -1, 1)
self.InterruptDisplay.Border:SetPoint("BOTTOMRIGHT", self.InterruptDisplay, "BOTTOMRIGHT", 1, -1)
self.InterruptDisplay.Number = self.InterruptDisplay:CreateFontString(nil, "OVERLAY")
self.InterruptDisplay.Number:SetTextColor(1, 0, 0, 1)
self.InterruptDisplay.Name = self.InterruptDisplay:CreateFontString(nil, "OVERLAY")
self.InterruptDisplay.Name:SetTextColor(1, 1, 1, 1)
end
self.InterruptDisplay:ClearAllPoints()
self.InterruptDisplay:SetSize(NSRT.InterruptSettings.Width, NSRT.InterruptSettings.Height)
self.InterruptDisplay:SetPoint(NSRT.InterruptSettings.Anchor, NSI.NSRTFrame, NSRT.InterruptSettings.relativeTo, NSRT.InterruptSettings.xOffset, NSRT.InterruptSettings.yOffset)
self.InterruptDisplay.Number:ClearAllPoints()
self.InterruptDisplay.Number:SetPoint(NSRT.InterruptSettings.NumberAnchor, self.InterruptDisplay, NSRT.InterruptSettings.NumberRelativeTo, NSRT.InterruptSettings.NumberxOffset, NSRT.InterruptSettings.NumberyOffset)
self.InterruptDisplay.Number:SetFont(self.LSM:Fetch("font", NSRT.InterruptSettings.NumberFont), NSRT.InterruptSettings.NumberFontSize, NSRT.InterruptSettings.NumberFontFlags)
self.InterruptDisplay.Name:ClearAllPoints()
self.InterruptDisplay.Name:SetPoint(NSRT.InterruptSettings.NameAnchor, self.InterruptDisplay, NSRT.InterruptSettings.NameRelativeTo, NSRT.InterruptSettings.NamexOffset, NSRT.InterruptSettings.NameyOffset)
self.InterruptDisplay.Name:SetFont(self.LSM:Fetch("font", NSRT.InterruptSettings.NameFont), NSRT.InterruptSettings.NameFontSize, NSRT.InterruptSettings.NameFontFlags)
end
function NSI:DisplayInterrupt(isCastStart)
local s = NSRT.InterruptSettings
local myKick = self.Interrupts.myKick
local castCount = self.Interrupts.castCount
local unit = self.Interrupts.myTable[castCount]
local name = unit and UnitExists(unit) and NSAPI:Shorten(unit, 12, false, "GlobalNickNames", false, false) or ""
self:CreateInterruptDisplay()
self.InterruptDisplay.Number:SetText(castCount or "")
self.InterruptDisplay.Name:SetText(name)
if castCount == myKick then
if isCastStart then -- player interrupts now
self.InterruptDisplay.Box:SetColorTexture(unpack(s.InterruptNowColor))
self.InterruptDisplay.Number:SetTextColor(unpack(s.InterruptNowTextColor))
else -- player interrupts next
self.InterruptDisplay.Box:SetColorTexture(unpack(s.InterruptNextColor))
self.InterruptDisplay.Number:SetTextColor(unpack(s.InterruptNextTextColor))
end
elseif (castCount+1 == myKick) or (myKick == 1 and castCount == self.Interrupts.max) then
self.InterruptDisplay.Box:SetColorTexture(unpack(s.InterruptNextColor))
self.InterruptDisplay.Number:SetTextColor(unpack(s.InterruptNextTextColor))
else
self.InterruptDisplay.Box:SetColorTexture(unpack(s.InterruptDefaultColor))
self.InterruptDisplay.Number:SetTextColor(unpack(s.InterruptDefaultTextColor))
end
self.InterruptDisplay:Show()
end
function NSI:PlayInterruptSound()
local sound = NSRT.InterruptSettings.InterruptSound
if sound then
PlaySoundFile(NSI.LSM:Fetch("sound", sound), "Master")
end
end
function NSI:HideInterrupt()
if self.InterruptDisplay then
self.InterruptDisplay:Hide()
end
end
function NSI:ResetInterrupts()
self.Interrupts.castCount = 1
self.Interrupts.myTrackedID = self.Interrupts.myID
self:HideInterrupt()
self:HideInterruptBar()
end
function NSI:InterruptOnCastStart(info)
if not self.Interrupts or self.Interrupts.disabled then return end
if self.Interrupts.myTrackedID == 0 then return end
self:DisplayInterrupt(true)
if self.Interrupts.castCount == self.Interrupts.myKick then
self:PlayInterruptSound()
if NSRT.InterruptSettings.ShowBar and info then
self:ShowInterruptBar(info)
end
end
end
function NSI:ShowInterruptBar(info)
info.DisplayType = "Bar"
info.TTS = false
info.text = "Interrupt"
local alert = self:CreateReminder(info, true)
self.InterruptBar = self:DisplayReminder(alert)
end
function NSI:HideInterruptBar()
if self.InterruptBar then
self.InterruptBar:Hide()
self.InterruptBar = nil
self:ArrangeStates("Bars")
end
end
function NSI:OnInterrupt()
if not self.Interrupts or self.Interrupts.disabled then return end
if self.Interrupts.myTrackedID == 0 then return end
self:DisplayInterrupt()
self:HideInterruptBar()
end
function NSI:OnCastStop()
if not self.Interrupts or self.Interrupts.disabled then return end
if self.Interrupts.myTrackedID == 0 then return end
self.Interrupts.castCount = self.Interrupts.castCount + 1
if self.Interrupts.castCount > self.Interrupts.max then
self.Interrupts.castCount = 1
end
self:DisplayInterrupt()
end
function NSI:ReadInterruptNote(StartNumber)
local pers, shared = NSAPI:GetReminderString()
if not pers then pers = "" end
if not shared then shared = "" end
local MRT = C_AddOns.IsAddOnLoaded("MRT") and _G.VMRT.Note.Text1 or ""
local str = shared.."\n"..pers.."\n"..MRT
local count = StartNumber or 0
self.Interrupts = self.Interrupts or {}
self.Interrupts.assignTable = {}
self.Interrupts.myID = 0
self.Interrupts.myKick = 0
self.Interrupts.myTrackedID = 0
self.Interrupts.castCount = 1
self.Interrupts.disabled = false
self.Interrupts.max = 0
self.Interrupts.myTable = {}
self.Interrupts.disabled = true
local assign = false
str = str:gsub("||r", "")
str = str:gsub("||c%x%x%x%x%x%x%x%x", "")
str = strtrim(str)
for line in string.gmatch(str,'[^\r\n]+') do
line = strtrim(line)
if strlower(line) == "intend" then
assign = false
self.Interrupts.myTrackedID = self.Interrupts.myID
self.Interrupts.myTable = self.Interrupts.assignTable[self.Interrupts.myID] or {}
break
elseif strlower(line) == "intstart" then
assign = true
elseif assign then
local num = 0
count = count+1
self.Interrupts.assignTable[count] = self.Interrupts.assignTable[count] or {}
for name in line:gmatch("%S+") do
name = NSAPI:GetChar(name, true, "GlobalNickNames")
if UnitInRaid(name) then
num = num+1
table.insert(self.Interrupts.assignTable[count], name)
if UnitIsUnit(name, "player") then
self.Interrupts.disabled = false
self.Interrupts.myID = count
self.Interrupts.myKick = num
end
if count == self.Interrupts.myID then
self.Interrupts.max = #self.Interrupts.assignTable[count]
end
end
end
end
end
end