diff --git a/MicRecord.gd b/MicRecord.gd index e990c3b..e0e57c8 100644 --- a/MicRecord.gd +++ b/MicRecord.gd @@ -32,21 +32,40 @@ func save_words(): fl.close() func _process(delta: float) -> void: + auto_timer_t+=delta + if auto_timer and auto_timer_t>=auto_timer_val: + auto_timer_t=0 + if last_item_index!=null: + run_swap_code(1) if Input.is_action_just_pressed("ui_right"): if last_item_index!=null: - run_swap_code(last_item_index+1) + run_swap_code(1) if Input.is_action_just_pressed("ui_left"): if last_item_index!=null: - run_swap_code(last_item_index-1) + run_swap_code(-1) -func run_swap_code(new_index): +var auto_timer := false +var auto_timer_val := 1.0 +var auto_timer_t := 0.0 +func _on_auto_switch_pressed() -> void: + auto_timer_val = %Time.value + auto_timer_t=0 + auto_timer=!auto_timer + if auto_timer: + %AutoSwitch.text="Stop Timer" + else: + %AutoSwitch.text="Start Timer" + + +func run_swap_code(dir): if effect.is_recording_active(): start_new_record() await get_tree().process_frame _on_save_button_pressed() + var new_index = last_item_index+dir if words.size()<=new_index: new_index=0 - if 0>new_index: + elif 0>new_index: new_index=words.size()-1 %WordList.select(new_index) %WordList.ensure_current_is_visible() @@ -179,7 +198,7 @@ func _on_play_text_btn_pressed() -> void: if play: var txt :String= %TextWordsEdit.text - txt=txt.replace("\n"," ").replace("\t"," ") + txt=txt.replace("\n"," ").replace("\t"," ").replace(",","").replace(",","") var wrds = txt.split(" ",false) for wrd in wrds: var path = %SavePath.text.path_join(wrd+".wav") diff --git a/MicRecord.tscn b/MicRecord.tscn index 476a93d..c88beba 100644 --- a/MicRecord.tscn +++ b/MicRecord.tscn @@ -32,10 +32,9 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -current_tab = 1 +current_tab = 0 [node name="Record" type="VBoxContainer" parent="TabContainer"] -visible = false layout_mode = 2 metadata/_tab_index = 0 @@ -209,6 +208,26 @@ text = "Save" layout_mode = 2 text = "Open User Folder" +[node name="HBoxContainer3" type="HBoxContainer" parent="TabContainer/Record/HBoxContainer3/Controls"] +layout_mode = 2 +alignment = 1 + +[node name="AutoSwitch" type="Button" parent="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer3"] +unique_name_in_owner = true +layout_mode = 2 +text = "Start Timer" + +[node name="Time" type="HSlider" parent="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer3"] +unique_name_in_owner = true +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +size_flags_vertical = 1 +min_value = 0.5 +max_value = 5.0 +step = 0.25 +value = 1.0 +ticks_on_borders = true + [node name="HSeparator2" type="HSeparator" parent="TabContainer/Record/HBoxContainer3/Controls"] self_modulate = Color(1, 1, 1, 0) custom_minimum_size = Vector2(0, 40) @@ -223,6 +242,7 @@ layout_mode = 2 text = "Delete" [node name="PlanText" type="VBoxContainer" parent="TabContainer"] +visible = false layout_mode = 2 metadata/_tab_index = 1 @@ -295,6 +315,7 @@ placeholder_text = "Text to read load worlds" [connection signal="pressed" from="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer/PlayButton" to="." method="_on_play_button_pressed"] [connection signal="pressed" from="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer/SaveButton" to="." method="_on_save_button_pressed"] [connection signal="pressed" from="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer/OpenUserFolderButton" to="." method="_on_open_user_folder_button_pressed"] +[connection signal="pressed" from="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer3/AutoSwitch" to="." method="_on_auto_switch_pressed"] [connection signal="pressed" from="TabContainer/Record/HBoxContainer3/Controls/HBoxContainer2/DeleteButton" to="." method="_on_delete_button_pressed"] [connection signal="pressed" from="TabContainer/PlanText/HBoxContainer2/PlayTextBTN" to="." method="_on_play_text_btn_pressed"] [connection signal="pressed" from="TabContainer/PlanText/HBoxContainer2/AddWordsBTN" to="." method="_on_add_words_btn_pressed"]