add simple slider component

This commit is contained in:
Insality
2019-09-26 00:27:27 +03:00
parent 7917a08f5c
commit 6cebc9d0c9
4 changed files with 158 additions and 4 deletions

View File

@@ -1570,6 +1570,69 @@ nodes {
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: 0.0
y: 20.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 100.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "50%"
font: "game"
id: "text_progress_slider"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "slider_back"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 0.0

View File

@@ -11,7 +11,7 @@ end
local function random_progress(progress, text)
local rnd = math.random()
gui.set_text(text, math.ceil(rnd * 100))
gui.set_text(text, math.ceil(rnd * 100) .. "%")
progress:to(rnd)
end
@@ -38,10 +38,10 @@ end
local function setup_progress(self)
local progress = self.druid:new_progress("progress_fill", "x", 0.4)
random_progress(progress, gui.get_node("text_progress"))
self.progress = self.druid:new_progress("progress_fill", "x", 0.4)
random_progress(self.progress, gui.get_node("text_progress"))
timer.delay(2, true, function()
random_progress(progress, gui.get_node("text_progress_amount"))
random_progress(self.progress, gui.get_node("text_progress_amount"))
end)
end
@@ -62,6 +62,13 @@ local function setup_grid(self)
end
local function setup_slider(self)
self.druid:new_slider("slider_pin", vmath.vector3(95, 0, 0), function(_, value)
gui.set_text(gui.get_node("text_progress_slider"), math.ceil(value * 100) .. "%")
end)
end
local function setup_checkbox(self)
self.druid:new_checkbox("radio1/check", nil, "radio1/back")
self.druid:new_checkbox("radio2/check", nil, "radio2/back")
@@ -97,6 +104,7 @@ function M.setup_page(self)
setup_timer(self)
setup_checkbox(self)
setup_scroll(self)
setup_slider(self)
setup_back_handler(self)
end