Skip to content

Commit 69ffb19

Browse files
committed
Modularise formatting non-table node key names
1 parent 8c48037 commit 69ffb19

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

lua/blobsprofiler/client/cl_blobsprofiler.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,13 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
442442
end
443443
else
444444
local nodeText = nodeKey
445-
if varType == "SQLite.Schema" then
446-
nodeText = nodeKey .. ": " .. tostring(nodeValue)
447-
elseif varType == "Files" then
448-
nodeText = nodeValue
449-
elseif varType == "Profiling.Targets" then
450-
nodeText = nodeValue.name or nodeKey
445+
446+
local getModule = blobsProfiler.GetModule(varType)
447+
if getModule.FormatNodeName then
448+
nodeText = getModule.FormatNodeName(luaState, nodeKey, nodeValue)
451449
end
452450

453-
childNode = useParent:AddNode(istable(nodeValue) and nodeValue.displayName or nodeText)
451+
childNode = useParent:AddNode(nodeText)
454452
childNode.Icon:SetImage("icon16/".. (blobsProfiler.TypesToIcon[visualDataType] || "page_white_text") ..".png")
455453

456454
childNode.DoClick = function()

lua/blobsprofiler/shared/modules/bp_files.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,8 @@ blobsProfiler.RegisterModule("Files", {
176176
icon = "icon16/page_copy.png"
177177
}
178178
}
179-
}
179+
},
180+
FormatNodeName = function(luaState, nodeKey, nodeValue)
181+
return tostring(nodeValue)
182+
end
180183
})

lua/blobsprofiler/shared/modules/bp_profiling.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ blobsProfiler.RegisterSubModule("Profiling", "Targets", {
8686

8787
end
8888
end
89+
end,
90+
FormatNodeName = function(luaState, nodeKey, nodeValue)
91+
return nodeValue.name or nodeKey
8992
end
9093
})
9194

lua/blobsprofiler/shared/modules/bp_sqlite.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ blobsProfiler.RegisterSubModule("SQLite", "Schema", {
125125
},
126126
TypeIconOverride = {
127127
["table"] = "icon16/table.png"
128-
}
128+
},
129+
FormatNodeName = function(luaState, nodeKey, nodeValue)
130+
return nodeKey .. ": " .. tostring(nodeValue)
131+
end
129132
})
130133

131134
local function splitAndProcessQueries(query) -- why the fuck did I bother

0 commit comments

Comments
 (0)