List of commits:
Subject Hash Author Date (UTC)
feat: Reduce update load 76a011715619c33caed714fec4161e53ecb1512c Vladyslav Bondarenko 2021-01-16 19:47:37
feat: Track more relevant effects f5f8803fa3cb59b43e144d9e53ea50fafcc23008 Vladyslav Bondarenko 2021-01-16 12:40:07
fix: Code base maintainance Add documentation and sanitise some arguments. 52e74dfb3f9fce8617ed4d4c63105966bb388daa Vladyslav Bondarenko 2021-01-12 13:07:49
fix: Typo The error did not affect performance. 216d3738bf4ef2de6be1361b7e2b57a6a7387f71 Vladyslav Bondarenko 2021-01-12 01:28:45
feat!: Show indicators correctly while in combat 0b6bf32b2a6ad2537b8cba766384e2d7f4b053d5 Vladyslav Bondarenko 2021-01-11 23:35:19
Initial commit 447e6a5ac2cc64f0f818663ba08681615327b19a Vladyslav Bondarenko 2021-01-11 20:26:55
Commit 76a011715619c33caed714fec4161e53ecb1512c - feat: Reduce update load
To improve performance reduce the frequency of cooldown text updates.
Track more relevant effects.

Additionally improve maintainability of the initialization code
and tighten the GUI appearance.
Author: Vladyslav Bondarenko
Author date (UTC): 2021-01-16 19:47
Committer name: Vladyslav Bondarenko
Committer date (UTC): 2021-01-16 19:47
Parent(s): dd6de088ac75f2787164a135e8d7e247048c43eb
Signer:
Signing key:
Signing status: N
Tree: a3fb6702d7fa1a08b6dfc16e0a57b6cb2c8d6b9a
File Lines added Lines deleted
daybreak.lua 82 88
daybreak.toc 1 1
File daybreak.lua changed (mode: 100644) (index 2b3088a..11564d9)
... ... local function getMaxHolyPower()
22 22 end end
23 23
24 24 --[[-- --[[--
25 Process reaction to UNIT_AURA event for aura indicator.
26 When aura disappears from the unit associated with this button,
27 hide the button. Show it otherwise.
28 @function acceptUnitAura
29 @tparam button frame this button frame to update
30 @tparam string eventCategory given event category designation
25 Process timer tick to update remaining aura duration.
26 The update employs artificial delay to hopefully reduce the memory cost of updates.
27 @function applyUpdate
28 @tparam frame button button to update
29 @tparam number updateDurationSec amount of seconds elapsed since last update
31 30 @return nothing @return nothing
32 31 ]] ]]
33 local function acceptUnitAura(button, eventCategory)
32 local function applyUpdate(button, updateDurationSec)
34 33 assert (button ~= nil) assert (button ~= nil)
35 assert (eventCategory ~= nil)
36 assert ('string' == type(eventCategory))
37 assert (string.len(eventCategory) >= 2)
38 assert (string.len(eventCategory) <= 256)
34
35 assert (updateDurationSec ~= nil)
36 assert ('number' == type(updateDurationSec))
37 updateDurationSec = math.max(0, updateDurationSec)
38
39 local updateCooldownDurationSec = button.updateCooldownDurationSec
40 if nil == updateCooldownDurationSec then
41 updateCooldownDurationSec = 0
42 end
43 assert (updateCooldownDurationSec ~= nil)
44 assert ('number' == type(updateCooldownDurationSec))
45 updateCooldownDurationSec = math.max(0, updateCooldownDurationSec)
46 updateCooldownDurationSec = updateCooldownDurationSec - updateDurationSec
47
48 if updateCooldownDurationSec > 0 then
49 button.updateCooldownDurationSec = updateCooldownDurationSec
50 return
51 else
52 updateCooldownDurationSec = 0.084
53 button.updateCooldownDurationSec = updateCooldownDurationSec
54 end
39 55
40 56 local auraName = button.spell local auraName = button.spell
41 57 assert (auraName ~= nil) assert (auraName ~= nil)
 
