Skip to content

Commit

Permalink
Update the panel druid profiler, remove events counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Jan 30, 2025
1 parent 0514625 commit b6c0e15
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 156 deletions.
114 changes: 20 additions & 94 deletions example/components/panel_druid_profiler/panel_druid_profiler.gui
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,25 @@ nodes {
z: 0.157
}
type: TYPE_BOX
texture: "druid_example/pixel"
id: "root"
adjust_mode: ADJUST_MODE_STRETCH
inherit_alpha: true
}
nodes {
size {
x: 1040.0
y: 50.0
}
type: TYPE_BOX
id: "layout"
xanchor: XANCHOR_LEFT
adjust_mode: ADJUST_MODE_STRETCH
parent: "root"
inherit_alpha: true
size_mode: SIZE_MODE_AUTO
visible: false
}
nodes {
position {
x: -530.0
Expand All @@ -32,7 +47,7 @@ nodes {
type: TYPE_BOX
id: "group_memory"
pivot: PIVOT_W
parent: "root"
parent: "layout"
inherit_alpha: true
visible: false
}
Expand Down Expand Up @@ -149,7 +164,7 @@ nodes {
}
nodes {
position {
x: -130.0
x: -31.0
}
size {
x: 16.0
Expand All @@ -158,7 +173,7 @@ nodes {
type: TYPE_BOX
texture: "druid_example/empty"
id: "group_fps"
parent: "root"
parent: "layout"
inherit_alpha: true
visible: false
}
Expand Down Expand Up @@ -279,7 +294,7 @@ nodes {
}
nodes {
position {
x: 130.0
x: 355.0
}
size {
x: 16.0
Expand All @@ -288,7 +303,7 @@ nodes {
type: TYPE_BOX
texture: "druid_example/empty"
id: "group_components"
parent: "root"
parent: "layout"
inherit_alpha: true
visible: false
}
Expand Down Expand Up @@ -366,95 +381,6 @@ nodes {
outline_alpha: 0.0
shadow_alpha: 0.0
}
nodes {
position {
x: 530.0
}
size {
x: 16.0
y: 50.0
}
type: TYPE_BOX
id: "group_events"
pivot: PIVOT_E
parent: "root"
inherit_alpha: true
visible: false
}
nodes {
position {
x: -163.0
}
scale {
x: 0.8
y: 0.8
}
size {
x: 200.0
y: 50.0
}
color {
x: 0.306
y: 0.31
z: 0.314
}
type: TYPE_TEXT
text: "Events"
font: "text_bold"
id: "text_events"
outline {
x: 1.0
y: 1.0
z: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
}
parent: "group_events"
layer: "text_bold"
inherit_alpha: true
outline_alpha: 0.0
shadow_alpha: 0.0
}
nodes {
position {
x: -59.0
}
scale {
x: 0.8
y: 0.8
}
size {
x: 200.0
y: 50.0
}
color {
x: 0.463
y: 0.475
z: 0.49
}
type: TYPE_TEXT
text: "6000"
font: "text_bold"
id: "text_events_amount"
outline {
x: 1.0
y: 1.0
z: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
}
parent: "group_events"
layer: "text_bold"
inherit_alpha: true
outline_alpha: 0.0
shadow_alpha: 0.0
}
layers {
name: "druid"
}
Expand Down
51 changes: 11 additions & 40 deletions example/components/panel_druid_profiler/panel_druid_profiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,30 @@ function M:init(template, nodes)
self.group_memory = self.root:add_container("group_memory")
self.group_fps = self.root:add_container("group_fps")
self.group_components = self.root:add_container("group_components")
self.group_events = self.root:add_container("group_events")

self.root:add_container("layout", nil, function()
self.layout:set_dirty()
end)
self.layout = self.druid:new_layout("layout", "horizontal")
self.layout:add(self.group_memory.node)
self.layout:add(self.group_fps.node)
self.layout:add(self.group_components.node)
self.layout:set_justify(true)

self.druid:new_button("group_memory", self.run_collectgarbage)

self.group_memory:set_min_size(270, nil)
self.group_fps:set_min_size(270, nil)
self.group_components:set_min_size(270, nil)
self.group_events:set_min_size(270, nil)

self.text_memory_amount = self.druid:new_text("text_memory_amount")
self.text_fps_amount = self.druid:new_text("text_fps_amount")
self.text_fps_min = self.druid:new_text("text_fps_min")
self.text_components_amount = self.druid:new_text("text_components_amount")
self.text_events_amount = self.druid:new_text("text_events_amount")

self.druid:new_lang_text("text_memory", "ui_profiler_memory")
self.druid:new_lang_text("text_fps", "ui_profiler_fps")
self.druid:new_lang_text("text_components", "ui_profiler_components")
self.druid:new_lang_text("text_events", "ui_profiler_events")

self.previous_time = nil
self.fps_samples = {}
Expand All @@ -55,17 +60,12 @@ function M:init(template, nodes)
self:get_node("text_components"),
self:get_node("text_components_amount"),
}
self.nodes_events = {
self:get_node("text_events"),
self:get_node("text_events_amount"),
}

timer.delay(0.16, true, function()
self:update_memory()
self:update_fps()
self:update_components()
self:update_events()
self:align_fps_components()
self.layout:set_dirty()
end)
end

Expand All @@ -74,8 +74,7 @@ function M:on_language_change()
self:update_memory()
self:update_fps()
self:update_components()
self:update_events()
self:align_fps_components()
self.layout:set_dirty()
end


Expand Down Expand Up @@ -120,34 +119,6 @@ function M:update_components()
end


function M:update_events()
self.text_events_amount:set_text("unsupported")

local width = helper.centrate_nodes(2, unpack(self.nodes_events))
for index = 1, #self.nodes_events do
local node = self.nodes_events[index]
local position_x = gui.get(node, "position.x")
gui.set(node, "position.x", position_x - width/2)
end
self.group_events:set_size(width, nil)
end


function M:align_fps_components()
local pos_x_memory = gui.get(self.group_memory.node, "position.x") + gui.get(self.group_memory.node, "size.x")
local pos_x_events = gui.get(self.group_events.node, "position.x") - gui.get(self.group_events.node, "size.x")
local width = pos_x_events - pos_x_memory

-- Align FPS and Components
local fps_size = gui.get(self.group_fps.node, "size.x")
local components_size = gui.get(self.group_components.node, "size.x")

local free_width = width - fps_size - components_size
gui.set(self.group_fps.node, "position.x", pos_x_memory + fps_size/2 + free_width/3)
gui.set(self.group_components.node, "position.x", pos_x_events - components_size/2 - free_width/3)
end


function M:update()
self:sample_fps()
end
Expand Down
30 changes: 9 additions & 21 deletions example/druid.gui
Original file line number Diff line number Diff line change
Expand Up @@ -4824,10 +4824,16 @@ nodes {
}
nodes {
type: TYPE_BOX
id: "panel_druid_profiler/group_memory"
id: "panel_druid_profiler/layout"
parent: "panel_druid_profiler/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "panel_druid_profiler/group_memory"
parent: "panel_druid_profiler/layout"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "panel_druid_profiler/text_memory"
Expand All @@ -4849,7 +4855,7 @@ nodes {
nodes {
type: TYPE_BOX
id: "panel_druid_profiler/group_fps"
parent: "panel_druid_profiler/root"
parent: "panel_druid_profiler/layout"
template_node_child: true
}
nodes {
Expand All @@ -4873,7 +4879,7 @@ nodes {
nodes {
type: TYPE_BOX
id: "panel_druid_profiler/group_components"
parent: "panel_druid_profiler/root"
parent: "panel_druid_profiler/layout"
template_node_child: true
}
nodes {
Expand All @@ -4888,24 +4894,6 @@ nodes {
parent: "panel_druid_profiler/group_components"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "panel_druid_profiler/group_events"
parent: "panel_druid_profiler/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "panel_druid_profiler/text_events"
parent: "panel_druid_profiler/group_events"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "panel_druid_profiler/text_events_amount"
parent: "panel_druid_profiler/group_events"
template_node_child: true
}
layers {
name: "druid"
}
Expand Down
2 changes: 1 addition & 1 deletion settings_deployer
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
bob_folder=./

# You can point bob version for project in format "filename:sha"
bob_sha="195:87b6907759f7b8dff830d54b2250b8d721bde291"
bob_sha="196:11d2cd3a9be17b2fc5a2cb5cea59bbfb4af1ca96"

# Select Defold channel. Values: stable, beta, alpha
bob_channel="stable"
Expand Down

0 comments on commit b6c0e15

Please sign in to comment.