Skip to content

Commit 0b2d83d

Browse files
committed
Profiling module tweaks
1 parent 1a0c866 commit 0b2d83d

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

lua/blobsprofiler/client/cl_blobsprofiler.lua

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
646646
visualDataType = nodeValue.fakeVarType
647647
end
648648

649-
if isRoot && varType == "Globals" then
649+
if isRoot && varType == "Lua.Globals" then
650650
local dataType = type(nodeData.value)
651651
local specialFolderPanel = blobsProfiler.Menu.TypeFolders[luaState][visualDataType]
652652
if specialFolderPanel && type(specialFolderPanel) == "Panel" then
@@ -705,7 +705,7 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
705705
childNode.oldExpand(...)
706706
end
707707

708-
if varType == "Schema" then
708+
if varType == "SQLite.Schema" then
709709
if nodeValue["ID"] or nodeValue["Default"] or nodeValue["Not NULL"] then -- TODO: Gotta be a better way to determine if this is a SQL table entry
710710
childNode.Label:SetText(nodeValue.Name)
711711
end
@@ -715,7 +715,7 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
715715
end
716716
else
717717
local nodeText = nodeKey
718-
if varType == "Schema" then
718+
if varType == "SQLite.Schema" then
719719
nodeText = nodeKey .. ": " .. tostring(nodeValue)
720720
elseif varType == "Files" then
721721
nodeText = nodeValue
@@ -749,7 +749,7 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
749749
end
750750
end
751751

752-
varType = varType or "Globals"
752+
varType = varType or "Lua.Globals"
753753

754754
if parentNode.Restrictions then
755755
childNode.Restrictions = parentNode.Restrictions
@@ -861,9 +861,14 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
861861
end
862862

863863
if visualDataType and visualDataType == "function" then
864-
childNode.FunctionRef = {name=nodeKey, func=nodeValue, path = "_G." .. childNode.GlobalPath}
864+
childNode.FunctionRef = {name=nodeKey, func=nodeValue, path = childNode.GlobalPath, fakeVarType = "function"}
865865
childNode:SetForceShowExpander(true)
866-
childNode:IsFunc()
866+
867+
if varType ~= "Profiling.Targets" then
868+
childNode:IsFunc() -- This is what swaps the expander for a dcheckbox if it's a function
869+
else
870+
childNode:SetForceShowExpander(false) -- No need to select already selected functions for profiling..
871+
end
867872

868873
blobsProfiler[luaState].Profile = blobsProfiler[luaState].Profile or {}
869874

@@ -922,6 +927,17 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
922927

923928
childNode.varType = varType
924929

930+
if varType == "Profiling.Targets" and isRoot then
931+
local fullModuleName = nodeData.key
932+
local splitModuleName = string.Explode(".", fullModuleName)
933+
934+
if #splitModuleName == 1 then
935+
childNode.Icon:SetImage(blobsProfiler.Modules[splitModuleName[1]].Icon)
936+
else
937+
childNode.Icon:SetImage(blobsProfiler.Modules[splitModuleName[1]].SubModules[splitModuleName[2]].Icon)
938+
end
939+
end
940+
925941
return childNode
926942
end
927943

@@ -947,7 +963,7 @@ local function buildDTree(luaState, parentPanel, rvarType, dataTableOverride)
947963
dataTable = blobsProfiler.GetDataTableForRealm(luaState, rvarType) or {}
948964
end
949965

950-
if varType == "Globals" then -- TODO: make this shit modular
966+
if rvarType == "Lua.Globals" then -- TODO: make this shit modular
951967
for key, value in pairs(dataTable) do
952968
table.insert(rootNodes, {
953969
key = key,
@@ -967,7 +983,7 @@ local function buildDTree(luaState, parentPanel, rvarType, dataTableOverride)
967983

968984
for index, nodeData in ipairs(specialNodes) do
969985
if blobsProfiler.Menu.TypeFolders[luaState][nodeData.special] == true then
970-
blobsProfiler.Menu.TypeFolders[luaState][nodeData.special] = addDTreeNode(dTree, nodeData, true, true, varType, luaState)
986+
blobsProfiler.Menu.TypeFolders[luaState][nodeData.special] = addDTreeNode(dTree, nodeData, true, true, rvarType, luaState)
971987
blobsProfiler.Menu.TypeFolders[luaState][nodeData.special].nodeData = nodeData
972988
end
973989
end
@@ -999,7 +1015,7 @@ local function buildDTree(luaState, parentPanel, rvarType, dataTableOverride)
9991015
local rootNodesLen = #rootNodes
10001016

10011017
for index, nodeData in ipairs(rootNodes) do
1002-
addDTreeNode(dTree, nodeData, false, true, varType, luaState)
1018+
addDTreeNode(dTree, nodeData, false, true, rvarType, luaState)
10031019

10041020
if index == rootNodesLen then
10051021
dTree:SetVisible(true)
@@ -1235,7 +1251,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
12351251

12361252
local dynamicH = (moduleTab.GetActiveTab and moduleTab:GetActiveTab() == s) and h-7 or h -- this is SO dumb
12371253
local startY = (moduleTab.GetActiveTab and moduleTab:GetActiveTab() == s) and 0 or 1
1238-
1254+
12391255
draw.RoundedBoxEx(4, 0, startY, perc * w, dynamicH, Color(255,255,0,50), true, true)
12401256
elseif blobsProfiler.Modules[moduleName].SubModules[subModuleName].flashyUpdate then
12411257
if (moduleTab.GetActiveTab and moduleTab:GetActiveTab() == s) then -- TODO: DPanel subModuleTabs will never stop flashing

lua/blobsprofiler/shared/modules/bp_profiling.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ blobsProfiler.RegisterSubModule("Profiling", "Targets", {
77
Icon = "icon16/book_addresses.png",
88
OrderPriority = 1,
99
OnOpen = function(luaState, parentPanel)
10-
print("profiling on open!", luaState, parentPanel)
11-
local profilerData = table.Copy(blobsProfiler.Client.Profile or {})
10+
local profilerData = table.Copy(blobsProfiler[luaState].Profile or {})
1211
profilerData.Raw = nil -- we dont need to display this
1312

1413
blobsProfiler.buildDTree(luaState, parentPanel, "Profiling.Targets", profilerData)

0 commit comments

Comments
 (0)