Skip to content

Commit 994cbc0

Browse files
committed
Merge branch 'feature/annotations'
2 parents 679ba97 + db27f42 commit 994cbc0

File tree

12 files changed

+296
-101
lines changed

12 files changed

+296
-101
lines changed

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
"WOW_PROJECT_ID",
4242
"WOW_PROJECT_MAINLINE"
4343
],
44-
"Lua.workspace.library": [
45-
"~/.vscode/extensions/ketho.wow-api-0.17.4/Annotations"
46-
],
4744
"Lua.runtime.builtin": {
4845
"basic": "disable",
4946
"debug": "disable",

Broker.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
1818
--]]
1919

20-
local _, KT = ...
20+
---@class KillTrack
21+
local KT = select(2, ...)
2122

22-
KT.Broker = {
23+
---@class KillTrackBroker
24+
local KTB = {
2325
Text = {
2426
Short = "KPM: %.2f",
2527
Long = "Kills Per Minute: %.2f"
2628
}
2729
}
2830

31+
KT.Broker = KTB
2932
local KTT = KT.Tools
30-
local KTB = KT.Broker
3133

3234
local UPDATE = 1
3335
local t = 0
@@ -62,9 +64,10 @@ local clickFunctions = {
6264
}
6365
}
6466

65-
local obj = ldb:NewDataObject("Broker_KillTrack", data)
67+
local obj = ldb:NewDataObject("Broker_KillTrack", data) --[[@as LibDataBroker.DataDisplay]]
6668

67-
function obj:OnTooltipShow()
69+
---@param self GameTooltip
70+
function obj.OnTooltipShow(self)
6871
self:AddLine(("%s |cff00FF00(%s)|r"):format(KT.Name, KT.Version), 1, 1, 1)
6972
self:AddLine(" ")
7073
local _, kpm, kph, length = KT:GetSessionStats()
@@ -110,7 +113,7 @@ function obj:OnClick(button)
110113
end
111114

112115
function obj:OnEnter()
113-
GameTooltip:SetOwner(self, "ANCHOR_NONE")
116+
GameTooltip:SetOwner(self --[[@as Frame]], "ANCHOR_NONE")
114117
GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT")
115118
KTB:UpdateTooltip()
116119
tooltipVisible = true
@@ -132,6 +135,8 @@ function KTB:UpdateTooltip()
132135
GameTooltip:Show()
133136
end
134137

138+
---@param _ Frame
139+
---@param elapsed number
135140
function KTB:OnUpdate(_, elapsed)
136141
t = t + elapsed
137142
if t >= UPDATE then
@@ -155,6 +160,7 @@ function KTB:OnLoad()
155160
self:UpdateText()
156161
end
157162

163+
---@param enabled boolean
158164
function KTB:SetMinimap(enabled)
159165
KT.Global.BROKER.MINIMAP.hide = not enabled
160166
if enabled then

Command.lua

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@
1717
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
1818
--]]
1919

20-
local _, KT = ...
20+
---@class KillTrack
21+
local KT = select(2, ...)
2122

