Skip to content

Commit

Permalink
Framework Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Dec 4, 2023
1 parent 3b91363 commit 6abc2cc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@
---@field GetCombatUID fun(combat: combat) : uniquecombatid
---@field GetTimeData fun(combat: combat, dataName: string) : table
---@field GetPhases fun(combat: combat) : table
---@field GetCombatTime fun(combat) : number
---@field GetRunTime fun(combat) : number
---@field GetCombatTime fun(comba: combat) : number
---@field GetRunTime fun(combat: combat) : number return the elapsed time of a mythic+ dungeon run, if not exists, return the combat time
---@field GetRunTimeNoDefault fun(combat: combat) : number return the elapsed time of a mythic+ dungeon run, nil if not exists
---@field GetDeaths fun(combat) : table --get the table which contains the deaths of the combat
---@field GetStartTime fun(combat: combat) : number
---@field SetStartTime fun(combat: combat, time: number)
Expand Down
20 changes: 11 additions & 9 deletions Libs/DF/buildmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ local setToggleProperties = function(parent, widget, widgetTable, currentXOffset
end
else
if (widgetTable.boxfirst or bUseBoxFirstOnAllWidgets) then
widget:SetPoint("left", label, "right", 2, 0)
label:SetPoint("topleft", parent, "topleft", currentXOffset, currentYOffset)
label:SetPoint("left", widget.widget or widget, "right", 2, 0)
widget:SetPoint("topleft", parent, "topleft", currentXOffset, currentYOffset)

local nextWidgetTable = menuOptions[index+1]
if (nextWidgetTable) then
Expand Down Expand Up @@ -304,11 +304,13 @@ local setToggleProperties = function(parent, widget, widgetTable, currentXOffset
return maxColumnWidth, maxWidgetWidth, extraPaddingY
end

local setRangeProperties = function(parent, widget, widgetTable, currentXOffset, currentYOffset, template, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, bIsDecimals)
local setRangeProperties = function(parent, widget, widgetTable, currentXOffset, currentYOffset, template, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, bIsDecimals, bAttachSliderButtonsToLeft)
widget._get = widgetTable.get
widget.widget_type = "range"
widget:SetTemplate(template)

widget.bAttachButtonsToLeft = bAttachSliderButtonsToLeft

if (bIsDecimals) then
widget.slider:SetValueStep(0.01)
else
Expand Down Expand Up @@ -658,12 +660,13 @@ local parseOptionsTable = function(menuOptions)
local bAlignAsPairs = menuOptions.align_as_pairs
local nAlignAsPairsLength = menuOptions.align_as_pairs_string_space or 160
local nAlignAsPairsSpacing = menuOptions.align_as_pairs_spacing or 20
local bAttachSliderButtonsToLeft = menuOptions.slider_buttons_to_left

--if a scrollbox is passed, the height can be ignored
--the scrollBox child will be used as the parent, and the height of the child will be resized to fit the widgets
local bUseScrollFrame = menuOptions.use_scrollframe
local languageAddonId = menuOptions.language_addonId
return bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId
return bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId, bAttachSliderButtonsToLeft
end

local parseParent = function(bUseScrollFrame, parent, height, yOffset)
Expand Down Expand Up @@ -915,7 +918,7 @@ function detailsFramework:BuildMenuVolatile(parent, menuOptions, xOffset, yOffse
}

parseOptionsTypes(menuOptions)
local bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId = parseOptionsTable(menuOptions)
local bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId, bAttachSliderButtonsToLeft = parseOptionsTable(menuOptions)
parent, height = parseParent(bUseScrollFrame, parent, height, yOffset)
local languageTable = parseLanguageTable(languageAddonId)

Expand Down Expand Up @@ -1015,7 +1018,7 @@ function detailsFramework:BuildMenuVolatile(parent, menuOptions, xOffset, yOffse
slider.hasLabel.text = namePhrase
slider.hasLabel:SetTemplate(widgetTable.text_template or textTemplate)

maxColumnWidth, maxWidgetWidth = setRangeProperties(parent, slider, widgetTable, currentXOffset, currentYOffset, sliderTemplate, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, widgetTable.usedecimals)
maxColumnWidth, maxWidgetWidth = setRangeProperties(parent, slider, widgetTable, currentXOffset, currentYOffset, sliderTemplate, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, widgetTable.usedecimals, bAttachSliderButtonsToLeft)
amountLineWidgetAdded = amountLineWidgetAdded + 1

--color
Expand Down Expand Up @@ -1147,7 +1150,7 @@ function detailsFramework:BuildMenu(parent, menuOptions, xOffset, yOffset, heigh

--parse settings and the options table
parseOptionsTypes(menuOptions)
local bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId = parseOptionsTable(menuOptions)
local bUseBoxFirstOnAllWidgets, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, nAlignAsPairsSpacing, bUseScrollFrame, languageAddonId, bAttachSliderButtonsToLeft = parseOptionsTable(menuOptions)
parent, height = parseParent(bUseScrollFrame, parent, height, yOffset)
local languageTable = parseLanguageTable(languageAddonId)

Expand Down Expand Up @@ -1276,8 +1279,7 @@ function detailsFramework:BuildMenu(parent, menuOptions, xOffset, yOffset, heigh
local namePhraseId = getNamePhraseID(widgetTable, languageAddonId, languageTable, true)
DetailsFramework.Language.RegisterObjectWithDefault(languageAddonId, label.widget, namePhraseId, formatOptionNameWithColon(widgetTable.name, useColon))

maxColumnWidth, maxWidgetWidth = setRangeProperties(parent, slider, widgetTable, currentXOffset, currentYOffset, sliderTemplate, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, bIsDecimals)

maxColumnWidth, maxWidgetWidth = setRangeProperties(parent, slider, widgetTable, currentXOffset, currentYOffset, sliderTemplate, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, maxWidgetWidth, bIsDecimals, bAttachSliderButtonsToLeft)
--store the widget created into the overall table and the widget by type
table.insert(parent.widget_list, slider)
table.insert(parent.widget_list_by_type.slider, slider)
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/externals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function detailsFramework:LoadLCC(LibCC)
end
end

if IS_WOW_PROJECT_CLASSIC_ERA then
if IS_WOW_PROJECT_CLASSIC_ERA and false then --disable this for now, as it appears to be working now through API changes...
local LibCC = LibStub("LibClassicCasterino", true)
if (LibCC and not _G.DetailsFrameworkLCCLoaded) then
detailsFramework:LoadLCC(LibCC)
Expand Down
5 changes: 3 additions & 2 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 485
local dversion = 490
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -1329,7 +1329,7 @@ function DF:SetFontOutline(fontString, outline)
outline = "OUTLINE"

elseif (type(outline) == "boolean" and not outline) then
outline = "NONE"
outline = "" --"NONE"

elseif (outline == 1) then
outline = "OUTLINE"
Expand All @@ -1338,6 +1338,7 @@ function DF:SetFontOutline(fontString, outline)
outline = "THICKOUTLINE"
end
end
outline = (not outline or outline == "NONE") and "" or outline

fontString:SetFont(font, fontSize, outline)
end
Expand Down
38 changes: 32 additions & 6 deletions Libs/DF/slider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
return
end

DetailsFrameworkSliderButtons1:ShowMe(slider)
DetailsFrameworkSliderButtons1:ShowMe(slider, object.bAttachButtonsToLeft)

local kill = object:RunHooksForWidget("OnEnter", slider, object)
if (kill) then
Expand Down Expand Up @@ -363,6 +363,14 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
local sliderButtonsParentFrame = DetailsFrameworkSliderButtons1 or CreateFrame("frame", "DetailsFrameworkSliderButtons1", UIParent, "BackdropTemplate")
sliderButtonsParentFrame:Hide()
sliderButtonsParentFrame:SetHeight(18) --width is set by setpoint

C_Timer.After(0, function()
if (not sliderButtonsParentFrame.__background) then
DetailsFramework:ApplyStandardBackdrop(sliderButtonsParentFrame) --ApplyStandardBackdrop loads after this file
end
sliderButtonsParentFrame:SetBackdropBorderColor(0, 0, 0, 0)
sliderButtonsParentFrame:SetBackdropColor(.05, .05, .05, .9)
end)
sliderButtonsParentFrame.isGoingToHide = false

local timeToHide = 0
Expand All @@ -375,11 +383,27 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
end
end

function sliderButtonsParentFrame:ShowMe(sliderFrame)
function sliderButtonsParentFrame:ShowMe(sliderFrame, bAnchorToLeft)
sliderButtonsParentFrame.bAnchorToLeft = bAnchorToLeft
sliderButtonsParentFrame:SetParent(sliderFrame)
sliderButtonsParentFrame:ClearAllPoints()
sliderButtonsParentFrame:SetPoint("bottomleft", sliderFrame, "topleft", -5, -5)
sliderButtonsParentFrame:SetPoint("bottomright", sliderFrame, "topright", 5, -5)

sliderButtonsParentFrame.buttonMinor:ClearAllPoints()
sliderButtonsParentFrame.buttonPlus:ClearAllPoints()

sliderButtonsParentFrame:SetWidth(35)

if (sliderButtonsParentFrame.bAnchorToLeft) then
sliderButtonsParentFrame:SetPoint("topright", sliderFrame, "topleft", 0, 0)
sliderButtonsParentFrame:SetPoint("bottomright", sliderFrame, "bottomleft", 0, 0)
sliderButtonsParentFrame.buttonPlus:SetPoint("right", sliderButtonsParentFrame, "right", -2, 0)
sliderButtonsParentFrame.buttonMinor:SetPoint("right", sliderButtonsParentFrame.buttonPlus, "left", 0, 0)
else
sliderButtonsParentFrame:SetPoint("topleft", sliderFrame, "topright", 2, 0)
sliderButtonsParentFrame:SetPoint("bottomleft", sliderFrame, "bottomright", 2, 0)
sliderButtonsParentFrame.buttonMinor:SetPoint("left", sliderButtonsParentFrame, "left", 2, 0)
sliderButtonsParentFrame.buttonPlus:SetPoint("left", sliderButtonsParentFrame.buttonMinor, "right", 0, 0)
end

sliderButtonsParentFrame:SetFrameStrata("FULLSCREEN")
sliderButtonsParentFrame:SetFrameLevel(sliderFrame:GetFrameLevel() + 1000)
Expand All @@ -399,10 +423,12 @@ DF:Mixin(DFSliderMetaFunctions, DF.ScriptHookMixin)
sliderButtonsParentFrame:SetScript("OnUpdate", onUpdateTimeToHide)
end

local buttonPlus = CreateFrame("button", "DetailsFrameworkSliderButtonsPlusButton", sliderButtonsParentFrame, "BackdropTemplate")
local buttonMinor = CreateFrame("button", "DetailsFrameworkSliderButtonsMinorButton", sliderButtonsParentFrame, "BackdropTemplate")
local buttonPlus = DetailsFrameworkSliderButtonsPlusButton or CreateFrame("button", "DetailsFrameworkSliderButtonsPlusButton", sliderButtonsParentFrame, "BackdropTemplate")
local buttonMinor = DetailsFrameworkSliderButtonsMinorButton or CreateFrame("button", "DetailsFrameworkSliderButtonsMinorButton", sliderButtonsParentFrame, "BackdropTemplate")
buttonPlus:SetFrameStrata(sliderButtonsParentFrame:GetFrameStrata())
buttonMinor:SetFrameStrata(sliderButtonsParentFrame:GetFrameStrata())
sliderButtonsParentFrame.buttonPlus = buttonPlus
sliderButtonsParentFrame.buttonMinor = buttonMinor

buttonPlus:SetScript("OnEnter", function(self)
if (sliderButtonsParentFrame.isGoingToHide) then
Expand Down

0 comments on commit 6abc2cc

Please sign in to comment.