idk richtext stuff

This commit is contained in:
2025-09-15 00:40:58 -05:00
parent 39aca9aa3f
commit 2b58781907
44 changed files with 335 additions and 1009 deletions

View File

@@ -86,7 +86,7 @@ func _enter_tree():
_parse_input_actions()
func _exit_tree():
Mapper.queue_free()
Mapper = null
func _parse_input_actions():
_custom_input_actions.clear()
@@ -189,10 +189,13 @@ func refresh():
func get_joypad_type(controller: int = _last_controller) -> ControllerSettings.Devices:
return Mapper._get_joypad_type(controller, _settings.joypad_fallback)
func parse_path(path: String, input_type = _last_input_type, last_controller = _last_controller) -> Texture:
func get_last_input_type() -> InputType:
return _last_input_type
func parse_path(path: String, input_type = _last_input_type, last_controller = _last_controller, forced_controller_icon_style = ControllerSettings.Devices.NONE) -> Texture:
if typeof(input_type) == TYPE_NIL:
return null
var root_paths := _expand_path(path, input_type, last_controller)
var root_paths := _expand_path(path, input_type, last_controller, forced_controller_icon_style)
for root_path in root_paths:
if _load_icon(root_path):
continue
@@ -228,6 +231,7 @@ func parse_event_modifiers(event: InputEvent) -> Array[Texture]:
for icon_path in _expand_path(modifier, InputType.KEYBOARD_MOUSE, -1):
if _load_icon(icon_path) == OK:
icons.push_back(_cached_icons[icon_path])
break
return icons
@@ -270,7 +274,7 @@ func get_matching_event(path: String, input_type: InputType = _last_input_type,
else:
events = InputMap.action_get_events(path)
var fallback = null
var fallbacks = []
for event in events:
if not is_instance_valid(event): continue
@@ -283,13 +287,15 @@ func get_matching_event(path: String, input_type: InputType = _last_input_type,
# Use the first device specific mapping if there is one.
if event.device == controller:
return event
# Otherwise use the first "all devices" mapping.
elif fallback == null and event.device < 0:
fallback = event
# Otherwise, we create a fallback prioritizing events with 'ALL_DEVICE'
if event.device < 0: # All-device event
fallbacks.push_front(event)
else:
fallbacks.push_back(event)
return fallback
return fallbacks[0] if not fallbacks.is_empty() else null
func _expand_path(path: String, input_type: int, controller: int) -> Array:
func _expand_path(path: String, input_type: int, controller: int, forced_controller_icon_style = ControllerSettings.Devices.NONE) -> Array:
var paths := []
var base_paths := [
_settings.custom_asset_dir + "/",
@@ -298,20 +304,20 @@ func _expand_path(path: String, input_type: int, controller: int) -> Array:
for base_path in base_paths:
if base_path.is_empty():
continue
base_path += _convert_path_to_asset_file(path, input_type, controller)
base_path += _convert_path_to_asset_file(path, input_type, controller, forced_controller_icon_style)
paths.push_back(base_path + "." + _base_extension)
return paths
func _convert_path_to_asset_file(path: String, input_type: int, controller: int) -> String:
func _convert_path_to_asset_file(path: String, input_type: int, controller: int, forced_controller_icon_style = ControllerSettings.Devices.NONE) -> String:
match get_path_type(path):
PathType.INPUT_ACTION:
var event := get_matching_event(path, input_type, controller)
if event:
return _convert_event_to_path(event)
return _convert_event_to_path(event, controller, forced_controller_icon_style)
return path
PathType.JOYPAD_PATH:
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback)
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback, forced_controller_icon_style)
PathType.SPECIFIC_PATH, _:
return path
@@ -372,7 +378,7 @@ func _convert_asset_file_to_tts(path: String) -> String:
_:
return path
func _convert_event_to_path(event: InputEvent):
func _convert_event_to_path(event: InputEvent, controller: int = _last_controller, forced_controller_icon_style = ControllerSettings.Devices.NONE):
if event is InputEventKey:
# If this is a physical key, convert to localized scancode
if event.keycode == 0:
@@ -381,9 +387,9 @@ func _convert_event_to_path(event: InputEvent):
elif event is InputEventMouseButton:
return _convert_mouse_button_to_path(event.button_index)
elif event is InputEventJoypadButton:
return _convert_joypad_button_to_path(event.button_index, event.device)
return _convert_joypad_button_to_path(event.button_index, controller, forced_controller_icon_style)
elif event is InputEventJoypadMotion:
return _convert_joypad_motion_to_path(event.axis, event.device)
return _convert_joypad_motion_to_path(event.axis, controller, forced_controller_icon_style)
func _convert_key_to_path(scancode: int):
match scancode:
@@ -615,7 +621,7 @@ func _convert_mouse_button_to_path(button_index: int):
_:
return "mouse/sample"
func _convert_joypad_button_to_path(button_index: int, controller: int):
func _convert_joypad_button_to_path(button_index: int, controller: int, forced_controller_icon_style = ControllerSettings.Devices.NONE):
var path
match button_index:
JOY_BUTTON_A:
@@ -652,9 +658,9 @@ func _convert_joypad_button_to_path(button_index: int, controller: int):
path = "joypad/share"
_:
return ""
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback)
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback, forced_controller_icon_style)
func _convert_joypad_motion_to_path(axis: int, controller: int):
func _convert_joypad_motion_to_path(axis: int, controller: int, forced_controller_icon_style = ControllerSettings.Devices.NONE):
var path : String
match axis:
JOY_AXIS_LEFT_X, JOY_AXIS_LEFT_Y:
@@ -667,7 +673,7 @@ func _convert_joypad_motion_to_path(axis: int, controller: int):
path = "joypad/rt"
_:
return ""
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback)
return Mapper._convert_joypad_path(path, controller, _settings.joypad_fallback, forced_controller_icon_style)
func _load_icon(path: String) -> int:
if _cached_icons.has(path): return OK

