Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 10 | Seerah-7 | -- ZAM_BuffDisplay © ZAM Network LLC |
2 | Seerah-7 | -- All Rights Reserved |
|
3 | Seerah-7 | ||
4 | 13 | Seerah-7 | local zbdVersion = "1.2" |
5 | 4 | Seerah-7 | local wm = WINDOW_MANAGER |
6 | 7 | Seerah-7 | local em = EVENT_MANAGER |
7 | Seerah-7 | local playerPool, reticlePool, db, _ |
|
8 | 4 | Seerah-7 | local pbc = wm:CreateTopLevelWindow("ZAM_BuffDisplayPlayerContainer") |
9 | 7 | Seerah-7 | local rbc = wm:CreateTopLevelWindow("ZAM_BuffDisplayReticleoverContainer") |
10 | 4 | Seerah-7 | local GetNumBuffs = GetNumBuffs |
11 | Seerah-7 | local GetUnitBuffInfo = GetUnitBuffInfo |
|
12 | 7 | Seerah-7 | local GetBuffColor = GetBuffColor |
13 | Seerah-7 | local GetControl = GetControl |
|
14 | Seerah-7 | local zo_ceil = zo_ceil |
|
15 | 13 | Seerah-7 | local LAM = LibStub("LibAddonMenu-2.0") |
16 | 4 | Seerah-7 | local LMP = LibStub("LibMediaProvider-1.0") |
17 | Seerah-7 | ||
18 | 10 | Seerah-7 | --add option later to change text color (maybe also separate bar colors if buff/debuff?) |
19 | 4 | Seerah-7 | local defaults = { |
20 | Seerah-7 | isLocked = true, |
|
21 | 7 | Seerah-7 | player = { |
22 | Seerah-7 | anchor = { |
|
23 | Seerah-7 | a = TOPLEFT, |
|
24 | Seerah-7 | b = TOPLEFT, |
|
25 | Seerah-7 | x = 5, |
|
26 | Seerah-7 | y = 100, |
|
27 | Seerah-7 | }, |
|
28 | Seerah-7 | growUp = false, |
|
29 | 4 | Seerah-7 | }, |
30 | 7 | Seerah-7 | reticleover = { |
31 | Seerah-7 | anchor = { |
|
32 | Seerah-7 | a = TOPLEFT, |
|
33 | Seerah-7 | b = TOP, |
|
34 | Seerah-7 | x = 150, |
|
35 | Seerah-7 | y = 85, |
|
36 | Seerah-7 | }, |
|
37 | Seerah-7 | growUp = false, |
|
38 | Seerah-7 | }, |
|
39 | 10 | Seerah-7 | displayBars = true, |
40 | 4 | Seerah-7 | font = "Arial Narrow", |
41 | 10 | Seerah-7 | barTex = "ESO Basic", |
42 | 5 | Seerah-7 | barColor = { |
43 | Seerah-7 | r = .35, |
|
44 | Seerah-7 | g = .35, |
|
45 | Seerah-7 | b = .35, |
|
46 | 13 | Seerah-7 | a = 1, |
47 | Seerah-7 | }, |
|
48 | Seerah-7 | defaultTextColor = true, |
|
49 | Seerah-7 | customTextColors = { |
|
50 | Seerah-7 | [BUFF_EFFECT_TYPE_NOT_AN_EFFECT] = { r = 1, g = 1, b = 1}, --[0] |
|
51 | Seerah-7 | [BUFF_EFFECT_TYPE_BUFF] = { r = 0, g = 1, b = 0}, --[1] |
|
52 | Seerah-7 | [BUFF_EFFECT_TYPE_DEBUFF] = { r = 1, g = 0, b = 0}, --[2] |
|
53 | Seerah-7 | }, |
|
54 | 10 | Seerah-7 | cmbtShow = false, |
55 | Seerah-7 | attackShow = false, |
|
56 | Seerah-7 | menuHide = false, |
|
57 | 4 | Seerah-7 | } |
58 | Seerah-7 | ||
59 | 7 | Seerah-7 | local function HandleAnchors(buff, buffID, unit) |
60 | 4 | Seerah-7 | buff:ClearAnchors() |
61 | 7 | Seerah-7 | local bc = unit == "player" and pbc or rbc |
62 | Seerah-7 | local pool = unit == "player" and playerPool or reticlePool |
|
63 | Seerah-7 | local anchorBuff = buffID == 1 and bc or pool:AcquireObject(buffID-1) |
|
64 | Seerah-7 | if db[unit].growUp then |
|
65 | Seerah-7 | buff:SetAnchor(BOTTOMLEFT, anchorBuff, anchorBuff == bc and BOTTOMLEFT or TOPLEFT) |
|
66 | Seerah-7 | buff:SetAnchor(BOTTOMRIGHT, anchorBuff, anchorBuff == bc and BOTTOMRIGHT or TOPRIGHT) |
|
67 | 4 | Seerah-7 | else |
68 | 7 | Seerah-7 | buff:SetAnchor(TOPLEFT, anchorBuff, anchorBuff == bc and TOPLEFT or BOTTOMLEFT) |
69 | Seerah-7 | buff:SetAnchor(TOPRIGHT, anchorBuff, anchorBuff == bc and TOPRIGHT or BOTTOMRIGHT) |
|
70 | 4 | Seerah-7 | end |
71 | Seerah-7 | end |
|
72 | Seerah-7 | ||
73 | Seerah-7 | local function SetFonts(buff) |
|
74 | Seerah-7 | buff.name:SetFont(LMP:Fetch("font", db.font).."|18|soft-shadow-thin") |
|
75 | Seerah-7 | buff.time:SetFont(LMP:Fetch("font", db.font).."|18|soft-shadow-thin") |
|
76 | Seerah-7 | end |
|
77 | Seerah-7 | ||
78 | 10 | Seerah-7 | local function SetTexture(buff) |
79 | Seerah-7 | buff.bar:SetTexture(LMP:Fetch("statusbar", db.barTex)) |
|
80 | Seerah-7 | end |
|
81 | Seerah-7 | ||
82 | 13 | Seerah-7 | local function SetTextColors(unit, pool) |
83 | Seerah-7 | --local pool = unit == "player" and playerPool or reticlePool |
|
84 | Seerah-7 | for i = 1, GetNumBuffs(unit) do |
|
85 | Seerah-7 | local buffName, timeStarted, timeEnding, buffSlot, stackCount, iconFilename, buffType, effectType, abilityType, statusEffectType = GetUnitBuffInfo(unit, i) |
|
86 | Seerah-7 | local myBuff = pool:AcquireObject(i) |
|
87 | Seerah-7 | if db.defaultTextColor then |
|
88 | Seerah-7 | myBuff.name:SetColor(GetBuffColor(effectType):UnpackRGBA()) |
|
89 | Seerah-7 | else |
|
90 | Seerah-7 | local color = db.customTextColors[effectType] |
|
91 | Seerah-7 | myBuff.name:SetColor(color.r, color.g, color.b) |
|
92 | Seerah-7 | end |
|
93 | Seerah-7 | end |
|
94 | Seerah-7 | end |
|
95 | Seerah-7 | ||
96 | 4 | Seerah-7 | local function CreateBuff(pool) |
97 | 7 | Seerah-7 | local forPlayer = pool == playerPool |
98 | Seerah-7 | local buff = ZO_ObjectPool_CreateControl(forPlayer and "ZAM_BuffDisplay_Player" or "ZAM_BuffDisplay_Reticleover", pool, forPlayer and pbc or rbc) |
|
99 | 4 | Seerah-7 | buff.icon = GetControl(buff, "Icon") |
100 | Seerah-7 | buff.time = GetControl(buff, "Time") |
|
101 | Seerah-7 | buff.name = GetControl(buff, "Name") |
|
102 | Seerah-7 | --GetControl(myBuff, "Name"):SetWidth(170) |
|
103 | Seerah-7 | buff.bar = GetControl(buff, "Statusbar") |
|
104 | 5 | Seerah-7 | buff.bar:SetColor(db.barColor.r, db.barColor.g, db.barColor.b, db.barColor.a) |
105 | 4 | Seerah-7 | buff.bar:SetHidden(not db.displayBars) |
106 | Seerah-7 | local buffID = pool.m_NextControlId |
|
107 | 7 | Seerah-7 | HandleAnchors(buff, buffID, forPlayer and "player" or "reticleover") |
108 | 4 | Seerah-7 | SetFonts(buff) |
109 | 10 | Seerah-7 | SetTexture(buff) |
110 | 4 | Seerah-7 | buff.timeLastRun = 0 |
111 | Seerah-7 | buff:SetHandler("OnUpdate", function(self, updateTime) |
|
112 | Seerah-7 | if (updateTime - self.timeLastRun) >= .5 then |
|
113 | Seerah-7 | self.timeLastRun = updateTime |
|
114 | Seerah-7 | --if self.endTime == "\195\236" then |
|
115 | Seerah-7 | if self.endTime == "--" then |
|
116 | Seerah-7 | return |
|
117 | Seerah-7 | else |
|
118 | Seerah-7 | local timeLeft = (self.endTime-updateTime) |
|
119 | Seerah-7 | if timeLeft < 60 then |
|
120 | Seerah-7 | self.time:SetText(zo_ceil(timeLeft).."s") |
|
121 | Seerah-7 | else |
|
122 | Seerah-7 | self.time:SetText(zo_ceil(timeLeft/60).."m") |
|
123 | Seerah-7 | end |
|
124 | Seerah-7 | end |
|
125 | Seerah-7 | end |
|
126 | Seerah-7 | end) |
|
127 | Seerah-7 | buff.bar.timeLastRun = 0 |
|
128 | Seerah-7 | buff.bar:SetHandler("OnUpdate", function(self,updateTime) |
|
129 | Seerah-7 | if (updateTime - self.timeLastRun) >= .01 then |
|
130 | Seerah-7 | self.timeLastRun = updateTime |
|
131 | Seerah-7 | if self.noDur then |
|
132 | Seerah-7 | return |
|
133 | Seerah-7 | else |
|
134 | Seerah-7 | self:SetValue((buff.endTime - updateTime) + self.min) |
|
135 | Seerah-7 | end |
|
136 | Seerah-7 | end |
|
137 | Seerah-7 | end) |
|
138 | Seerah-7 | ||
139 | Seerah-7 | return buff |
|
140 | Seerah-7 | end |
|
141 | Seerah-7 | ||
142 | Seerah-7 | local function RemoveBuff(buffFrame) |
|
143 | Seerah-7 | buffFrame:SetHidden(true) |
|
144 | Seerah-7 | end |
|
145 | Seerah-7 | ||
146 | 7 | Seerah-7 | local function UpdateBuffs(unit) |
147 | 9 | Seerah-7 | unit = unit or "player" |
148 | 10 | Seerah-7 | if unit ~= "player" and db.attackShow then |
149 | Seerah-7 | if IsUnitAttackable(unit) then |
|
150 | Seerah-7 | rbc:SetHidden(false) |
|
151 | Seerah-7 | return |
|
152 | Seerah-7 | else |
|
153 | Seerah-7 | rbc:SetHidden(true) |
|
154 | Seerah-7 | end |
|
155 | Seerah-7 | end |
|
156 | 7 | Seerah-7 | local pool = unit == "player" and playerPool or reticlePool |
157 | Seerah-7 | local numBuffs = GetNumBuffs(unit) |
|
158 | 4 | Seerah-7 | for i = 1, numBuffs do |
159 | 8 | Seerah-7 | local buffName, timeStarted, timeEnding, buffSlot, stackCount, iconFilename, buffType, effectType, abilityType, statusEffectType = GetUnitBuffInfo(unit, i) |
160 | 7 | Seerah-7 | local myBuff = pool:AcquireObject(i) |
161 | 4 | Seerah-7 | myBuff.name:SetText(buffName) |
162 | Seerah-7 | myBuff.name:SetColor(GetBuffColor(effectType):UnpackRGBA()) |
|
163 | Seerah-7 | --myBuff.bar:SetColor(GetBuffColor(effectType):UnpackRGBA()) |
|
164 | Seerah-7 | myBuff.icon:SetTexture(iconFilename) |
|
165 | Seerah-7 | myBuff:SetHidden(false) |
|
166 | Seerah-7 | local noDur = timeStarted == timeEnding |
|
167 | Seerah-7 | myBuff.bar.noDur = noDur |
|
168 | Seerah-7 | myBuff.endTime = noDur and "--" or timeEnding |
|
169 | Seerah-7 | if noDur then |
|
170 | Seerah-7 | myBuff.time:SetText(myBuff.endTime) |
|
171 | Seerah-7 | end |
|
172 | Seerah-7 | myBuff.bar.min = timeStarted |
|
173 | Seerah-7 | myBuff.bar.max = timeEnding |
|
174 | Seerah-7 | myBuff.bar:SetMinMax(myBuff.bar.min, myBuff.bar.max) |
|
175 | Seerah-7 | end |
|
176 | Seerah-7 | local activeBuffs = pool:GetActiveObjectCount() |
|
177 | Seerah-7 | if activeBuffs > numBuffs then |
|
178 | Seerah-7 | for i = numBuffs+1, activeBuffs do |
|
179 | Seerah-7 | pool:ReleaseObject(i) |
|
180 | Seerah-7 | end |
|
181 | Seerah-7 | end |
|
182 | Seerah-7 | end |
|
183 | Seerah-7 | ||
184 | 7 | Seerah-7 | local function SetUpContainer(unit) |
185 | Seerah-7 | local bc = unit == "player" and pbc or rbc |
|
186 | Seerah-7 | bc:SetDimensions(250,30) |
|
187 | Seerah-7 | local anchors = db[unit].anchor |
|
188 | Seerah-7 | bc:SetAnchor(anchors.a, GuiRoot, anchors.b, anchors.x, anchors.y) |
|
189 | Seerah-7 | bc:SetDrawLayer(DL_BACKGROUND) |
|
190 | Seerah-7 | bc:SetMouseEnabled(true) |
|
191 | Seerah-7 | bc:SetMovable(not db.isLocked) |
|
192 | Seerah-7 | bc:SetClampedToScreen(true) |
|
193 | Seerah-7 | bc:SetHandler("OnReceiveDrag", function(self) |
|
194 | 4 | Seerah-7 | if not db.isLocked then |
195 | Seerah-7 | self:StartMoving() |
|
196 | Seerah-7 | end |
|
197 | Seerah-7 | end) |
|
198 | 7 | Seerah-7 | bc:SetHandler("OnMouseUp", function(self) |
199 | 4 | Seerah-7 | self:StopMovingOrResizing() |
200 | 7 | Seerah-7 | _, anchors.a, _, anchors.b, anchors.x, anchors.y = self:GetAnchor() |
201 | 4 | Seerah-7 | end) |
202 | Seerah-7 | ||
203 | 7 | Seerah-7 | bc.bg = wm:CreateControl("ZAM_BuffDisplay"..unit.."ContainerBG", bc, CT_TEXTURE) |
204 | Seerah-7 | bc.bg:SetAnchor(TOPLEFT, bc, TOPLEFT, -3, -3) |
|
205 | Seerah-7 | bc.bg:SetAnchor(BOTTOMRIGHT, bc, BOTTOMRIGHT, 3, 3) |
|
206 | Seerah-7 | bc.bg:SetColor(1,1,1,.5) |
|
207 | Seerah-7 | bc.bg:SetAlpha(db.isLocked and 0 or .5) |
|
208 | 4 | Seerah-7 | end |
209 | Seerah-7 | ||
210 | 10 | Seerah-7 | local function CombatVisibility(event, inCombat) |
211 | Seerah-7 | rbc:SetHidden(not inCombat) |
|
212 | Seerah-7 | end |
|
213 | Seerah-7 | ||
214 | Seerah-7 | local changevisibility = EVENT_ACTION_LAYER_PUSHED |
|
215 | Seerah-7 | --popped & pushed can fire 2-3 times in a row... |
|
216 | Seerah-7 | local function MenuVisibility(event) |
|
217 | Seerah-7 | if event == EVENT_ACTION_LAYER_PUSHED and changevisibility == event then |
|
218 | Seerah-7 | pbc:SetHidden(true) |
|
219 | Seerah-7 | changevisibility = EVENT_ACTION_LAYER_POPPED |
|
220 | Seerah-7 | elseif event == EVENT_ACTION_LAYER_POPPED and changevisibility == event then |
|
221 | Seerah-7 | pbc:SetHidden(false) |
|
222 | Seerah-7 | changevisibility = EVENT_ACTION_LAYER_PUSHED |
|
223 | Seerah-7 | end |
|
224 | Seerah-7 | end |
|
225 | Seerah-7 | ||
226 | 13 | Seerah-7 | |
227 | Seerah-7 | local panelData = { |
|
228 | Seerah-7 | type = "panel", |
|
229 | Seerah-7 | name = "ZAM BuffDisplay", |
|
230 | Seerah-7 | displayName = "|t72:36:ZAM_BuffDisplay\\ZAM_Logo.dds|t BuffDisplay", |
|
231 | Seerah-7 | slashCommand = "/zambd", |
|
232 | Seerah-7 | registerForRefresh = true, |
|
233 | Seerah-7 | registerForDefaults = true, |
|
234 | Seerah-7 | resetFunc = function() |
|
235 | Seerah-7 | db.player.anchor = defaults.player.anchor |
|
236 | Seerah-7 | pbc:ClearAnchors() |
|
237 | Seerah-7 | local anchor = db.player.anchor |
|
238 | Seerah-7 | pbc:SetAnchor(anchor.a, GuiRoot, anchor.b, anchor.x, anchor.y) |
|
239 | Seerah-7 | db.reticleover.anchor = defaults.reticleover.anchor |
|
240 | Seerah-7 | pbc:ClearAnchors() |
|
241 | Seerah-7 | local anchor = db.reticleover.anchor |
|
242 | Seerah-7 | pbc:SetAnchor(anchor.a, GuiRoot, anchor.b, anchor.x, anchor.y) |
|
243 | Seerah-7 | end, |
|
244 | Seerah-7 | author = "Seerah", |
|
245 | Seerah-7 | version = zbdVersion, |
|
246 | Seerah-7 | } |
|
247 | Seerah-7 | local optionsData = { |
|
248 | Seerah-7 | [1] = { |
|
249 | Seerah-7 | type = "checkbox", |
|
250 | Seerah-7 | name = "Lock Buff Displays", |
|
251 | Seerah-7 | tooltip = "Lock or unlock the buff anchors to move them.", |
|
252 | Seerah-7 | getFunc = function() return db.isLocked end, |
|
253 | Seerah-7 | setFunc = function(value) |
|
254 | Seerah-7 | db.isLocked = value |
|
255 | Seerah-7 | pbc:SetMovable(not db.isLocked) |
|
256 | Seerah-7 | pbc.bg:SetAlpha(db.isLocked and 0 or 1) |
|
257 | Seerah-7 | rbc:SetMovable(not db.isLocked) |
|
258 | Seerah-7 | rbc.bg:SetAlpha(db.isLocked and 0 or 1) |
|
259 | Seerah-7 | end, |
|
260 | Seerah-7 | default = defaults.isLocked, |
|
261 | Seerah-7 | }, |
|
262 | Seerah-7 | [2] = { |
|
263 | Seerah-7 | type = "header", |
|
264 | Seerah-7 | name = "Skinning Options", |
|
265 | Seerah-7 | }, |
|
266 | Seerah-7 | [3] = { |
|
267 | Seerah-7 | type = "dropdown", |
|
268 | Seerah-7 | name = "Font", |
|
269 | Seerah-7 | tooltip = "The font to use for the text.", |
|
270 | Seerah-7 | choices = LMP:List("font"), |
|
271 | Seerah-7 | getFunc = function() return db.font end, |
|
272 | Seerah-7 | setFunc = function(val) |
|
273 | 5 | Seerah-7 | db.font = val |
274 | 7 | Seerah-7 | for i = 1, playerPool:GetTotalObjectCount() do |
275 | Seerah-7 | SetFonts(playerPool:AcquireObject(i)) |
|
276 | 5 | Seerah-7 | end |
277 | 7 | Seerah-7 | for i = 1, reticlePool:GetTotalObjectCount() do |
278 | Seerah-7 | SetFonts(reticlePool:AcquireObject(i)) |
|
279 | Seerah-7 | end |
|
280 | 13 | Seerah-7 | end, |
281 | Seerah-7 | default = defaults.font, |
|
282 | Seerah-7 | }, |
|
283 | Seerah-7 | [4] = { |
|
284 | Seerah-7 | type = "dropdown", |
|
285 | Seerah-7 | name = "Bar Texture", |
|
286 | Seerah-7 | tooltip = "The texture used for the bars.", |
|
287 | Seerah-7 | choices = LMP:List("statusbar"), |
|
288 | Seerah-7 | getFunc = function() return db.barTex end, |
|
289 | Seerah-7 | setFunc = function(val) |
|
290 | 10 | Seerah-7 | db.barTex = val |
291 | Seerah-7 | for i = 1, playerPool:GetTotalObjectCount() do |
|
292 | Seerah-7 | SetTexture(playerPool:AcquireObject(i)) |
|
293 | Seerah-7 | end |
|
294 | Seerah-7 | for i = 1, reticlePool:GetTotalObjectCount() do |
|
295 | Seerah-7 | SetTexture(reticlePool:AcquireObject(i)) |
|
296 | Seerah-7 | end |
|
297 | 13 | Seerah-7 | end, |
298 | Seerah-7 | default = defaults.barTex, |
|
299 | Seerah-7 | }, |
|
300 | Seerah-7 | [5] = { |
|
301 | Seerah-7 | type = "colorpicker", |
|
302 | Seerah-7 | name = "Statusbar Color", |
|
303 | Seerah-7 | tooltip = "The color of the statusbar.", |
|
304 | Seerah-7 | getFunc = function() return db.barColor.r, db.barColor.g, db.barColor.b, db.barColor.a end, |
|
305 | Seerah-7 | setFunc = function(r,g,b,a) |
|
306 | 10 | Seerah-7 | db.barColor.r = r |
307 | Seerah-7 | db.barColor.g = g |
|
308 | Seerah-7 | db.barColor.b = b |
|
309 | Seerah-7 | db.barColor.a = a |
|
310 | Seerah-7 | for i = 1, playerPool:GetTotalObjectCount() do |
|
311 | Seerah-7 | (playerPool:AcquireObject(i)).bar:SetColor(r, g, b, a) |
|
312 | Seerah-7 | end |
|
313 | Seerah-7 | for i = 1, reticlePool:GetTotalObjectCount() do |
|
314 | Seerah-7 | (reticlePool:AcquireObject(i)).bar:SetColor(r, g, b, a) |
|
315 | Seerah-7 | end |
|
316 | 13 | Seerah-7 | end, |
317 | Seerah-7 | default = defaults.barColor, |
|
318 | Seerah-7 | }, |
|
319 | Seerah-7 | [6] = { |
|
320 | Seerah-7 | type = "checkbox", |
|
321 | Seerah-7 | name = "Grow Player Buffs Upward", |
|
322 | Seerah-7 | tooltip = "When enabled, new buffs will be added above the anchor instead of below.", |
|
323 | Seerah-7 | getFunc = function() return db.player.growUp end, |
|
324 | Seerah-7 | setFunc = function(value) --setFunc |
|
325 | Seerah-7 | db.player.growUp = value |
|
326 | 7 | Seerah-7 | for i = 1, playerPool:GetTotalObjectCount() do |
327 | Seerah-7 | HandleAnchors(playerPool:AcquireObject(i), i, "player") |
|
328 | 4 | Seerah-7 | end |
329 | 13 | Seerah-7 | end, |
330 | Seerah-7 | default = defaults.player.growUp, |
|
331 | Seerah-7 | }, |
|
332 | Seerah-7 | [7] = { |
|
333 | Seerah-7 | type = "checkbox", |
|
334 | Seerah-7 | name = "Grow Reticleover Buffs Upward", |
|
335 | Seerah-7 | tooltip = "When enabled, new buffs will be added above the anchor instead of below.", |
|
336 | Seerah-7 | getFunc = function() return db.reticleover.growUp end, |
|
337 | Seerah-7 | setFunc = function(value) --setFunc |
|
338 | Seerah-7 | db.reticleover.growUp = value |
|
339 | 7 | Seerah-7 | for i = 1, reticlePool:GetTotalObjectCount() do |
340 | Seerah-7 | HandleAnchors(reticlePool:AcquireObject(i), i, "reticleover") |
|
341 | Seerah-7 | end |
|
342 | 13 | Seerah-7 | end, |
343 | Seerah-7 | default = defaults.reticleover.growUp, |
|
344 | Seerah-7 | }, |
|
345 | Seerah-7 | [8] = { |
|
346 | Seerah-7 | type = "checkbox", |
|
347 | Seerah-7 | name = "Display Statusbar", |
|
348 | Seerah-7 | tooltip = "Display the statusbar counting down the duration of the buff.", |
|
349 | Seerah-7 | getFunc = function() return db.displayBars end, |
|
350 | Seerah-7 | setFunc = function(value) --setFunc |
|
351 | Seerah-7 | db.displayBars = value |
|
352 | 7 | Seerah-7 | for i = 1, playerPool:GetTotalObjectCount() do |
353 | Seerah-7 | (playerPool:AcquireObject(i)).bar:SetHidden(not db.displayBars) |
|
354 | 4 | Seerah-7 | end |
355 | 7 | Seerah-7 | for i = 1, reticlePool:GetTotalObjectCount() do |
356 | Seerah-7 | (reticlePool:AcquireObject(i)).bar:SetHidden(not db.displayBars) |
|
357 | Seerah-7 | end |
|
358 | 13 | Seerah-7 | end, |
359 | Seerah-7 | default = defaults.displayBars, |
|
360 | Seerah-7 | }, |
|
361 | Seerah-7 | [9] = { |
|
362 | Seerah-7 | type = "checkbox", |
|
363 | Seerah-7 | name = "Use Default Colors for Buff/Debuff Text", |
|
364 | Seerah-7 | tooltip = "Use the default UI values for buffs (bright green) and debuffs (bright red).", |
|
365 | Seerah-7 | getFunc = function() return db.defaultTextColor end, |
|
366 | Seerah-7 | setFunc = function(value) |
|
367 | Seerah-7 | db.defaultTextColor = value |
|
368 | Seerah-7 | SetTextColors("player", playerPool) |
|
369 | Seerah-7 | SetTextColors("reticleover", reticlePool) |
|
370 | Seerah-7 | end, |
|
371 | Seerah-7 | default = defaults.defaultTextColor, |
|
372 | Seerah-7 | }, |
|
373 | Seerah-7 | [10] = { |
|
374 | Seerah-7 | type = "colorpicker", |
|
375 | Seerah-7 | name = "Buff Text Color", |
|
376 | Seerah-7 | tooltip = "The color of the text on a buff bar.", |
|
377 | Seerah-7 | getFunc = function() return db.customTextColors[BUFF_EFFECT_TYPE_BUFF].r, db.customTextColors[BUFF_EFFECT_TYPE_BUFF].g, db.customTextColors[BUFF_EFFECT_TYPE_BUFF].b end, |
|
378 | Seerah-7 | setFunc = function(r,g,b) |
|
379 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_BUFF].r = r |
|
380 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_BUFF].g = g |
|
381 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_BUFF].b = b |
|
382 | Seerah-7 | SetTextColors("player", playerPool) |
|
383 | Seerah-7 | SetTextColors("reticleover", reticlePool) |
|
384 | Seerah-7 | end, |
|
385 | Seerah-7 | width = "half", |
|
386 | Seerah-7 | disabled = function() return db.defaultTextColor end, |
|
387 | Seerah-7 | default = defaults.customTextColors[BUFF_EFFECT_TYPE_BUFF], |
|
388 | Seerah-7 | }, |
|
389 | Seerah-7 | [11] = { |
|
390 | Seerah-7 | type = "colorpicker", |
|
391 | Seerah-7 | name = "Debuff Text Color", |
|
392 | Seerah-7 | tooltip = "The color of the text on a debuff bar.", |
|
393 | Seerah-7 | getFunc = function() return db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].r, db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].g, db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].b end, |
|
394 | Seerah-7 | setFunc = function(r,g,b) |
|
395 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].r = r |
|
396 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].g = g |
|
397 | Seerah-7 | db.customTextColors[BUFF_EFFECT_TYPE_DEBUFF].b = b |
|
398 | Seerah-7 | SetTextColors("player", playerPool) |
|
399 | Seerah-7 | SetTextColors("reticleover", reticlePool) |
|
400 | Seerah-7 | end, |
|
401 | Seerah-7 | width = "half", |
|
402 | Seerah-7 | disabled = function() return db.defaultTextColor end, |
|
403 | Seerah-7 | default = defaults.customTextColors[BUFF_EFFECT_TYPE_DEBUFF], |
|
404 | Seerah-7 | }, |
|
405 | Seerah-7 | [12] = { |
|
406 | Seerah-7 | type = "header", |
|
407 | Seerah-7 | name = "Visibility Options", |
|
408 | Seerah-7 | }, |
|
409 | Seerah-7 | [13] = { |
|
410 | Seerah-7 | type = "checkbox", |
|
411 | Seerah-7 | name = "Only Show If Attackable", |
|
412 | Seerah-7 | tooltip = "Display the target's buffs only if you can attack the unit.", |
|
413 | Seerah-7 | getFunc = function() return db.attackShow end, |
|
414 | Seerah-7 | setFunc = function(value) --setFunc |
|
415 | Seerah-7 | db.attackShow = value |
|
416 | 10 | Seerah-7 | rbc:SetHidden(db.attackShow) |
417 | 13 | Seerah-7 | end, |
418 | Seerah-7 | default = defaults.attackShow, |
|
419 | Seerah-7 | }, |
|
420 | Seerah-7 | [14] = { |
|
421 | Seerah-7 | type = "checkbox", |
|
422 | Seerah-7 | name = "Only Show In Combat", |
|
423 | Seerah-7 | tooltip = "Display the target's buffs only when you are in combat.", |
|
424 | Seerah-7 | getFunc = function() return db.cmbtShow end, |
|
425 | Seerah-7 | setFunc = function(value) --setFunc |
|
426 | Seerah-7 | db.cmbtShow = value |
|
427 | 10 | Seerah-7 | if db.cmbtShow then |
428 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_COMBAT_STATE, CombatVisibility) |
|
429 | Seerah-7 | else |
|
430 | Seerah-7 | em:UnregisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_COMBAT_STATE) |
|
431 | Seerah-7 | end |
|
432 | Seerah-7 | rbc:SetHidden(db.cmbtShow) |
|
433 | 13 | Seerah-7 | end, |
434 | Seerah-7 | default = defaults.cmbtShow, |
|
435 | Seerah-7 | }, |
|
436 | Seerah-7 | [15] = { |
|
437 | Seerah-7 | type = "checkbox", |
|
438 | Seerah-7 | name = "Hide In Menus", |
|
439 | Seerah-7 | tooltip = "Hide the player buffs when in game menus and UI screens.", |
|
440 | Seerah-7 | getFunc = function() return db.menuHide end, |
|
441 | Seerah-7 | setFunc = function(value) --setFunc |
|
442 | Seerah-7 | db.menuHide = value |
|
443 | 10 | Seerah-7 | if db.menuHide then |
444 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_POPPED, MenuVisibility) |
|
445 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_PUSHED, MenuVisibility) |
|
446 | Seerah-7 | else |
|
447 | Seerah-7 | em:UnregisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_POPPED, MenuVisibility) |
|
448 | Seerah-7 | em:UnregisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_PUSHED, MenuVisibility) |
|
449 | Seerah-7 | end |
|
450 | Seerah-7 | pbc:SetHidden(db.menuHide) |
|
451 | Seerah-7 | changevisibility = EVENT_ACTION_LAYER_POPPED |
|
452 | 13 | Seerah-7 | end, |
453 | Seerah-7 | default = defaults.menuHide, |
|
454 | Seerah-7 | }, |
|
455 | Seerah-7 | } |
|
456 | Seerah-7 | ||
457 | Seerah-7 | local function CreateOptions() |
|
458 | Seerah-7 | LAM:RegisterAddonPanel("ZAMBuffDisplayOptions", panelData) |
|
459 | Seerah-7 | LAM:RegisterOptionControls("ZAMBuffDisplayOptions", optionsData) |
|
460 | 4 | Seerah-7 | end |
461 | Seerah-7 | ||
462 | Seerah-7 | local function Initialize() |
|
463 | Seerah-7 | ZAM_BuffDisplayDB = ZAM_BuffDisplayDB or {} |
|
464 | Seerah-7 | for k,v in pairs(defaults) do |
|
465 | Seerah-7 | if type(ZAM_BuffDisplayDB[k]) == "nil" then |
|
466 | Seerah-7 | ZAM_BuffDisplayDB[k] = v |
|
467 | Seerah-7 | end |
|
468 | Seerah-7 | end |
|
469 | Seerah-7 | db = ZAM_BuffDisplayDB |
|
470 | Seerah-7 | ||
471 | 7 | Seerah-7 | SetUpContainer("player") |
472 | Seerah-7 | SetUpContainer("reticleover") |
|
473 | 4 | Seerah-7 | CreateOptions() |
474 | Seerah-7 | ||
475 | 7 | Seerah-7 | playerPool = ZO_ObjectPool:New(CreateBuff, RemoveBuff) |
476 | Seerah-7 | reticlePool = ZO_ObjectPool:New(CreateBuff, RemoveBuff) |
|
477 | Seerah-7 | UpdateBuffs("player") |
|
478 | 4 | Seerah-7 | |
479 | 10 | Seerah-7 | if db.cmbtShow then |
480 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_COMBAT_STATE, CombatVisibility) |
|
481 | Seerah-7 | rbc:SetHidden(true) |
|
482 | Seerah-7 | end |
|
483 | Seerah-7 | if db.menuHide then |
|
484 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_POPPED, MenuVisibility) |
|
485 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_ACTION_LAYER_PUSHED, MenuVisibility) |
|
486 | Seerah-7 | end |
|
487 | Seerah-7 | ||
488 | 7 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_EFFECT_CHANGED, function(event, changeType, effectSlot, effectName, unitTag, beginTime, endTime, stackCount, iconName, buffType, effectType, abilityType, statusEffectType) |
489 | Seerah-7 | if unitTag =="player" or unitTag == "reticleover" then |
|
490 | Seerah-7 | UpdateBuffs(unitTag) |
|
491 | 4 | Seerah-7 | end |
492 | 7 | Seerah-7 | if effectType == 5 then print(effectName.." = passive?") return end |
493 | 4 | Seerah-7 | end) |
494 | 11 | Seerah-7 | em:UnregisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_ACTIVATED) --the next event handler was adding to instead of replacing the old one >< |
495 | 9 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_ACTIVATED, function() |
496 | Seerah-7 | UpdateBuffs("player") |
|
497 | Seerah-7 | end) |
|
498 | 4 | Seerah-7 | end |
499 | Seerah-7 | ||
500 | 10 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_PLAYER_ACTIVATED, function() |
501 | Seerah-7 | --em:RegisterForEvent("ZAM_BuffDisplay", EVENT_ADD_ON_LOADED, function(event, addon) |
|
502 | 13 | Seerah-7 | -- if addon == "ZAM_BuffDisplay" then |
503 | 4 | Seerah-7 | Initialize() |
504 | 13 | Seerah-7 | -- em:UnregisterForEvent("ZAM_BuffDisplay", EVENT_ADD_ON_LOADED) |
505 | Seerah-7 | -- end |
|
506 | 4 | Seerah-7 | end) |
507 | 7 | Seerah-7 | em:RegisterForEvent("ZAM_BuffDisplay", EVENT_RETICLE_TARGET_CHANGED, function() |
508 | Seerah-7 | UpdateBuffs("reticleover") |
|
509 | Seerah-7 | end) |
|
510 | 4 | Seerah-7 | |
511 | 7 | Seerah-7 | --em:RegisterForEvent("ZAM_BuffDisplay", EVENT_EFFECTS_FULL_UPDATE, function() print("full update") endem |