Update annotations P.1

This commit is contained in:
Insality
2024-10-29 20:31:45 +02:00
parent a46f38734e
commit c85d66fdca
40 changed files with 1458 additions and 3941 deletions

View File

@@ -1,11 +1,11 @@
script: ""
fonts {
name: "game"
font: "/example/assets/fonts/game.font"
name: "text_bold"
font: "/example/assets/fonts/text_bold.font"
}
textures {
name: "kenney"
texture: "/example/assets/images/kenney.atlas"
name: "druid"
texture: "/example/assets/druid.atlas"
}
background_color {
x: 0.0
@@ -33,8 +33,8 @@ nodes {
w: 1.0
}
size {
x: 1.0
y: 1.0
x: 500.0
y: 80.0
z: 0.0
w: 1.0
}
@@ -46,7 +46,7 @@ nodes {
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
texture: ""
id: "root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -65,7 +65,11 @@ nodes {
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: false
material: ""
}
nodes {
position {
@@ -87,8 +91,8 @@ nodes {
w: 1.0
}
size {
x: 190.0
y: 45.0
x: 500.0
y: 80.0
z: 0.0
w: 1.0
}
@@ -100,7 +104,7 @@ nodes {
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/progress_back"
texture: "druid/rect_round2_width1"
id: "button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -110,17 +114,21 @@ nodes {
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
x: 4.0
y: 4.0
z: 4.0
w: 4.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@@ -136,27 +144,27 @@ nodes {
w: 1.0
}
scale {
x: 0.5
y: 0.5
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 300.0
x: 480.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 0.9490196
y: 0.9490196
z: 0.9490196
x: 0.31
y: 0.318
z: 0.322
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Placeholder"
font: "game"
font: "text_bold"
id: "placeholder_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -179,11 +187,15 @@ nodes {
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
@@ -199,27 +211,27 @@ nodes {
w: 1.0
}
scale {
x: 0.6
y: 0.6
z: 1.0
w: 1.0
}
size {
x: 300.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 480.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "User input"
font: "game"
font: "text_bold"
id: "input_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -242,15 +254,19 @@ nodes {
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 67.0
x: 118.0
y: 0.0
z: 0.0
w: 1.0
@@ -262,26 +278,26 @@ nodes {
w: 1.0
}
scale {
x: 0.6
y: 0.6
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 1.0
y: 1.0
x: 16.0
y: 50.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
x: 0.631
y: 0.843
z: 0.961
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
texture: "druid/ui_circle_16"
id: "cursor_node"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -291,22 +307,26 @@ nodes {
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
x: 8.0
y: 8.0
z: 8.0
w: 8.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
alpha: 0.5
template_node_child: false
size_mode: SIZE_MODE_AUTO
size_mode: SIZE_MODE_MANUAL
custom_type: 0
enabled: true
visible: true
material: ""
}
nodes {
position {
x: 0.0
y: 2.0
y: 4.0
z: 0.0
w: 1.0
}
@@ -317,8 +337,8 @@ nodes {
w: 1.0
}
scale {
x: 1.0
y: 1.0
x: 1.2
y: 1.2
z: 1.0
w: 1.0
}
@@ -329,15 +349,15 @@ nodes {
w: 1.0
}
color {
x: 0.2
y: 0.2
z: 0.2
x: 0.722
y: 0.741
z: 0.761
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "|"
font: "game"
font: "text_bold"
id: "cursor_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -358,13 +378,17 @@ nodes {
line_break: false
parent: "cursor_node"
layer: ""
inherit_alpha: true
inherit_alpha: false
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
custom_type: 0
enabled: true
visible: true
material: ""
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT

View File

@@ -6,13 +6,13 @@
-- @alias druid.rich_input
--- The component druid instance
-- @tfield DruidInstance druid @{DruidInstance}
-- @tfield DruidInstance druid DruidInstance
--- Root node
-- @tfield node root
--- On input field text change callback(self, input_text)
-- @tfield Input input @{Input}
-- @tfield Input input Input
--- On input field text change to empty string callback(self, input_text)
-- @tfield node cursor
@@ -44,16 +44,23 @@ local utf8_lua = require("druid.system.utf8")
local utf8 = utf8 or utf8_lua
local input = require("druid.extended.input")
local RichInput = component.create("druid.rich_input")
local SCHEME = {
ROOT = "root",
BUTTON = "button",
PLACEHOLDER = "placeholder_text",
INPUT = "input_text",
CURSOR = "cursor_node",
CURSOR_TEXT = "cursor_text",
}
---@class druid.rich_input: druid.base_component
---@field root node
---@field input druid.input
---@field cursor node
---@field cursor_text node
---@field cursor_position vector3
local M = component.create("druid.rich_input")
--local SCHEME = {
-- ROOT = "root",
-- BUTTON = "button",
-- PLACEHOLDER = "placeholder_text",
-- INPUT = "input_text",
-- CURSOR = "cursor_node",
-- CURSOR_TEXT = "cursor_text",
--}
local DOUBLE_CLICK_TIME = 0.35
@@ -189,13 +196,11 @@ local function on_drag_callback(self, dx, dy, x, y, touch)
end
--- The @{RichInput} constructor
-- @tparam RichInput self @{RichInput}
-- @tparam string template The template string name
-- @tparam table nodes Nodes table from gui.clone_tree
function RichInput.init(self, template, nodes)
---@param template string The template string name
---@param nodes table Nodes table from gui.clone_tree
function M:init(template, nodes)
self.druid = self:get_druid(template, nodes)
self.root = self:get_node(SCHEME.ROOT)
self.root = self:get_node("root")
self._last_touch_info = {
cursor_index = nil,
@@ -204,20 +209,20 @@ function RichInput.init(self, template, nodes)
self.is_lshift = false
self.is_lctrl = false
self.input = self.druid:new(input, self:get_node(SCHEME.BUTTON), self:get_node(SCHEME.INPUT))
self.input = self.druid:new(input, "button", "input_text")
self.is_button_input_enabled = gui.is_enabled(self.input.button.node)
self.cursor = self:get_node(SCHEME.CURSOR)
self.cursor = self:get_node("cursor_node")
self.cursor_position = gui.get_position(self.cursor)
self.cursor_text = self:get_node(SCHEME.CURSOR_TEXT)
self.cursor_text = self:get_node("cursor_text")
self.drag = self.druid:new_drag(self:get_node(SCHEME.BUTTON), on_drag_callback)
self.drag = self.druid:new_drag("button", on_drag_callback)
self.drag.on_touch_start:subscribe(on_touch_start_callback)
self.drag:set_input_priority(const.PRIORITY_INPUT_MAX + 1)
self.drag:set_enabled(false)
self.input:set_text("")
self.placeholder = self.druid:new_text(self:get_node(SCHEME.PLACEHOLDER))
self.placeholder = self.druid:new_text("placeholder_text")
self.text_position = gui.get_position(self.input.text.node)
self.input.on_input_text:subscribe(update_text)
@@ -230,7 +235,7 @@ function RichInput.init(self, template, nodes)
end
function RichInput.on_input(self, action_id, action)
function M:on_input(action_id, action)
if action_id == const.ACTION_LSHIFT then
if action.pressed then
self.is_lshift = true
@@ -258,26 +263,26 @@ end
--- Set placeholder text
-- @tparam RichInput self @{RichInput}
-- @tparam RichInput self RichInput
-- @tparam string placeholder_text The placeholder text
function RichInput.set_placeholder(self, placeholder_text)
function M:set_placeholder(placeholder_text)
self.placeholder:set_to(placeholder_text)
return self
end
--- Select input field
-- @tparam RichInput self @{RichInput}
function RichInput.select(self)
-- @tparam RichInput self RichInput
function M:select()
self.input:select()
end
--- Set input field text
-- @tparam RichInput self @{RichInput}
-- @tparam RichInput self RichInput
-- @treturn druid.input Current input instance
-- @tparam string text The input text
function RichInput.set_text(self, text)
function M:set_text(text)
self.input:set_text(text)
gui.set_enabled(self.placeholder.node, true and #self.input:get_text() == 0)
@@ -286,10 +291,10 @@ end
--- Set input field font
-- @tparam RichInput self @{RichInput}
-- @tparam RichInput self RichInput
-- @tparam hash font The font hash
-- @treturn druid.input Current input instance
function RichInput.set_font(self, font)
function M:set_font(font)
gui.set_font(self.input.text.node, font)
gui.set_font(self.placeholder.node, font)
@@ -298,8 +303,8 @@ end
--- Set input field text
-- @tparam RichInput self @{RichInput}
function RichInput.get_text(self)
-- @tparam RichInput self RichInput
function M:get_text()
return self.input:get_text()
end
@@ -307,14 +312,14 @@ end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @tparam RichInput self @{RichInput}
-- @tparam RichInput self RichInput
-- @tparam string characters Regulax exp. for validate user input
-- @treturn RichInput Current instance
function RichInput.set_allowed_characters(self, characters)
function M:set_allowed_characters(characters)
self.input:set_allowed_characters(characters)
return self
end
return RichInput
return M