From 323a5fc34507d53947a2cc02c02de5b0093cac80 Mon Sep 17 00:00:00 2001 From: domi41 Date: Sun, 9 Aug 2020 18:55:51 +0200 Subject: [PATCH] feat: add a form to configure the settings --- core/App.gd | 10 +- gui/MainMenu.gd | 4 + gui/MainMenu.tscn | 1 + gui/forms/NewPollForm.gd | 4 +- gui/forms/SettingsForm.gd | 16 +++ gui/forms/SettingsForm.tscn | 114 ++++++++++++++++++++ gui/forms/twitch_config/TwitchAuthConfig.gd | 4 +- 7 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 gui/forms/SettingsForm.gd create mode 100644 gui/forms/SettingsForm.tscn diff --git a/core/App.gd b/core/App.gd index b9bc826..f259473 100644 --- a/core/App.gd +++ b/core/App.gd @@ -10,9 +10,17 @@ func _ready(): func go_to_main_menu(): - get_tree().change_scene("res://gui/MainMenu.tscn") + var _done = get_tree().change_scene("res://gui/MainMenu.tscn") +func go_to_settings(): + var _done = get_tree().change_scene("res://gui/forms/SettingsForm.tscn") + + +func go_to_twitch_settings(): + var _done = get_tree().change_scene("res://gui/forms/twitch_config/TwitchAuthConfig.tscn") + + func load_config(): if File.new().file_exists(self.config_path): self.config = load(self.config_path) diff --git a/gui/MainMenu.gd b/gui/MainMenu.gd index 18c8f27..ca9f233 100644 --- a/gui/MainMenu.gd +++ b/gui/MainMenu.gd @@ -16,3 +16,7 @@ func _on_NewPollButton_pressed(): func _on_ExitButton_pressed(): get_tree().quit() + + +func _on_SettingsButton_pressed(): + App.go_to_settings() diff --git a/gui/MainMenu.tscn b/gui/MainMenu.tscn index 5c8695f..79ed6ac 100644 --- a/gui/MainMenu.tscn +++ b/gui/MainMenu.tscn @@ -51,4 +51,5 @@ margin_bottom = 86.0 text = "v0.1" align = 1 [connection signal="pressed" from="CenterContainer/VBoxContainer/NewPollButton" to="." method="_on_NewPollButton_pressed"] +[connection signal="pressed" from="CenterContainer/VBoxContainer/SettingsButton" to="." method="_on_SettingsButton_pressed"] [connection signal="pressed" from="CenterContainer/VBoxContainer/ExitButton" to="." method="_on_ExitButton_pressed"] diff --git a/gui/forms/NewPollForm.gd b/gui/forms/NewPollForm.gd index d22fd14..93c7330 100644 --- a/gui/forms/NewPollForm.gd +++ b/gui/forms/NewPollForm.gd @@ -2,7 +2,7 @@ extends Control func _on_CancelButton_pressed(): - get_tree().change_scene("res://gui/MainMenu.tscn") + var _done = get_tree().change_scene("res://gui/MainMenu.tscn") func _on_LaunchButton_pressed(): @@ -18,7 +18,7 @@ func collect_poll_from_form(form:Control) -> MajorityJudgmentPoll: if title_line_edit.text: poll.set_title(title_line_edit.text) - var candidates_tree = form.find_node("CandidatesTree", true, false) +# var candidates_tree = form.find_node("CandidatesTree", true, false) return poll diff --git a/gui/forms/SettingsForm.gd b/gui/forms/SettingsForm.gd new file mode 100644 index 0000000..8f5e28a --- /dev/null +++ b/gui/forms/SettingsForm.gd @@ -0,0 +1,16 @@ +extends Control + + + +func _on_DoneButton_pressed(): + App.go_to_main_menu() + + +func _on_TwitchConfigureButton_pressed(): + App.go_to_twitch_settings() + + + +func _on_TwitchCheckButton_toggled(button_pressed): + if button_pressed: + App.go_to_twitch_settings() diff --git a/gui/forms/SettingsForm.tscn b/gui/forms/SettingsForm.tscn new file mode 100644 index 0000000..36ba935 --- /dev/null +++ b/gui/forms/SettingsForm.tscn @@ -0,0 +1,114 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://gui/widgets/Background.tscn" type="PackedScene" id=1] +[ext_resource path="res://gui/forms/SettingsForm.gd" type="Script" id=2] + +[node name="SettingsForm" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Background" parent="." instance=ExtResource( 1 )] + +[node name="CenterContainer" type="CenterContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +margin_left = 337.0 +margin_top = 188.0 +margin_right = 687.0 +margin_bottom = 412.0 + +[node name="TabContainer" type="TabContainer" parent="CenterContainer/VBoxContainer"] +margin_right = 350.0 +margin_bottom = 200.0 +rect_min_size = Vector2( 350, 200 ) + +[node name="Providers" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="VBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers"] +anchor_right = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TwitchCheckButton" type="CheckButton" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"] +margin_right = 229.0 +margin_bottom = 40.0 +text = "Twitch Chat Commands" + +[node name="TwitchConfigureButton" type="Button" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"] +margin_left = 233.0 +margin_right = 305.0 +margin_bottom = 40.0 +text = "Configure" + +[node name="General" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="HelpLabel" type="RichTextLabel" parent="CenterContainer/VBoxContainer/TabContainer/General"] +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +text = "TODO: General settings like background color (right now you ned to run the source and change the clear color in the project settings)" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ColorPicker" type="ColorPicker" parent="CenterContainer/VBoxContainer/TabContainer/General"] +visible = false +margin_left = 12.0 +margin_top = 12.0 +margin_right = 320.0 +margin_bottom = 474.0 +color = Color( 0.341176, 0.133333, 0.133333, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="PanelContainer" type="PanelContainer" parent="CenterContainer/VBoxContainer"] +visible = false +margin_top = 40.0 +margin_right = 350.0 +margin_bottom = 240.0 +rect_min_size = Vector2( 350, 200 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"] +margin_top = 204.0 +margin_right = 350.0 +margin_bottom = 224.0 + +[node name="VSeparator" type="VSeparator" parent="CenterContainer/VBoxContainer/HBoxContainer"] +self_modulate = Color( 1, 1, 1, 0 ) +margin_right = 296.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 + +[node name="DoneButton" type="Button" parent="CenterContainer/VBoxContainer/HBoxContainer"] +margin_left = 300.0 +margin_right = 350.0 +margin_bottom = 20.0 +text = "DONE" +[connection signal="toggled" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchCheckButton" to="." method="_on_TwitchCheckButton_toggled"] +[connection signal="pressed" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchConfigureButton" to="." method="_on_TwitchConfigureButton_pressed"] +[connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/DoneButton" to="." method="_on_DoneButton_pressed"] diff --git a/gui/forms/twitch_config/TwitchAuthConfig.gd b/gui/forms/twitch_config/TwitchAuthConfig.gd index fcfee27..4932eeb 100644 --- a/gui/forms/twitch_config/TwitchAuthConfig.gd +++ b/gui/forms/twitch_config/TwitchAuthConfig.gd @@ -109,8 +109,8 @@ func _on_CancelButton_pressed(): func _on_ClientIdHelpButton_pressed(): - OS.shell_open("https://dev.twitch.tv/dashboard/apps/create") + var _done = OS.shell_open("https://dev.twitch.tv/dashboard/apps/create") func _on_OAuthHelpButton_pressed(): - OS.shell_open("https://twitchapps.com/tmi/") + var _done = OS.shell_open("https://twitchapps.com/tmi/")