diff --git a/scenes/main.tscn b/scenes/main.tscn index 56c5cc3..af8859a 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -48,6 +48,10 @@ size_flags_vertical = 3 layout_mode = 2 text = "New Version" +[node name="OptionsButton" type="Button" parent="NormalView/Root"] +layout_mode = 2 +text = "Options" + [node name="DeleteConfirmation" type="ConfirmationDialog" parent="NormalView"] unique_name_in_owner = true initial_position = 2 @@ -146,8 +150,45 @@ layout_mode = 2 size_flags_vertical = 8 text = "Done" +[node name="OptionsView" type="MarginContainer" parent="."] +visible = false +layout_mode = 2 +theme_override_constants/margin_left = 32 +theme_override_constants/margin_top = 32 +theme_override_constants/margin_right = 32 +theme_override_constants/margin_bottom = 32 +metadata/_tab_index = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="OptionsView"] +layout_mode = 2 + +[node name="Label" type="Label" parent="OptionsView/VBoxContainer"] +layout_mode = 2 +text = "Close launcher on launch" + +[node name="CloseOnLaunchBox" type="CheckBox" parent="OptionsView/VBoxContainer/Label"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 11 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -24.0 +grow_horizontal = 0 +grow_vertical = 2 +size_flags_horizontal = 8 +button_pressed = true + +[node name="Button" type="Button" parent="OptionsView/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 10 +text = "Done" + [connection signal="pressed" from="NormalView/Root/NewButton" to="." method="_open_create_menu"] +[connection signal="pressed" from="NormalView/Root/OptionsButton" to="." method="_open_options_menu"] [connection signal="canceled" from="NormalView/DeleteConfirmation" to="." method="_delete_confirmation_canceled"] [connection signal="pressed" from="NewView/VBoxContainer/CreateButton" to="." method="_create_version"] [connection signal="pressed" from="NewView/VBoxContainer/DoneButton" to="." method="set_current_tab" binds= [0]] [connection signal="pressed" from="EditArgsView/VBoxContainer/Button" to="." method="_modify_args"] +[connection signal="toggled" from="OptionsView/VBoxContainer/Label/CloseOnLaunchBox" to="." method="_toggle_close_on_launch"] +[connection signal="pressed" from="OptionsView/VBoxContainer/Button" to="." method="set_current_tab" binds= [0]] diff --git a/scripts/main.gd b/scripts/main.gd index 58b05ae..9867904 100644 --- a/scripts/main.gd +++ b/scripts/main.gd @@ -10,6 +10,7 @@ var choice_res: PackedScene = preload("res://scenes/choice.tscn") @onready var args_edit: TextEdit = %ArgsEdit @onready var progress_bar: ProgressBar = %ProgressBar @onready var delete_confirmation: AcceptDialog = %DeleteConfirmation +@onready var close_on_launch_box: CheckBox = %CloseOnLaunchBox var save: Dictionary = {} var downloads: Dictionary = {} @@ -30,6 +31,17 @@ func _load_save() -> void: if !save.has("versions"): save.versions = [] + # maybe i should make a proper options system + if !save.has("options"): + save.options = { + "close_on_launch": true + } + else: + if !save.options.has("close_on_launch"): + save.options.close_on_launch = true + + close_on_launch_box.set_pressed_no_signal(save.options.close_on_launch) + for child in choice_container.get_children(): child.queue_free() @@ -45,6 +57,11 @@ func _load_save() -> void: choice_container.add_child(choice) +func _toggle_close_on_launch(toggled_on: bool) -> void: + save.options.close_on_launch = !save.options.close_on_launch + _save_save() + + # makes the _mono happen after the lack of anything ones func _sort_name_change(v_name: String) -> String: if v_name.ends_with("_mono"): return v_name @@ -81,7 +98,8 @@ func _on_open(version: Dictionary) -> void: OS.execute("bash", ["-c", command]) - get_tree().quit(0) + if save.options.close_on_launch: + get_tree().quit(0) func _search_path(dir: DirAccess, on_file: Callable, previous: String = "") -> String: @@ -143,6 +161,10 @@ func _open_create_menu() -> void: push_error("An error occurred in the HTTP request.") +func _open_options_menu() -> void: + current_tab = 3 + + func _recv_versions(_result: int, _response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void: var json: Array = JSON.parse_string(body.get_string_from_utf8())