theme organization, bigger scroll container

This commit is contained in:
2025-09-06 05:54:08 +02:00
parent 8a7624e807
commit c4e15dcc2f
13 changed files with 129 additions and 306 deletions

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://v5lk1jcyag2q"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island/theme.tres" id="1_k44u5"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/theme.tres" id="1_k44u5"]
[node name="Button" type="Button"]
theme = ExtResource("1_k44u5")

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://nbnsf3pmh4jg"]
[ext_resource type="Script" uid="uid://cvhue8e0ory00" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/chooser/simple.gd" id="1"]
[ext_resource type="Theme" uid="uid://dvwfrnya2nhxu" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/theme.tres" id="2"]
[ext_resource type="Theme" uid="uid://dvwfrnya2nhxu" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/theme/dialog.tres" id="2"]
[sub_resource type="Gradient" id="1"]
colors = PackedColorArray(1, 0, 0, 1, 1, 0, 0, 1)
@@ -16,10 +16,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 313.0
offset_top = 191.0
offset_right = 313.0
offset_bottom = 191.0
offset_left = 258.0
offset_top = -5.0
offset_right = 258.0
offset_bottom = -5.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
@@ -40,6 +40,7 @@ theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer"]
custom_minimum_size = Vector2(0, 800)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ScrollContainer"]

View File

@@ -8,6 +8,5 @@ offset_left = 1057.0
offset_top = 533.0
offset_right = 1259.0
offset_bottom = 551.0
theme_override_fonts/font = ExtResource("1")
text = "Haz click para acelerar el texto"
script = ExtResource("2")

View File

@@ -1,7 +1,39 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dvwfrnya2nhxu"]
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dlo07cyfhpilq"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4wcyb"]
[sub_resource type="StyleBoxFlat" id="1"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.462745)
corner_radius_top_right = 5
corner_radius_bottom_right = 5
expand_margin_left = 19.0
[sub_resource type="StyleBoxFlat" id="2"]
bg_color = Color(0, 0, 0, 0.509804)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="3"]
bg_color = Color(0, 0, 0, 0.388235)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
expand_margin_left = 5.0
expand_margin_top = 5.0
expand_margin_right = 5.0
expand_margin_bottom = 5.0
[resource]
RichTextLabel/styles/fill = SubResource("StyleBoxFlat_4wcyb")
VBoxContainer/constants/separation = 1
Label/colors/font_color = Color(1, 1, 1, 1)
Label/colors/font_color_shadow = Color(0, 0, 0, 0)
Label/colors/font_outline_modulate = Color(1, 0, 0, 1)
Label/colors/label_box_bg = Color(0, 0, 0, 0.745098)
Label/styles/normal = SubResource("1")
RichTextLabel/font_sizes/font_size = 20
RichTextLabel/styles/focus = SubResource("2")
RichTextLabel/styles/normal = SubResource("3")

View File

@@ -0,0 +1,38 @@
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dvwfrnya2nhxu"]
[sub_resource type="StyleBoxFlat" id="1"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.462745)
corner_radius_top_right = 5
corner_radius_bottom_right = 5
expand_margin_left = 19.0
[sub_resource type="StyleBoxFlat" id="2"]
bg_color = Color(0, 0, 0, 0.509804)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="3"]
bg_color = Color(0, 0, 0, 0.388235)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
expand_margin_left = 5.0
expand_margin_top = 5.0
expand_margin_right = 5.0
expand_margin_bottom = 5.0
[resource]
Label/colors/font_color = Color(1, 1, 1, 1)
Label/colors/font_color_shadow = Color(0, 0, 0, 0)
Label/colors/font_outline_modulate = Color(1, 0, 0, 1)
Label/colors/label_box_bg = Color(0, 0, 0, 0.745098)
Label/styles/normal = SubResource("1")
RichTextLabel/styles/focus = SubResource("2")
RichTextLabel/styles/normal = SubResource("3")

View File

