From 2fe9d8e220b81e3a5116ec93ef46ada8035eb069 Mon Sep 17 00:00:00 2001 From: jinyang Date: Thu, 10 Jul 2025 18:02:18 +0800 Subject: [PATCH 1/2] Fix choice button color --- .../Modules/Choice/node_choice_button.gd | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/addons/dialogic/Modules/Choice/node_choice_button.gd b/addons/dialogic/Modules/Choice/node_choice_button.gd index 4a09c29ce..b652533fb 100644 --- a/addons/dialogic/Modules/Choice/node_choice_button.gd +++ b/addons/dialogic/Modules/Choice/node_choice_button.gd @@ -33,6 +33,14 @@ func _ready() -> void: add_to_group('dialogic_choice_button') shortcut_in_tooltip = false hide() + + # For players who use a mouse to make choices, mouse hover should grab focus. + # Otherwise the auto-focused button will always show a highlighted color when + # the mouse cursor is hovering on another button. + if not mouse_entered.is_connected(grab_focus): + mouse_entered.connect(grab_focus) + if not focus_entered.is_connected(_on_choice_button_focus_entred): + focus_entered.connect(_on_choice_button_focus_entred.bind(self)) ## Custom choice buttons can override this for specialized behavior when the choice button is pressed. @@ -65,3 +73,36 @@ func set_choice_text(new_text: String) -> void: text_node.text = new_text else: text = new_text + + +## For players who use many devices (mouse/keyboard/gamepad, etc) at the same time to make choices, +## a grabing-focus triggered by keyboard/gamepad should also change the mouse cursor's +## position otherwise two buttons will have highlighted color(one highlighted button +## triggered by mouse hover and another highlighted button triggered by other devices' choice). +## So this function do such thing: make sure the mouse cursor does not hover on an unfocused button. +func _on_choice_button_focus_entred(focused_button: Button): + var global_mouse_pos = get_global_mouse_position() + var focused_button_rect = focused_button.get_global_rect() + if focused_button_rect.has_point(global_mouse_pos): + return + # Only change mouse curor position when an unfocused button' rect has the cursor. + for node in get_tree().get_nodes_in_group('dialogic_choice_button'): + if node is Button: + if node != focused_button and node.get_global_rect().has_point(global_mouse_pos): + # We prefer to change only mouse_position.y or mouse_position.x to warp the + # mouse to the focused button's rect to achieve the best visual effect. + var modify_y_pos = Vector2(global_mouse_pos.x, focused_button.get_global_rect().get_center().y) + if focused_button_rect.has_point(modify_y_pos): + get_viewport().warp_mouse(modify_y_pos) + return + + var modify_x_pos = Vector2(focused_button.get_global_rect().get_center().x, global_mouse_pos.y) + if focused_button_rect.has_point(modify_x_pos): + get_viewport().warp_mouse(modify_x_pos) + return + + # Maybe the buttons are not aligned as vertically or horizontlly. + # Or perhaps the length difference between the two buttons is quite large. + # So we just make the cursor hover on the center of the focused button. + get_viewport().warp_mouse(focused_button.get_global_rect().get_center()) + return From d5fe2f9829b09980b61d73dec11a32008e56a580 Mon Sep 17 00:00:00 2001 From: jinyang Date: Tue, 15 Jul 2025 17:25:19 +0800 Subject: [PATCH 2/2] Fix multiple styles missing sound --- .../Modules/Choice/node_choice_button.gd | 41 ------------------- .../dialogic/Modules/Text/node_type_sound.gd | 4 ++ .../dialogic/Modules/Text/subsystem_text.gd | 2 + addons/dialogic/Resources/character.gd | 1 + 4 files changed, 7 insertions(+), 41 deletions(-) diff --git a/addons/dialogic/Modules/Choice/node_choice_button.gd b/addons/dialogic/Modules/Choice/node_choice_button.gd index b652533fb..4a09c29ce 100644 --- a/addons/dialogic/Modules/Choice/node_choice_button.gd +++ b/addons/dialogic/Modules/Choice/node_choice_button.gd @@ -33,14 +33,6 @@ func _ready() -> void: add_to_group('dialogic_choice_button') shortcut_in_tooltip = false hide() - - # For players who use a mouse to make choices, mouse hover should grab focus. - # Otherwise the auto-focused button will always show a highlighted color when - # the mouse cursor is hovering on another button. - if not mouse_entered.is_connected(grab_focus): - mouse_entered.connect(grab_focus) - if not focus_entered.is_connected(_on_choice_button_focus_entred): - focus_entered.connect(_on_choice_button_focus_entred.bind(self)) ## Custom choice buttons can override this for specialized behavior when the choice button is pressed. @@ -73,36 +65,3 @@ func set_choice_text(new_text: String) -> void: text_node.text = new_text else: text = new_text - - -## For players who use many devices (mouse/keyboard/gamepad, etc) at the same time to make choices, -## a grabing-focus triggered by keyboard/gamepad should also change the mouse cursor's -## position otherwise two buttons will have highlighted color(one highlighted button -## triggered by mouse hover and another highlighted button triggered by other devices' choice). -## So this function do such thing: make sure the mouse cursor does not hover on an unfocused button. -func _on_choice_button_focus_entred(focused_button: Button): - var global_mouse_pos = get_global_mouse_position() - var focused_button_rect = focused_button.get_global_rect() - if focused_button_rect.has_point(global_mouse_pos): - return - # Only change mouse curor position when an unfocused button' rect has the cursor. - for node in get_tree().get_nodes_in_group('dialogic_choice_button'): - if node is Button: - if node != focused_button and node.get_global_rect().has_point(global_mouse_pos): - # We prefer to change only mouse_position.y or mouse_position.x to warp the - # mouse to the focused button's rect to achieve the best visual effect. - var modify_y_pos = Vector2(global_mouse_pos.x, focused_button.get_global_rect().get_center().y) - if focused_button_rect.has_point(modify_y_pos): - get_viewport().warp_mouse(modify_y_pos) - return - - var modify_x_pos = Vector2(focused_button.get_global_rect().get_center().x, global_mouse_pos.y) - if focused_button_rect.has_point(modify_x_pos): - get_viewport().warp_mouse(modify_x_pos) - return - - # Maybe the buttons are not aligned as vertically or horizontlly. - # Or perhaps the length difference between the two buttons is quite large. - # So we just make the cursor hover on the center of the focused button. - get_viewport().warp_mouse(focused_button.get_global_rect().get_center()) - return diff --git a/addons/dialogic/Modules/Text/node_type_sound.gd b/addons/dialogic/Modules/Text/node_type_sound.gd index 5a5667d90..1a33afe9d 100644 --- a/addons/dialogic/Modules/Text/node_type_sound.gd +++ b/addons/dialogic/Modules/Text/node_type_sound.gd @@ -42,6 +42,10 @@ func _ready() -> void: get_parent().continued_revealing_text.connect(_on_continued_revealing_text) get_parent().finished_revealing_text.connect(_on_finished_revealing_text) + if DialogicUtil.autoload(): + var current_speaker = DialogicUtil.autoload().Text.get_current_speaker() + if current_speaker: + load_overwrite(current_speaker.custom_info.get('sound_moods', {}).get(current_speaker.current_mood, {})) func _on_started_revealing_text() -> void: if !enabled or (get_parent() is DialogicNode_DialogText and !get_parent().enabled): diff --git a/addons/dialogic/Modules/Text/subsystem_text.gd b/addons/dialogic/Modules/Text/subsystem_text.gd index fe4ac1295..13b9224e6 100644 --- a/addons/dialogic/Modules/Text/subsystem_text.gd +++ b/addons/dialogic/Modules/Text/subsystem_text.gd @@ -218,12 +218,14 @@ func update_name_label(character:DialogicCharacter): func update_typing_sound_mood_from_character(character:DialogicCharacter, mood:String) -> void: + character.current_mood = mood if character.custom_info.get("sound_moods", {}).is_empty(): update_typing_sound_mood() elif mood in character.custom_info.get("sound_moods", {}): update_typing_sound_mood(character.custom_info.get("sound_moods", {})[mood]) else: var default_mood : String = character.custom_info.get("sound_mood_default", "") + character.current_mood = default_mood update_typing_sound_mood(character.custom_info.get("sound_moods", {}).get(default_mood, {})) diff --git a/addons/dialogic/Resources/character.gd b/addons/dialogic/Resources/character.gd index 475378b3c..3efca6fa2 100644 --- a/addons/dialogic/Resources/character.gd +++ b/addons/dialogic/Resources/character.gd @@ -29,6 +29,7 @@ enum TranslatedProperties { var _translation_id := "" +var current_mood := "" func _get_extension() -> String: return "dch"