More fixes for the "Report to Discord" bugs; Implementations to show plugins in the breakdown window;

This commit is contained in:
Tercio Jose
2023-06-12 19:59:15 -03:00
parent f9d32df3a4
commit efd131ef04
16 changed files with 391 additions and 183 deletions
+14 -7
View File
@@ -1319,18 +1319,25 @@ detailsFramework.CloseButtonMixin = {
---@return df_closebutton
function detailsFramework:CreateCloseButton(parent, frameName)
---@type df_closebutton
local closeButton = CreateFrame("button", frameName, parent)
local closeButton = CreateFrame("button", frameName, parent, "UIPanelCloseButton")
closeButton:SetFrameLevel(parent:GetFrameLevel() + 1)
closeButton:SetSize(16, 16)
detailsFramework:Mixin(closeButton, detailsFramework.CloseButtonMixin)
closeButton:SetNormalTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
closeButton:SetHighlightTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
closeButton:SetPushedTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
closeButton:GetNormalTexture():SetDesaturated(true)
closeButton:GetHighlightTexture():SetDesaturated(true)
closeButton:GetPushedTexture():SetDesaturated(true)
local normalTexture = closeButton:GetNormalTexture()
local pushedTexture = closeButton:GetPushedTexture()
local highlightTexture = closeButton:GetHighlightTexture()
local disabledTexture = closeButton:GetDisabledTexture()
normalTexture:SetAtlas("RedButton-Exit")
highlightTexture:SetAtlas("RedButton-Highlight")
pushedTexture:SetAtlas("RedButton-exit-pressed")
disabledTexture:SetAtlas("RedButton-Exit-Disabled")
normalTexture:SetDesaturated(true)
highlightTexture:SetDesaturated(true)
pushedTexture:SetDesaturated(true)
closeButton:SetAlpha(0.7)
closeButton:SetScript("OnClick", closeButton.OnClick)
+79 -21
View File
@@ -6,7 +6,34 @@ end
local _
---@class df_chart: frame, data
---@field _dataInfo data
---@field nextLine number
---@field minValue number
---@field maxValue number
---@field lineThickness number
---@field data table
---@field lines table
---@field ChartFrameConstructor fun(self: df_chart) set the default values for the chart frame
---@field GetLine fun(self: df_chart) : line return a line and also internally handle next line
---@field GetLines fun(self: df_chart) : line[] return a table with all lines already created
---@field GetLineWidth fun(self: df_chart) : number calculate the width of each drawn line
---@field SetLineWidth fun(self: df_chart, width: number) set the line width to a fixed value
---@field Plot fun(self: df_chart) draw the graphic using lines and following the data set by SetData()
---@field GetAmountLines fun(self: df_chart) : number return the amount of lines in use
---@field OnSizeChanged fun(self: df_chart)
---@field HideLines fun(self: df_chart) hide all lines already created
---@field Reset fun(self: df_chart) hide all lines and reset the next line to 1
---@field SetLineThickness fun(self: df_chart, thickness: number) set the line thickness
---@field CalcYAxisPointForValue fun(self: df_chart, value: number)
---@field UpdateFrameSizeCache fun(self: df_chart)
local ChartFrameMixin = {
---set the default values for the chart frame
---@param self df_chart
ChartFrameConstructor = function(self)
self.nextLine = 1
self.minValue = 0
@@ -19,7 +46,8 @@ local ChartFrameMixin = {
self:SetScript("OnSizeChanged", self.OnSizeChanged)
end,
--internally handle next line
---internally handle next line
---@param self df_chart
GetLine = function(self)
local line = self.lines[self.nextLine]
if (not line) then
@@ -31,14 +59,22 @@ local ChartFrameMixin = {
return line
end,
---return all lines created for this chart
---@param self df_chart
---@return line[]
GetLines = function(self)
return self.lines
end,
---return the amount of lines in use
---@param self df_chart
---@return number
GetAmountLines = function(self)
return self.nextLine - 1
end,
---hide all lines already created
---@param self df_chart
HideLines = function(self)
local allLines = self:GetLines()
for i = 1, #allLines do
@@ -47,17 +83,22 @@ local ChartFrameMixin = {
end
end,
---hide all lines and reset the next line to 1
---@param self df_chart
Reset = function(self)
self:HideLines()
self.nextLine = 1
end,
---@param self df_chart
---@param value number
SetLineThickness = function(self, value)
assert(type(value) == "number", "number expected on :SetLineThickness(number)")
self.lineThickness = value
end,
--calculate the width of each drawn line
---calculate the width of each drawn line
---@param self df_chart
GetLineWidth = function(self)
--self:SetLineWidth(nil) to erase the fixed value
if (self.fixedLineWidth) then
@@ -69,24 +110,32 @@ local ChartFrameMixin = {
end
end,
---set the line width to a fixed value
---@param self df_chart
---@param width number
SetLineWidth = function(self, width)
assert(type(width) == "number", "number expected on :SetLineWidth(number)")
self.fixedLineWidth = width
end,
---@param self df_chart
---@param value number
CalcYAxisPointForValue = function(self, value)
return value / self.maxValue * self.height
end,
---@param self df_chart
UpdateFrameSizeCache = function(self)
self.width = self:GetWidth()
self.height = self:GetHeight()
end,
---@param self df_chart
OnSizeChanged = function(self)
self:UpdateFrameSizeCache()
end,
---@param self df_chart
Plot = function(self)
--debug
--self:SetData({38, 26, 12, 63, 100, 96, 42, 94, 25, 75, 61, 54, 71, 40, 34, 100, 66, 90, 39, 13, 99, 18, 72, 18, 83, 45, 56, 24, 33, 85, 95, 71, 15, 66, 19, 58, 52, 9, 83, 99, 100, 4, 3, 56, 6, 80, 94, 7, 40, 55, 98, 92, 20, 9, 35, 89, 72, 7, 13, 81, 29, 78, 55, 70, 12, 33, 39, 3, 84, 31, 10, 53, 51, 69, 66, 58, 71, 60, 31, 71, 27, 76, 21, 75, 15, 89, 2, 81, 72, 78, 74, 80, 97, 10, 59, 0, 31, 5, 1, 82, 71, 89, 78, 94, 74, 20, 65, 72, 56, 40, 92, 91, 40, 79, 4, 56, 18, 88, 88, 20, 20, 10, 47, 26, 80, 26, 75, 21, 57, 10, 67, 66, 84, 83, 14, 47, 83, 9, 7, 73, 63, 32, 64, 20, 40, 3, 46, 54, 17, 37, 82, 66, 65, 22, 12, 1, 100, 41, 1, 72, 38, 41, 71, 69, 88, 34, 10, 50, 9, 25, 19, 27, 3, 13, 40, 75, 3, 11, 93, 58, 81, 80, 93, 25, 74, 68, 91, 87, 79, 48, 66, 53, 64, 18, 51, 19, 32, 4, 21, 43})
@@ -128,31 +177,36 @@ local ChartFrameMixin = {
end,
}
---create a chart frame object
---@param parent frame
---@param name string|nil
---@return df_chart
local createChartFrame = function(parent, name)
local f = CreateFrame("frame", name, parent, "BackdropTemplate")
---@type df_chart
local chartFrame = CreateFrame("frame", name, parent, "BackdropTemplate")
DF:Mixin(f, DF.DataMixin)
DF:Mixin(f, DF.ValueMixin)
DF:Mixin(f, ChartFrameMixin)
DF:Mixin(chartFrame, DF.DataMixin)
DF:Mixin(chartFrame, DF.ValueMixin)
DF:Mixin(chartFrame, ChartFrameMixin)
f:DataConstructor()
f:ValueConstructor()
f:ChartFrameConstructor()
chartFrame:DataConstructor()
chartFrame:ValueConstructor()
chartFrame:ChartFrameConstructor()
--when a new data is set, update the min and max values
local onSetDataCallback = function()
local minValue, maxValue = f:GetDataMinMaxValues()
f:SetMinMaxValues(minValue, maxValue)
local minValue, maxValue = chartFrame:GetDataMinMaxValues()
chartFrame:SetMinMaxValues(minValue, maxValue)
--clear the lines
f:HideLines()
chartFrame:HideLines()
end
f:AddDataChangeCallback(onSetDataCallback)
chartFrame:AddDataChangeCallback(onSetDataCallback)
return f
return chartFrame
end
function DF:CreateGraphicLineFrame(parent, name)
---@type df_chart
local newGraphicFrame = createChartFrame(parent, name)
return newGraphicFrame
end
@@ -244,16 +298,20 @@ local MultiChartFrameMixin = {
end,
}
---create a chart frame object with support to multi lines
---@param parent frame
---@param name string|nil
---@return df_chart
function DF:CreateGraphicMultiLineFrame(parent, name)
name = name or ("DetailsMultiChartFrameID" .. math.random(1, 10000000))
local f = CreateFrame("frame", name, parent, "BackdropTemplate")
local chartFrame = CreateFrame("frame", name, parent, "BackdropTemplate")
DF:Mixin(f, DF.ValueMixin)
DF:Mixin(f, MultiChartFrameMixin)
DF:Mixin(chartFrame, DF.ValueMixin)
DF:Mixin(chartFrame, MultiChartFrameMixin)
f:ValueConstructor()
f:MultiChartFrameConstructor()
chartFrame:ValueConstructor()
chartFrame:MultiChartFrameConstructor()
return f
return chartFrame
end
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 436
local dversion = 438
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
+16 -2
View File
@@ -375,14 +375,14 @@ detailsFramework.ScriptHookMixin = {
local isRemoval = false
for i = #self.HookList[hookType], 1, -1 do
if (self.HookList[hookType][i] == func) then
tremove(self.HookList[hookType], i)
table.remove(self.HookList[hookType], i)
isRemoval = true
break
end
end
if (not isRemoval) then
tinsert(self.HookList[hookType], func)
table.insert(self.HookList[hookType], func)
end
else
if (detailsFramework.debug) then
@@ -717,6 +717,19 @@ detailsFramework.SortFunctions = {
end
}
---@class data : table
---@field data table
---@field dataCurrentIndex number
---@field callbacks table
---@field DataConstructor fun(self: data)
---@field AddDataChangeCallback fun(self: data, callback: function, ...: any)
---@field RemoveDataChangeCallback fun(self: data, callback: function)
---@field GetData fun(self: data)
---@field SetData fun(self: data, data: table)
---@field GetDataNextValue fun(self: data) : any
---@field ResetDataIndex fun(self: data)
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.DataMixin)
---add 'data' to a table, this table can be used to store data for the object
---@class DetailsFramework.DataMixin
@@ -781,6 +794,7 @@ detailsFramework.DataMixin = {
end,
---reset the data index, making GetDataNextValue() return the first value again
---@param self table
ResetDataIndex = function(self)
self._dataInfo.dataCurrentIndex = 1
end,
+83 -32
View File
@@ -1,6 +1,6 @@
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
local detailsFramework = _G["DetailsFramework"]
if (not detailsFramework or not DetailsFrameworkCanLoad) then
return
end
@@ -10,15 +10,15 @@ local APITextEntryFunctions = false
do
local metaPrototype = {
WidgetType = "textentry",
dversion = DF.dversion,
dversion = detailsFramework.dversion,
}
--check if there's a metaPrototype already existing
if (_G[DF.GlobalWidgetControlNames["textentry"]]) then
if (_G[detailsFramework.GlobalWidgetControlNames["textentry"]]) then
--get the already existing metaPrototype
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["textentry"]]
local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames["textentry"]]
--check if is older
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then
--the version is older them the currently loading one
--copy the new values into the old metatable
for funcName, _ in pairs(metaPrototype) do
@@ -27,18 +27,18 @@ do
end
else
--first time loading the framework
_G[DF.GlobalWidgetControlNames["textentry"]] = metaPrototype
_G[detailsFramework.GlobalWidgetControlNames["textentry"]] = metaPrototype
end
end
local TextEntryMetaFunctions = _G[DF.GlobalWidgetControlNames["textentry"]]
local TextEntryMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames["textentry"]]
DF:Mixin(TextEntryMetaFunctions, DF.SetPointMixin)
DF:Mixin(TextEntryMetaFunctions, DF.FrameMixin)
DF:Mixin(TextEntryMetaFunctions, DF.TooltipHandlerMixin)
DF:Mixin(TextEntryMetaFunctions, DF.ScriptHookMixin)
detailsFramework:Mixin(TextEntryMetaFunctions, detailsFramework.SetPointMixin)
detailsFramework:Mixin(TextEntryMetaFunctions, detailsFramework.FrameMixin)
detailsFramework:Mixin(TextEntryMetaFunctions, detailsFramework.TooltipHandlerMixin)
detailsFramework:Mixin(TextEntryMetaFunctions, detailsFramework.ScriptHookMixin)
DF.TextEntryCounter = DF.TextEntryCounter or 1
detailsFramework.TextEntryCounter = detailsFramework.TextEntryCounter or 1
------------------------------------------------------------------------------------------------------------
--metatables
@@ -231,7 +231,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
self.editbox:SetBackdropColor(unpack(self.enabled_backdrop_color))
self.editbox:SetTextColor(unpack(self.enabled_text_color))
if (self.editbox.borderframe) then
local r, g, b, a = DF:ParseColors(unpack(self.editbox.borderframe.onleave_backdrop))
local r, g, b, a = detailsFramework:ParseColors(unpack(self.editbox.borderframe.onleave_backdrop))
self.editbox.borderframe:SetBackdropColor(r, g, b, a)
end
end
@@ -320,7 +320,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
local OnEnterPressed = function(textentry, byScript)
local object = textentry.MyObject
if (object.ignoreNextCallback) then
DF.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
detailsFramework.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
return
end
@@ -329,7 +329,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
return
end
local text = DF:Trim(textentry:GetText())
local text = detailsFramework:Trim(textentry:GetText())
if (string.len(text) > 0) then
textentry.text = text
if (textentry.MyObject.func) then
@@ -372,7 +372,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
local OnEditFocusLost = function(textEntry)
local object = textEntry.MyObject
if (object.ignoreNextCallback) then
DF.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
detailsFramework.Schedules.RunNextTick(function() object.ignoreNextCallback = nil end)
return
end
@@ -383,7 +383,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
end
if (not textEntry.focuslost) then
local text = DF:Trim(textEntry:GetText())
local text = detailsFramework:Trim(textEntry:GetText())
if (string.len(text) > 0) then
textEntry.MyObject.currenttext = text
if (textEntry.MyObject.func) then
@@ -447,6 +447,57 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
OnEnterPressed(self.editbox, byScript)
end
function TextEntryMetaFunctions:SetAsSearchBox()
if (self.__bIsSearchBox) then
return
end
self:SetJustifyH("left")
self:SetJustifyV("center")
self:SetTextInsets(18, 14, 0, 0)
local magnifyingGlassTexture = self:CreateTexture(nil, "OVERLAY")
magnifyingGlassTexture:SetAtlas("common-search-magnifyingglass")
magnifyingGlassTexture:SetPoint("left", self.widget, "left", 4, 0)
magnifyingGlassTexture:SetSize(self:GetHeight()-10, self:GetHeight()-10)
magnifyingGlassTexture:SetAlpha(0.5)
local searchFontString = self:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
searchFontString:SetText("search")
searchFontString:SetAlpha(0.3)
searchFontString:SetPoint("left", magnifyingGlassTexture, "right", 2, 0)
detailsFramework:SetFontSize(searchFontString, 10)
local clearSearchButton = CreateFrame("button", nil, self.widget, "UIPanelCloseButton")
clearSearchButton:SetPoint("right", self.widget, "right", -3, 0)
clearSearchButton:SetSize(10, 10)
clearSearchButton:SetAlpha(0.3)
clearSearchButton:GetNormalTexture():SetAtlas("common-search-clearbutton")
clearSearchButton:GetHighlightTexture():SetAtlas("common-search-clearbutton")
clearSearchButton:GetPushedTexture():SetAtlas("common-search-clearbutton")
clearSearchButton:Hide()
clearSearchButton:SetScript("OnClick", function()
self:SetText("")
local bByScript = true
self:PressEnter(bByScript)
self:ClearFocus()
end)
self:SetHook("OnEditFocusGained", function()
clearSearchButton:Show()
searchFontString:Hide()
end)
self:SetHook("OnEditFocusLost", function()
if (self:GetText() == "") then
searchFontString:Show()
clearSearchButton:Hide()
end
end)
self.__bIsSearchBox = true
end
------------------------------------------------------------------------------------------------------------
function TextEntryMetaFunctions:SetTemplate(template)
@@ -461,12 +512,12 @@ function TextEntryMetaFunctions:SetTemplate(template)
self.editbox:SetBackdrop(template.backdrop)
end
if (template.backdropcolor) then
local r, g, b, a = DF:ParseColors(template.backdropcolor)
local r, g, b, a = detailsFramework:ParseColors(template.backdropcolor)
self.editbox:SetBackdropColor(r, g, b, a)
self.onleave_backdrop = {r, g, b, a}
end
if (template.backdropbordercolor) then
local r, g, b, a = DF:ParseColors(template.backdropbordercolor)
local r, g, b, a = detailsFramework:ParseColors(template.backdropbordercolor)
self.editbox:SetBackdropBorderColor(r, g, b, a)
self.editbox.current_bordercolor[1] = r
self.editbox.current_bordercolor[2] = g
@@ -479,14 +530,14 @@ end
------------------------------------------------------------------------------------------------------------
--object constructor
function DF:CreateTextEntry(parent, func, w, h, member, name, with_label, entry_template, label_template)
return DF:NewTextEntry(parent, parent, name, member, w, h, func, nil, nil, nil, with_label, entry_template, label_template)
function detailsFramework:CreateTextEntry(parent, func, w, h, member, name, with_label, entry_template, label_template)
return detailsFramework:NewTextEntry(parent, parent, name, member, w, h, func, nil, nil, nil, with_label, entry_template, label_template)
end
function DF:NewTextEntry(parent, container, name, member, width, height, func, param1, param2, space, withLabel, entryTemplate, labelTemplate)
function detailsFramework:NewTextEntry(parent, container, name, member, width, height, func, param1, param2, space, withLabel, entryTemplate, labelTemplate)
if (not name) then
name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter
DF.TextEntryCounter = DF.TextEntryCounter + 1
name = "DetailsFrameworkTextEntryNumber" .. detailsFramework.TextEntryCounter
detailsFramework.TextEntryCounter = detailsFramework.TextEntryCounter + 1
elseif (not parent) then
return error("Details! FrameWork: parent not found.", 2)
@@ -497,7 +548,7 @@ function DF:NewTextEntry(parent, container, name, member, width, height, func, p
end
if (name:find("$parent")) then
local parentName = DF.GetParentName(parent)
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
@@ -607,7 +658,7 @@ function DF:NewTextEntry(parent, container, name, member, width, height, func, p
setmetatable(newTextEntryObject, TextEntryMetaFunctions)
if (withLabel) then
local label = DF:CreateLabel(newTextEntryObject.editbox, withLabel, nil, nil, nil, "label", nil, "overlay")
local label = detailsFramework:CreateLabel(newTextEntryObject.editbox, withLabel, nil, nil, nil, "label", nil, "overlay")
label.text = withLabel
newTextEntryObject.editbox:SetPoint("left", label.widget, "right", 2, 0)
if (labelTemplate) then
@@ -623,8 +674,8 @@ function DF:NewTextEntry(parent, container, name, member, width, height, func, p
return newTextEntryObject, withLabel
end
function DF:NewSpellEntry(parent, func, width, height, param1, param2, member, name)
local editbox = DF:NewTextEntry(parent, parent, name, member, width, height, func, param1, param2)
function detailsFramework:NewSpellEntry(parent, func, width, height, param1, param2, member, name)
local editbox = detailsFramework:NewTextEntry(parent, parent, name, member, width, height, func, param1, param2)
return editbox
end
@@ -890,9 +941,9 @@ local set_speciallua_editor_font_size = function(borderFrame, newSize)
borderFrame.editboxlines:SetFont(file, newSize, flags)
end
function DF:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointent, showLineNumbers)
function detailsFramework:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointent, showLineNumbers)
if (name:find("$parent")) then
local parentName = DF.GetParentName(parent)
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
@@ -976,7 +1027,7 @@ function DF:NewSpecialLuaEditorEntry(parent, width, height, member, name, nointe
scrollframeNumberLines.editbox:SetSize(scrollframe.editbox:GetSize())
local text = scrollframe.editbox:GetText()
local textInArray = DF:SplitTextInLines(text)
local textInArray = detailsFramework:SplitTextInLines(text)
local maxStringWidth = scrollframe.editbox:GetWidth()
scrollframeNumberLines.editbox:SetWidth(maxStringWidth)
+11 -5
View File
@@ -195,7 +195,13 @@
---@field SetSmoothing fun(self: animation, smoothing: string)
---@field Stop fun(self: animation)
---@class line : uiobject
---@field SetStartPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject, relativePoint: anchorpoint, xOffset: number, yOffset: number)
---@field SetEndPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject, relativePoint: anchorpoint, xOffset: number, yOffset: number)
---@field SetColorTexture fun(self: line, red: number, green: number, blue: number, alpha: number)
---@class frame : uiobject
---@field CreateLine fun(self: frame, name: string|nil, drawLayer: drawlayer, templateName: string|nil, subLevel: number|nil) : line
---@field SetID fun(self: frame, id: number) set an ID for the frame
---@field SetAttribute fun(self: frame, name: string, value: any)
---@field SetScript fun(self: frame, event: string, handler: function|nil)
@@ -237,11 +243,11 @@
---@class button : frame
---@field Click fun(self: button)
---@field SetNormalTexture fun(self: button, texture: texture)
---@field SetPushedTexture fun(self: button, texture: texture)
---@field SetHighlightTexture fun(self: button, texture: texture)
---@field SetDisabledTexture fun(self: button, texture: texture)
---@field SetCheckedTexture fun(self: button, texture: texture)
---@field SetNormalTexture fun(self: button, texture: textureid|texturepath)
---@field SetPushedTexture fun(self: button, texture: textureid|texturepath)
---@field SetHighlightTexture fun(self: button, texture: textureid|texturepath)
---@field SetDisabledTexture fun(self: button, texture: textureid|texturepath)
---@field SetCheckedTexture fun(self: button, texture: textureid|texturepath)
---@field SetNormalFontObject fun(self: button, fontString: fontstring)
---@field SetHighlightFontObject fun(self: button, fontString: fontstring)
---@field SetDisabledFontObject fun(self: button, fontString: fontstring)