22-
KT.Command = {
23+
---@class KillTrackCommand
24+
local C = {
2325
Slash = {
2426
"killtrack",
2527
"kt"
2628
},
29+
---@type { [string]: fun(args: string[]) }
2730
Commands = {}
2831
}
2932

30-
local C = KT.Command
33+
KT.Command = C
3134
local KTT = KT.Tools
3235

3336
-- Argument #1 (command) can be either string or a table.
37+
---@param command string|string[]
38+
---@param func fun(args: string[])
3439
function C:Register(command, func)
3540
if type(command) == "string" then
3641
command = {command}
@@ -43,18 +48,24 @@ function C:Register(command, func)
4348
end
4449
end
4550

51+
---@param command string
52+
---@return boolean
4653
function C:HasCommand(command)
4754
for k,_ in pairs(self.Commands) do
4855
if k == command then return true end
4956
end
5057
return false
5158
end
5259

60+
---@param command string
61+
---@return fun(args: string[])
5362
function C:GetCommand(command)
5463
local cmd = self.Commands[command]
5564
if cmd then return cmd else return self.Commands["__DEFAULT__"] end
5665
end
5766

67+
---@param command string
68+
---@param args string[]
5869
function C:HandleCommand(command, args)
5970
local cmd = self:GetCommand(command)
6071
if cmd then
@@ -112,10 +123,10 @@ C:Register({"printnew", "pn"}, function()
112123
end)
113124

114125
C:Register({"set", "edit"}, function(args)
115-
local id = tonumber(args[1])
126+
local id = tonumber(args[1]) --[[@as integer]]
116127
local name = args[2]
117-
local global = tonumber(args[3])
118-
local char = tonumber(args[4])
128+
local global = tonumber(args[3]) --[[@as integer]]
129+
local char = tonumber(args[4]) --[[@as integer]]
119130

120131
local err
121132

@@ -166,8 +177,9 @@ C:Register({"delete", "del", "remove", "rem"}, function(args)
166177
end)
167178

168179
C:Register({"purge"}, function(args)
180+
---@type integer?
169181
local threshold
170-
if #args >= 1 then threshold = tonumber(args[1]) end
182+
if #args >= 1 then threshold = tonumber(args[1]) --[[@as integer]] end
171183
KT:ShowPurge(threshold)
172184
end)
173185

@@ -218,7 +230,7 @@ C:Register({"immediate", "imm", "i"}, function(args)
218230
if #args < 1 then
219231
KT.Immediate:Show()
220232
elseif args[1]:match("^t") then
221-
local threshold = tonumber(args[2])
233+
local threshold = tonumber(args[2]) --[[@as integer]]
222234
if #args < 2 then
223235
KT:Msg("Usage: immediate threshold <threshold>")
224236
KT:Msg("E.g: /kt immediate threshold 50")

Dialogs.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
1818
--]]
1919

20-
local _, KT = ...
20+
---@class KillTrack
21+
local KT = select(2, ...)
2122

2223
StaticPopupDialogs.KILLTRACK_FINISH = {
2324
text = "%s entries removed.",
@@ -47,7 +48,7 @@ StaticPopupDialogs.KILLTRACK_PURGE = {
4748
button2 = "Cancel",
4849
hasEditBox = true,
4950
OnAccept = function(self)
50-
KT:Purge(tonumber(self.editBox:GetText())) KT.MobList:UpdateMobs() KT.MobList:UpdateEntries()
51+
KT:Purge(tonumber(self.editBox:GetText()) --[[@as integer]]) KT.MobList:UpdateMobs() KT.MobList:UpdateEntries()
5152
end,
5253
OnCancel = function() KT.Temp.Threshold = nil end,
5354
OnShow = function(self)
@@ -83,14 +84,17 @@ StaticPopupDialogs.KILLTRACK_RESET = {
8384
hideOnEscape = true
8485
}
8586

87+
---@param id integer|string
88+
---@param name string
8689
function KT:ShowDelete(id, name)
87-
id = tonumber(id)
90+
id = tonumber(id) --[[@as integer]]
8891
name = tostring(name)
8992
if not id then error("'id' must be a number.") end
9093
self.Temp.DeleteId = id
9194
StaticPopup_Show("KILLTRACK_DELETE", name, id)
9295
end
9396

97+
---@param threshold integer?
9498
function KT:ShowPurge(threshold)
9599
if tonumber(threshold) then
96100
self.Temp.Threshold = tonumber(threshold)

ExpTracker.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
1818
--]]
1919

20-
local _, KT = ...
20+
---@class KillTrack
21+
local KT = select(2, ...)
2122

22-
KT.ExpTracker = {
23+
---@class KillTrackExpTracker
24+
local ET = {
25+
---@type string[]
2326
Strings = {
2427
---@diagnostic disable: undefined-field
2528
_G.COMBATLOG_XPGAIN_EXHAUSTION1, -- %s dies, you gain %d experience. (%s exp %s bonus)
@@ -41,7 +44,7 @@ KT.ExpTracker = {
4144
}
4245
}
4346

44-
local ET = KT.ExpTracker
47+
KT.ExpTracker = ET
4548

4649
local initialized = false
4750

@@ -52,6 +55,7 @@ local function Initialize()
5255
initialized = true
5356
end
5457

58+
---@param message string
5559
function ET:CheckMessage(message)
5660
if not initialized then Initialize() end
5761
local name, exp

ImmediateFrame.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
1818
--]]
1919

20-
local _, KT = ...
20+
---@class KillTrack
21+
local KT = select(2, ...)
2122

22-
KT.Immediate = {
23+
---@class KillTrackImmediateFrame
24+
local I = {
2325
Active = false,
2426
Kills = 0
2527
}
2628

27-
local I = KT.Immediate
29+
KT.Immediate = I
2830

2931
local frame
3032

@@ -98,15 +100,15 @@ end
98100
function I:Show()
99101
if not frame then SetupFrame() end
100102
self.Kills = 0
101-
frame.killCount:SetText(self.Kills)
103+
frame.killCount:SetText(tostring(self.Kills))
102104
frame:Show()
103105
self.Active = true
104106
end
105107

106108
function I:Hide()
107109
frame:Hide()
108110
self.Kills = 0
109-
frame.killCount:SetText(self.Kills)
111+
frame.killCount:SetText(tostring(self.Kills))
110112
self.Active = false
111113
end
112114

0 commit comments

Comments
 (0)