Skip to content

Commit

Permalink
Added a confirmation after selecting resign.
Browse files Browse the repository at this point in the history
  • Loading branch information
ra314 committed Sep 11, 2021
1 parent 2b14364 commit 9f83cd0
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 56 deletions.
166 changes: 111 additions & 55 deletions Scenes/Levels/Level Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -75,61 +75,6 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="Init Buttons" type="Control" parent="CanvasLayer"]
margin_right = 40.0
margin_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Start Game" type="Button" parent="CanvasLayer/Init Buttons"]
margin_left = 0.0701532
margin_top = 1012.03
margin_right = 298.07
margin_bottom = 1080.03
custom_fonts/font = ExtResource( 8 )
text = "Start Game"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Reroll Spawn" type="Button" parent="CanvasLayer/Init Buttons"]
margin_left = 0.0701532
margin_top = 932.034
margin_right = 341.07
margin_bottom = 1000.03
custom_fonts/font = ExtResource( 8 )
text = "Reroll Spawn"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Online" type="Control" parent="CanvasLayer/Init Buttons"]
margin_right = 40.0
margin_bottom = 40.0

[node name="Play Red" type="Button" parent="CanvasLayer/Init Buttons/Online"]
margin_left = 0.0701532
margin_top = 716.034
margin_right = 449.07
margin_bottom = 784.034
custom_fonts/font = ExtResource( 8 )
text = "Host plays as Red"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Play Blue" type="Button" parent="CanvasLayer/Init Buttons/Online"]
margin_left = 0.0701532
margin_top = 796.034
margin_right = 464.07
margin_bottom = 864.034
custom_fonts/font = ExtResource( 8 )
text = "Host plays as Blue"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Player and Round Tracker" type="Label" parent="CanvasLayer"]
margin_top = 119.0
margin_right = 40.0
Expand Down Expand Up @@ -190,6 +135,64 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="Init Buttons" type="Control" parent="CanvasLayer"]
margin_right = 40.0
margin_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Start Game" type="Button" parent="CanvasLayer/Init Buttons"]
margin_left = 0.0701532
margin_top = 1012.03
margin_right = 298.07
margin_bottom = 1080.03
custom_fonts/font = ExtResource( 8 )
text = "Start Game"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Reroll Spawn" type="Button" parent="CanvasLayer/Init Buttons"]
margin_left = 0.0701532
margin_top = 932.034
margin_right = 341.07
margin_bottom = 1000.03
custom_fonts/font = ExtResource( 8 )
text = "Reroll Spawn"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Online" type="Control" parent="CanvasLayer/Init Buttons"]
margin_right = 40.0
margin_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Play Red" type="Button" parent="CanvasLayer/Init Buttons/Online"]
margin_left = 0.0701532
margin_top = 716.034
margin_right = 449.07
margin_bottom = 784.034
custom_fonts/font = ExtResource( 8 )
text = "Host plays as Red"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Play Blue" type="Button" parent="CanvasLayer/Init Buttons/Online"]
margin_left = 0.0701532
margin_top = 796.034
margin_right = 464.07
margin_bottom = 864.034
custom_fonts/font = ExtResource( 8 )
text = "Host plays as Blue"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Win Screen" type="Control" parent="CanvasLayer"]
visible = false
margin_left = 1620.0
Expand Down Expand Up @@ -236,6 +239,59 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="Confirm Resign" type="CenterContainer" parent="CanvasLayer"]
visible = false
margin_right = 1920.0
margin_bottom = 1080.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Confirm Resign"]
margin_left = 551.0
margin_top = 473.0
margin_right = 1369.0
margin_bottom = 607.0

[node name="Label" type="Label" parent="CanvasLayer/Confirm Resign/VBoxContainer"]
margin_right = 818.0
margin_bottom = 62.0
custom_styles/normal = ExtResource( 13 )
custom_fonts/font = ExtResource( 8 )
text = "Are you sure you want to resign?"

[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer/Confirm Resign/VBoxContainer"]
margin_top = 66.0
margin_right = 818.0
margin_bottom = 134.0

[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/Confirm Resign/VBoxContainer/CenterContainer"]
margin_left = 316.0
margin_right = 502.0
margin_bottom = 68.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Yes" type="Button" parent="CanvasLayer/Confirm Resign/VBoxContainer/CenterContainer/HBoxContainer"]
margin_right = 98.0
margin_bottom = 68.0
custom_fonts/font = ExtResource( 8 )
text = "Yes"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="No" type="Button" parent="CanvasLayer/Confirm Resign/VBoxContainer/CenterContainer/HBoxContainer"]
margin_left = 102.0
margin_right = 186.0
margin_bottom = 68.0
custom_fonts/font = ExtResource( 8 )
text = "No"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Our World" type="Sprite" parent="."]
visible = false
scale = Vector2( 0.5, 0.5 )
Expand Down
12 changes: 11 additions & 1 deletion Scripts/Levels/Level Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ func _ready():
get_node("CanvasLayer/Help").connect("button_down", self, "show_help_menu")

# Button to resign game
get_node("CanvasLayer/Resign").connect("button_down", self, "resign")
get_node("CanvasLayer/Resign").connect("button_down", self, "show_resignation_menu")
get_node("CanvasLayer/Confirm Resign/VBoxContainer/CenterContainer/HBoxContainer/No").connect("button_down", self, "confirm_resign", [false])
get_node("CanvasLayer/Confirm Resign/VBoxContainer/CenterContainer/HBoxContainer/Yes").connect("button_down", self, "confirm_resign", [true])

func show_resignation_menu():
get_node("CanvasLayer/Confirm Resign").visible = true

func confirm_resign(confirmation_bool):
if confirmation_bool:
resign()
get_node("CanvasLayer/Confirm Resign").visible = false

func resign():
if _root.online_game:
Expand Down

0 comments on commit 9f83cd0

Please sign in to comment.