mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Update example with new brand one
This commit is contained in:
89
example/examples/basic/progress_bar/basic_progress_bar.gui
Normal file
89
example/examples/basic/progress_bar/basic_progress_bar.gui
Normal file
@@ -0,0 +1,89 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/example/assets/fonts/text_bold.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid"
|
||||
texture: "/example/assets/druid.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 1000.0
|
||||
y: 1000.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -150.0
|
||||
}
|
||||
size {
|
||||
x: 300.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.463
|
||||
y: 0.475
|
||||
z: 0.49
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/pixel"
|
||||
id: "progress_bar_back"
|
||||
pivot: PIVOT_W
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 300.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.631
|
||||
y: 0.843
|
||||
z: 0.961
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/pixel"
|
||||
id: "progress_bar_fill"
|
||||
pivot: PIVOT_W
|
||||
parent: "progress_bar_back"
|
||||
inherit_alpha: true
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 50.0
|
||||
}
|
||||
size {
|
||||
x: 150.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.722
|
||||
y: 0.741
|
||||
z: 0.761
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "0 %"
|
||||
font: "text_bold"
|
||||
id: "progress_value"
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
28
example/examples/basic/progress_bar/basic_progress_bar.lua
Normal file
28
example/examples/basic/progress_bar/basic_progress_bar.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
local component = require("druid.component")
|
||||
local progress = require("druid.extended.progress")
|
||||
|
||||
---@class basic_progress_bar: druid.base_component
|
||||
---@field druid druid_instance
|
||||
---@field progress druid.progress
|
||||
local M = component.create("basic_progress_bar")
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.progress = self.druid:new(progress, "progress_bar_fill", "x")
|
||||
self.text_value = self:get_node("progress_value")
|
||||
|
||||
self:set_value(self.progress:get())
|
||||
end
|
||||
|
||||
|
||||
function M:set_value(value)
|
||||
gui.set_text(self.text_value, math.ceil(value * 100) .. "%")
|
||||
self.progress:set_to(value)
|
||||
end
|
||||
|
||||
|
||||
return M
|
@@ -0,0 +1,101 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/example/assets/fonts/text_bold.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid"
|
||||
texture: "/example/assets/druid.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 1000.0
|
||||
y: 1000.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -150.0
|
||||
}
|
||||
size {
|
||||
x: 300.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.463
|
||||
y: 0.475
|
||||
z: 0.49
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/ui_circle_16"
|
||||
id: "progress_bar_back"
|
||||
pivot: PIVOT_W
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 8.0
|
||||
y: 8.0
|
||||
z: 8.0
|
||||
w: 8.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 300.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.631
|
||||
y: 0.843
|
||||
z: 0.961
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/ui_circle_16"
|
||||
id: "progress_bar_fill"
|
||||
pivot: PIVOT_W
|
||||
parent: "progress_bar_back"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 8.0
|
||||
y: 8.0
|
||||
z: 8.0
|
||||
w: 8.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 50.0
|
||||
}
|
||||
size {
|
||||
x: 150.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.722
|
||||
y: 0.741
|
||||
z: 0.761
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "0 %"
|
||||
font: "text_bold"
|
||||
id: "progress_value"
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
@@ -0,0 +1,28 @@
|
||||
local component = require("druid.component")
|
||||
local progress = require("druid.extended.progress")
|
||||
|
||||
---@class basic_progress_bar_slice9: druid.base_component
|
||||
---@field druid druid_instance
|
||||
---@field progress druid.progress
|
||||
local M = component.create("basic_progress_bar_slice9")
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.progress = self.druid:new(progress, "progress_bar_fill", "x")
|
||||
self.text_value = self:get_node("progress_value")
|
||||
|
||||
self:set_value(self.progress:get())
|
||||
end
|
||||
|
||||
|
||||
function M:set_value(value)
|
||||
gui.set_text(self.text_value, math.ceil(value * 100) .. "%")
|
||||
self.progress:set_to(value)
|
||||
end
|
||||
|
||||
|
||||
return M
|
Reference in New Issue
Block a user