mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Update properties panel, add refresh button
This commit is contained in:
parent
22c49540df
commit
2133492efe
@ -28,4 +28,7 @@ images {
|
|||||||
images {
|
images {
|
||||||
image: "/druid/images/icons/icon_arrow.png"
|
image: "/druid/images/icons/icon_arrow.png"
|
||||||
}
|
}
|
||||||
|
images {
|
||||||
|
image: "/druid/images/icons/icon_refresh.png"
|
||||||
|
}
|
||||||
extrude_borders: 2
|
extrude_borders: 2
|
||||||
|
BIN
druid/images/icons/icon_refresh.png
Normal file
BIN
druid/images/icons/icon_refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 593 B |
@ -106,6 +106,24 @@ nodes {
|
|||||||
x: 152.0
|
x: 152.0
|
||||||
y: -4.0
|
y: -4.0
|
||||||
}
|
}
|
||||||
|
color {
|
||||||
|
x: 0.306
|
||||||
|
y: 0.31
|
||||||
|
z: 0.314
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
texture: "druid/icon_refresh"
|
||||||
|
id: "icon_refresh"
|
||||||
|
pivot: PIVOT_NE
|
||||||
|
parent: "header"
|
||||||
|
inherit_alpha: true
|
||||||
|
size_mode: SIZE_MODE_AUTO
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 112.0
|
||||||
|
y: -4.0
|
||||||
|
}
|
||||||
scale {
|
scale {
|
||||||
x: -1.0
|
x: -1.0
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,10 @@ function M:init()
|
|||||||
end)
|
end)
|
||||||
gui.set_enabled(self.button_back.node, false)
|
gui.set_enabled(self.button_back.node, false)
|
||||||
|
|
||||||
|
self.button_refresh = self.druid:new_button("icon_refresh", function()
|
||||||
|
self.is_dirty = true
|
||||||
|
end)
|
||||||
|
|
||||||
-- We not using as a part of properties, since it handled in a way to be paginable
|
-- We not using as a part of properties, since it handled in a way to be paginable
|
||||||
self.paginator = self.druid:new_widget(property_left_right_selector, "property_left_right_selector", "root")
|
self.paginator = self.druid:new_widget(property_left_right_selector, "property_left_right_selector", "root")
|
||||||
self.paginator:set_text("Page")
|
self.paginator:set_text("Page")
|
||||||
@ -388,8 +392,7 @@ function M:render_lua_table(data)
|
|||||||
|
|
||||||
for i = 1, #component_order do
|
for i = 1, #component_order do
|
||||||
local component_id = component_order[i]
|
local component_id = component_order[i]
|
||||||
local component = data[component_id]
|
self:add_property_component(component_id, data)
|
||||||
self:add_property_component(component_id, component, data)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local metatable = getmetatable(data)
|
local metatable = getmetatable(data)
|
||||||
@ -403,7 +406,7 @@ function M:render_lua_table(data)
|
|||||||
for i = 1, #metatable_order do
|
for i = 1, #metatable_order do
|
||||||
local component_id = metatable_order[i]
|
local component_id = metatable_order[i]
|
||||||
local component = metatable.__index[component_id]
|
local component = metatable.__index[component_id]
|
||||||
self:add_property_component("M:" .. component_id, component, data)
|
self:add_property_component("M:" .. component_id, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -411,12 +414,13 @@ end
|
|||||||
|
|
||||||
---@private
|
---@private
|
||||||
---@param component_id string
|
---@param component_id string
|
||||||
---@param component table
|
---@param data table
|
||||||
---@param context table
|
function M:add_property_component(component_id, data)
|
||||||
function M:add_property_component(component_id, component, context)
|
local component = data[component_id]
|
||||||
local component_type = type(component)
|
local component_type = type(component)
|
||||||
|
|
||||||
if component_type == "table" then
|
if component_type == "table" then
|
||||||
|
self:add_button(function(button)
|
||||||
local is_empty = next(component) == nil
|
local is_empty = next(component) == nil
|
||||||
local is_array = component[1] ~= nil
|
local is_array = component[1] ~= nil
|
||||||
local name = "Inspect"
|
local name = "Inspect"
|
||||||
@ -436,7 +440,6 @@ function M:add_property_component(component_id, component, context)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:add_button(function(button)
|
|
||||||
button:set_text_property(button_name)
|
button:set_text_property(button_name)
|
||||||
button:set_text_button(name)
|
button:set_text_button(name)
|
||||||
button.button.on_click:subscribe(function()
|
button.button.on_click:subscribe(function()
|
||||||
@ -450,9 +453,9 @@ function M:add_property_component(component_id, component, context)
|
|||||||
if component_type == "string" then
|
if component_type == "string" then
|
||||||
self:add_input(function(input)
|
self:add_input(function(input)
|
||||||
input:set_text_property(tostring(component_id))
|
input:set_text_property(tostring(component_id))
|
||||||
input:set_text_value(tostring(component))
|
input:set_text_value(tostring(data[component_id]))
|
||||||
input:on_change(function(_, value)
|
input:on_change(function(_, value)
|
||||||
context[component_id] = value
|
data[component_id] = value
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -460,9 +463,9 @@ function M:add_property_component(component_id, component, context)
|
|||||||
if component_type == "number" then
|
if component_type == "number" then
|
||||||
self:add_input(function(input)
|
self:add_input(function(input)
|
||||||
input:set_text_property(tostring(component_id))
|
input:set_text_property(tostring(component_id))
|
||||||
input:set_text_value(tostring(helper.round(component, 3)))
|
input:set_text_value(tostring(helper.round(data[component_id], 3)))
|
||||||
input:on_change(function(_, value)
|
input:on_change(function(_, value)
|
||||||
context[component_id] = tonumber(value)
|
data[component_id] = tonumber(value)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -470,9 +473,9 @@ function M:add_property_component(component_id, component, context)
|
|||||||
if component_type == "boolean" then
|
if component_type == "boolean" then
|
||||||
self:add_checkbox(function(checkbox)
|
self:add_checkbox(function(checkbox)
|
||||||
checkbox:set_text_property(tostring(component_id))
|
checkbox:set_text_property(tostring(component_id))
|
||||||
checkbox:set_value(component)
|
checkbox:set_value(data[component_id])
|
||||||
checkbox:on_change(function(value)
|
checkbox:on_change(function(value)
|
||||||
context[component_id] = value
|
data[component_id] = value
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -482,17 +485,17 @@ function M:add_property_component(component_id, component, context)
|
|||||||
---@cast component vector3
|
---@cast component vector3
|
||||||
self:add_vector3(function(vector3)
|
self:add_vector3(function(vector3)
|
||||||
vector3:set_text_property(tostring(component_id))
|
vector3:set_text_property(tostring(component_id))
|
||||||
vector3:set_value(component.x, component.y, component.z)
|
vector3:set_value(data[component_id].x, data[component_id].y, data[component_id].z)
|
||||||
vector3.on_change:subscribe(function(value)
|
vector3.on_change:subscribe(function(value)
|
||||||
component.x = value.x
|
data[component_id].x = value.x
|
||||||
component.y = value.y
|
data[component_id].y = value.y
|
||||||
component.z = value.z
|
data[component_id].z = value.z
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
self:add_text(function(text)
|
self:add_text(function(text)
|
||||||
text:set_text_property(tostring(component_id))
|
text:set_text_property(tostring(component_id))
|
||||||
text:set_text_value(tostring(component))
|
text:set_text_value(tostring(data[component_id]))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -502,7 +505,7 @@ function M:add_property_component(component_id, component, context)
|
|||||||
button:set_text_property(tostring(component_id))
|
button:set_text_property(tostring(component_id))
|
||||||
button:set_text_button("Call")
|
button:set_text_button("Call")
|
||||||
button.button.on_click:subscribe(function()
|
button.button.on_click:subscribe(function()
|
||||||
component(context)
|
component(data)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user