Add interface sound feedback
This commit is contained in:
@@ -2,7 +2,7 @@ extends VBoxContainer
|
||||
|
||||
const Style := preload("res://scripts/ui/ui_style.gd")
|
||||
const FEEDBACK_FADE_SECONDS := 0.45
|
||||
const CORRECT_ADVANCE_DELAY_SECONDS := 0.6
|
||||
const CORRECT_ADVANCE_DELAY_SECONDS := 1.25
|
||||
const TEXT_SCALE_MIN := 0.85
|
||||
const TEXT_SCALE_MAX := 1.35
|
||||
const TEXT_SCALE_STEP := 0.1
|
||||
@@ -108,6 +108,7 @@ func _ready() -> void:
|
||||
text_smaller_button.tooltip_text = "Decrease text size"
|
||||
text_smaller_button.custom_minimum_size = Vector2(44, 44)
|
||||
Style.style_chip(text_smaller_button, Style.CYAN)
|
||||
UISoundService.set_button_sound(text_smaller_button, "toggle")
|
||||
text_smaller_button.pressed.connect(func(): _adjust_question_text_scale(-TEXT_SCALE_STEP))
|
||||
question_toolbar.add_child(text_smaller_button)
|
||||
|
||||
@@ -116,6 +117,7 @@ func _ready() -> void:
|
||||
text_larger_button.tooltip_text = "Increase text size"
|
||||
text_larger_button.custom_minimum_size = Vector2(44, 44)
|
||||
Style.style_chip(text_larger_button, Style.CYAN)
|
||||
UISoundService.set_button_sound(text_larger_button, "toggle")
|
||||
text_larger_button.pressed.connect(func(): _adjust_question_text_scale(TEXT_SCALE_STEP))
|
||||
question_toolbar.add_child(text_larger_button)
|
||||
|
||||
@@ -124,6 +126,7 @@ func _ready() -> void:
|
||||
labs_button.icon = _make_labs_icon()
|
||||
labs_button.custom_minimum_size = Vector2(44, 44)
|
||||
Style.style_chip(labs_button, Style.LIME)
|
||||
UISoundService.set_button_sound(labs_button, "open")
|
||||
labs_button.pressed.connect(_show_labs_modal)
|
||||
question_toolbar.add_child(labs_button)
|
||||
|
||||
@@ -132,6 +135,7 @@ func _ready() -> void:
|
||||
clear_highlight_button.icon = _make_clear_highlights_icon()
|
||||
clear_highlight_button.custom_minimum_size = Vector2(44, 44)
|
||||
Style.style_chip(clear_highlight_button, Style.CYAN)
|
||||
UISoundService.set_button_sound(clear_highlight_button, "eliminate")
|
||||
clear_highlight_button.pressed.connect(_clear_current_highlights)
|
||||
question_toolbar.add_child(clear_highlight_button)
|
||||
|
||||
@@ -141,6 +145,7 @@ func _ready() -> void:
|
||||
flag_button.icon = _make_flag_icon()
|
||||
flag_button.custom_minimum_size = Vector2(44, 44)
|
||||
Style.style_chip(flag_button, Style.AMBER)
|
||||
UISoundService.set_button_sound(flag_button, "toggle")
|
||||
flag_button.toggled.connect(func(value: bool):
|
||||
flagged = value
|
||||
_refresh_toolbar_state()
|
||||
@@ -217,6 +222,7 @@ func _ready() -> void:
|
||||
button.custom_minimum_size = Vector2(0, 64)
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
Style.style_answer_button(button)
|
||||
UISoundService.set_button_sound(button, "select")
|
||||
_set_scaled_button_font(button, 17)
|
||||
button.pressed.connect(func(i := index): _select_choice(i))
|
||||
button.gui_input.connect(func(event: InputEvent, i := index): _choice_gui_input(event, i))
|
||||
@@ -288,6 +294,7 @@ func _ready() -> void:
|
||||
skip_button.text = "Skip"
|
||||
skip_button.custom_minimum_size = Vector2(120, 48)
|
||||
Style.style_chip(skip_button, Style.AMBER)
|
||||
UISoundService.set_button_sound(skip_button, "back")
|
||||
skip_button.pressed.connect(_skip_current_question)
|
||||
actions.add_child(skip_button)
|
||||
|
||||
@@ -535,6 +542,7 @@ func _choice_gui_input(event: InputEvent, index: int) -> void:
|
||||
eliminated.erase(choice_id)
|
||||
else:
|
||||
eliminated.append(choice_id)
|
||||
UISoundService.play_sound("eliminate")
|
||||
_set_choice_button_text(index, choice)
|
||||
_apply_saved_choice_state()
|
||||
|
||||
@@ -549,6 +557,7 @@ func _toggle_eliminate_selected() -> void:
|
||||
eliminated.erase(selected_choice)
|
||||
else:
|
||||
eliminated.append(selected_choice)
|
||||
UISoundService.play_sound("eliminate")
|
||||
_set_choice_button_text(index, choices[index])
|
||||
_apply_saved_choice_state()
|
||||
|
||||
@@ -663,6 +672,7 @@ func _lock_wrong_choice(choice_id: String) -> void:
|
||||
|
||||
|
||||
func _trigger_wrong_feedback() -> void:
|
||||
UISoundService.play_sound("error")
|
||||
shake_time = 0.28
|
||||
shake_origin = position
|
||||
green_fog_time = 0.0
|
||||
@@ -672,6 +682,7 @@ func _trigger_wrong_feedback() -> void:
|
||||
|
||||
|
||||
func _trigger_correct_feedback() -> void:
|
||||
UISoundService.play_sound("correct")
|
||||
pending_correct_advance = true
|
||||
correct_advance_delay = CORRECT_ADVANCE_DELAY_SECONDS
|
||||
red_fog_time = 0.0
|
||||
@@ -1010,6 +1021,7 @@ func _build_labs_modal() -> void:
|
||||
close_button.tooltip_text = "Close lab results"
|
||||
close_button.custom_minimum_size = Vector2(42, 38)
|
||||
Style.style_chip(close_button, Style.RED)
|
||||
UISoundService.set_button_sound(close_button, "close")
|
||||
close_button.pressed.connect(_hide_labs_modal)
|
||||
header.add_child(close_button)
|
||||
|
||||
@@ -1331,6 +1343,7 @@ func _build_followup_panel(index: int, choice_id: String) -> void:
|
||||
option_button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
option_button.custom_minimum_size = Vector2(0, 32)
|
||||
Style.style_chip(option_button, Style.CYAN)
|
||||
UISoundService.set_button_sound(option_button, "select")
|
||||
_set_scaled_button_font(option_button, 15)
|
||||
option_button.set_meta("option_id", str(option.get("id", "")))
|
||||
option_button.pressed.connect(func(option_id := str(option.get("id", "")), selected_button := option_button, followup_data := followup):
|
||||
@@ -1459,6 +1472,7 @@ func _build_collapsed_followup(index: int, state: Dictionary) -> void:
|
||||
summary.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
summary.custom_minimum_size = Vector2(0, 40)
|
||||
Style.style_chip(summary, Style.AMBER)
|
||||
UISoundService.set_button_sound(summary, "open")
|
||||
_set_scaled_button_font(summary, 15)
|
||||
summary.gui_input.connect(func(_event: InputEvent): _mark_review_input_handled())
|
||||
summary.pressed.connect(func(choice_id := str(state.get("choice_id", ""))): _toggle_followup_state(choice_id))
|
||||
@@ -1472,6 +1486,7 @@ func _build_readonly_followup(index: int, state: Dictionary) -> void:
|
||||
summary.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
summary.custom_minimum_size = Vector2(0, 36)
|
||||
Style.style_chip(summary, Style.AMBER)
|
||||
UISoundService.set_button_sound(summary, "close")
|
||||
_set_scaled_button_font(summary, 15)
|
||||
summary.gui_input.connect(func(_event: InputEvent): _mark_review_input_handled())
|
||||
summary.pressed.connect(func(choice_id := str(state.get("choice_id", ""))): _toggle_followup_state(choice_id))
|
||||
|
||||
Reference in New Issue
Block a user