From 8b82b9829e9322b08b9ba60eefe5080e758a002e Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 2 Aug 2024 13:22:57 -0300 Subject: [PATCH] Added dump actor data in the debug window --- classes/class_instance.lua | 21 +++++++++++++++++++++ frames/window_debug.lua | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/classes/class_instance.lua b/classes/class_instance.lua index 8d8f3c55..187ce2bf 100644 --- a/classes/class_instance.lua +++ b/classes/class_instance.lua @@ -595,6 +595,27 @@ local instanceMixins = { instance:ResetWindow() instance:RefreshWindow(true) end, + + ---open a window with the keys and values of the actor object being shown in the line index + ---this function doesn't not return the values, it will 'dump' the values in a new window by calling 'dumpt' + ---@param self instance + ---@param index number + GetActorInfoFromLineIndex = function(self, index) + local actor = self.barras[index] and self.barras[index].minha_tabela + if (actor) then + local tableToDump = {} + for k, v in pairs(actor) do + if (type(k) == "string") then + if (type(v) == "number" or type(v) == "string") then + tableToDump[k] = v + end + end + end + dumpt(tableToDump) + else + Details:Msg("no actor found in line index", index) + end + end, } ---get the table with all instances, these instance could be not initialized yet, some might be open, some not in use diff --git a/frames/window_debug.lua b/frames/window_debug.lua index d2f9eef6..1b6b687c 100644 --- a/frames/window_debug.lua +++ b/frames/window_debug.lua @@ -194,6 +194,29 @@ local createDebugOptionsFrame = function() }, } + --/run Details:GetWindow(1):GetActorInfoFromLineIndex(3) + + --create a label with the text "actor info from window and line index" + local actorInfoLabel = detailsFramework:CreateLabel(debugOptionsPanel, "Get Actor Info From Window 'X' and Line Index 'X'", 12) + actorInfoLabel:SetPoint("bottomleft", debugOptionsPanel, "bottomleft", 5, 50) + + local instanceIdEntry = detailsFramework:CreateTextEntry(debugOptionsPanel, function()end, 20, 20, _, _, _, detailsFramework:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + instanceIdEntry:SetPoint("topleft", actorInfoLabel, "bottomleft", 0, -5) + instanceIdEntry:SetText("1") + + local lineIndexEntry = detailsFramework:CreateTextEntry(debugOptionsPanel, function()end, 20, 20, _, _, _, detailsFramework:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + lineIndexEntry:SetPoint("left", instanceIdEntry, "right", 5, 0) + lineIndexEntry:SetText("1") + + --create a button with the get "Get", when the button is pressed, it get the text in the instanceIdEntry and lineIndexEntry and call the function GetActorInfoFromWindowAndLineIndex + local getButton = detailsFramework:CreateButton(debugOptionsPanel, function() + local instanceId = tonumber(instanceIdEntry:GetText()) + local lineIndex = tonumber(lineIndexEntry:GetText()) + Details:GetWindow(instanceId):GetActorInfoFromLineIndex(lineIndex) + end, 50, 20, "Get") + getButton:SetPoint("left", lineIndexEntry, "right", 5, 0) + getButton:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) + options.always_boxfirst = true options.align_as_pairs = true options.align_as_pairs_string_space = 260