From 1f83933177a685527b9d0db8d1b4f82db0fa8263 Mon Sep 17 00:00:00 2001 From: astra137 Date: Mon, 6 Oct 2025 06:58:17 -0700 Subject: [PATCH] Fix TTS calls --- bark_buttons.gd | 8 ++++---- game_manager.gd | 14 ++++++-------- main.tscn | 30 +++++++++++++++++++++++++++--- turn_manager.gd | 31 +++++++++++++++++++++---------- 4 files changed, 58 insertions(+), 25 deletions(-) diff --git a/bark_buttons.gd b/bark_buttons.gd index 6f645f2..bcb79ed 100644 --- a/bark_buttons.gd +++ b/bark_buttons.gd @@ -7,22 +7,22 @@ signal auctioneer_bark func _on_great_buy_button_down() -> void: auctioneer_bark.emit() $GreatBuy.mouse_default_cursor_shape = Control.CURSOR_DRAG - turn_manager.speak("Great buy!", bark_speed) + turn_manager.speak_bark("Great buy!", bark_speed) func _on_investment_piece_button_down() -> void: auctioneer_bark.emit() $InvestmentPiece.mouse_default_cursor_shape = Control.CURSOR_DRAG - turn_manager.speak("Investment piece!", bark_speed) + turn_manager.speak_bark("Investment piece!", bark_speed) func _on_stunning_message_button_down() -> void: auctioneer_bark.emit() $StunningMessage.mouse_default_cursor_shape = Control.CURSOR_DRAG - turn_manager.speak("Stunning message!", bark_speed) + turn_manager.speak_bark("Stunning message!", bark_speed) func _on_innovative_artist_button_down() -> void: auctioneer_bark.emit() $InnovativeArtist.mouse_default_cursor_shape = Control.CURSOR_DRAG - turn_manager.speak("Innovative artist!", bark_speed) + turn_manager.speak_bark("Innovative artist!", bark_speed) func _on_great_buy_button_release() -> void: diff --git a/game_manager.gd b/game_manager.gd index 75cac42..fb23a49 100644 --- a/game_manager.gd +++ b/game_manager.gd @@ -51,7 +51,7 @@ func _ready() -> void: var intro_msg := "You have %s paintings. Sell them fast for at least $%s or face the consequences!" % [PAINTINGS_TOTAL, target_sales] intro_msg += "\nHit the gavel and input the starting price to begin!" - turn_manager.speak(intro_msg) + turn_manager.speak_sentence(intro_msg) #build out the initialization process, which should: # -- generate paintings and assign values @@ -80,10 +80,10 @@ func destroy_painting(): cancel_bidding() get_painting_display().move_painting_to_pile(%PaintingPileDiscard) next_painting() - turn_manager.speak("Oh nooooooo! Took too long!\nTry to make it up on the next painting!") + turn_manager.speak_sentence("Oh nooooooo! Took too long!\nTry to make it up on the next painting!") else: turn_manager.restart_turn() - turn_manager.speak("Oops! Took too long! Quickly, try again!") + turn_manager.speak_sentence("Oops! Took too long! Quickly, try again!") func sell_painting(): @@ -91,7 +91,7 @@ func sell_painting(): move_painting_to_bidders_pile() paintings[current_painting_idx].sold_for = current_bid current_bid_display.set_text("Sold for $%s!" % [current_bid]) - turn_manager.speak("Sold for $%s!" % [current_bid]) + turn_manager.speak_sentence("Sold for $%s!" % [current_bid]) print("Congrats on selling your painting for $%s! You have made $%s so far." % [current_bid, get_total_sales()]) @@ -122,11 +122,11 @@ func end_auction(): #add in logic for displaying/transitioning to score screen if get_total_sales() >= target_sales: #add context specific score text? - turn_manager.speak("Congratulations! The auction house will run another day.") + turn_manager.speak_sentence("Congratulations! The auction house will run another day.") emit_signal("won") else: #add context specific score text? - turn_manager.speak("You have failed. We must find a new auctioneer.") + turn_manager.speak_sentence("You have failed. We must find a new auctioneer.") emit_signal("lost") @@ -159,8 +159,6 @@ class PaintingInfo: var is_sold: bool: get(): return sold_for > 0 ->> >> >> > wip_astra137 - # OTHER THINGS TO ADD: # UI elements for score # Bark manager diff --git a/main.tscn b/main.tscn index d968ebd..7f28467 100644 --- a/main.tscn +++ b/main.tscn @@ -195,9 +195,9 @@ size_flags_horizontal = 3 [node name="PaintingPiles" type="HBoxContainer" parent="."] unique_name_in_owner = true -offset_left = 142.0 -offset_top = 242.0 -offset_right = 759.0 +offset_left = 86.0 +offset_top = 280.0 +offset_right = 847.0 offset_bottom = 310.0 theme_override_constants/separation = 24 metadata/_edit_group_ = true @@ -222,6 +222,30 @@ size_flags_horizontal = 3 layout_mode = 2 size_flags_horizontal = 3 +[node name="PaintingPile6" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile7" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile8" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile9" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile10" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaintingPile11" parent="PaintingPiles" instance=ExtResource("4_1u8w0")] +layout_mode = 2 +size_flags_horizontal = 3 + [connection signal="timer_timeout" from="TurnManager" to="GameManager" method="_on_turn_manager_timer_timeout"] [connection signal="button_down" from="BarkButtons/GreatBuy" to="BarkButtons" method="_on_great_buy_button_down"] [connection signal="button_up" from="BarkButtons/GreatBuy" to="BarkButtons" method="_on_great_buy_button_release"] diff --git a/turn_manager.gd b/turn_manager.gd index 356e2a3..86cb56e 100644 --- a/turn_manager.gd +++ b/turn_manager.gd @@ -3,10 +3,10 @@ class_name TurnManager extends Node2D signal timer_timeout @export var turn_timer := 7.0 -@export var tts_number_speed = 7.0 -@export var tts_sentence_speed = 5.0 -@export var tts_volume = 75 -@export var tts_pitch = 1.0 +@export var _tts_number_speed := 7.0 +@export var _tts_sentence_speed := 5.0 +@export var tts_volume := 75 +@export var tts_pitch := 1.0 @export var desk: Desk @export var captions: CaptionLabel @@ -26,8 +26,19 @@ func _ready() -> void: print('voices available: ', _voices.size()) -func speak(text: String, speed := tts_number_speed) -> void: - print('tts: ', text) +func speak_number(text: String) -> void: + captions.display_caption(text) + if not _voices.is_empty(): + DisplayServer.tts_speak(text, _voices[0], tts_volume, tts_pitch, _tts_number_speed) + + +func speak_sentence(text: String) -> void: + captions.display_caption(text) + if not _voices.is_empty(): + DisplayServer.tts_speak(text, _voices[0], tts_volume, tts_pitch, _tts_sentence_speed) + + +func speak_bark(text: String, speed: float) -> void: captions.display_caption(text) if not _voices.is_empty(): DisplayServer.tts_speak(text, _voices[0], tts_volume, tts_pitch, speed) @@ -36,13 +47,13 @@ func speak(text: String, speed := tts_number_speed) -> void: func _speak_ask_proposed(amount): var speech_variance = randf() if speech_variance < 0.45: - speak('%s' % [amount]) + speak_number('%s' % [amount]) elif speech_variance > 0.45 and speech_variance < 0.65: - speak('Do I hear %s?' % [amount]) + speak_number('Do I hear %s?' % [amount]) elif speech_variance > 0.65 and speech_variance < 0.8: - speak('%s, anybody?' % [amount]) + speak_number('%s, anybody?' % [amount]) else: - speak('Can I get a %s?' % [amount]) + speak_number('Can I get a %s?' % [amount]) func _handle_ask_accepted():