add auto timer
This commit is contained in:
parent
8e8da25b77
commit
5d1d653ada
2 changed files with 47 additions and 7 deletions
29
MicRecord.gd
29
MicRecord.gd
|
@ -32,21 +32,40 @@ func save_words():
|
||||||
fl.close()
|
fl.close()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
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 Input.is_action_just_pressed("ui_right"):
|
||||||
if last_item_index!=null:
|
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 Input.is_action_just_pressed("ui_left"):
|
||||||
if last_item_index!=null:
|
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():
|
if effect.is_recording_active():
|
||||||
start_new_record()
|
start_new_record()
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
_on_save_button_pressed()
|
_on_save_button_pressed()
|
||||||
|
var new_index = last_item_index+dir
|
||||||
if words.size()<=new_index:
|
if words.size()<=new_index:
|
||||||
new_index=0
|
new_index=0
|
||||||
if 0>new_index:
|
elif 0>new_index:
|
||||||
new_index=words.size()-1
|
new_index=words.size()-1
|
||||||
%WordList.select(new_index)
|
%WordList.select(new_index)
|
||||||
%WordList.ensure_current_is_visible()
|
%WordList.ensure_current_is_visible()
|
||||||
|
@ -179,7 +198,7 @@ func _on_play_text_btn_pressed() -> void:
|
||||||
|
|
||||||
if play:
|
if play:
|
||||||
var txt :String= %TextWordsEdit.text
|
var txt :String= %TextWordsEdit.text
|
||||||
txt=txt.replace("\n"," ").replace("\t"," ")
|
txt=txt.replace("\n"," ").replace("\t"," ").replace(",","").replace(",","")
|
||||||
var wrds = txt.split(" ",false)
|
var wrds = txt.split(" ",false)
|
||||||
for wrd in wrds:
|
for wrd in wrds:
|
||||||
var path = %SavePath.text.path_join(wrd+".wav")
|
var path = %SavePath.text.path_join(wrd+".wav")
|
||||||
|
|
|
@ -32,10 +32,9 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
current_tab = 1
|
current_tab = 0
|
||||||
|
|
||||||
[node name="Record" type="VBoxContainer" parent="TabContainer"]
|
[node name="Record" type="VBoxContainer" parent="TabContainer"]
|
||||||
visible = false
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
metadata/_tab_index = 0
|
metadata/_tab_index = 0
|
||||||
|
|
||||||
|
@ -209,6 +208,26 @@ text = "Save"
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Open User Folder"
|
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"]
|
[node name="HSeparator2" type="HSeparator" parent="TabContainer/Record/HBoxContainer3/Controls"]
|
||||||
self_modulate = Color(1, 1, 1, 0)
|
self_modulate = Color(1, 1, 1, 0)
|
||||||
custom_minimum_size = Vector2(0, 40)
|
custom_minimum_size = Vector2(0, 40)
|
||||||
|
@ -223,6 +242,7 @@ layout_mode = 2
|
||||||
text = "Delete"
|
text = "Delete"
|
||||||
|
|
||||||
[node name="PlanText" type="VBoxContainer" parent="TabContainer"]
|
[node name="PlanText" type="VBoxContainer" parent="TabContainer"]
|
||||||
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
metadata/_tab_index = 1
|
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/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/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/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/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/PlayTextBTN" to="." method="_on_play_text_btn_pressed"]
|
||||||
[connection signal="pressed" from="TabContainer/PlanText/HBoxContainer2/AddWordsBTN" to="." method="_on_add_words_btn_pressed"]
|
[connection signal="pressed" from="TabContainer/PlanText/HBoxContainer2/AddWordsBTN" to="." method="_on_add_words_btn_pressed"]
|
||||||
|
|
Loading…
Reference in a new issue