forked from Tercioo/Details-Damage-Meter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_macros.lua
148 lines (117 loc) · 6.39 KB
/
window_macros.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
local Details = _G.Details
local DF = _G.DetailsFramework
local _
function Details:InitializeMacrosWindow()
local DetailsMacrosPanel = DF:CreateSimplePanel(UIParent, 700, 480, "Details! Useful Macros", "DetailsMacrosPanel")
DetailsMacrosPanel.Frame = DetailsMacrosPanel
DetailsMacrosPanel.__name = "Macros"
DetailsMacrosPanel.real_name = "DETAILS_MACROSWINDOW"
DetailsMacrosPanel.__icon = [[Interface\MacroFrame\MacroFrame-Icon]]
DetailsMacrosPanel.__iconcoords = {0, 1, 0, 1}
DetailsMacrosPanel.__iconcolor = "white"
DetailsPluginContainerWindow.EmbedPlugin (DetailsMacrosPanel, DetailsMacrosPanel, true)
function DetailsMacrosPanel.RefreshWindow()
Details.OpenMacrosWindow()
end
DetailsMacrosPanel:Hide()
end
function Details.OpenMacrosWindow()
if (not DetailsMacrosPanel or not DetailsMacrosPanel.Initialized) then
DetailsMacrosPanel.Initialized = true
local f = DetailsMacrosPanel or DF:CreateSimplePanel(UIParent, 700, 480, "Details! Useful Macros", "DetailsMacrosPanel")
local scrollbox_line_backdrop_color = {0, 0, 0, 0.2}
local scrollbox_line_backdrop_color_onenter = {.3, .3, .3, 0.5}
local scrollbox_lines = 7
local scrollbox_line_height = 79.5
local scrollbox_size = {890, 563}
f.bg1 = f:CreateTexture(nil, "background")
f.bg1:SetTexture([[Interface\AddOns\Details\images\background]], true)
f.bg1:SetAlpha(0.8)
f.bg1:SetVertexColor(0.27, 0.27, 0.27)
f.bg1:SetVertTile(true)
f.bg1:SetHorizTile(true)
f.bg1:SetSize(790, 454)
f.bg1:SetAllPoints()
f:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
f:SetBackdropColor(.5, .5, .5, .7)
f:SetBackdropBorderColor(0, 0, 0, 1)
local macrosAvailable = Details.MacroList
local OnEnterMacroButton = function(self)
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_onenter))
end
local onLeaveMacroButton = function(self)
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
end
local updateMacroLine = function(self, index, title, desc, macroText)
self.Title:SetText(title)
self.Desc:SetText(desc)
self.MacroTextEntry:SetText(macroText)
end
local textEntryOnFocusGained = function(self)
self:HighlightText()
end
local textEntryOnFocusLost = function(self)
self:HighlightText (0, 0)
end
local refreshMacroScrollbox = function(self, data, offset, totalLines)
for i = 1, totalLines do
local index = i + offset
local macro = macrosAvailable [index]
if (macro) then
local line = self:GetLine (i)
line:UpdateLine (index, macro.Name, macro.Desc, macro.MacroText)
end
end
end
local macroListCreateLine = function(self, index)
--create a new line
local line = CreateFrame("button", "$parentLine" .. index, self,"BackdropTemplate")
--set its parameters
line:SetPoint("topleft", self, "topleft", 0, -((index-1) * (scrollbox_line_height+1)))
line:SetSize(scrollbox_size[1], scrollbox_line_height)
line:SetScript("OnEnter", OnEnterMacroButton)
line:SetScript("OnLeave", onLeaveMacroButton)
line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
line:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
line:SetBackdropBorderColor(0, 0, 0, 0.3)
local titleLabel = DF:CreateLabel(line, "", DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
titleLabel.textsize = 14
titleLabel.textcolor = "yellow"
local descLabel = DF:CreateLabel(line, "", DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
descLabel.textsize = 12
local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
options_dropdown_template = DF.table.copy({}, options_dropdown_template)
options_dropdown_template.backdropcolor = {.51, .51, .51, .3}
options_dropdown_template.onenterbordercolor = {.51, .51, .51, .2}
local textEntry = DF:CreateTextEntry(line, function()end, scrollbox_size[1] - 10, 40, "MacroTextEntry", _, _, options_dropdown_template)
textEntry:SetHook("OnEditFocusGained", textEntryOnFocusGained)
textEntry:SetHook("OnEditFocusLost", textEntryOnFocusLost)
textEntry:SetJustifyH("left")
textEntry:SetTextInsets(8, 8, 0, 0)
titleLabel:SetPoint("topleft", line, "topleft", 5, -5)
descLabel:SetPoint("topleft", titleLabel, "bottomleft", 0, -2)
textEntry:SetPoint("topleft", descLabel, "bottomleft", 0, -4)
line.Title = titleLabel
line.Desc = descLabel
line.MacroTextEntry = textEntry
line.UpdateLine = updateMacroLine
line:Hide()
return line
end
local macroScrollbox = DF:CreateScrollBox (f, "$parentMacroScrollbox", refreshMacroScrollbox, macrosAvailable, scrollbox_size[1], scrollbox_size[2], scrollbox_lines, scrollbox_line_height)
macroScrollbox:SetPoint("topleft", f, "topleft", 5, -30)
macroScrollbox:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
macroScrollbox:SetBackdropColor(0, 0, 0, 0)
macroScrollbox:SetBackdropBorderColor(0, 0, 0, 1)
f.MacroScrollbox = macroScrollbox
DF:ReskinSlider(macroScrollbox)
macroScrollbox.__background:Hide()
--create the scrollbox lines
for i = 1, scrollbox_lines do
macroScrollbox:CreateLine (macroListCreateLine)
end
end
DetailsPluginContainerWindow.OpenPlugin (DetailsMacrosPanel)
DetailsMacrosPanel.MacroScrollbox:Refresh()
DetailsMacrosPanel:Show()
end