mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Update
This commit is contained in:
@@ -110,7 +110,7 @@ end
|
||||
|
||||
|
||||
function M:update_components()
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
---@diagnostic disable-next-line, invisible
|
||||
local components = #self.druid.components_all
|
||||
|
||||
self.text_components_amount:set_text(tostring(components))
|
||||
|
@@ -1,18 +1,12 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class property_button: druid.component
|
||||
---@class property_button: druid.widget
|
||||
---@field root node
|
||||
---@field text_name druid.lang_text
|
||||
---@field button druid.button
|
||||
---@field text_button druid.text
|
||||
---@field druid druid.instance
|
||||
local M = component.create("property_button")
|
||||
local M = {}
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]]
|
||||
self.selected = self:get_node("selected")
|
||||
|
@@ -1,18 +1,12 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class property_checkbox: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class property_checkbox: druid.widget
|
||||
---@field root druid.container
|
||||
---@field text_name druid.lang_text
|
||||
---@field button druid.button
|
||||
---@field selected node
|
||||
local M = component.create("property_checkbox")
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
function M:init()
|
||||
self.root = self.druid:new_container("root") --[[@as druid.container]]
|
||||
|
||||
self.icon = self:get_node("icon")
|
||||
|
@@ -1,19 +1,12 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class property_slider: druid.component
|
||||
---@field druid druid.instance
|
||||
---@class property_slider: druid.widget
|
||||
---@field root druid.container
|
||||
---@field text_name druid.lang_text
|
||||
---@field text_value druid.text
|
||||
---@field slider druid.slider
|
||||
local M = component.create("property_slider")
|
||||
local M = {}
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
function M:init()
|
||||
self.root = self.druid:new_container("root") --[[@as druid.container]]
|
||||
self.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
|
@@ -87,7 +87,7 @@ end
|
||||
---@return property_slider
|
||||
function M:add_slider(text_id, initial_value, on_change_callback)
|
||||
local nodes = gui.clone_tree(self.property_slider_prefab)
|
||||
local instance = self.druid:new(property_slider, "property_slider", nodes) --[[@as property_slider]]
|
||||
local instance = self.druid:new_widget(property_slider, "property_slider", nodes) --[[@as property_slider]]
|
||||
instance.text_name:translate(text_id)
|
||||
instance:set_value(initial_value, true)
|
||||
|
||||
|
@@ -6,5 +6,9 @@ embedded_instances {
|
||||
" id: \"druid\"\n"
|
||||
" component: \"/example/druid.gui\"\n"
|
||||
"}\n"
|
||||
"components {\n"
|
||||
" id: \"druid1\"\n"
|
||||
" component: \"/druid/druid.script\"\n"
|
||||
"}\n"
|
||||
""
|
||||
}
|
||||
|
@@ -4785,6 +4785,25 @@ nodes {
|
||||
parent: "property_input/E_Anchor"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_TEMPLATE
|
||||
id: "example_tiling_node"
|
||||
parent: "widgets"
|
||||
inherit_alpha: true
|
||||
template: "/example/examples/widgets/tiling_node/example_tiling_node.gui"
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "example_tiling_node/root"
|
||||
parent: "example_tiling_node"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "example_tiling_node/tiling_node"
|
||||
parent: "example_tiling_node/root"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -20.0
|
||||
|
@@ -3,7 +3,7 @@ local intro_panthera = require("example.examples.intro.intro.intro_panthera")
|
||||
|
||||
---@class examples.intro: druid.widget
|
||||
---@field root node
|
||||
---@field animation panthera.instance
|
||||
---@field animation panthera.animation
|
||||
local M = {}
|
||||
|
||||
|
||||
|
@@ -7,9 +7,9 @@ local character_animation_blend = require("example.examples.panthera.animation_b
|
||||
---@class examples.animation_blend: druid.widget
|
||||
---@field root node
|
||||
---@field root_size vector3
|
||||
---@field animation_idle panthera.instance
|
||||
---@field animation_vertical panthera.instance
|
||||
---@field animation_horizontal panthera.instance
|
||||
---@field animation_idle panthera.animation
|
||||
---@field animation_vertical panthera.animation
|
||||
---@field animation_horizontal panthera.animation
|
||||
---@field rich_text druid.rich_text
|
||||
---@field on_update event
|
||||
local M = {}
|
||||
|
@@ -3,7 +3,7 @@ local panthera = require("panthera.panthera")
|
||||
local basic_animation_panthera = require("example.examples.panthera.basic_animation.basic_animation_panthera")
|
||||
|
||||
---@class examples.basic_animation: druid.widget
|
||||
---@field animation panthera.instance
|
||||
---@field animation panthera.animation
|
||||
---@field button druid.button
|
||||
local M = {}
|
||||
|
||||
|
@@ -177,6 +177,37 @@ function M.get_examples()
|
||||
end
|
||||
end)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name_id = "ui_example_widget_tiling_node",
|
||||
information_text_id = "ui_example_widget_tiling_node_description",
|
||||
template = "example_tiling_node",
|
||||
root = "example_tiling_node/root",
|
||||
code_url = "example/examples/widgets/tiling_node/example_tiling_node.lua",
|
||||
widget_class = require("example.examples.widgets.tiling_node.example_tiling_node"),
|
||||
properties_control = function(instance, properties_panel)
|
||||
---@cast instance examples.example_tiling_node
|
||||
properties_panel:add_slider("Repeat X", 0, function(value)
|
||||
local repeat_x = math.floor(value * 10)
|
||||
instance.tiling_node:refresh(repeat_x, nil)
|
||||
end)
|
||||
properties_panel:add_slider("Repeat Y", 0, function(value)
|
||||
local repeat_y = math.floor(value * 10)
|
||||
instance.tiling_node:refresh(nil, repeat_y)
|
||||
end)
|
||||
properties_panel:add_slider("Offset X", 0, function(value)
|
||||
instance.tiling_node:set_offset(value, nil)
|
||||
end)
|
||||
properties_panel:add_slider("Offset Y", 0, function(value)
|
||||
instance.tiling_node:set_offset(nil, value)
|
||||
end)
|
||||
properties_panel:add_slider("Margin X", 0, function(value)
|
||||
instance.tiling_node:set_margin(value, nil)
|
||||
end)
|
||||
properties_panel:add_slider("Margin Y", 0, function(value)
|
||||
instance.tiling_node:set_margin(nil, value)
|
||||
end)
|
||||
end,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
33
example/examples/widgets/tiling_node/example_tiling_node.gui
Normal file
33
example/examples/widgets/tiling_node/example_tiling_node.gui
Normal file
@@ -0,0 +1,33 @@
|
||||
textures {
|
||||
name: "tiling_texture"
|
||||
texture: "/example/examples/widgets/tiling_node/tiling_texture.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 500.0
|
||||
y: 500.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "tiling_texture/pattern_0004"
|
||||
id: "tiling_node"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
material: "gui_tiling_node"
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
materials {
|
||||
name: "gui_tiling_node"
|
||||
material: "/druid/materials/gui_tiling_node/gui_tiling_node.material"
|
||||
}
|
12
example/examples/widgets/tiling_node/example_tiling_node.lua
Normal file
12
example/examples/widgets/tiling_node/example_tiling_node.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local tiling_node = require("druid.widget.tiling_node.tiling_node")
|
||||
|
||||
---@class examples.example_tiling_node: druid.widget
|
||||
local M = {}
|
||||
|
||||
|
||||
function M:init()
|
||||
self.tiling_node = self.druid:new_widget(tiling_node, nil, nil, self:get_node("tiling_node"))
|
||||
end
|
||||
|
||||
|
||||
return M
|
BIN
example/examples/widgets/tiling_node/pattern_0004.png
Normal file
BIN
example/examples/widgets/tiling_node/pattern_0004.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,3 @@
|
||||
images {
|
||||
image: "/example/examples/widgets/tiling_node/pattern_0004.png"
|
||||
}
|
@@ -10,7 +10,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima
|
||||
---@field button_close druid.button
|
||||
---@field button_accept druid.button
|
||||
---@field button_decline druid.button
|
||||
---@field animation panthera.instance
|
||||
---@field animation panthera.animation
|
||||
local M = {}
|
||||
|
||||
|
||||
|
@@ -8,7 +8,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima
|
||||
---@field text_description druid.lang_text
|
||||
---@field button_close druid.button
|
||||
---@field button_accept druid.button
|
||||
---@field animation panthera.instance
|
||||
---@field animation panthera.animation
|
||||
local M = {}
|
||||
|
||||
|
||||
|
@@ -11,7 +11,7 @@ local window_animation_panthera = require("example.examples.windows.window_anima
|
||||
---@field lang_buttons table<string, druid.button>
|
||||
---@field grid druid.grid
|
||||
---@field on_language_change event
|
||||
---@field animation panthera.instance
|
||||
---@field animation panthera.animation
|
||||
local M = {}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user