View File

@@ -1 +1 @@
uid://cxxl7e1hu587n
uid://b06g4dpg627b5

View File

@@ -3,6 +3,7 @@ extends Resource
class_name ControllerSettings
enum Devices {
NONE = -1,
LUNA,
OUYA,
PS3,

View File

@@ -0,0 +1 @@
uid://bih8ls5msy63l

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Ricardo Subtil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,8 +1,8 @@
extends Node
extends RefCounted
class_name ControllerMapper
func _convert_joypad_path(path: String, device: int, fallback: ControllerSettings.Devices) -> String:
match _get_joypad_type(device, fallback):
func _convert_joypad_path(path: String, device: int, fallback: ControllerSettings.Devices, force_controller_icon_style = ControllerSettings.Devices.NONE) -> String:
match _get_joypad_type(device, fallback, force_controller_icon_style):
ControllerSettings.Devices.LUNA:
return _convert_joypad_to_luna(path)
ControllerSettings.Devices.PS3:
@@ -32,7 +32,9 @@ func _convert_joypad_path(path: String, device: int, fallback: ControllerSetting
_:
return ""
func _get_joypad_type(device, fallback):
func _get_joypad_type(device, fallback, force_controller_icon_style):
if force_controller_icon_style != ControllerSettings.Devices.NONE:
return force_controller_icon_style
var available = Input.get_connected_joypads()
if available.is_empty():
return fallback
@@ -264,7 +266,7 @@ func _convert_joypad_to_steamdeck(path: String):
"rt":
return path.replace("/rt", "/r2")
"select":
return path.replace("/select", "/square")
return path.replace("/select", "/inventory")
"start":
return path.replace("/start", "/menu")
"home":

View File

@@ -1 +1 @@
uid://dtgqdoflwmo0b
uid://5wx82aghglqr

View File

@@ -1 +0,0 @@
uid://dygveqy02jjgx

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ds5yo8kn81uem"
path="res://.godot/imported/inventory.png-2e96b194d1562d723597b2d307313c1b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/controller_icons/assets/steamdeck/inventory.png"
dest_files=["res://.godot/imported/inventory.png-2e96b194d1562d723597b2d307313c1b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1 +1 @@
uid://lm0qpml4w2mx
uid://jcpjcl10iatx

View File

@@ -1 +1 @@
uid://dkn6l8tlu56d8
uid://xp37xj8kduow

View File

@@ -1 +1 @@
uid://sg5ntoaywgfd
uid://r1qngdbv7gh4

View File

@@ -1 +1 @@
uid://125nay2twqlr
uid://bsynmd02318ph

View File

@@ -1 +1 @@
uid://d1hrxvtfr4t5w
uid://da3havxu352nb

View File

@@ -50,7 +50,7 @@ class_name ControllerIconTexture
## # res://addons/controller_icons/assets/steam/gyro.png
## path = "steam/gyro"
## [/codeblock]
@export var path : String = "":
@export var path: String = "":
set(_path):
path = _path
_load_texture_path()
@@ -63,15 +63,29 @@ enum ShowMode {
## Show the icon only if a specific input method is being used. When hidden,
## the icon will not occupy have any space (no width and height).
@export var show_mode : ShowMode = ShowMode.ANY:
@export var show_mode: ShowMode = ShowMode.ANY:
set(_show_mode):
show_mode = _show_mode
_load_texture_path()
## Forces the icon to show a specific controller style, regardless of the
## currently used controller type.
##[br][br]
## This will override force_device if set to a value other than NONE.
##[br][br]
## This is only relevant for paths using input actions, and has no effect on
## other scenarios.
@export var force_controller_icon_style: ControllerSettings.Devices = ControllerSettings.Devices.NONE:
set(_force_controller_icon_style):
force_controller_icon_style = _force_controller_icon_style
_load_texture_path()
enum ForceType {
NONE, ## Icon will swap according to the used input method.
KEYBOARD_MOUSE, ## Icon will always show the keyboard/mouse action.
CONTROLLER, ## Icon will always show the controller action.
CONTROLLER, ## Icon will always show the controller action.
}
## Forces the icon to show either the keyboard/mouse or controller icon,
@@ -79,14 +93,42 @@ enum ForceType {
##[br][br]
## This is only relevant for paths using input actions, and has no effect on
## other scenarios.
@export var force_type : ForceType = ForceType.NONE:
@export var force_type: ForceType = ForceType.NONE:
set(_force_type):
force_type = _force_type
_load_texture_path()
enum ForceDevice {
DEVICE_0,
DEVICE_1,
DEVICE_2,
DEVICE_3,
DEVICE_4,
DEVICE_5,
DEVICE_6,
DEVICE_7,
DEVICE_8,
DEVICE_9,
DEVICE_10,
DEVICE_11,
DEVICE_12,
DEVICE_13,
DEVICE_14,
DEVICE_15,
ANY # No device will be forced
}
## Forces the icon to use the textures for the device connected at the specified index.
## For example, if a PlayStation 5 controller is connected at device_index 0,
## the icon will always show PlayStation 5 textures.
@export var force_device: ForceDevice = ForceDevice.ANY:
set(_force_device):
force_device = _force_device
_load_texture_path()
@export_subgroup("Text Rendering")
## Custom LabelSettings. If set, overrides the addon's global label settings.
@export var custom_label_settings : LabelSettings:
@export var custom_label_settings: LabelSettings:
set(_custom_label_settings):
custom_label_settings = _custom_label_settings
_load_texture_path()
@@ -117,7 +159,7 @@ func _can_be_shown():
0, _:
return true
var _textures : Array[Texture2D]:
var _textures: Array[Texture2D]:
set(__textures):
# UPGRADE: In Godot 4.2, for-loop variables can be
# statically typed:
@@ -147,9 +189,9 @@ var _textures : Array[Texture2D]:
if tex:
tex.connect("changed", _reload_resource)
var _font : Font
var _label_settings : LabelSettings
var _text_size : Vector2
var _font: Font
var _label_settings: LabelSettings
var _text_size: Vector2
func _on_label_settings_changed():
_font = ThemeDB.fallback_font if not _label_settings.font else _label_settings.font
@@ -161,13 +203,14 @@ func _reload_resource():
emit_changed()
func _load_texture_path_impl():
var textures : Array[Texture2D] = []
var textures: Array[Texture2D] = []
if ControllerIcons.is_node_ready() and _can_be_shown():
var input_type = ControllerIcons._last_input_type if force_type == ForceType.NONE else force_type - 1
if ControllerIcons.get_path_type(path) == ControllerIcons.PathType.INPUT_ACTION:
var event := ControllerIcons.get_matching_event(path, input_type)
textures.append_array(ControllerIcons.parse_event_modifiers(event))
var tex := ControllerIcons.parse_path(path, input_type)
var target_device = force_device if force_device != ForceDevice.ANY else ControllerIcons._last_controller
var tex := ControllerIcons.parse_path(path, input_type, target_device, force_controller_icon_style)
if tex:
textures.append(tex)
_textures = textures
@@ -200,7 +243,7 @@ func _get_width() -> int:
return accum
, 0)
if _label_settings:
ret += max(0, _textures.size()-1) * _text_size.x
ret += max(0, _textures.size() - 1) * _text_size.x
# If ret is 0, return a size of 2 to prevent triggering engine checks
# for null sizes. The correct size will be set at a later frame.
return ret if ret > 0 else _NULL_SIZE
@@ -235,7 +278,7 @@ func _draw(to_canvas_item: RID, pos: Vector2, modulate: Color, transpose: bool):
var position := pos
for i in range(_textures.size()):
var tex:Texture2D = _textures[i]
var tex: Texture2D = _textures[i]
if !tex: continue
if i != 0:
@@ -256,7 +299,7 @@ func _draw_rect(to_canvas_item: RID, rect: Rect2, tile: bool, modulate: Color, t
var height_ratio := rect.size.y / _get_height()
for i in range(_textures.size()):
var tex:Texture2D = _textures[i]
var tex: Texture2D = _textures[i]
if !tex: continue
if i != 0:
@@ -278,7 +321,7 @@ func _draw_rect_region(to_canvas_item: RID, rect: Rect2, src_rect: Rect2, modula
var height_ratio := rect.size.y / _get_height()
for i in range(_textures.size()):
var tex:Texture2D = _textures[i]
var tex: Texture2D = _textures[i]
if !tex: continue
if i != 0:
@@ -314,15 +357,15 @@ func _draw_text(to_canvas_item: RID, font_position: Vector2, text: String):
_font.draw_string_outline(to_canvas_item, font_position, text, HORIZONTAL_ALIGNMENT_LEFT, -1, _label_settings.font_size, _label_settings.outline_size, _label_settings.outline_color)
_font.draw_string(to_canvas_item, font_position, text, HORIZONTAL_ALIGNMENT_CENTER, -1, _label_settings.font_size, _label_settings.font_color)
var _helper_viewport : Viewport
var _is_stitching_texture : bool = false
var _helper_viewport: Viewport
var _is_stitching_texture: bool = false
func _stitch_texture():
if _textures.is_empty():
return
_is_stitching_texture = true
var font_image : Image
var font_image: Image
if _textures.size() > 1:
# Generate a viewport to draw the text
_helper_viewport = SubViewport.new()
@@ -345,7 +388,7 @@ func _stitch_texture():
_helper_viewport.free()
var position := Vector2i(0, 0)
var img : Image
var img: Image
for i in range(_textures.size()):
if !_textures[i]: continue
@@ -375,7 +418,7 @@ func _stitch_texture():
# This is necessary for 3D sprites, as the texture is assigned to a material, and not drawn directly.
# For multi prompts, we need to generate a texture
var _dirty := true
var _texture_3d : Texture
var _texture_3d: Texture
func _get_rid():
if _dirty:
if not _is_stitching_texture:

View File

@@ -1 +1 @@
uid://ddxpo5u73ssi2
uid://cxab4gf8nejc2

View File

@@ -1 +1 @@
uid://k2tud3diool
uid://dlwwg6hbxcg6r

View File

@@ -1 +1 @@
uid://bpos4yaigyeqr
uid://dns2c4458ekvc

View File

@@ -1 +1 @@
uid://dmp4w4ojx7klt
uid://cispm18xp24wt

View File

@@ -1 +1 @@
uid://bu8t48xqekc8o
uid://c6lqhrewwbp61

View File

@@ -1 +1 @@
uid://da1ors8v36hv3
uid://texv8inbqrdh

View File

@@ -1 +1 @@
uid://dt82cmmp3uy7l
uid://wnl1k7337x2u

View File

@@ -3,5 +3,5 @@
name="Controller Icons"
description="Provides icons for all major controllers and keyboard, with automatic icon remapping."
author="rsubtil"
version="3.1.4"
version="3.1.5"
script="plugin.gd"

View File

@@ -1 +1 @@
uid://cajvrhetudhyg
uid://xvjobdx0h3gi

View File

@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="ControllerSettings" load_steps=2 format=3 uid="uid://dolsrvh5w47et"]
[ext_resource type="Script" path="res://addons/controller_icons/Settings.gd" id="1"]
[ext_resource type="Script" path="res://addons/controller_icons/ControllerSettings.gd" id="1"]
[resource]
script = ExtResource("1")

View File

@@ -1,186 +1,10 @@
[gd_resource type="Resource" script_class="DialogData" load_steps=73 format=3 uid="uid://dxkjjrap15vxu"]
[gd_resource type="Resource" script_class="DialogData" load_steps=8 format=3 uid="uid://dxkjjrap15vxu"]
[ext_resource type="Script" uid="uid://bw2q2eucjkylk" path="res://addons/madtalk/components/resources/DialogData.gd" id="1_giduu"]
[ext_resource type="Script" uid="uid://c2bv5lwcvdmrb" path="res://addons/madtalk/components/resources/DialogNodeItemData.gd" id="2_48vp3"]
[ext_resource type="Script" uid="uid://bfg2ff7c0tanh" path="res://addons/madtalk/components/resources/DialogNodeOptionData.gd" id="3_dways"]
[ext_resource type="Script" uid="uid://b2mrnotqjr75d" path="res://addons/madtalk/components/resources/DialogNodeData.gd" id="4_f2ijm"]
[ext_resource type="Script" uid="uid://butd1fwy4a2hn" path="res://addons/madtalk/components/resources/DialogSheetData.gd" id="5_vkpn8"]
[sub_resource type="Resource" id="1"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = "foo"
message_speaker_variant = ""
message_voice_clip = ""
message_text = "This is an example sheet. You can rename and use it, or discard and create your own."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="4"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Would you like to see more dialog messages?"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 1
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="5"]
script = ExtResource("3_dways")
text = "Yes"
text_locales = {}
connected_to_id = 8
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="6"]
script = ExtResource("3_dways")
text = "No"
text_locales = {}
connected_to_id = -1
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="2"]
script = ExtResource("4_f2ijm")
sequence_id = 0
position = Vector2(-20, 120)
comment = ""
items = [SubResource("1"), SubResource("4")]
options = [SubResource("5"), SubResource("6")]
continue_sequence_id = -1
continue_port_index = -1
[sub_resource type="Resource" id="v4udn"]
script = ExtResource("2_48vp3")
item_type = 2
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = ""
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 1
effect_values = ["my_var", 5.0]
[sub_resource type="Resource" id="Resource_jrxya"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "my_var was set to: <<my_var>>
{{if my_var < 4: Since it's less than 4, you see this message.}}
{{if my_var < 6: Since it's less than 6, you see this message.}}"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_ixt6j"]
script = ExtResource("4_f2ijm")
sequence_id = 6
position = Vector2(920, 120)
comment = ""
items = [SubResource("v4udn"), SubResource("Resource_jrxya")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="7"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = "bar"
message_speaker_variant = ""
message_voice_clip = ""
message_text = "The speaker IDs are \"foo\" and \"bar\", but the display names are \"Maria\" and \"Francesco\"."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="8"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = "bar"
message_speaker_variant = ""
message_voice_clip = ""
message_text = "This is so you can have fancy nice looking display names, but you don't have to type them all the time in the system."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="9"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "A blank speaker ID is valid. If there are no characters with blank ID, it's treated as empty name."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="Resource_j2kw6"]
script = ExtResource("4_f2ijm")
sequence_id = 8
position = Vector2(460, 60)
comment = ""
items = [SubResource("7"), SubResource("8"), SubResource("9")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="3"]
script = ExtResource("5_vkpn8")
sheet_id = "1_start_here"
sheet_description = "Demonstration sheet. You can delete this in your game, or repurpose it."
next_sequence_id = 9
nodes = [SubResource("2"), SubResource("Resource_ixt6j"), SubResource("Resource_j2kw6")]
[sub_resource type="Resource" id="Resource_vx7w3"]
script = ExtResource("2_48vp3")
item_type = 0
@@ -188,7 +12,7 @@ connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "This example demonstrates the bare minimum nodes you need for the dialog to work."
message_text = "Example this is [input action=down][/input] a down input."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
@@ -214,699 +38,9 @@ sheet_description = ""
next_sequence_id = 2
nodes = [SubResource("Resource_duvjw")]
[sub_resource type="Resource" id="12"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "If you do not assign a node to Dialog Button Container (dialog_buttons_container), automatic menu will not be enabled.
In this case, if you want menu options, you have to process the menu externally.
(You can, however, have dialogs without menus: simply never use menu options.)"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="13"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "If you [b][i]do[/i][/b] use menu options in the dialog sheet, and do not assign a node for automatic menus and also do not handle the menu externally, then menus will not work (attempting to show menu options will cause the dialog to get stuck)."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="16"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Processing the menu externally is easy:
When the dialog reaches a menu, the [color=#99ff00][b]external_menu_requested([color=#ff9955]options, metadata[/color])[/b][/color] signal is called, where [color=#ff9955][b]options[/b][/color] is an Array with the menu options, and [color=#ff9955][b]metadata[/b][/color] is an Array of Dictionaries.
Each item has a [color=#99ffff][b]text[/b][/color] property containing the text for that option, from the dialog sheet.
So [b][color=#ff9955]options[[color=#ffff00]0[/color]][/color].[color=#99ffff]text[/color][/b] is the text for first option, and [b][color=#ff9955]metadata[lb][color=#ffff00]0[/color][rb][lb][color=#ffff99]\"enabled\"[/color][rb][/color][/b] is the bool indicating if that option is enabled, etc."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="17"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "The menu will then pause and wait for your code to select one of the options from that array.
You take the input from the player in any way you like, and then select an option by calling the method [b][color=#9999ff]select_menu_option( [color=#ffff00]index[/color] )[/color][/b] where the argument is the index of the desired option from the [color=#ff9955][b]options[/b][/color] array.
Selecting an invalid index is simply ignored."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="18"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Using external menus, the option text can be used as IDs, as CSV lines packing several fields, or any other purpose you like, since building the menu is up to you.
This way you can have more control and flexibility, while still having all the dialog managed by MadTalk."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="14"]
script = ExtResource("4_f2ijm")
sequence_id = 0
position = Vector2(0, 0)
comment = ""
items = [SubResource("12"), SubResource("13"), SubResource("16"), SubResource("17"), SubResource("18")]
options = []
continue_sequence_id = 1
continue_port_index = 0
[sub_resource type="Resource" id="19"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Please select an option with double click."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 1
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="20"]
script = ExtResource("3_dways")
text = "red,PokaTola"
text_locales = {}
connected_to_id = 2
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="21"]
script = ExtResource("3_dways")
text = "red,PokaTola Diet"
text_locales = {}
connected_to_id = 3
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="22"]
script = ExtResource("3_dways")
text = "blue,Zepsi"
text_locales = {}
connected_to_id = 4
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="23"]
script = ExtResource("3_dways")
text = "blue,Zepsi Zero"
text_locales = {}
connected_to_id = 5
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="25"]
script = ExtResource("3_dways")
text = "green,Buaraná Ankartida"
text_locales = {}
connected_to_id = 6
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="26"]
script = ExtResource("3_dways")
text = "yellow,Strike"
text_locales = {}
connected_to_id = 7
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="24"]
script = ExtResource("4_f2ijm")
sequence_id = 1
position = Vector2(600, 40)
comment = ""
items = [SubResource("19")]
options = [SubResource("20"), SubResource("21"), SubResource("22"), SubResource("23"), SubResource("25"), SubResource("26")]
continue_sequence_id = -1
continue_port_index = -1
[sub_resource type="Resource" id="27"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You have selected the normal PokaTola"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="28"]
script = ExtResource("4_f2ijm")
sequence_id = 2
position = Vector2(1280, -320)
comment = ""
items = [SubResource("27")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="29"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You have selected the Diet PokaTola"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="30"]
script = ExtResource("4_f2ijm")
sequence_id = 3
position = Vector2(1280, -120)
comment = ""
items = [SubResource("29")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="31"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You have selecteed the normal Zepsi"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="32"]
script = ExtResource("4_f2ijm")
sequence_id = 4
position = Vector2(1280, 80)
comment = ""
items = [SubResource("31")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="33"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You have selected the Diet Zepsi"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="34"]
script = ExtResource("4_f2ijm")
sequence_id = 5
position = Vector2(1280, 280)
comment = ""
items = [SubResource("33")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="35"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Good choice! You have selected the Buaraná Ankartida"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="36"]
script = ExtResource("4_f2ijm")
sequence_id = 6
position = Vector2(1280, 480)
comment = ""
items = [SubResource("35")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="37"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You have selected the Strike"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 0
condition_values = []
effect_type = 0
effect_values = []
[sub_resource type="Resource" id="38"]
script = ExtResource("4_f2ijm")
sequence_id = 7
position = Vector2(1280, 680)
comment = ""
items = [SubResource("37")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="15"]
script = ExtResource("5_vkpn8")
sheet_id = "external_menu"
sheet_description = ""
next_sequence_id = 8
nodes = [SubResource("14"), SubResource("24"), SubResource("28"), SubResource("30"), SubResource("32"), SubResource("34"), SubResource("36"), SubResource("38")]
[sub_resource type="Resource" id="Resource_rlxbw"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Hello! Welcome to the localized example!
Warning: the next message will play an audio clip."
message_voice_clip_locales = {}
message_text_locales = {
"es": "¡Hola! ¡Bienvenido al ejemplo localizado!
Advertencia: el siguiente mensaje reproducirá un clip de audio.",
"pt": "Olá! Seja bem vindo ao teste localizado!
Aviso: a próxima mensagem reproduzirá um clipe de áudio."
}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_quvr4"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = "res://example_scene/voices/example_localized_en.ogg"
message_text = "You are now seeing messages in English, because either this is your system language, or because your language is not included in this test."
message_voice_clip_locales = {
"es": "res://example_scene/voices/example_localized_es.ogg",
"pt": "res://example_scene/voices/example_localized_pt.ogg"
}
message_text_locales = {
"es": "Ahora estás viendo los mensajes en español, porque este es el idioma de tu sistema.",
"pt": "Você está agora vendo mensagens em Português, porque esse é o idioma do seu sistema."
}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_w6lj3"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "Thank you for playing this test!"
message_voice_clip_locales = {}
message_text_locales = {
"es": "¡Gracias por jugar esta prueba!",
"pt": "Obrigado por jogar esse teste!"
}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_dlpdt"]
script = ExtResource("3_dways")
text = "First option"
text_locales = {
"": "First option",
"es": "Primera opción",
"pt": "Primeira opção"
}
connected_to_id = -1
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_x0nqb"]
script = ExtResource("3_dways")
text = "Second option"
text_locales = {
"": "Second option",
"es": "Segunda opción",
"pt": "Segunda opção"
}
connected_to_id = -1
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_ml5yl"]
script = ExtResource("4_f2ijm")
sequence_id = 0
position = Vector2(0, 0)
comment = ""
items = [SubResource("Resource_rlxbw"), SubResource("Resource_quvr4"), SubResource("Resource_w6lj3")]
options = [SubResource("Resource_dlpdt"), SubResource("Resource_x0nqb")]
continue_sequence_id = -1
continue_port_index = -1
[sub_resource type="Resource" id="Resource_cvf4j"]
script = ExtResource("5_vkpn8")
sheet_id = "localized"
sheet_description = ""
next_sequence_id = 2
nodes = [SubResource("Resource_ml5yl")]
[sub_resource type="Resource" id="Resource_gfy7a"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You will now be presented with menu options."
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_5plx1"]
script = ExtResource("3_dways")
text = "Option 1"
text_locales = {
"": "Option 1"
}
connected_to_id = 1
is_conditional = true
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_4ierx"]
script = ExtResource("3_dways")
text = "Second option"
text_locales = {
"": "Second option"
}
connected_to_id = 2
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_c0esp"]
script = ExtResource("3_dways")
text = "Another cool option"
text_locales = {
"": "Another cool option"
}
connected_to_id = 3
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_28bfi"]
script = ExtResource("4_f2ijm")
sequence_id = 0
position = Vector2(40, 20)
comment = ""
items = [SubResource("Resource_gfy7a")]
options = [SubResource("Resource_5plx1"), SubResource("Resource_4ierx"), SubResource("Resource_c0esp")]
continue_sequence_id = -1
continue_port_index = -1
[sub_resource type="Resource" id="Resource_dyln1"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You selected option 1"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_v4udn"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "This option also has another menu. Select your option:"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_kur6e"]
script = ExtResource("3_dways")
text = "Yes"
text_locales = {
"": "Yes"
}
connected_to_id = 0
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_gi4cx"]
script = ExtResource("3_dways")
text = "Uh... no?"
text_locales = {
"": "Uh... no?"
}
connected_to_id = -1
is_conditional = false
condition_variable = ""
condition_operator = "="
condition_value = ""
autodisable_mode = 0
inactive_mode = 0
[sub_resource type="Resource" id="Resource_wn6qm"]
script = ExtResource("4_f2ijm")
sequence_id = 1
position = Vector2(60, -320)
comment = ""
items = [SubResource("Resource_dyln1"), SubResource("Resource_v4udn")]
options = [SubResource("Resource_kur6e"), SubResource("Resource_gi4cx")]
continue_sequence_id = -1
continue_port_index = -1
[sub_resource type="Resource" id="Resource_qsky1"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You selected the second option"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_5vhe7"]
script = ExtResource("4_f2ijm")
sequence_id = 2
position = Vector2(640, 120)
comment = ""
items = [SubResource("Resource_qsky1")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="Resource_xshh7"]
script = ExtResource("2_48vp3")
item_type = 0
connected_to_id = -1
message_speaker_id = ""
message_speaker_variant = ""
message_voice_clip = ""
message_text = "You selected the cool option"
message_voice_clip_locales = {}
message_text_locales = {}
message_hide_on_end = 0
condition_type = 10
condition_values = []
effect_type = 10
effect_values = []
[sub_resource type="Resource" id="Resource_pnwrx"]
script = ExtResource("4_f2ijm")
sequence_id = 3
position = Vector2(640, 340)
comment = ""
items = [SubResource("Resource_xshh7")]
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="Resource_s3y14"]
script = ExtResource("5_vkpn8")
sheet_id = "minimum_menu"
sheet_description = ""
next_sequence_id = 4
nodes = [SubResource("Resource_28bfi"), SubResource("Resource_wn6qm"), SubResource("Resource_5vhe7"), SubResource("Resource_pnwrx")]
[sub_resource type="Resource" id="kur6e"]
script = ExtResource("4_f2ijm")
sequence_id = 0
position = Vector2(0, 0)
comment = ""
items = []
options = []
continue_sequence_id = -1
continue_port_index = 0
[sub_resource type="Resource" id="Resource_mjnvi"]
script = ExtResource("5_vkpn8")
sheet_id = "new_sheet_1"
sheet_description = ""
next_sequence_id = 1
nodes = [SubResource("kur6e")]
[resource]
script = ExtResource("1_giduu")
version = 1.0
sheets = {
"1_start_here": SubResource("3"),
"bare_minimum": SubResource("Resource_sxgqo"),
"external_menu": SubResource("15"),
"localized": SubResource("Resource_cvf4j"),
"minimum_menu": SubResource("Resource_s3y14"),
"new_sheet_1": SubResource("Resource_mjnvi")
"bare_minimum": SubResource("Resource_sxgqo")
}

12
map/TestMap.gd Normal file
View File

@@ -0,0 +1,12 @@
extends Node3D
func _ready():
UI.MADTALK.start_dialog("bare_minimum")
func _input(event):
if (
(event is InputEventKey) and (event.pressed) and (not event.echo) and (event.keycode in [KEY_SPACE, KEY_ENTER, KEY_KP_ENTER])
) or (
(event is InputEventMouseButton) and (event.pressed) and (event.button_index == MOUSE_BUTTON_LEFT)
):
UI.MADTALK.dialog_acknowledge()

1
map/TestMap.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://xe6pcuq741xi

View File

@@ -1,10 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://d0ywgijpuqy0r"]
[gd_scene load_steps=5 format=3 uid="uid://d0ywgijpuqy0r"]
[ext_resource type="Script" uid="uid://xe6pcuq741xi" path="res://map/TestMap.gd" id="1_6ms5s"]
[ext_resource type="PackedScene" uid="uid://cluuhtfjeodwb" path="res://map/TestMapBase.tscn" id="1_ox0si"]
[ext_resource type="PackedScene" uid="uid://2ch34sio36nv" path="res://entity/player/Player.tscn" id="2_0d2qr"]
[ext_resource type="PackedScene" uid="uid://kabs7mopalmo" path="res://entity/npc/NPC.tscn" id="3_0vfw4"]
[node name="TestMap" type="Node3D"]
script = ExtResource("1_6ms5s")
[node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")]

View File

@@ -25,6 +25,7 @@ QUEST="*res://singleton/Quest.tscn"
OVERWORLD="*res://singleton/Overworld.gd"
SCENE="*res://singleton/Scene.gd"
MadTalkGlobals="*res://addons/madtalk/runtime/MadTalkGlobals.tscn"
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
[debug]

View File

@@ -1,4 +1,5 @@
class_name UISingleton extends Control
@export var TEXTBOX: VNTextbox
@export var PAUSE: PauseMenu
@export var PAUSE: PauseMenu
@onready var MADTALK:Node = $VNTextbox/MadTalk;

View File

@@ -16,9 +16,7 @@ TEXTBOX = NodePath("VNTextbox")
PAUSE = NodePath("PauseMenu")
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
visible = false
layout_mode = 1
[node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")]
visible = false
layout_mode = 1

View File

@@ -1,44 +0,0 @@
@tool
class_name AdvancedRichText extends RichTextLabel
@export_multiline var advancedText:String = "":
get():
return advancedText
set(value):
advancedText = value
_parseAdvancedText()
@export var translate:bool = true:
set(value):
translate = value
_parseAdvancedText()
get():
return translate
func _init() -> void:
self._parseAdvancedText()
func _enter_tree() -> void:
self._parseAdvancedText()
func _parseAdvancedText() -> void:
if advancedText.is_empty():
self.text = ""
return
var key = advancedText
if self.translate:
key = tr(key)
self.text = processInputTags(key)
func processInputTags(_text:String) -> String:
var regex = RegEx.new()
regex.compile(r"\[input action=(.*?)\](.*?)\[/input\]")
var result = text
for match in regex.search_all(text):
var action = match.get_string(1).to_lower()
var height:int = 32
# var device = get_current_device_type()
# var icon_path = get_icon_for_action(action, device)
var img_tag = "[img height=%d valign=center,center]res://textures/input/%s.tres[/img]" % [ height, action ]
result = result.replace(match.get_string(0), img_tag)
return result

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://bkx3l0kckf4a8"]
[gd_scene load_steps=5 format=3 uid="uid://bkx3l0kckf4a8"]
[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://ui/UI Theme.tres" id="1_wx4lp"]
[ext_resource type="Script" uid="uid://h8lw23ypcfty" path="res://ui/component/VNTextbox.gd" id="2_uo1gm"]
[ext_resource type="Script" uid="uid://bjj6upgk1uvxd" path="res://ui/component/AdvancedRichText.gd" id="3_m60k3"]
[ext_resource type="Script" uid="uid://c6av3xe4m2ujl" path="res://addons/madtalk/runtime/madtalk_runtime.gd" id="3_2x6s1"]
[ext_resource type="Script" uid="uid://bjj6upgk1uvxd" path="res://ui/component/advancedrichtext/AdvancedRichText.gd" id="3_m60k3"]
[node name="VNTextbox" type="PanelContainer"]
anchors_preset = 12
@@ -15,6 +16,12 @@ grow_vertical = 0
theme = ExtResource("1_wx4lp")
script = ExtResource("2_uo1gm")
[node name="MadTalk" type="Node" parent="."]
script = ExtResource("3_2x6s1")
DialogMainControl = NodePath("..")
DialogMessageBox = NodePath("../MarginContainer")
DialogMessageLabel = NodePath("../MarginContainer/Label")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme = ExtResource("1_wx4lp")
@@ -27,12 +34,8 @@ theme_override_constants/margin_bottom = 4
layout_mode = 2
theme = ExtResource("1_wx4lp")
bbcode_enabled = true
text = "TEST
TEST
TEST
TEST"
text = "To get through tight spaces, press[input action=down][/input]"
fit_content = true
script = ExtResource("3_m60k3")
advancedText = "TEST
TEST
TEST
TEST"
userText = "To get through tight spaces, press[input action=down][/input]"
finalText = "To get through tight spaces, press[img height=12 valign=center,center]res://ui/input/down.tres[/img]"

View File

@@ -0,0 +1,104 @@
@tool
class_name AdvancedRichText extends RichTextLabel
@export_multiline var userText:String = "" # The text the user is asking for
@export_multiline var finalText:String = "" # The final text after processing (translation, wrapping, etc.)
# Hides the original RichTextLabel text property
func _set(property: StringName, value) -> bool:
if property == "text":
userText = value
_recalcText()
return true
elif property == "richtextlabel_text":
text = value
return true
return false
func _get(property: StringName):
if property == "text":
return userText
elif property == "richtextlabel_text":
return text
return null
@export var translate:bool = true:
set(value):
translate = value
_recalcText()
get():
return translate
@export var smartWrap:bool = true:
set(value):
smartWrap = value
_recalcText()
get():
return smartWrap
func _init() -> void:
_recalcText()
func _enter_tree() -> void:
_recalcText()
self.resized.connect(_recalcText)
func _exit_tree() -> void:
self.resized.disconnect(_recalcText)
func _recalcText() -> void:
if userText.is_empty():
self.richtextlabel_text = ""
return
# Translate if needed
var textTranslated = userText
if self.translate:
textTranslated = tr(textTranslated)
# Replace input bb tags.
var regex = RegEx.new()
regex.compile(r"\[input action=(.*?)\](.*?)\[/input\]")
var inputIconText = textTranslated
for match in regex.search_all(textTranslated):
var action = match.get_string(1).to_lower()
var height:int = get_theme_font_size("normal_font_size")
# var device = get_current_device_type()
# var icon_path = get_icon_for_action(action, device)
var img_tag = "[img height=%d valign=center,center]res://ui/input/%s.tres[/img]" % [ height, action ]
inputIconText = inputIconText.replace(match.get_string(0), img_tag)
# Perform smart wrapping
var wrappedText = inputIconText
if smartWrap:
var unwrappedText = wrappedText.strip_edges()
self.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART;
self.richtextlabel_text = unwrappedText
self.visible_characters = -1;
self.fit_content = true;
var newlineIndexes = [];
# Determine where the wrapped newlines are
var line = 0;
var wasNewLine = false;
for i in range(0, unwrappedText.length()):
var tLine = self.get_character_line(i);
if tLine == line || tLine == -1:
wasNewLine = false
if unwrappedText[i] == "\n":
wasNewLine = true
continue;
if !wasNewLine:
newlineIndexes.append(i);
line = tLine;
# Create fake pre-wrapped text.
wrappedText = "";
for i in range(0, unwrappedText.length()):
if newlineIndexes.find(i) != -1 and i != 0:
wrappedText += "\n";
wrappedText += unwrappedText[i];
finalText = wrappedText
self.richtextlabel_text = wrappedText

View File

@@ -1,6 +1,6 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://vb20551utmet"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_iw3l5"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_iw3l5"]
[resource]
resource_local_to_scene = false
@@ -8,5 +8,6 @@ resource_name = ""
script = ExtResource("1_iw3l5")
path = "debug"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,12 +1,13 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://cyfh2wyhh1cjg"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_p6b3a"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_p6b3a"]
[resource]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("1_p6b3a")
path = "down"
path = "move_back"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,12 +1,13 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://b3ii1cu3mc7jc"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_ngf5d"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_ngf5d"]
[resource]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("1_ngf5d")
path = "up"
path = "interact"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,12 +1,13 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://thb0gnik8oo3"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_fijpq"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_fijpq"]
[resource]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("1_fijpq")
path = "left"
path = "move_left"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,6 +1,6 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://byijoyarhygot"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_o0qtj"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_o0qtj"]
[resource]
resource_local_to_scene = false
@@ -8,5 +8,6 @@ resource_name = ""
script = ExtResource("1_o0qtj")
path = "pause"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,12 +1,13 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://dajlk4u1q8rsp"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_guxqd"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_guxqd"]
[resource]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("1_guxqd")
path = "right"
path = "move_right"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16

View File

@@ -1,12 +1,13 @@
[gd_resource type="Texture2D" script_class="ControllerIconTexture" load_steps=2 format=3 uid="uid://blut4glc4n0ck"]
[ext_resource type="Script" uid="uid://ddxpo5u73ssi2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_y6k0e"]
[ext_resource type="Script" uid="uid://cxab4gf8nejc2" path="res://addons/controller_icons/objects/ControllerIconTexture.gd" id="1_y6k0e"]
[resource]
resource_local_to_scene = false
resource_name = ""
script = ExtResource("1_y6k0e")
path = "left"
path = "move_left"
show_mode = 0
force_controller_icon_style = -1
force_type = 0
metadata/_custom_type_script = "uid://ddxpo5u73ssi2"
force_device = 16