You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
6.5 KiB

4 years ago
local Details = _G.Details
local DF = _G.DetailsFramework
local _
function Details:InitializeMacrosWindow()
3 years ago
local DetailsMacrosPanel = DF:CreateSimplePanel(UIParent, 700, 480, "Details! Useful Macros", "DetailsMacrosPanel")
4 years ago
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
3 years ago
local f = DetailsMacrosPanel or DF:CreateSimplePanel(UIParent, 700, 480, "Details! Useful Macros", "DetailsMacrosPanel")
4 years ago
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}
3 years ago
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)
4 years ago
f.bg1:SetAllPoints()
3 years ago
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)
4 years ago
local macrosAvailable = Details.MacroList
3 years ago
local OnEnterMacroButton = function(self)
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_onenter))
4 years ago
end
3 years ago
local onLeaveMacroButton = function(self)
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
4 years ago
end
3 years ago
local updateMacroLine = function(self, index, title, desc, macroText)
self.Title:SetText(title)
self.Desc:SetText(desc)
self.MacroTextEntry:SetText(macroText)
4 years ago
end
3 years ago
local textEntryOnFocusGained = function(self)
4 years ago
self:HighlightText()
end
3 years ago
local textEntryOnFocusLost = function(self)
4 years ago
self:HighlightText (0, 0)
end
3 years ago
local refreshMacroScrollbox = function(self, data, offset, totalLines)
4 years ago
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
3 years ago
local macroListCreateLine = function(self, index)
4 years ago
--create a new line
3 years ago
local line = CreateFrame("button", "$parentLine" .. index, self,"BackdropTemplate")
4 years ago
--set its parameters
3 years ago
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)
4 years ago
3 years ago
local titleLabel = DF:CreateLabel(line, "", DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
4 years ago
titleLabel.textsize = 14
titleLabel.textcolor = "yellow"
3 years ago
local descLabel = DF:CreateLabel(line, "", DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
4 years ago
descLabel.textsize = 12
3 years ago
local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
options_dropdown_template = DF.table.copy({}, options_dropdown_template)
4 years ago
options_dropdown_template.backdropcolor = {.51, .51, .51, .3}
options_dropdown_template.onenterbordercolor = {.51, .51, .51, .2}
3 years ago
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)
4 years ago
3 years ago
titleLabel:SetPoint("topleft", line, "topleft", 5, -5)
descLabel:SetPoint("topleft", titleLabel, "bottomleft", 0, -2)
textEntry:SetPoint("topleft", descLabel, "bottomleft", 0, -4)
4 years ago
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)
3 years ago
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)
4 years ago
f.MacroScrollbox = macroScrollbox
3 years ago
DF:ReskinSlider(macroScrollbox)
4 years ago
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