From 7903a8d9f3f49657fa5f900ecbcb227605356f84 Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Thu, 28 Jan 2021 11:55:53 +0100 Subject: [PATCH] Sneaking survey into game before quitting --- project.godot | 2 +- scenes/game.gd | 12 ++++ scenes/game.tscn | 6 ++ scenes/level_select.gd | 3 +- scenes/level_select.tscn | 5 +- scenes/survey.gd | 14 +++++ scenes/survey.tscn | 110 +++++++++++++++++++++++++++++++++ scenes/title.gd | 4 ++ styles/alert_button_hover.tres | 8 +++ 9 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 scenes/game.tscn create mode 100644 scenes/survey.gd create mode 100644 scenes/survey.tscn create mode 100644 styles/alert_button_hover.tres diff --git a/project.godot b/project.godot index 9db9211..9808e04 100644 --- a/project.godot +++ b/project.godot @@ -57,9 +57,9 @@ boot_splash/bg_color=Color( 0, 0, 0, 1 ) [autoload] -game="*res://scenes/game.gd" helpers="*res://scenes/helpers.gd" levels="*res://scenes/levels.gd" +game="*res://scenes/game.tscn" [display] diff --git a/scenes/game.gd b/scenes/game.gd index aa68229..f4e9e84 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -15,6 +15,9 @@ var _file = "user://savegame.json" var state = {} func _ready(): + if OS.has_feature("standalone"): + get_tree().set_auto_accept_quit(false) + global_shell = Shell.new() create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig")) @@ -23,6 +26,12 @@ func _ready(): copy_script_to_game_env("hint") load_state() + +func _notification(what): + if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: + #get_tree().quit() # default behavio + get_tree().change_scene("res://scenes/survey.tscn") + func copy_script_to_game_env(name): create_file_in_game_env(name, helpers.read_file("res://scripts/%s" % name)) @@ -73,3 +82,6 @@ func notify(text, target=null, hint_slug=null): if hint_slug: state["received_hints"].push_back(hint_slug) save_state() + +func open_survey(): + OS.shell_open("https://docs.google.com/forms/d/e/1FAIpQLSehHVcYfELT59h6plcn2ilbuqBcmDX3TH0qzB4jCgFIFOy_qg/viewform") diff --git a/scenes/game.tscn b/scenes/game.tscn new file mode 100644 index 0000000..c37a93b --- /dev/null +++ b/scenes/game.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scenes/game.gd" type="Script" id=1] + +[node name="Node" type="Node"] +script = ExtResource( 1 ) diff --git a/scenes/level_select.gd b/scenes/level_select.gd index 927af7c..598236b 100644 --- a/scenes/level_select.gd +++ b/scenes/level_select.gd @@ -59,5 +59,4 @@ func reload(): chapter_id += 1 -func onSurveyPressed(): - OS.shell_open("https://docs.google.com/forms/d/e/1FAIpQLSehHVcYfELT59h6plcn2ilbuqBcmDX3TH0qzB4jCgFIFOy_qg/viewform") + diff --git a/scenes/level_select.tscn b/scenes/level_select.tscn index 9b58dad..ff1e8b8 100644 --- a/scenes/level_select.tscn +++ b/scenes/level_select.tscn @@ -66,6 +66,7 @@ margin_right = 40.0 margin_bottom = 40.0 [node name="HelpLabel" type="Label" parent="."] +visible = false margin_left = 63.0 margin_top = 159.0 margin_right = 378.0 @@ -77,9 +78,9 @@ __meta__ = { } [node name="Button3" type="Button" parent="HelpLabel"] -margin_left = -1.0 +margin_left = -2.0 margin_top = 68.0 -margin_right = 314.0 +margin_right = 313.0 margin_bottom = 118.0 custom_styles/hover = SubResource( 1 ) custom_styles/focus = ExtResource( 3 ) diff --git a/scenes/survey.gd b/scenes/survey.gd new file mode 100644 index 0000000..7952543 --- /dev/null +++ b/scenes/survey.gd @@ -0,0 +1,14 @@ +extends Control + +func _ready(): + get_tree().set_auto_accept_quit(true) + +func quit(): + get_tree().quit() + +func levels(): + get_tree().change_scene("res://scenes/level_select.tscn") + + +func on_survey_pressed(): + game.open_survey() diff --git a/scenes/survey.tscn b/scenes/survey.tscn new file mode 100644 index 0000000..ae22153 --- /dev/null +++ b/scenes/survey.tscn @@ -0,0 +1,110 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://styles/theme.tres" type="Theme" id=1] +[ext_resource path="res://nodes/head.svg" type="Texture" id=2] +[ext_resource path="res://scenes/survey.gd" type="Script" id=3] +[ext_resource path="res://fonts/big.tres" type="DynamicFont" id=4] +[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5] +[ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=6] +[ext_resource path="res://styles/alert_button_hover.tres" type="StyleBox" id=7] + +[node name="Title" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +theme = ExtResource( 1 ) +script = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ColorRect" type="ColorRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +color = Color( 0, 0, 0, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_left = 854.463 +margin_top = 234.592 +margin_right = 1034.46 +margin_bottom = 290.592 +custom_fonts/font = ExtResource( 4 ) +text = "git-hydra" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label2" type="Label" parent="."] +margin_left = 774.698 +margin_top = 297.059 +margin_right = 1115.7 +margin_bottom = 353.059 +custom_fonts/font = ExtResource( 5 ) +custom_colors/font_color = Color( 0.533333, 0.392157, 0.392157, 1 ) +text = "by bleeptrack & blinry" +align = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="head" type="Sprite" parent="."] +position = Vector2( 946.624, 163.148 ) +texture = ExtResource( 2 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -175.997 +margin_top = -183.0 +margin_right = 175.997 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Button2" type="Button" parent="VBoxContainer"] +margin_right = 351.0 +margin_bottom = 39.0 +text = "Quit" + +[node name="VBoxContainer2" type="VBoxContainer" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -233.0 +margin_top = -175.0 +margin_right = 233.0 +margin_bottom = 175.0 +custom_constants/separation = 24 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="VBoxContainer2"] +margin_right = 466.0 +margin_bottom = 93.0 +text = "Thank you very much for playing! +Please help us improve git-hydra +by filling out this survey:" +align = 1 + +[node name="Button" type="Button" parent="VBoxContainer2"] +margin_top = 117.0 +margin_right = 466.0 +margin_bottom = 156.0 +focus_mode = 0 +custom_styles/hover = ExtResource( 7 ) +custom_styles/pressed = ExtResource( 7 ) +custom_styles/focus = ExtResource( 7 ) +custom_styles/normal = ExtResource( 6 ) +enabled_focus_mode = 0 +text = "To the survey /o/" +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="VBoxContainer/Button2" to="." method="quit"] +[connection signal="pressed" from="VBoxContainer2/Button" to="." method="on_survey_pressed"] diff --git a/scenes/title.gd b/scenes/title.gd index 2a724fe..b488785 100644 --- a/scenes/title.gd +++ b/scenes/title.gd @@ -8,3 +8,7 @@ func quit(): func levels(): get_tree().change_scene("res://scenes/level_select.tscn") + + +func on_survey_pressed(): + game.open_survey() diff --git a/styles/alert_button_hover.tres b/styles/alert_button_hover.tres new file mode 100644 index 0000000..e40aeb0 --- /dev/null +++ b/styles/alert_button_hover.tres @@ -0,0 +1,8 @@ +[gd_resource type="StyleBoxFlat" format=2] + +[resource] +bg_color = Color( 0.631373, 0.0745098, 0.0745098, 1 ) +corner_radius_top_left = 4 +corner_radius_top_right = 4 +corner_radius_bottom_right = 4 +corner_radius_bottom_left = 4