-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ImmediateFrame.lua
126 lines (111 loc) · 3.68 KB
/
ImmediateFrame.lua
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
--[[
* Copyright (c) 2013 by Adam Hellberg.
*
* This file is part of KillTrack.
*
* KillTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KillTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with KillTrack. If not, see <http://www.gnu.org/licenses/>.
--]]
---@class KillTrack
local KT = select(2, ...)
---@class KillTrackImmediateFrame
local I = {
Active = false,
Kills = 0
}
KT.Immediate = I
local frame
local function SetupFrame()
if frame then return end
local G = KT.Global.IMMEDIATE
frame = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate")
frame:Hide()
frame:EnableMouse(true)
frame:SetMovable(true)
if G.POSITION.POINT then
frame:SetPoint(G.POSITION.POINT, UIParent, G.POSITION.RELATIVE, G.POSITION.X, G.POSITION.Y)
else
frame:SetPoint("CENTER")
end
frame:SetWidth(240)
frame:SetHeight(30)
local bd = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
edgeSize = 16,
tileSize = 32,
insets = {
left = 2.5,
right = 2.5,
top = 2.5,
bottom = 2.5
}
}
frame:SetBackdrop(bd)
frame:SetScript("OnMouseDown", function(f) f:StartMoving() end)
frame:SetScript("OnMouseUp", function(f)
f:StopMovingOrSizing()
local point, _, relative, x, y = f:GetPoint()
G.POSITION.POINT = point
G.POSITION.RELATIVE = relative
G.POSITION.X = x
G.POSITION.Y = y
end)
---@diagnostic disable-next-line: inject-field
frame.killLabel = frame:CreateFontString(nil, "OVERLAY", nil)
frame.killLabel:SetFont("Fonts\\FRIZQT__.TTF", 16, nil)
frame.killLabel:SetWidth(100)
--frame.killLabel:SetHeight(24)
frame.killLabel:SetPoint("LEFT", frame, "LEFT", 2, 0)
frame.killLabel:SetText("Kills so far:")
---@diagnostic disable-next-line: inject-field
frame.killCount = frame:CreateFontString(nil, "OVERLAY", nil)
frame.killCount:SetFont("Fonts\\FRIZQT__.TTF", 16, nil)
frame.killCount:SetWidth(100)
--frame.killCount:SetHeight(24)
frame.killCount:SetPoint("RIGHT", frame, "RIGHT", -68, 0)
frame.killCount:SetJustifyH("RIGHT")
frame.killCount:SetText("0")
---@diagnostic disable-next-line: inject-field
frame.closeButton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
frame.closeButton:SetWidth(60)
frame.closeButton:SetHeight(24)
frame.closeButton:SetPoint("RIGHT", frame, "RIGHT", -3, 0)
frame.closeButton:SetText("Close")
frame.closeButton:SetScript("OnClick", function() I:Hide() end)
end
function I:Show()
if not frame then SetupFrame() end
self.Kills = 0
frame.killCount:SetText(tostring(self.Kills))
frame:Show()
self.Active = true
end
function I:Hide()
frame:Hide()
self.Kills = 0
frame.killCount:SetText(tostring(self.Kills))
self.Active = false
end
function I:Toggle()
if frame and frame:IsShown() then
self:Hide()
else
self:Show()
end
end
function I:AddKill()
self.Kills = self.Kills + 1
frame.killCount:SetText(tostring(self.Kills))
end