... ... local function acceptUnitAura(button, eventCategory)
49 65 assert (string.len(unitDesignation) >= 2) assert (string.len(unitDesignation) >= 2)
50 66 assert (string.len(unitDesignation) <= 256) assert (string.len(unitDesignation) <= 256)
51 67
52 local name, _, icon = UnitBuff(unitDesignation, auraName)
53 if name then
54 --[[ FIXME Apply graphics only once instead of every aura update ]]--
55 button:SetNormalTexture(icon)
56 button:Show()
57 else
58 button:Hide()
68 local _, _, _, _, _, _, expirationInstance = UnitBuff(unitDesignation, auraName)
69 if nil == expirationInstance then
70 return
59 71 end end
72 local now = GetTime()
73 local remainingDuration = math.max(0, math.ceil(expirationInstance - now))
74 button:SetText(remainingDuration)
60 75 end end
61 76
62 77 --[[-- --[[--
63 Process timer tick to update remaining aura duration.
64 @function applyUpdate
65 @tparam frame button to update
78 Process reaction to UNIT_AURA event for aura indicator.
79 When aura disappears from the unit associated with this button,
80 hide the button. Show it otherwise.
81 @function acceptUnitAura
82 @tparam button frame this button frame to update
83 @tparam string eventCategory given event category designation
66 84 @return nothing @return nothing
67 85 ]] ]]
68 local function applyUpdate(button)
86 local function acceptUnitAura(button, eventCategory)
69 87 assert (button ~= nil) assert (button ~= nil)
88 assert (eventCategory ~= nil)
89 assert ('string' == type(eventCategory))
90 assert (string.len(eventCategory) >= 2)
91 assert (string.len(eventCategory) <= 256)
70 92
71 93 local auraName = button.spell local auraName = button.spell
72 94 assert (auraName ~= nil) assert (auraName ~= nil)
 
... ... local function applyUpdate(button)
80 102 assert (string.len(unitDesignation) >= 2) assert (string.len(unitDesignation) >= 2)
81 103 assert (string.len(unitDesignation) <= 256) assert (string.len(unitDesignation) <= 256)
82 104
83 local _, _, _, _, _, _, expirationInstance = UnitBuff(unitDesignation, auraName)
84 if nil == expirationInstance then
85 return
105 local name, _, icon = UnitBuff(unitDesignation, auraName)
106 if name then
107 --[[ FIXME Apply graphics only once instead of every aura update ]]--
108 button:SetNormalTexture(icon)
109 button:Show()
110 button:SetScript('OnUpdate', applyUpdate)
111 else
112 button:Hide()
113 button:SetScript('OnUpdate', nil)
86 114 end end
87 local now = GetTime()
88 local remainingDuration = math.ceil(expirationInstance - now)
89 button:SetText(remainingDuration)
90 115 end end
91 116
92 117 --[[-- --[[--
 
... ... end
146 171 Allocate button frame that represents a single aura Allocate button frame that represents a single aura
147 172 New button has two custom fields: unit and spell. New button has two custom fields: unit and spell.
148 173 that is potentially applied to the player character. that is potentially applied to the player character.
174 The order of parameters allows for predictable
175 code line sorting.
149 176 @function createButton @function createButton
177 @tparam number column horizontal position
178 @tparam number row vertical position
179 @tparam string localizedSpellName aura name to track
150 180 @tparam string buttonName @tparam string buttonName
151 181 @tparam frame parentFrame @tparam frame parentFrame
152 @tparam string localizedSpellName aura name to track
153 182 @treturn frame newly allocated button frame instance @treturn frame newly allocated button frame instance
154 183 ]] ]]
155 local function createButton(buttonName, parentFrame, localizedSpellName)
184 local function createButton(column, row, localizedSpellName, buttonName, parentFrame)
156 185 assert (buttonName ~= nil) assert (buttonName ~= nil)
157 186 assert ('string' == type(buttonName)) assert ('string' == type(buttonName))
158 187 assert (string.len(buttonName) >= 2) assert (string.len(buttonName) >= 2)
 