@@ -1,239 +0,0 @@
# A dialog GUI showing a dialog box and character portraits
extends Window
# Signal emitted when text has been said
signal say_finished
# Signal emitted when text has just become fully visible
signal say_visible
# The text speed per character for normal display
var _text_time_per_character: float
# The text speed per character if the dialog line is skipped
var _fast_text_time_per_character: float
# The reading speed to be used in determining the length of time text remains
# on the screen.
var _reading_speed_in_wpm: int
# Used to extract words from lines of text.
var _word_regex: RegEx = RegEx.new()
# Whether the current dialog is speeding up
var _is_speeding_up: bool = false
# The current line of text being displayed.
var _current_line: String
# The node holding the avatar
@onready var avatar_node = $Panel/MarginContainer/HSplitContainer/VBoxContainer\
/avatar
# The node showing the text
@onready var text_node = $Panel/MarginContainer/HSplitContainer/text
# The tween node for text animations
@onready var tween: Tween3 = Tween3.new(self)
# Whether the dialog manager is paused
@onready var is_paused: bool = true
# Build up the UI
func _ready():
_text_time_per_character = ProjectSettings.get_setting(
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS
)
if _text_time_per_character < 0:
escoria.logger.warn(
self,
"%s setting must be a non-negative number. Will use default value of %s." %
[
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
escoria.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
]
)
_text_time_per_character = escoria.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE
_fast_text_time_per_character = ProjectSettings.get_setting(
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST
)
if _fast_text_time_per_character < 0:
escoria.logger.warn(
self,
"%s setting must be a non-negative number. Will use default value of %s." %
[
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
escoria.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
]
)
_fast_text_time_per_character = escoria.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE
_reading_speed_in_wpm = ProjectSettings.get_setting(
RTMISimpleDialogSettings.READING_SPEED_IN_WPM
)
if _reading_speed_in_wpm <= 0:
escoria.logger.warn(
self,
"%s setting must be a positive number. Will use default value of %s." %
[
RTMISimpleDialogSettings.READING_SPEED_IN_WPM,
escoria.READING_SPEED_IN_WPM_DEFAULT_VALUE
]
)
_reading_speed_in_wpm = escoria.READING_SPEED_IN_WPM_DEFAULT_VALUE
_word_regex.compile("\\S+")
text_node.bbcode_enabled = true
tween.finished.connect(_on_dialog_line_typed.bind("", ""))
escoria.paused.connect(_on_paused)
escoria.resumed.connect(_on_resumed)
tree_exited.connect(_on_tree_exited)
# Switch the current character
#
# #### Parameters
# - name: The name of the current character
func set_current_character(name: String):
if ProjectSettings.get_setting("escoria/dialog_simple/avatars_path").is_empty():
escoria.logger.warn(self, "Unable to load avatar '%s': Avatar path not specified" % name)
return
var avatar = "%s/%s.tres" % [
ProjectSettings.get_setting("escoria/dialog_simple/avatars_path"),
name
]
if ResourceLoader.exists(avatar):
avatar_node.texture = ResourceLoader.load(avatar)
if avatar_node.texture is AnimatedTexture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = false
else:
escoria.logger.warn(self, "Unable to load avatar '%s': Resource not found in path '%s'" %
[name, ProjectSettings.get_setting("escoria/dialog_simple/avatars_path")])
# Make a character say something
#
# #### Parameters
# - character: The global id of the character speaking
# - line: Line to say
func say(character: String, line: String):
_current_line = line
_is_speeding_up = false
popup_centered()
set_current_character(character)
text_node.text = tr(line)
text_node.visible_ratio = 0.0
var time_show_full_text = _text_time_per_character / 1000 * len(line)
tween.reset()
tween.interpolate_property(text_node, "visible_ratio",
0.0, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.play()
# Called by the dialog player when the
func speedup():
if not _is_speeding_up:
_is_speeding_up = true
var time_show_full_text = _fast_text_time_per_character / 1000 * len(_current_line)
tween.reset()
tween.interpolate_property(text_node, "visible_ratio",
text_node.visible_ratio, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.play()
# Called by the dialog player when user wants to finish dialogue immediately.
func finish():
tween.reset()
tween.interpolate_property(text_node, "visible_ratio",
text_node.visible_ratio, 1.0, 0.0)
tween.play()
# To be called if voice audio has finished.
func voice_audio_finished():
if avatar_node and avatar_node.texture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = true
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
if avatar_node.texture is AnimatedTexture:
avatar_node.texture.current_frame = 0
avatar_node.texture.pause = true
text_node.visible_characters = -1
var time_to_disappear: float = _calculate_time_to_disappear()
if not $Timer.timeout.is_connected(_on_dialog_finished):
$Timer.timeout.connect(_on_dialog_finished)
$Timer.start(time_to_disappear)
say_visible.emit()
func _calculate_time_to_disappear() -> float:
return (_get_number_of_words() / _reading_speed_in_wpm as float) * 60
func _get_number_of_words() -> int:
return _word_regex.search_all(text_node.get_text()).size()
# Ending the dialog
func _on_dialog_finished():
$Timer.stop()
# Only trigger to clear the text if we aren't limiting the clearing trigger to a click.
if not ESCProjectSettingsManager.get_setting(RTMISimpleDialogSettings.CLEAR_TEXT_BY_CLICK_ONLY):
say_finished.emit()
# Handler managing pause notification from Escoria
func _on_paused():
if tween.is_running():
is_paused = true
tween.stop()
# Handler managing resume notification from Escoria
func _on_resumed():
if not tween.is_running():
# We can't rely on "show()" to make an invisible popup reappear, as per the docs for
# CanvasItem. Instead, we need to use one of the popup_* methods.
if is_inside_tree():
popup_centered()
is_paused = false
tween.resume()
func _on_tree_exited():
queue_free()

View File

@@ -1,46 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cp75ofyuetxux"]
[ext_resource type="Script" uid="uid://yv6l5iarc1ki" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/types/avatar.gd" id="1"]
[node name="dialog_box" type="Popup"]
size = Vector2i(510, 180)
visible = true
script = ExtResource("1")
[node name="Timer" type="Timer" parent="."]
[node name="Panel" type="Panel" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="HSplitContainer" type="HSplitContainer" parent="Panel/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 35
dragger_visibility = 1
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/HSplitContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.3
[node name="avatar" type="TextureRect" parent="Panel/MarginContainer/HSplitContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
stretch_mode = 4
[node name="text" type="RichTextLabel" parent="Panel/MarginContainer/HSplitContainer"]
layout_mode = 2
size_flags_horizontal = 3
bbcode_enabled = true
text = "Here be some text"

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://x2crry528c4o"]
[ext_resource type="Script" uid="uid://d12nyx86nlc6h" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/types/floating.gd" id="1"]
[ext_resource type="Theme" uid="uid://dvwfrnya2nhxu" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/theme.tres" id="2"]
[ext_resource type="Theme" uid="uid://dvwfrnya2nhxu" path="res://addons/escoria-ui-return-monkey-island-dialog-simple/theme/dialog.tres" id="2"]
[node name="dialog_label" type="RichTextLabel"]
offset_right = 672.0

View File

@@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://bbf2w51korm6e" path="res://addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://cv545ye40v70b" path="res://addons/escoria-ui-return-monkey-island/cursors/rounded_mouse_right.png" id="2"]
[ext_resource type="Texture2D" uid="uid://naf4ovsgrbyp" path="res://addons/escoria-ui-return-monkey-island/cursors/rounded_mouse_left.png" id="3"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island/theme.tres" id="4"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island/theme/ui.tres" id="4"]
[node name="tooltipManager" type="Node2D"]
script = ExtResource("1")

View File

@@ -5,17 +5,17 @@
[ext_resource type="PackedScene" uid="uid://dmw5gicuenj53" path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" id="3"]
[ext_resource type="PackedScene" uid="uid://d2kogebvoxy51" path="res://addons/escoria-ui-return-monkey-island/esc_rich_tooltip.tscn" id="4"]
[ext_resource type="Script" uid="uid://lkc4isk3g0rj" path="res://addons/escoria-ui-return-monkey-island/game.gd" id="5"]
[ext_resource type="Texture2D" uid="uid://c0rchilnmxyd" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note.svg" id="6"]
[ext_resource type="Texture2D" uid="uid://ce2rx8nm1s6gh" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note.svg" id="6"]
[ext_resource type="PackedScene" uid="uid://d3wdxi18u52c5" path="res://addons/escoria-ui-return-monkey-island/menus/main_menu/main_menu.tscn" id="7"]
[ext_resource type="PackedScene" uid="uid://dl7w8oqk1rmhw" path="res://addons/escoria-ui-return-monkey-island/menus/pause_menu/pause_menu.tscn" id="8"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island/theme.tres" id="9"]
[ext_resource type="Texture2D" uid="uid://ch7vmpx5l23fy" path="res://addons/escoria-ui-return-monkey-island/icons/cog-64-hover.svg" id="10"]
[ext_resource type="Texture2D" uid="uid://btng6bg3t644v" path="res://addons/escoria-ui-return-monkey-island/icons/cog-64.svg" id="11"]
[ext_resource type="Theme" uid="uid://bf2eet52fueam" path="res://addons/escoria-ui-return-monkey-island/theme/menu.tres" id="9"]
[ext_resource type="Texture2D" uid="uid://doahvd61d05u8" path="res://addons/escoria-ui-return-monkey-island/icons/cog-64-hover.svg" id="10"]
[ext_resource type="Texture2D" uid="uid://cvxd4tjmdwj5l" path="res://addons/escoria-ui-return-monkey-island/icons/cog-64.svg" id="11"]
[ext_resource type="PackedScene" uid="uid://ctg3fukoficqk" path="res://addons/escoria-ui-return-monkey-island/video_player/video_player.tscn" id="12"]
[ext_resource type="Texture2D" uid="uid://dwkquq28fkf8n" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-hover.svg" id="13"]
[ext_resource type="Texture2D" uid="uid://dghklsdy5nmcg" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-hover.svg" id="13"]
[ext_resource type="Script" uid="uid://chas0xyx88njl" path="res://addons/escoria-ui-return-monkey-island/MusicButton.gd" id="14"]
[ext_resource type="Texture2D" uid="uid://p214fv1y4fr4" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-hover-disabled.svg" id="15"]
[ext_resource type="Texture2D" uid="uid://bcurldbc1pvn2" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-disabled.svg" id="16"]
[ext_resource type="Texture2D" uid="uid://d2sehci16hioi" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-hover-disabled.svg" id="15"]
[ext_resource type="Texture2D" uid="uid://e2xk0aimdte" path="res://addons/escoria-ui-return-monkey-island/icons/music-double-note-disabled.svg" id="16"]
[node name="game" type="Node2D"]
script = ExtResource("5")

View File

@@ -1,4 +1,4 @@
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://bf2eet52fueam"]
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dvpaon5mw2w8l"]
[sub_resource type="StyleBoxFlat" id="1"]
content_margin_left = 4.0

View File

@@ -0,0 +1,16 @@
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://djtwqnfbbt5t8"]
[sub_resource type="StyleBoxFlat" id="1"]
bg_color = Color(0.14902, 0.14902, 0.14902, 0.784314)
[sub_resource type="StyleBoxFlat" id="2"]
bg_color = Color(0.285156, 0.285156, 0.285156, 0.784314)
[sub_resource type="StyleBoxFlat" id="3"]
bg_color = Color(0.027451, 0.027451, 0.027451, 0.745098)
[resource]
Button/styles/focus = SubResource("1")
Button/styles/hover = SubResource("2")
Button/styles/normal = SubResource("1")
Button/styles/pressed = SubResource("3")

View File

@@ -0,0 +1,38 @@
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://bf2eet52fueam"]
[sub_resource type="StyleBoxFlat" id="1"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.462745)
corner_radius_top_right = 5
corner_radius_bottom_right = 5
expand_margin_left = 19.0
[sub_resource type="StyleBoxFlat" id="2"]
bg_color = Color(0, 0, 0, 0.509804)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="3"]
bg_color = Color(0, 0, 0, 0.388235)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
expand_margin_left = 5.0
expand_margin_top = 5.0
expand_margin_right = 5.0
expand_margin_bottom = 5.0
[resource]
Label/colors/font_color = Color(1, 1, 1, 1)
Label/colors/font_color_shadow = Color(0, 0, 0, 0)
Label/colors/font_outline_modulate = Color(1, 0, 0, 1)
Label/colors/label_box_bg = Color(0, 0, 0, 0.745098)
Label/styles/normal = SubResource("1")
RichTextLabel/styles/focus = SubResource("2")
RichTextLabel/styles/normal = SubResource("3")