Version Bump and Framework Update
This commit is contained in:
+24
-237
@@ -1976,37 +1976,50 @@ local no_options = {}
|
||||
---UseStatusBar = false, --if true, creates a status bar at the bottom of the frame (frame.StatusBar)
|
||||
---NoCloseButton = false, --if true, won't show the close button
|
||||
---NoTitleBar = false, --if true, don't create the title bar
|
||||
---@param parent table
|
||||
---@param width number|nil
|
||||
---@param height number|nil
|
||||
---@param title string|nil
|
||||
---@param frameName string|nil
|
||||
---@param panelOptions table|nil
|
||||
---@param savedVariableTable table|nil
|
||||
---@return table
|
||||
---@class simplepanel
|
||||
---@field TitleBar frame
|
||||
---@field Title fontstring
|
||||
---@field Close button
|
||||
---@field SetTitle fun(self: simplepanel, title: string)
|
||||
---@param parent frame the parent frame
|
||||
---@param width number|nil the width of the panel
|
||||
---@param height number|nil the height of the panel
|
||||
---@param title string|nil a string to show in the title bar
|
||||
---@param frameName string|nil the name of the frame
|
||||
---@param panelOptions table|nil a table with options described above
|
||||
---@param savedVariableTable table|nil a table to save the scale of the panel
|
||||
---@return frame
|
||||
function detailsFramework:CreateSimplePanel(parent, width, height, title, frameName, panelOptions, savedVariableTable)
|
||||
--create a saved variable table if the savedVariableTable has been not passed within the function call
|
||||
if (savedVariableTable and frameName and not savedVariableTable[frameName]) then
|
||||
savedVariableTable[frameName] = {
|
||||
scale = 1
|
||||
}
|
||||
end
|
||||
|
||||
--create a frame name if the frameName has been not passed within the function call
|
||||
if (not frameName) then
|
||||
frameName = "DetailsFrameworkSimplePanel" .. detailsFramework.SimplePanelCounter
|
||||
detailsFramework.SimplePanelCounter = detailsFramework.SimplePanelCounter + 1
|
||||
end
|
||||
|
||||
--default parent is UIParent
|
||||
if (not parent) then
|
||||
parent = UIParent
|
||||
parent = _G["UIParent"]
|
||||
end
|
||||
|
||||
--default options
|
||||
panelOptions = panelOptions or no_options
|
||||
|
||||
local simplePanel = CreateFrame("frame", frameName, UIParent,"BackdropTemplate")
|
||||
--create the frame
|
||||
local simplePanel = CreateFrame("frame", frameName, _G["UIParent"],"BackdropTemplate")
|
||||
simplePanel:SetSize(width or 400, height or 250)
|
||||
simplePanel:SetPoint("center", UIParent, "center", 0, 0)
|
||||
simplePanel:SetPoint("center", _G["UIParent"], "center", 0, 0)
|
||||
simplePanel:SetFrameStrata("FULLSCREEN")
|
||||
simplePanel:EnableMouse()
|
||||
simplePanel:SetMovable(true)
|
||||
|
||||
--set the backdrop
|
||||
simplePanel:SetBackdrop(SimplePanel_frame_backdrop)
|
||||
simplePanel:SetBackdropColor(unpack(SimplePanel_frame_backdrop_color))
|
||||
simplePanel:SetBackdropBorderColor(unpack(SimplePanel_frame_backdrop_border_color))
|
||||
@@ -3418,232 +3431,6 @@ function detailsFramework:FindHighestParent(self)
|
||||
return highestParent
|
||||
end
|
||||
|
||||
detailsFramework.TabContainerFunctions = {}
|
||||
|
||||
local button_tab_template = detailsFramework.table.copy({}, detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
button_tab_template.backdropbordercolor = nil
|
||||
|
||||
detailsFramework.TabContainerFunctions.CreateUnderlineGlow = function(button)
|
||||
local selectedGlow = button:CreateTexture(nil, "background", nil, -4)
|
||||
selectedGlow:SetPoint("topleft", button.widget, "bottomleft", -7, 0)
|
||||
selectedGlow:SetPoint("topright", button.widget, "bottomright", 7, 0)
|
||||
selectedGlow:SetTexture([[Interface\BUTTONS\UI-Panel-Button-Glow]])
|
||||
selectedGlow:SetTexCoord(0, 95/128, 30/64, 38/64)
|
||||
selectedGlow:SetBlendMode("ADD")
|
||||
selectedGlow:SetHeight(8)
|
||||
selectedGlow:SetAlpha(.75)
|
||||
selectedGlow:Hide()
|
||||
button.selectedUnderlineGlow = selectedGlow
|
||||
end
|
||||
|
||||
detailsFramework.TabContainerFunctions.OnMouseDown = function(self, button)
|
||||
--search for UIParent
|
||||
local f = detailsFramework:FindHighestParent (self)
|
||||
local container = self:GetParent()
|
||||
|
||||
if (button == "LeftButton") then
|
||||
if (not f.IsMoving and f:IsMovable()) then
|
||||
f:StartMoving()
|
||||
f.IsMoving = true
|
||||
end
|
||||
elseif (button == "RightButton") then
|
||||
if (not f.IsMoving and container.IsContainer) then
|
||||
if (self.IsFrontPage) then
|
||||
if (container.CanCloseWithRightClick) then
|
||||
if (f.CloseFunction) then
|
||||
f:CloseFunction()
|
||||
else
|
||||
f:Hide()
|
||||
end
|
||||
end
|
||||
else
|
||||
--goes back to front page
|
||||
detailsFramework.TabContainerFunctions.SelectIndex (self, _, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
detailsFramework.TabContainerFunctions.OnMouseUp = function(self, button)
|
||||
local f = detailsFramework:FindHighestParent (self)
|
||||
if (f.IsMoving) then
|
||||
f:StopMovingOrSizing()
|
||||
f.IsMoving = false
|
||||
end
|
||||
end
|
||||
|
||||
detailsFramework.TabContainerFunctions.SelectIndex = function(self, fixedParam, menuIndex)
|
||||
local mainFrame = self.AllFrames and self or self.mainFrame or self:GetParent()
|
||||
|
||||
for i = 1, #mainFrame.AllFrames do
|
||||
mainFrame.AllFrames[i]:Hide()
|
||||
if (mainFrame.ButtonNotSelectedBorderColor) then
|
||||
mainFrame.AllButtons[i]:SetBackdropBorderColor(unpack(mainFrame.ButtonNotSelectedBorderColor))
|
||||
end
|
||||
if (mainFrame.AllButtons[i].selectedUnderlineGlow) then
|
||||
mainFrame.AllButtons[i].selectedUnderlineGlow:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
mainFrame.AllFrames[menuIndex]:Show()
|
||||
if mainFrame.AllFrames[menuIndex].RefreshOptions then
|
||||
mainFrame.AllFrames[menuIndex]:RefreshOptions()
|
||||
end
|
||||
if (mainFrame.ButtonSelectedBorderColor) then
|
||||
mainFrame.AllButtons[menuIndex]:SetBackdropBorderColor(unpack(mainFrame.ButtonSelectedBorderColor))
|
||||
end
|
||||
if (mainFrame.AllButtons[menuIndex].selectedUnderlineGlow) then
|
||||
mainFrame.AllButtons[menuIndex].selectedUnderlineGlow:Show()
|
||||
end
|
||||
mainFrame.CurrentIndex = menuIndex
|
||||
|
||||
if (mainFrame.hookList.OnSelectIndex) then
|
||||
detailsFramework:QuickDispatch(mainFrame.hookList.OnSelectIndex, mainFrame, mainFrame.AllButtons[menuIndex])
|
||||
end
|
||||
end
|
||||
|
||||
detailsFramework.TabContainerFunctions.SetIndex = function(self, index)
|
||||
self.CurrentIndex = index
|
||||
end
|
||||
|
||||
local tab_container_on_show = function(self)
|
||||
local index = self.CurrentIndex
|
||||
self.SelectIndex (self.AllButtons[index], nil, index)
|
||||
end
|
||||
|
||||
function detailsFramework:CreateTabContainer (parent, title, frameName, frameList, optionsTable, hookList, languageInfo)
|
||||
local options_text_template = detailsFramework:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")
|
||||
local options_dropdown_template = detailsFramework:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
|
||||
local options_switch_template = detailsFramework:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE")
|
||||
local options_slider_template = detailsFramework:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE")
|
||||
local options_button_template = detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")
|
||||
|
||||
optionsTable = optionsTable or {}
|
||||
local parentFrameWidth = parent:GetWidth()
|
||||
local y_offset = optionsTable.y_offset or 0
|
||||
local buttonWidth = optionsTable.button_width or 160
|
||||
local buttonHeight = optionsTable.button_height or 20
|
||||
local buttonAnchorX = optionsTable.button_x or 230
|
||||
local buttonAnchorY = optionsTable.button_y or -32
|
||||
local button_text_size = optionsTable.button_text_size or 10
|
||||
local containerWidthOffset = optionsTable.container_width_offset or 0
|
||||
|
||||
local mainFrame = CreateFrame("frame", frameName, parent.widget or parent, "BackdropTemplate")
|
||||
mainFrame:SetAllPoints()
|
||||
detailsFramework:Mixin(mainFrame, detailsFramework.TabContainerFunctions)
|
||||
mainFrame.hookList = hookList or {}
|
||||
|
||||
local mainTitle = detailsFramework:CreateLabel(mainFrame, title, 24, "white")
|
||||
mainTitle:SetPoint("topleft", mainFrame, "topleft", 10, -30 + y_offset)
|
||||
|
||||
mainFrame:SetFrameLevel(200)
|
||||
|
||||
mainFrame.AllFrames = {}
|
||||
mainFrame.AllButtons = {}
|
||||
mainFrame.CurrentIndex = 1
|
||||
mainFrame.IsContainer = true
|
||||
mainFrame.ButtonSelectedBorderColor = optionsTable.button_selected_border_color or {1, 1, 0, 1}
|
||||
mainFrame.ButtonNotSelectedBorderColor = optionsTable.button_border_color or {0, 0, 0, 0}
|
||||
|
||||
if (optionsTable.right_click_interact ~= nil) then
|
||||
mainFrame.CanCloseWithRightClick = optionsTable.right_click_interact
|
||||
else
|
||||
mainFrame.CanCloseWithRightClick = true
|
||||
end
|
||||
|
||||
--languageInfo
|
||||
local addonId = languageInfo and languageInfo.language_addonId or "none"
|
||||
|
||||
for i, frameInfo in ipairs(frameList) do
|
||||
local f = CreateFrame("frame", "$parent" .. frameInfo.name, mainFrame, "BackdropTemplate")
|
||||
f:SetAllPoints()
|
||||
f:SetFrameLevel(210)
|
||||
f:Hide()
|
||||
|
||||
--attempt to get the localized text from the language system using the addonId and the frameInfo.title
|
||||
local phraseId = frameInfo.title
|
||||
local bIsLanguagePrahseID = detailsFramework.Language.DoesPhraseIDExistsInDefaultLanguage(addonId, phraseId)
|
||||
|
||||
local title = detailsFramework:CreateLabel(f, "", 16, "silver")
|
||||
if (bIsLanguagePrahseID) then
|
||||
DetailsFramework.Language.RegisterObjectWithDefault(addonId, title.widget, frameInfo.title, frameInfo.title)
|
||||
else
|
||||
title:SetText(frameInfo.title)
|
||||
end
|
||||
|
||||
title:SetPoint("topleft", mainTitle, "bottomleft", 0, 0)
|
||||
f.titleText = title
|
||||
|
||||
local tabButton = detailsFramework:CreateButton(mainFrame, detailsFramework.TabContainerFunctions.SelectIndex, buttonWidth, buttonHeight, frameInfo.title, i, nil, nil, nil, "$parentTabButton" .. frameInfo.name, false, button_tab_template)
|
||||
|
||||
if (bIsLanguagePrahseID) then
|
||||
DetailsFramework.Language.RegisterObjectWithDefault(addonId, tabButton.widget, frameInfo.title, frameInfo.title)
|
||||
end
|
||||
|
||||
PixelUtil.SetSize(tabButton, buttonWidth, buttonHeight)
|
||||
tabButton:SetFrameLevel(220)
|
||||
tabButton.textsize = button_text_size
|
||||
tabButton.mainFrame = mainFrame
|
||||
detailsFramework.TabContainerFunctions.CreateUnderlineGlow(tabButton)
|
||||
|
||||
local rightClickToBack
|
||||
if (i == 1 or optionsTable.rightbutton_always_close) then
|
||||
rightClickToBack = detailsFramework:CreateLabel(f, "right click to close", 10, "gray")
|
||||
rightClickToBack:SetPoint("bottomright", f, "bottomright", -1, optionsTable.right_click_y or 0)
|
||||
if (optionsTable.close_text_alpha) then
|
||||
rightClickToBack:SetAlpha(optionsTable.close_text_alpha)
|
||||
end
|
||||
f.IsFrontPage = true
|
||||
else
|
||||
rightClickToBack = detailsFramework:CreateLabel(f, "right click to go back to main menu", 10, "gray")
|
||||
rightClickToBack:SetPoint("bottomright", f, "bottomright", -1, optionsTable.right_click_y or 0)
|
||||
if (optionsTable.close_text_alpha) then
|
||||
rightClickToBack:SetAlpha(optionsTable.close_text_alpha)
|
||||
end
|
||||
end
|
||||
|
||||
if (optionsTable.hide_click_label) then
|
||||
rightClickToBack:Hide()
|
||||
end
|
||||
|
||||
f:SetScript("OnMouseDown", detailsFramework.TabContainerFunctions.OnMouseDown)
|
||||
f:SetScript("OnMouseUp", detailsFramework.TabContainerFunctions.OnMouseUp)
|
||||
|
||||
tinsert(mainFrame.AllFrames, f)
|
||||
tinsert(mainFrame.AllButtons, tabButton)
|
||||
end
|
||||
|
||||
--order buttons
|
||||
local x = buttonAnchorX
|
||||
local y = buttonAnchorY
|
||||
local spaceBetweenButtons = 3
|
||||
|
||||
local allocatedSpaceForButtons = parentFrameWidth - ((#frameList - 2) * spaceBetweenButtons) - buttonAnchorX + containerWidthOffset
|
||||
local amountButtonsPerRow = floor(allocatedSpaceForButtons / buttonWidth)
|
||||
|
||||
mainFrame.AllButtons[1]:SetPoint("topleft", mainTitle, "topleft", x, y)
|
||||
x = x + buttonWidth + 2
|
||||
|
||||
for i = 2, #mainFrame.AllButtons do
|
||||
local button = mainFrame.AllButtons[i]
|
||||
PixelUtil.SetPoint(button, "topleft", mainTitle, "topleft", x, y)
|
||||
x = x + buttonWidth + 2
|
||||
|
||||
if (i % amountButtonsPerRow == 0) then
|
||||
x = buttonAnchorX
|
||||
y = y - buttonHeight - 1
|
||||
end
|
||||
end
|
||||
|
||||
--when show the frame, reset to the current internal index
|
||||
mainFrame:SetScript("OnShow", tab_container_on_show)
|
||||
--select the first frame
|
||||
mainFrame.SelectIndex (mainFrame.AllButtons[1], nil, 1)
|
||||
|
||||
print()
|
||||
return mainFrame
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ~right ~click to ~close
|
||||
|
||||
|
||||
Reference in New Issue
Block a user