... ... local function createButton(buttonName, parentFrame, localizedSpellName)
166 195 assert (string.len(localizedSpellName) <= 256) assert (string.len(localizedSpellName) <= 256)
167 196
168 197 local button = CreateFrame('BUTTON', buttonName, parentFrame) local button = CreateFrame('BUTTON', buttonName, parentFrame)
198 local padding = 8
169 199 local size = getDefaultButtonSize() local size = getDefaultButtonSize()
200 local s = size + padding
170 201 button:SetSize(size, size) button:SetSize(size, size)
202 button:SetPoint('BOTTOMLEFT', column * s, row * s)
171 203
172 204 local text = button:CreateFontString(button:GetName() .. 'Text', 'OVERLAY') local text = button:CreateFontString(button:GetName() .. 'Text', 'OVERLAY')
173 205 text:SetFontObject(DaybreakFont) text:SetFontObject(DaybreakFont)
 
... ... local function createButton(buttonName, parentFrame, localizedSpellName)
181 213
182 214 button:RegisterEvent('UNIT_AURA') button:RegisterEvent('UNIT_AURA')
183 215 button:SetScript('OnEvent', acceptUnitAura) button:SetScript('OnEvent', acceptUnitAura)
184 button:SetScript('OnUpdate', applyUpdate)
185 216
186 217 button:Hide() button:Hide()
187 218
 
... ... Must only be executed once per script lifetime.
198 229 local function init(rootFrame) local function init(rootFrame)
199 230 assert (rootFrame ~= nil) assert (rootFrame ~= nil)
200 231
201 rootFrame:SetSize(384, 384)
232 rootFrame:SetSize(256, 256)
202 233 rootFrame:SetPoint('CENTER', UIParent, rootFrame:SetPoint('CENTER', UIParent,
203 234 'CENTER', 0, 0) 'CENTER', 0, 0)
204 235
 
