diff --git a/druid/custom/rich_text/rich_text/richtext.lua b/druid/custom/rich_text/rich_text/richtext.lua index a2e14d9..1064e35 100755 --- a/druid/custom/rich_text/rich_text/richtext.lua +++ b/druid/custom/rich_text/rich_text/richtext.lua @@ -11,9 +11,6 @@ local M = {} M.ADJUST_STEPS = 10 M.ADJUST_SCALE_DELTA = 0.02 -local V3_ZERO = vmath.vector3(0) - - ---@class rich_text.metrics ---@field width number ---@field height number diff --git a/example/examples/custom/rich_text/rich_text.gui b/example/examples/custom/rich_text/rich_text.gui index a2b0f13..5ec4968 100644 --- a/example/examples/custom/rich_text/rich_text.gui +++ b/example/examples/custom/rich_text/rich_text.gui @@ -149,7 +149,7 @@ nodes { } size { x: 600.0 - y: 1500.0 + y: 1800.0 z: 0.0 w: 1.0 } @@ -500,8 +500,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -858,8 +858,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -917,7 +917,7 @@ nodes { w: 1.0 } size { - x: 520.0 + x: 533.0 y: 150.0 z: 0.0 w: 1.0 @@ -1282,8 +1282,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1640,8 +1640,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1931,8 +1931,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -2223,8 +2223,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -2582,8 +2582,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -2877,8 +2877,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -3172,8 +3172,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -3467,8 +3467,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -3760,8 +3760,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -4054,8 +4054,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -4348,8 +4348,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -4643,8 +4643,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -4938,8 +4938,8 @@ nodes { w: 1.0 } size { - x: 21.0 - y: 20.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -5036,6 +5036,360 @@ nodes { enabled: true visible: true } +nodes { + position { + x: 0.0 + y: -1455.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: 700.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_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "You can get the tagged word to make logic around" + font: "game" + id: "hint" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_N + outline { + x: 0.0 + y: 0.2 + z: 0.2 + w: 1.0 + } + shadow { + x: 0.101960786 + y: 0.3019608 + z: 0.3019608 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: true + parent: "scroll_content" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 0.5 + shadow_alpha: 0.1 + template_node_child: false + text_leading: 1.0 + text_tracking: 0.0 + custom_type: 0 + enabled: true + visible: true +} +nodes { + position { + x: 0.0 + y: -1622.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: 150.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.101960786 + y: 0.3019608 + z: 0.3019608 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "" + id: "case6" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "scroll_content" + 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: false + 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: 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: "rich_text_6" + parent: "case6" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/druid/custom/rich_text/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: 400.0 + y: 150.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: "rich_text_6/root" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "rich_text_6" + 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: 400.0 + y: 150.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: "Rich text" + font: "game" + id: "rich_text_6/text_prefab" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + 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: "rich_text_6/root" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 0.75 + shadow_alpha: 0.0 + overridden_fields: 1 + overridden_fields: 4 + overridden_fields: 14 + overridden_fields: 18 + overridden_fields: 31 + 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: "rich_text_6/icon_prefab" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "rich_text_6/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/custom/rich_text/rich_text.gui_script b/example/examples/custom/rich_text/rich_text.gui_script index b548d16..2d65d79 100644 --- a/example/examples/custom/rich_text/rich_text.gui_script +++ b/example/examples/custom/rich_text/rich_text.gui_script @@ -29,12 +29,9 @@ function init(self) self.rich_text = self.druid:new(RichText, "rich_text_1") self.rich_text:set_text("Here is basic Rich Text without any text settings") - -- self.rich_text:set_text("Lorem long text with differrent placeholder or just text without any sense here to check multiline without long words") - --self.rich_text:set_text("Some text with image in the middle") - --self.rich_text:set_text("Some text with image in the middle") self.rich_text_2 = self.druid:new(RichText, "rich_text_2") - self.rich_text_2:set_text("Here is example to compare Rich Text posing with usual GUI Text Node.") + self.rich_text_2:set_text("Here is example to compare Rich Text posing with usual GUI Text Node.") local rich_text_2_root = self.rich_text_2.root gui.animate(rich_text_2_root, "color.w", 0, gui.EASING_LINEAR, 4, 0, nil, gui.PLAYBACK_LOOP_PINGPONG) gui.animate(gui.get_node("text_case_2"), "color.w", 1, gui.EASING_LINEAR, 4, 0, nil, gui.PLAYBACK_LOOP_PINGPONG) @@ -62,6 +59,17 @@ function init(self) --self.rich_text_3 = self.druid:new(RichText, "rich_text_3") --local words3 = self.rich_text_3:set_text("Energy is full. To restore") --highlight_nodes(words3) + self.rich_text_6 = self.druid:new(RichText, "rich_text_6") + self.rich_text_6:set_text("Example text with clickable tagged words") + local tagged = self.rich_text_6:tagged("customlink") + pprint(tagged) + for index = 1, #tagged do + ---@type rich_text.word + local word = tagged[index] + self.druid:new_button(word.node, function() + print("on click tagged") + end) + end end