Release Candidate 1
This commit is contained in:
@@ -0,0 +1,552 @@
|
||||
--próximo: ao criar uma janela AllInOne, precisa criar uma nova instancia no Details!
|
||||
--na tabela de configuração precisa dizer que é uma all in one e o details vai chamar esse arquivo pra atualizar
|
||||
|
||||
--(ainda aqui) parei atualizando o height da titlebar
|
||||
--proximo passo: atualizar o resto das propriedade da title bar
|
||||
--fazer as funcções para setar os valores na titleBar
|
||||
--verificar se precisa adicionar funcções no mixin dos bottões como SetTexture, SetVertexColor
|
||||
|
||||
--tem que fazer a função de ShowWindow() e ToggleWindows()
|
||||
--fazer a criação do header e fazer o header ser redirecionado (aumentar ou diminuir o tamanho by dragging)
|
||||
|
||||
local LibWindow = LibStub("LibWindow-1.1")
|
||||
local df = DetailsFramework
|
||||
local detailsFramework = DetailsFramework
|
||||
|
||||
local textureCoords = {
|
||||
show_mainmenu = {0/256, 32/256, 0, 1},
|
||||
show_segments = {32/256, 64/256, 0, 1},
|
||||
show_report = {96/256, 128/256, 0, 1},
|
||||
show_reset = {128/256, 160/256, 0, 1},
|
||||
show_displays = {66/256, 93/256, 0, 1},
|
||||
show_close = {160/256, 192/256, 0, 1},
|
||||
}
|
||||
|
||||
--namespace
|
||||
Details.AllInOneWindow = {
|
||||
--store the frame of all AllInOne windows, this table does not same with the addon
|
||||
FramesCreated = {},
|
||||
WindowsOpened = 0,
|
||||
|
||||
--return a table: {{settings}, {settings}, {settings}, {settings}, ...}
|
||||
GetAllSettings = function()
|
||||
--setting within profile
|
||||
return Details.all_in_one_windows
|
||||
end,
|
||||
|
||||
--return the amount of settings by calling the above function and returning the amount of indexes
|
||||
GetNumSettings = function()
|
||||
return #Details.AllInOneWindow.GetAllSettings()
|
||||
end,
|
||||
|
||||
--return which will be the next settingID if a new setting is added
|
||||
GetNextSettingID = function()
|
||||
return #Details.all_in_one_windows + 1
|
||||
end,
|
||||
|
||||
--return the settingTable of a settingID
|
||||
GetSettingsByID = function(ID)
|
||||
return Details.AllInOneWindow.GetAllSettings()[ID]
|
||||
end,
|
||||
|
||||
--add a setting and return the settingID
|
||||
AddSetting = function(newSettingTable)
|
||||
local allSettings = Details.AllInOneWindow.GetAllSettings()
|
||||
allSettings[#allSettings+1] = newSettingTable
|
||||
return #allSettings
|
||||
end,
|
||||
|
||||
--frames already created on this session
|
||||
GetAllFrames = function()
|
||||
return Details.AllInOneWindow.FramesCreated
|
||||
end,
|
||||
|
||||
GetNumFrames = function()
|
||||
return #Details.AllInOneWindow.GetAllFrames()
|
||||
end,
|
||||
|
||||
GetFrameBySettingID = function(settingId)
|
||||
local numFramesCreated = Details.AllInOneWindow.GetNumFrames()
|
||||
for id = 1, numFramesCreated do
|
||||
local window = Details.AllInOneWindow.GetFrameByID(id)
|
||||
if (window:GetSettingsID() == settingId) then
|
||||
return window:GetSettings()
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
AddFrame = function(frame)
|
||||
Details.AllInOneWindow.FramesCreated[#Details.AllInOneWindow.FramesCreated+1] = frame
|
||||
return #Details.AllInOneWindow.FramesCreated+1
|
||||
end,
|
||||
|
||||
GetFrameByID = function(ID)
|
||||
return Details.AllInOneWindow.FramesCreated[ID]
|
||||
end,
|
||||
|
||||
RestoreAllWindows = function()
|
||||
|
||||
end,
|
||||
|
||||
ShowWindow = function(settingId)
|
||||
|
||||
end,
|
||||
|
||||
HideWindow = function(settingId)
|
||||
assert(type(settingId) ~= "number", "Details.AllInOneWindow.HideWindow require a number on 'settingId'")
|
||||
local settings = Details.AllInOneWindow.GetAllSettings()
|
||||
local windowSetting = settings[settingId]
|
||||
assert(type(windowSetting) ~= "table", "Details.AllInOneWindow.HideWindow settings not found for settingId: " .. settingId)
|
||||
|
||||
if (windowSetting) then
|
||||
if (windowSetting.isOpened) then
|
||||
windowSetting.isOpened = false
|
||||
--get the window being used by this setting
|
||||
local window = Details.AllInOneWindow.GetFrameBySettingID(settingId)
|
||||
if (window) then
|
||||
window:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
HideAllWindows = function()
|
||||
local numSettings = Details.AllInOneWindow.GetNumSettings()
|
||||
--table with all the settings for all AllInOne windows in the current profile
|
||||
local settings = Details.AllInOneWindow.GetAllSettings()
|
||||
for settingId = 1, numSettings do
|
||||
local windowSetting = Details.AllInOneWindow.GetSettingsByID(settingId)
|
||||
if (windowSetting.isOpened) then
|
||||
Details.AllInOneWindow.HideWindow(settingId)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
ToggleWindows = function()
|
||||
|
||||
end,
|
||||
}
|
||||
|
||||
local menuButtonMixin = {
|
||||
GetSettingName = function(button)
|
||||
return button.settingName
|
||||
end,
|
||||
}
|
||||
|
||||
local menuSupportFrameMixin = {
|
||||
Constructor = function(menuSupportFrame)
|
||||
menuSupportFrame:SetSize(1, 1)
|
||||
menuSupportFrame.allButtons = {}
|
||||
|
||||
menuSupportFrame:CreateMenuButton("CloseMenu", "show_close")
|
||||
menuSupportFrame:CreateMenuButton("MainMenu", "show_mainmenu")
|
||||
menuSupportFrame:CreateMenuButton("SegmentsMenu", "show_segments")
|
||||
menuSupportFrame:CreateMenuButton("DisplaysMenu", "show_report")
|
||||
menuSupportFrame:CreateMenuButton("ReportMenu", "show_reset")
|
||||
menuSupportFrame:CreateMenuButton("ResetMenu", "show_displays")
|
||||
end,
|
||||
|
||||
GetNumButtons = function(supportFrame)
|
||||
return #supportFrame.allButtons
|
||||
end,
|
||||
|
||||
GetButtonByIndex = function(supportFrame, buttonIndex)
|
||||
return supportFrame.allButtons[buttonIndex]
|
||||
end,
|
||||
|
||||
CreateMenuButton = function(supportFrame, name, settingName)
|
||||
local newButton = CreateFrame("button", "$parent" .. name, supportFrame)
|
||||
newButton:SetSize(20, 20)
|
||||
newButton:SetScale(1)
|
||||
supportFrame.allButtons[#supportFrame.allButtons+1] = newButton
|
||||
df:Mixin(newButton, menuButtonMixin)
|
||||
newButton.settingName = settingName
|
||||
return newButton
|
||||
end,
|
||||
|
||||
Refresh = function(supportFrame)
|
||||
local window = supportFrame:GetParent():GetParent()
|
||||
--problem: it is getting the settings from the AllInOneWindow settings, it should get from Details! default window settings
|
||||
--this settings should return the regular window setting from Details! on _detalhes.tabela_instancias[windowId]
|
||||
local settings = window:GetSettings().titlebar.menu_buttons
|
||||
|
||||
supportFrame:ClearAllPoints()
|
||||
supportFrame:SetSize(1, 1)
|
||||
supportFrame:SetScale(settings.scale)
|
||||
supportFrame:SetAlpha(settings.alpha)
|
||||
|
||||
--buttons currently allowed to show by the user settings
|
||||
local allShownButtons = {}
|
||||
for i = 1, supportFrame:GetNumButtons() do
|
||||
local button = supportFrame:GetButtonByIndex(i)
|
||||
if (settings[button:GetSettingName()]) then
|
||||
allShownButtons[#allShownButtons+1] = button
|
||||
button:Show()
|
||||
df:SetRegularButtonTexture(button, settings.texture_file, textureCoords[button:GetSettingName()])
|
||||
df:SetRegularButtonVertexColor(button, settings.color)
|
||||
else
|
||||
button:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--hardcoded to place the menu buttons in the left side of the window
|
||||
--if needed this can be "right" with the header leave space for it
|
||||
local attachPoint = "left"
|
||||
|
||||
if (settings.alignment == "horizontal") then
|
||||
--make it attach to the left side of the title bar or the right side of the title bar
|
||||
supportFrame:SetPoint(attachPoint, window.TitleBar, attachPoint, settings.x_offset, settings.y_offset)
|
||||
|
||||
local paddingAmount = attachPoint == "left" and settings.padding or (settings.padding * -1)
|
||||
for i = 1, #allShownButtons do
|
||||
local button = allShownButtons[i]
|
||||
if (i ==1) then
|
||||
button:SetPoint(attachPoint, supportFrame, attachPoint, 0, 0)
|
||||
else
|
||||
local previousButton = allShownButtons[i - 1]
|
||||
local sideToAttach = attachPoint == "left" and "right" or "left"
|
||||
button:SetPoint(attachPoint, previousButton, sideToAttach, paddingAmount, 0)
|
||||
end
|
||||
end
|
||||
|
||||
elseif (settings.alignment == "vertical") then
|
||||
if (attachPoint == "left") then
|
||||
supportFrame:SetPoint("topright", window.TitleBar, "topleft", settings.x_offset, settings.y_offset)
|
||||
else
|
||||
supportFrame:SetPoint("topleft", window.TitleBar, "topright", settings.x_offset, settings.y_offset)
|
||||
end
|
||||
|
||||
--here left == top to bottom | right = bottom to top
|
||||
local paddingAmount = attachPoint == "left" and settings.padding or (settings.padding * -1)
|
||||
local attachTo = attachPoint == "left" and "top" or "bottom"
|
||||
for i = 1, #allShownButtons do
|
||||
local button = allShownButtons[i]
|
||||
if (i ==1) then
|
||||
button:SetPoint(attachTo, supportFrame, attachTo, 0, 0)
|
||||
else
|
||||
local previousButton = allShownButtons[i - 1]
|
||||
local sideToAttach = attachTo == "left" and "bottom" or "top"
|
||||
button:SetPoint(attachTo, previousButton, sideToAttach, paddingAmount, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local titleBarMixin = {
|
||||
--run when the title bar is created
|
||||
Constructor = function(titleBar)
|
||||
titleBar:EnableMouse(false)
|
||||
|
||||
--create support frame for control buttons, it also will create the control buttons as children
|
||||
titleBar:CreateMenuSupportFrame()
|
||||
|
||||
--create the elapsed time string
|
||||
titleBar:CreateCombatTimeString()
|
||||
titleBar:SetCombatTimeText("02:36") --debug
|
||||
end,
|
||||
|
||||
GetSettings = function(titleBar)
|
||||
--get the settings from the main window
|
||||
return titleBar:GetParent():GetSettings()
|
||||
end,
|
||||
|
||||
SetSetting = function()
|
||||
--this function exists and get overriden by the SetSetting of the window mixin
|
||||
end,
|
||||
|
||||
SetTitleBarHeight = function(titleBar, height)
|
||||
assert(type(height) == "number", "Invalid height, usage: TitleBar:SetTitleBarHeight(height)")
|
||||
titleBar:SetHeight(height)
|
||||
titleBar:SetSetting(height, "titlebar", "height")
|
||||
titleBar:Refresh()
|
||||
end,
|
||||
|
||||
SetTitleBarTextSize = function(window, size)
|
||||
if (not size or type(size) ~= "number") then
|
||||
return
|
||||
end
|
||||
df:SetFontSize(window.TitleBar.CombatTime, size)
|
||||
|
||||
end,
|
||||
|
||||
SetTitleBarTextColor = function(window, color)
|
||||
local r, g, b, a = df:ParseColor(color)
|
||||
df:SetFontColor(window.TitleBar.CombatTime, r, g, b, a)
|
||||
end,
|
||||
|
||||
SetTitleBarTextFont = function(window, font)
|
||||
|
||||
end,
|
||||
|
||||
SetTitleBarTextOutline = function(window, outline)
|
||||
|
||||
end,
|
||||
|
||||
SetTitleBarTextShadow = function(window, shadow, xOffset, yOffset)
|
||||
|
||||
end,
|
||||
|
||||
CreateCombatTimeString = function(titleBar)
|
||||
local combatTimeString = titleBar:CreateFontString("$parentCombatTime", "overlay", "GameFontNormal")
|
||||
titleBar.CombatTime = combatTimeString
|
||||
return titleBar.CombatTime
|
||||
end,
|
||||
|
||||
GetCombatTimeString = function(titleBar)
|
||||
return titleBar.CombatTime
|
||||
end,
|
||||
|
||||
SetCombatTimeText = function(titleBar, combatTime)
|
||||
local combatTimeString = titleBar:GetCombatTimeString()
|
||||
if (type(combatTime) == "string") then
|
||||
combatTimeString:SetText(combatTime)
|
||||
|
||||
elseif (type(combatTime) == "number") then
|
||||
local timeAsString = DetailsFramework:IntegerToTimer(combatTime)
|
||||
combatTimeString:SetText(timeAsString)
|
||||
else
|
||||
--if no valid time passed, clear the timer
|
||||
combatTimeString:SetText("")
|
||||
end
|
||||
end,
|
||||
|
||||
Refresh = function(titleBar)
|
||||
local config = titleBar:GetSettings()
|
||||
|
||||
--height
|
||||
local height = config.titlebar.height
|
||||
titleBar:SetHeight(height)
|
||||
|
||||
local timerShown = config.timer_show
|
||||
|
||||
local menuSupportFrame = titleBar:GetMenuSupportFrame()
|
||||
menuSupportFrame:Update()
|
||||
|
||||
--[=[
|
||||
--height = 20,
|
||||
timer_show = true,
|
||||
timer_ignore_openworld = true,
|
||||
timer_only_encounters = false,
|
||||
|
||||
text_size = 10,
|
||||
text_font = "Friz Quadrata TT",
|
||||
text_outline = "NONE",
|
||||
text_shadow = {
|
||||
enabled = false,
|
||||
color = {1, 1, 1, 1},
|
||||
x_offset = 1,
|
||||
y_offset = -1,
|
||||
},
|
||||
--]=]
|
||||
|
||||
end,
|
||||
|
||||
GetMenuSupportFrame = function(titleBar)
|
||||
return titleBar.MenuSupportFrame
|
||||
end,
|
||||
|
||||
--menu support frame is the frame which will parent the menu buttons (cogwheel, segments, report button, etc)
|
||||
CreateMenuSupportFrame = function(titleBar)
|
||||
local menuSupportFrame = CreateFrame("frame", "$parentMenuSupportFrame", titleBar, "BackdropTemplate")
|
||||
titleBar.MenuSupportFrame = menuSupportFrame
|
||||
detailsFramework:Mixin(menuSupportFrame, menuSupportFrameMixin)
|
||||
menuSupportFrame:Constructor()
|
||||
return menuSupportFrame
|
||||
end,
|
||||
|
||||
}
|
||||
|
||||
local AllInOneWindowMixin = {
|
||||
SetSetting = function(window, value, ...)
|
||||
local config = window:GetSettings()
|
||||
local currentTable = config
|
||||
local lastKey = ""
|
||||
for index, key in ipairs({...}) do
|
||||
if (type(currentTable[key]) == "table") then
|
||||
currentTable = currentTable[value]
|
||||
else
|
||||
lastKey = key
|
||||
end
|
||||
end
|
||||
currentTable[lastKey] = value
|
||||
end,
|
||||
|
||||
IsOpened = function(window)
|
||||
return Details.AllInOneWindow.GetSettingsByID(window:GetSettingsID()).isOpened
|
||||
end,
|
||||
|
||||
SetWindowSize = function(self, width, height)
|
||||
|
||||
end,
|
||||
|
||||
GetSettings = function(window)
|
||||
return window.settings
|
||||
end,
|
||||
|
||||
SetSettingID = function(window, newSettingId)
|
||||
assert(type(newSettingId) ~= "number", "window.SetSettingID require a number on 'newSettingId'")
|
||||
local settings = Details.AllInOneWindow.GetSettingsByID(newSettingId)
|
||||
if (settings) then
|
||||
window.id = newSettingId
|
||||
window.settings = settings
|
||||
else
|
||||
error("window.SetSettingID could not find a settings for ID " .. newSettingId)
|
||||
end
|
||||
end,
|
||||
|
||||
GetSettingsID = function(window)
|
||||
return window.id
|
||||
end,
|
||||
|
||||
CreateTitleBar = function(window)
|
||||
local titleBar = CreateFrame("frame", "$parentTitleBar", window, "BackdropTemplate")
|
||||
window.TitleBar = titleBar
|
||||
df:Mixin(titleBar, titleBarMixin)
|
||||
titleBar:Constructor()
|
||||
return titleBar
|
||||
end,
|
||||
|
||||
GetTitleBar = function(window)
|
||||
return window.TitleBar
|
||||
end,
|
||||
|
||||
Refresh = function(window)
|
||||
local settingsId = window:GetSettingsID()
|
||||
local settings = window:GetSettings()
|
||||
|
||||
if (not settings.isOpened) then
|
||||
window:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
local titleBar = window:GetTitleBar()
|
||||
titleBar:Refresh()
|
||||
end,
|
||||
}
|
||||
|
||||
--override
|
||||
titleBarMixin.SetSetting = AllInOneWindowMixin.SetSetting
|
||||
|
||||
local defaultWindowSettings = {
|
||||
isOpened = true,
|
||||
|
||||
libwindow = {},
|
||||
width = 350, --
|
||||
height = 150, --
|
||||
|
||||
titlebar = {
|
||||
--done here: all options can be retrived from details! settings
|
||||
menu_buttons = {},
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
--create only the frame for a new window ~newwindow ñewwindow
|
||||
function Details.AllInOneWindow.CreateFrame(settingId)
|
||||
--create the new window
|
||||
local newWindowFrame = CreateFrame("frame", "DetailsNewWindow" .. settingId, UIParent, "BackdropTemplate")
|
||||
newWindowFrame.id = settingId
|
||||
df:Mixin(newWindowFrame, AllInOneWindowMixin)
|
||||
|
||||
newWindowFrame:SetPoint("center", UIParent, "center", -400, 0)
|
||||
|
||||
--create the title bar
|
||||
newWindowFrame:CreateTitleBar()
|
||||
|
||||
--creare header
|
||||
|
||||
|
||||
|
||||
--create scroll bar
|
||||
|
||||
|
||||
|
||||
--create resizers
|
||||
|
||||
|
||||
|
||||
--add the frame to the frame pool
|
||||
local frameId = Details.AllInOneWindow.AddFrame(newWindowFrame)
|
||||
return newWindowFrame
|
||||
end
|
||||
|
||||
--[=[
|
||||
lib window need to be on the AllInOneWindow:Update() so it can register the new libwindow table on profile change
|
||||
--register on libwindow
|
||||
LibWindow.RegisterConfig(newWindow, windowSettings.libwindow)
|
||||
LibWindow.RestorePosition(newWindow)
|
||||
LibWindow.MakeDraggable(newWindow)
|
||||
|
||||
--set the size using the settings
|
||||
newWindow:SetSize(windowSettings.width, windowSettings.height)
|
||||
|
||||
--rnable mouse for click through
|
||||
newWindow:EnableMouse(true)
|
||||
--setmovable for locked
|
||||
newWindow:SetMovable(true)
|
||||
|
||||
--title bar position (default on top)
|
||||
titleBar:SetPoint("topleft", newWindow, "topleft", 0, 0)
|
||||
titleBar:SetPoint("topright", newWindow, "topright", 0, 0)
|
||||
--title bar height
|
||||
titleBar:SetHeight(20)
|
||||
|
||||
--combat time position
|
||||
combatTimeString:SetPoint("left", titleBar, "left", 2, 0)
|
||||
--]=]
|
||||
|
||||
--create the settings for a new window plus the frames
|
||||
function Details:CreateNewAllInOneWindow()
|
||||
--get profile settings
|
||||
local profileSettings = Details:GetSettingsForAll_AllInOneWindows()
|
||||
|
||||
--get what is the ID if a new window is added
|
||||
local nextSettingId = Details.AllInOneWindow.GetNextSettingID()
|
||||
|
||||
--copy the settings prototype
|
||||
local windowSettings = df.table.deploy({}, defaultWindowSettings)
|
||||
--add the new settings table into the profile where the new window settings are stored
|
||||
local settingId = Details.AllInOneWindow.AddSetting(windowSettings)
|
||||
|
||||
--create window body
|
||||
local windowFrame = Details.AllInOneWindow.CreateFrame(settingId)
|
||||
|
||||
return windowFrame
|
||||
end
|
||||
|
||||
--assuming this will run when the profile is loaded
|
||||
|
||||
|
||||
--used when a profile finished loading
|
||||
--CURRENT THE ONLY ENTRY POINT
|
||||
function Details.AllInOneWindow.ReloadAll()
|
||||
--get the amount of settings
|
||||
local numSettings = Details.AllInOneWindow.GetNumSettings()
|
||||
|
||||
--table with all window frames already created on this session
|
||||
local framesCreated = Details.AllInOneWindow.GetAllFrames()
|
||||
--next frame to be used
|
||||
local frameIndex = 1
|
||||
|
||||
for settingId = 1, numSettings do
|
||||
local windowSetting = Details.AllInOneWindow.GetSettingsByID(settingId)
|
||||
if (windowSetting.isOpened) then
|
||||
local windowFrame = framesCreated[frameIndex]
|
||||
if (not windowFrame) then
|
||||
windowFrame = Details.AllInOneWindow.CreateFrame(settingId)
|
||||
end
|
||||
frameIndex = frameIndex + 1
|
||||
windowFrame:SetSettingID(settingId)
|
||||
--setup the frame using the settings
|
||||
windowFrame:Refresh()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user