diff --git a/docs_md/components/manual_rich_text.md b/docs_md/components/manual_rich_text.md
new file mode 100644
index 0000000..aa4ffef
--- /dev/null
+++ b/docs_md/components/manual_rich_text.md
@@ -0,0 +1,59 @@
+# Druid Rich Text
+
+## Links
+[Rich Text API here](https://insality.github.io/druid/modules/RichText.html)
+
+## Overview
+
+
+## Setup
+
+Rich Text requires the next GUI Node scheme:
+```bash
+ root
+ ├── text_prefab
+ └── node_prefab
+```
+or make the copy of `/druid/custom/rich_text/rich_text.gui` and adjust your default settings
+
+Create Rich Text:
+```lua
+local RichText = require("druid.custom.rich_text.rich_text")
+
+function init(self)
+ self.druid = druid.new(self)
+ self.rich_text = self.druid:new(RichText, "template_name")
+ self.rich_text:set_text("Insert your text here")
+end
+```
+
+## Usage
+
+| Tag | Description | Example |
+|---------|------------------------------------------------|---------------------------------------------|
+| a | Create a "hyperlink" that generates a message | `Foobar` |
+| | when clicked (see `richtext.on_click`) | |
+| br | Insert a line break (see notes on linebreak) | `
` |
+| color | Change text color | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| shadow | Change text shadow | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| outline | Change text shadow | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| | | `Foobar` |
+| font | Change font | `Foobar` |
+| img | Display image | `
` |
+| | Display image in fixed square | `
` |
+| | Display image in fixed rectangle | `
` |
+| nobr | Prevent the text from breaking | `Words inside tag won't break` |
+| size | Change text size, relative to default size | `Twice as large` |
+
+
+## Usecases
+
+## Notes
diff --git a/druid/custom/rich_text/module/rt.lua b/druid/custom/rich_text/module/rt.lua
index bbd1550..bb9a287 100755
--- a/druid/custom/rich_text/module/rt.lua
+++ b/druid/custom/rich_text/module/rt.lua
@@ -9,56 +9,9 @@ local utf8 = utf8 or utf8_lua
local M = {}
-M.ADJUST_STEPS = 10
+M.ADJUST_STEPS = 20
M.ADJUST_SCALE_DELTA = 0.02
----@class rich_text.metrics
----@field width number
----@field height number
----@field offset_x number|nil
----@field offset_y number|nil
----@field node_size vector3|nil @For images only
-
----@class rich_text.lines_metrics
----@field text_width number
----@field text_height number
----@field lines table
-
----@class rich_text.word
----@field node Node
----@field relative_scale number
----@field color vector4
----@field position vector3
----@field offset vector3
----@field scale vector3
----@field size vector3
----@field metrics rich_text.metrics
----@field pivot Pivot
----@field text string
----@field shadow vector4
----@field outline vector4
----@field font string
----@field image rich_text.word.image
----@field default_animation string
----@field anchor number
----@field br boolean
----@field nobr boolean
-
----@class rich_text.settings
----@field parent Node
----@field size number
----@field fonts table
----@field color vector4
----@field shadow vector4
----@field outline vector4
----@field position vector3
----@field image_pixel_grid_snap boolean
----@field combine_words boolean
----@field default_animation string
----@field node_prefab Node
----@field text_prefab Node
-
-
-- Trim spaces on string start
local function ltrim(text)
return text:match('^%s*(.*)')
@@ -125,7 +78,7 @@ local function get_text_metrics(word, previous_word, settings)
local text = word.text
local font_resource = gui.get_font_resource(word.font)
- ---@type rich_text.metrics
+ ---@type druid.rich_text.metrics
local metrics
local word_scale_x = word.relative_scale * settings.text_scale.x * settings.adjust_scale
local word_scale_y = word.relative_scale * settings.text_scale.y * settings.adjust_scale
@@ -158,9 +111,9 @@ local function get_text_metrics(word, previous_word, settings)
end
----@param word rich_text.word
----@param settings rich_text.settings
----@return rich_text.metrics
+---@param word druid.rich_text.word
+---@param settings druid.rich_text.settings
+---@return druid.rich_text.metrics
local function get_image_metrics(word, settings)
local node_prefab = settings.node_prefab
gui.play_flipbook(node_prefab, word.image.anim)
@@ -177,10 +130,10 @@ local function get_image_metrics(word, settings)
end
----@param word rich_text.word
----@param settings rich_text.settings
----@param previous_word rich_text.word|nil
----@return rich_text.metrics
+---@param word druid.rich_text.word
+---@param settings druid.rich_text.settings
+---@param previous_word druid.rich_text.word|nil
+---@return druid.rich_text.metrics
local function measure_node(word, settings, previous_word)
local metrics = word.image and get_image_metrics(word, settings) or get_text_metrics(word, previous_word, settings)
return metrics
@@ -242,9 +195,9 @@ function M.create(text, settings)
end
----@param words rich_text.word
----@param metrics rich_text.metrics
----@param settings rich_text.settings
+---@param word druid.rich_text.word
+---@param metrics druid.rich_text.metrics
+---@param settings druid.rich_text.settings
function M._fill_properties(word, metrics, settings)
word.metrics = metrics
word.position = vmath.vector3(0)
@@ -267,9 +220,9 @@ function M._fill_properties(word, metrics, settings)
end
----@param words rich_text.word[]
----@param settings rich_text.settings
----@return rich_text.word[][]
+---@param words druid.rich_text.word[]
+---@param settings druid.rich_text.settings
+---@return druid.rich_text.word[][]
function M._split_on_lines(words, settings)
local i = 1
local lines = {}
@@ -310,7 +263,7 @@ function M._split_on_lines(words, settings)
end
end
local overflow = (current_line_width + next_words_width) > settings.width
- local is_new_line = (overflow or word.br) and settings.is_multiline
+ local is_new_line = (overflow or word.br) and settings.is_multiline and not word.nobr
-- We recalculate metrics with previous_word if it follow for word on current line
if not is_new_line and previous_word then
diff --git a/druid/custom/rich_text/module/rt_tags.lua b/druid/custom/rich_text/module/rt_tags.lua
index 75c595f..885b1c6 100644
--- a/druid/custom/rich_text/module/rt_tags.lua
+++ b/druid/custom/rich_text/module/rt_tags.lua
@@ -104,11 +104,6 @@ M.register("img", function(params, settings)
width = width and tonumber(width)
height = height and tonumber(height)
- ---@class rich_text.word.image
- ---@field texture string
- ---@field anim string
- ---@field width number
- ---@field height number
settings.image = {
texture = texture,
anim = anim,
diff --git a/example/assets/fonts/Exo2-LightItalic.ttf b/example/assets/fonts/Exo2-LightItalic.ttf
new file mode 100644
index 0000000..ecd1459
Binary files /dev/null and b/example/assets/fonts/Exo2-LightItalic.ttf differ
diff --git a/example/assets/fonts/Exo2-Regular.ttf b/example/assets/fonts/Exo2-Regular.ttf
new file mode 100644
index 0000000..63bc4bb
Binary files /dev/null and b/example/assets/fonts/Exo2-Regular.ttf differ
diff --git a/example/assets/fonts/another_font.font b/example/assets/fonts/game_thin.font
similarity index 86%
rename from example/assets/fonts/another_font.font
rename to example/assets/fonts/game_thin.font
index 0e257ac..dfd0834 100644
--- a/example/assets/fonts/another_font.font
+++ b/example/assets/fonts/game_thin.font
@@ -1,4 +1,4 @@
-font: "/builtins/fonts/vera_mo_bd.ttf"
+font: "/example/assets/fonts/Exo2-Regular.ttf"
material: "/builtins/fonts/font-df.material"
size: 40
antialias: 1
diff --git a/example/assets/fonts/game_thin_italic.font b/example/assets/fonts/game_thin_italic.font
new file mode 100644
index 0000000..986ff68
--- /dev/null
+++ b/example/assets/fonts/game_thin_italic.font
@@ -0,0 +1,17 @@
+font: "/example/assets/fonts/Exo2-LightItalic.ttf"
+material: "/builtins/fonts/font-df.material"
+size: 40
+antialias: 1
+alpha: 1.0
+outline_alpha: 0.0
+outline_width: 0.0
+shadow_alpha: 0.0
+shadow_blur: 0
+shadow_x: 0.0
+shadow_y: 0.0
+extra_characters: ""
+output_format: TYPE_DISTANCE_FIELD
+all_chars: false
+cache_width: 0
+cache_height: 0
+render_mode: MODE_MULTI_LAYER
diff --git a/example/examples/rich_text/rich_text_texts/rich_text_texts.gui b/example/examples/rich_text/rich_text_texts/rich_text_texts.gui
index 0bc22f8..757aa39 100644
--- a/example/examples/rich_text/rich_text_texts/rich_text_texts.gui
+++ b/example/examples/rich_text/rich_text_texts/rich_text_texts.gui
@@ -4,8 +4,12 @@ fonts {
font: "/example/assets/fonts/game.font"
}
fonts {
- name: "another_font"
- font: "/example/assets/fonts/another_font.font"
+ name: "game_thin"
+ font: "/example/assets/fonts/game_thin.font"
+}
+fonts {
+ name: "game_thin_italic"
+ font: "/example/assets/fonts/game_thin_italic.font"
}
textures {
name: "kenney"
@@ -77,7 +81,7 @@ nodes {
nodes {
position {
x: 0.0
- y: 485.0
+ y: 415.0
z: 0.0
w: 1.0
}
@@ -95,7 +99,7 @@ nodes {
}
size {
x: 600.0
- y: 900.0
+ y: 1200.0
z: 0.0
w: 1.0
}
@@ -135,7 +139,7 @@ nodes {
nodes {
position {
x: 0.0
- y: -100.0
+ y: 0.0
z: 0.0
w: 1.0
}
@@ -583,7 +587,7 @@ nodes {
nodes {
position {
x: 0.0
- y: -300.0
+ y: -200.0
z: 0.0
w: 1.0
}
@@ -1032,7 +1036,7 @@ nodes {
nodes {
position {
x: 0.0
- y: -500.0
+ y: -400.0
z: 0.0
w: 1.0
}
@@ -1479,6 +1483,1370 @@ nodes {
enabled: true
visible: true
}
+nodes {
+ position {
+ x: 0.0
+ y: -600.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case4"
+ parent: "content"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/examples/rich_text/rich_text_texts/prefab_example_rich_text.gui"
+ template_node_child: false
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 200.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/empty"
+ id: "case4/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case4"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.8
+ y: 0.8
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 750.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Example with
and "
+ font: "game"
+ id: "case4/hint"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ outline {
+ x: 0.101960786
+ y: 0.101960786
+ z: 0.101960786
+ w: 1.0
+ }
+ shadow {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: true
+ parent: "case4/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.7
+ shadow_alpha: 0.0
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -60.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 130.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case4/area"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case4/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -65.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case4/rich_text"
+ parent: "case4/area"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/druid/custom/rich_text/rich_text.gui"
+ template_node_child: true
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 500.0
+ y: 130.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case4/rich_text/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case4/rich_text"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ overridden_fields: 4
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 300.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 0.2
+ y: 0.2
+ z: 0.2
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Rich Text"
+ font: "game"
+ id: "case4/rich_text/text_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_SW
+ outline {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: true
+ parent: "case4/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.0
+ overridden_fields: 8
+ overridden_fields: 14
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "items/checkmark"
+ id: "case4/rich_text/icon_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case4/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_AUTO
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -800.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case5"
+ parent: "content"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/examples/rich_text/rich_text_texts/prefab_example_rich_text.gui"
+ template_node_child: false
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 200.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/empty"
+ id: "case5/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case5"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 0.8
+ y: 0.8
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 750.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Rich Text can adjust text by height:"
+ font: "game"
+ id: "case5/hint"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ outline {
+ x: 0.101960786
+ y: 0.101960786
+ z: 0.101960786
+ w: 1.0
+ }
+ shadow {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: true
+ parent: "case5/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.7
+ shadow_alpha: 0.0
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -60.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 130.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case5/area"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case5/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -65.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case5/rich_text"
+ parent: "case5/area"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/druid/custom/rich_text/rich_text.gui"
+ template_node_child: true
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 400.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 0.8
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case5/rich_text/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case5/rich_text"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ overridden_fields: 4
+ overridden_fields: 5
+ overridden_fields: 46
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 300.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 0.2
+ y: 0.2
+ z: 0.2
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Rich Text"
+ font: "game"
+ id: "case5/rich_text/text_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_SW
+ outline {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: true
+ parent: "case5/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.0
+ overridden_fields: 8
+ overridden_fields: 14
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "items/checkmark"
+ id: "case5/rich_text/icon_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case5/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_AUTO
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -1000.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case6"
+ parent: "content"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/example/examples/rich_text/rich_text_texts/prefab_example_rich_text.gui"
+ template_node_child: false
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 200.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "kenney/empty"
+ id: "case6/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case6"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: false
+}
+nodes {
+ position {
+ x: 0.0
+ y: 9.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: 800.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Disabled Line Break in text_prefab, adjust by width"
+ font: "game"
+ id: "case6/hint"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ outline {
+ x: 0.101960786
+ y: 0.101960786
+ z: 0.101960786
+ w: 1.0
+ }
+ shadow {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: true
+ parent: "case6/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.7
+ shadow_alpha: 0.0
+ overridden_fields: 1
+ overridden_fields: 3
+ overridden_fields: 4
+ overridden_fields: 8
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -60.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 600.0
+ y: 130.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 0.9411765
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case6/area"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_N
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case6/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: -65.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_TEMPLATE
+ id: "case6/rich_text"
+ parent: "case6/area"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ template: "/druid/custom/rich_text/rich_text.gui"
+ template_node_child: true
+ custom_type: 0
+ enabled: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 400.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 0.8
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: ""
+ id: "case6/rich_text/root"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case6/rich_text"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ overridden_fields: 4
+ overridden_fields: 5
+ overridden_fields: 46
+ template_node_child: true
+ size_mode: SIZE_MODE_MANUAL
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 300.0
+ y: 60.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 0.2
+ y: 0.2
+ z: 0.2
+ w: 1.0
+ }
+ type: TYPE_TEXT
+ blend_mode: BLEND_MODE_ALPHA
+ text: "Rich Text"
+ font: "game"
+ id: "case6/rich_text/text_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_SW
+ outline {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ shadow {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ adjust_mode: ADJUST_MODE_FIT
+ line_break: false
+ parent: "case6/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ alpha: 1.0
+ outline_alpha: 0.0
+ shadow_alpha: 0.0
+ overridden_fields: 8
+ overridden_fields: 14
+ overridden_fields: 18
+ template_node_child: true
+ text_leading: 1.0
+ text_tracking: 0.0
+ custom_type: 0
+ enabled: true
+ visible: true
+}
+nodes {
+ position {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ rotation {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 1.0
+ }
+ scale {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ size {
+ x: 200.0
+ y: 100.0
+ z: 0.0
+ w: 1.0
+ }
+ color {
+ x: 1.0
+ y: 1.0
+ z: 1.0
+ w: 1.0
+ }
+ type: TYPE_BOX
+ blend_mode: BLEND_MODE_ALPHA
+ texture: "items/checkmark"
+ id: "case6/rich_text/icon_prefab"
+ xanchor: XANCHOR_NONE
+ yanchor: YANCHOR_NONE
+ pivot: PIVOT_CENTER
+ adjust_mode: ADJUST_MODE_FIT
+ parent: "case6/rich_text/root"
+ layer: ""
+ inherit_alpha: true
+ slice9 {
+ x: 0.0
+ y: 0.0
+ z: 0.0
+ w: 0.0
+ }
+ clipping_mode: CLIPPING_MODE_NONE
+ clipping_visible: true
+ clipping_inverted: false
+ alpha: 1.0
+ template_node_child: true
+ size_mode: SIZE_MODE_AUTO
+ custom_type: 0
+ enabled: true
+ visible: true
+}
layers {
name: "image"
}
diff --git a/example/examples/rich_text/rich_text_texts/rich_text_texts.gui_script b/example/examples/rich_text/rich_text_texts/rich_text_texts.gui_script
index 73c7ebc..2912299 100644
--- a/example/examples/rich_text/rich_text_texts/rich_text_texts.gui_script
+++ b/example/examples/rich_text/rich_text_texts/rich_text_texts.gui_script
@@ -14,7 +14,16 @@ function init(self)
self.rich_text_2:set_text("Here is color example for Rich Text. You can adjust the color, shadow or outline")
self.rich_text_3 = self.druid:new(RichText, "case3/rich_text")
- self.rich_text_3:set_text("Here font change example. Can be usedfor bold and italic fonts or other one")
+ self.rich_text_3:set_text("Here font change example. Can be usedfor bold and italic fonts or other one")
+
+ self.rich_text_4 = self.druid:new(RichText, "case4/rich_text")
+ self.rich_text_4:set_text("Hello! Here are new line
and this long text will be without any new line until nobr is end he
re text with br too")
+
+ self.rich_text_5 = self.druid:new(RichText, "case5/rich_text")
+ self.rich_text_5:set_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.")
+
+ self.rich_text_6 = self.druid:new(RichText, "case6/rich_text")
+ self.rich_text_6:set_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.")
end
diff --git a/utils/annotations_manual.lua b/utils/annotations_manual.lua
new file mode 100644
index 0000000..8259dd5
--- /dev/null
+++ b/utils/annotations_manual.lua
@@ -0,0 +1,51 @@
+---@class druid.rich_text.metrics
+---@field width number
+---@field height number
+---@field offset_x number|nil
+---@field offset_y number|nil
+---@field node_size vector3|nil @For images only
+
+---@class druid.rich_text.lines_metrics
+---@field text_width number
+---@field text_height number
+---@field lines table
+
+---@class druid.rich_text.word
+---@field node Node
+---@field relative_scale number
+---@field color vector4
+---@field position vector3
+---@field offset vector3
+---@field scale vector3
+---@field size vector3
+---@field metrics druid.rich_text.metrics
+---@field pivot Pivot
+---@field text string
+---@field shadow vector4
+---@field outline vector4
+---@field font string
+---@field image druid.rich_text.image
+---@field default_animation string
+---@field anchor number
+---@field br boolean
+---@field nobr boolean
+
+---@class druid.rich_text.word.image
+---@field texture string
+---@field anim string
+---@field width number
+---@field height number
+
+---@class druid.rich_text.settings
+---@field parent Node
+---@field size number
+---@field fonts table
+---@field color vector4
+---@field shadow vector4
+---@field outline vector4
+---@field position vector3
+---@field image_pixel_grid_snap boolean
+---@field combine_words boolean
+---@field default_animation string
+---@field node_prefab Node
+---@field text_prefab Node