... ... local function init(rootFrame)
206 237 hpf:SetPoint('CENTER', 0, 0) hpf:SetPoint('CENTER', 0, 0)
207 238 hpf:SetPoint('BOTTOM', 0, 0) hpf:SetPoint('BOTTOM', 0, 0)
208 239
209 local padding = 8
210 local size = getDefaultButtonSize() + padding
211
212 240 --[[ General ]]-- --[[ General ]]--
213 local wings = createButton('DaybreakButton01', rootFrame, 'Avenging Wrath')
214 wings:SetPoint('BOTTOMLEFT', 0 * size, 3 * size)
215
216 local protection = createButton('DaybreakButton02', rootFrame, 'Divine Protection')
217 protection:SetPoint('BOTTOMLEFT', 0 * size, 2 * size)
218
219 local bubble = createButton('DaybreakButton03', rootFrame, 'Divine Shield')
220 bubble:SetPoint('BOTTOMLEFT', 0 * size, 2 * size)
221
222 local plea = createButton('DaybreakButton04', rootFrame, 'Divine Plea')
223 plea:SetPoint('BOTTOMLEFT', 0 * size, 1 * size)
224
225 local crusader = createButton('DaybreakButton05', rootFrame, 'Crusader')
226 crusader:SetPoint('BOTTOMLEFT', 0 * size, 0 * size)
241 createButton(0, 0, 'Crusader', 'DaybreakButton01', rootFrame)
242 createButton(0, 1, 'Divine Plea', 'DaybreakButton02', rootFrame)
243 createButton(0, 2, 'Divine Shield', 'DaybreakButton03', rootFrame)
244 createButton(0, 3, 'Avenging Wrath', 'DaybreakButton04', rootFrame)
245 createButton(0, 3, 'Divine Protection', 'DaybreakButton05', rootFrame)
227 246
228 247 --[[ Effects that may be applied by other players place on the right side ]]-- --[[ Effects that may be applied by other players place on the right side ]]--
229 local hop = createButton('DaybreakButton06', rootFrame, 'Hand of Protection')
230 hop:SetPoint('BOTTOMRIGHT', 0 * size, 3 * size)
231
232 local freedom = createButton('DaybreakButton07', rootFrame, 'Hand of Freedom')
233 freedom:SetPoint('BOTTOMRIGHT', 0 * size, 0 * size)
234
235 local sac = createButton('DaybreakButton18', rootFrame, 'Hand of Sacrifice')
236 sac:SetPoint('BOTTOMRIGHT', 0 * size, 1 * size)
237
238 local divineSac = createButton('DaybreakButton19', rootFrame, 'Divine Sacrifice')
239 divineSac:SetPoint('BOTTOMRIGHT', 0 * size, 2 * size)
240
241 local illuminatedHealing = createButton('DaybreakButton08', rootFrame, 'Illuminated Healing')
242 illuminatedHealing:SetPoint('BOTTOMRIGHT', 1 * size, 1 * size)
248 createButton(6, 0, 'Hand of Freedom', 'DaybreakButton06', rootFrame)
249 createButton(6, 1, 'Hand of Sacrifice', 'DaybreakButton07', rootFrame)
250 createButton(6, 2, 'Hand of Protection', 'DaybreakButton08', rootFrame)
251 createButton(6, 3, 'Divine Sacrifice', 'DaybreakButton09', rootFrame)
252 createButton(7, 0, 'Illuminated Healing', 'DaybreakButton10', rootFrame)
243 253
244 254 --[[ Holy ]]-- --[[ Holy ]]--
245 local daybreak = createButton('DaybreakButton09', rootFrame, 'Daybreak')
246 daybreak:SetPoint('BOTTOMLEFT', 1 * size, 1 * size)
247
248 local infusion = createButton('DaybreakButton10', rootFrame, 'Infusion of Light')
249 infusion:SetPoint('BOTTOMLEFT', 1 * size, 2 * size)
250
251 local judgement = createButton('DaybreakButton11', rootFrame, 'Judgements of the Pure')
252 judgement:SetPoint('BOTTOMLEFT', 1 * size, 0 * size)
253
254 local favor = createButton('DaybreakButton12', rootFrame, 'Divine Favor')
255 favor:SetPoint('BOTTOMLEFT', 1 * size, 3 * size)
255 createButton(1, 0, 'Judgements of the Pure', 'DaybreakButton11', rootFrame)
256 createButton(1, 1, 'Daybreak', 'DaybreakButton12', rootFrame)
257 createButton(1, 2, 'Infusion of Light', 'DaybreakButton13', rootFrame)
258 createButton(1, 3, 'Divine Favor', 'DaybreakButton14', rootFrame)
256 259
257 260 --[[ Protection ]]-- --[[ Protection ]]--
258 local grandCrusader = createButton('DaybreakButton13', rootFrame, 'Grand Crusader')
259 grandCrusader:SetPoint('BOTTOMLEFT', 2 * size, 1 * size)
260
261 local shield = createButton('DaybreakButton15', rootFrame, 'Holy Shield')
262 shield:SetPoint('BOTTOMLEFT', 1 * size, 1 * size)
263
264 local absorb = createButton('DaybreakButton15', rootFrame, 'Guarded by the Light')
265 absorb:SetPoint('BOTTOMLEFT', 1 * size, 0 * size)
266
267 local duty = createButton('DaybreakButton16', rootFrame, 'Sacred Duty')
268 duty:SetPoint('BOTTOMLEFT', 2 * size, 0 * size)
269
270 local ardent = createButton('DaybreakButton17', rootFrame, 'Ardent Defender')
271 ardent:SetPoint('BOTTOMLEFT', 1 * size, 2 * size)
261 createButton(1, 0, 'Guarded by the Light', 'DaybreakButton15', rootFrame)
262 createButton(1, 1, 'Holy Shield', 'DaybreakButton16', rootFrame)
263 createButton(1, 2, 'Ardent Defender', 'DaybreakButton17', rootFrame)
264 createButton(1, 3, 'Grand Crusader', 'DaybreakButton18', rootFrame)
265 createButton(1, 4, 'Sacred Duty', 'DaybreakButton19', rootFrame)
272 266
273 267 --[[ Retribution ]]-- --[[ Retribution ]]--
274 268
File daybreak.toc changed (mode: 100644) (index 1dca9f2..15577f9)
1 1 ##Interface: 40300 ##Interface: 40300
2 2 ##Title: Daybreak ##Title: Daybreak
3 ##Version: 0.0.4-SNAPSHOT
3 ##Version: 0.0.5-SNAPSHOT
4 4 ##Notes: Add paladin player buff indicator ##Notes: Add paladin player buff indicator
5 5 daybreak.xml daybreak.xml
6 6 daybreak.lua daybreak.lua
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/wowaddons

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/wowaddons

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/wowaddons

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main