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

View File

@@ -63,7 +63,7 @@
-- @alias druid.rich_text
--- The component druid instance
-- @tfield DruidInstance druid @{DruidInstance}
-- @tfield DruidInstance druid DruidInstance
--- The root node of the Rich Text
-- @tfield node root
@@ -76,14 +76,19 @@
local component = require("druid.component")
local rich_text = require("druid.custom.rich_text.module.rt")
local RichText = component.create("rich_text")
---@class druid.rich_text: druid.base_component
---@field root node
---@field text_prefab node
---@field private _last_value string
---@field private _settings table
local M = component.create("rich_text")
--- The @{RichText} constructor
-- @tparam RichText self @{RichText}
--- The RichText constructor
-- @tparam RichText self RichText
-- @tparam node|string text_node The text node to make Rich Text
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
function RichText.init(self, text_node, value)
function M:init(text_node, value)
self.root = self:get_node(text_node)
self.text_prefab = self.root
@@ -98,7 +103,7 @@ function RichText.init(self, text_node, value)
end
function RichText.on_layout_change(self)
function M:on_layout_change()
if self._last_value then
self:set_text(self._last_value)
end
@@ -112,7 +117,7 @@ end
-- @tfield table|nil COLORS Rich Text color aliases. Default: {}
-- @tfield number|nil ADJUST_STEPS Amount steps of attemps text adjust by height. Default: 20
-- @tfield number|nil ADJUST_SCALE_DELTA Scale step on each height adjust step. Default: 0.02
function RichText.on_style_change(self, style)
function M:on_style_change(style)
self.style = {}
self.style.COLORS = style.COLORS or {}
self.style.ADJUST_STEPS = style.ADJUST_STEPS or 20
@@ -121,7 +126,7 @@ end
--- Set text for Rich Text
-- @tparam RichText self @{RichText}
-- @tparam RichText self RichText
-- @tparam string|nil text The text to set
-- @treturn druid.rich_text.word[] words
-- @treturn druid.rich_text.lines_metrics line_metrics
@@ -168,7 +173,7 @@ end
-- <img=texture:image/>
-- <img=texture:image,size/>
-- <img=texture:image,width,height/>
function RichText.set_text(self, text)
function M:set_text(text)
text = text or ""
self:clear()
self._last_value = text
@@ -184,14 +189,14 @@ end
--- Get current text
-- @tparam RichText self @{RichText}
-- @tparam RichText self RichText
-- @treturn string text
function RichText.get_text(self)
function M:get_text()
return self._last_value
end
function RichText:on_remove()
function M:on_remove()
gui.set_scale(self.root, self._default_scale)
gui.set_size(self.root, self._default_size)
self:clear()
@@ -199,7 +204,7 @@ end
--- Clear all created words.
function RichText:clear()
function M:clear()
if self._words then
rich_text.remove(self._words)
self._words = nil
@@ -209,10 +214,10 @@ end
--- Get all words, which has a passed tag.
-- @tparam RichText self @{RichText}
-- @tparam RichText self RichText
-- @tparam string tag
-- @treturn druid.rich_text.word[] words
function RichText.tagged(self, tag)
function M:tagged(tag)
if not self._words then
return
end
@@ -222,29 +227,29 @@ end
---Split a word into it's characters
-- @tparam RichText self @{RichText}
-- @tparam RichText self RichText
-- @tparam druid.rich_text.word word
-- @treturn druid.rich_text.word[] characters
function RichText.characters(self, word)
function M:characters(word)
return rich_text.characters(word)
end
--- Get all current words.
-- @treturn table druid.rich_text.word[]
function RichText:get_words()
function M:get_words()
return self._words
end
--- Get current line metrics
--- @treturn druid.rich_text.lines_metrics
function RichText:get_line_metric()
function M:get_line_metric()
return self._line_metrics
end
function RichText:_create_settings()
function M:_create_settings()
local root_size = gui.get_size(self.root)
local scale = gui.get_scale(self.root)
@@ -280,4 +285,4 @@ function RichText:_create_settings()
end
return RichText
return M