Skip to content

Commit

Permalink
Fixed rendering order by removing CanvasLayer from the CreationMenu
Browse files Browse the repository at this point in the history
Somehow having a CanvasLayer as parent is messing with the rendering order while the discord-rpc plugin is enabled.
See vaporvee/discord-rpc-godot#69
  • Loading branch information
Kesuaheli committed Sep 15, 2024
1 parent d3f5e2f commit 584eb39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
30 changes: 10 additions & 20 deletions scenes/menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,8 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_e6ve8")
theme_override_styles/focus = SubResource("StyleBoxFlat_sdl70")
text = "Quit Game"

[node name="RoundCreation" type="CanvasLayer" parent="."]
[node name="CreationMenu" type="Panel" parent="."]
visible = false

[node name="ColorRect" type="ColorRect" parent="RoundCreation"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.137255, 0.137255, 0.137255, 0.431373)

[node name="CreationMenu" type="Panel" parent="RoundCreation"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
Expand All @@ -146,7 +136,7 @@ grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_yhbp7")

[node name="ModeSelect" type="OptionButton" parent="RoundCreation/CreationMenu"]
[node name="ModeSelect" type="OptionButton" parent="CreationMenu"]
layout_mode = 1
offset_left = 40.0
offset_top = 100.0
Expand All @@ -155,15 +145,15 @@ offset_bottom = 140.0
theme = ExtResource("2_7ph5j")
theme_override_font_sizes/font_size = 40

[node name="Label" type="Label" parent="RoundCreation/CreationMenu/ModeSelect"]
[node name="Label" type="Label" parent="CreationMenu/ModeSelect"]
layout_mode = 1
offset_top = -40.0
offset_right = 120.0
theme = ExtResource("2_7ph5j")
text = "Game Mode"
vertical_alignment = 1

[node name="RoundDuration" type="SpinBox" parent="RoundCreation/CreationMenu"]
[node name="RoundDuration" type="SpinBox" parent="CreationMenu"]
layout_mode = 1
offset_left = 40.0
offset_top = 200.0
Expand All @@ -176,15 +166,15 @@ value = 30.0
suffix = "s"
custom_arrow_step = 5.0

[node name="Label" type="Label" parent="RoundCreation/CreationMenu/RoundDuration"]
[node name="Label" type="Label" parent="CreationMenu/RoundDuration"]
layout_mode = 1
offset_top = -40.0
offset_right = 160.0
theme = ExtResource("2_7ph5j")
text = "Round Duration"
vertical_alignment = 1

[node name="CategoryBox" type="Tree" parent="RoundCreation/CreationMenu"]
[node name="CategoryBox" type="Tree" parent="CreationMenu"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -209,7 +199,7 @@ columns = 2
column_titles_visible = true
hide_root = true

[node name="Cancel" type="Button" parent="RoundCreation/CreationMenu"]
[node name="Cancel" type="Button" parent="CreationMenu"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
Expand All @@ -228,7 +218,7 @@ theme_override_styles/hover = SubResource("StyleBoxFlat_v1l70")
theme_override_styles/pressed = SubResource("StyleBoxFlat_eb82c")
text = "Cancel"

[node name="Start" type="Button" parent="RoundCreation/CreationMenu"]
[node name="Start" type="Button" parent="CreationMenu"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
Expand All @@ -249,5 +239,5 @@ text = "Start Game"

[connection signal="pressed" from="Buttons/Play" to="." method="on_play_pressed"]
[connection signal="pressed" from="Buttons/Quit" to="." method="on_quit_pressed"]
[connection signal="pressed" from="RoundCreation/CreationMenu/Cancel" to="." method="on_cancel_pressed"]
[connection signal="pressed" from="RoundCreation/CreationMenu/Start" to="." method="on_btn_start_pressed"]
[connection signal="pressed" from="CreationMenu/Cancel" to="." method="on_cancel_pressed"]
[connection signal="pressed" from="CreationMenu/Start" to="." method="on_btn_start_pressed"]
20 changes: 10 additions & 10 deletions scripts/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const CATEGORY = preload("res://scenes/components/copy_category.tscn")

## ready is called when the node enters the scene tree for the first time.
func _ready():
$RoundCreation/CreationMenu/ModeSelect.add_item("Streamer VS Chat", 0)
$CreationMenu/ModeSelect.add_item("Streamer VS Chat", 0)
if (scene_manager.round_duration > 0):
round_duration = scene_manager.round_duration
$RoundCreation/CreationMenu/RoundDuration.value = round_duration
$CreationMenu/RoundDuration.value = round_duration
api.category(on_category_response)

var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox
var category_tree: Tree = $CreationMenu/CategoryBox
category_tree.create_item()
category_tree.set_column_title(0, "Category")
category_tree.set_column_title(1, "Amount")
Expand All @@ -28,7 +28,7 @@ func on_category_response(success: bool, categories: Dictionary = {}):

## update_category_list updates the category selection list with the given dictionary (mapping String to int).
func update_category_list(groups: Dictionary):
var category_tree: Tree = $RoundCreation/CreationMenu/CategoryBox
var category_tree: Tree = $CreationMenu/CategoryBox
var tree_root: TreeItem = category_tree.get_root()
print(groups)
for group_color in groups:
Expand Down Expand Up @@ -60,10 +60,10 @@ func update_category_list(groups: Dictionary):
## on_btn_start_pressed is called when pressed the start game button.
## It collects all the selected categories and creates a new game on the server.
func on_btn_start_pressed():
$RoundCreation/CreationMenu/Start.disabled = true
round_duration = $RoundCreation/CreationMenu/RoundDuration.value
$CreationMenu/Start.disabled = true
round_duration = $CreationMenu/RoundDuration.value
var groups: Dictionary = {}
var category: TreeItem = $RoundCreation/CreationMenu/CategoryBox.get_root().get_first_child()
var category: TreeItem = $CreationMenu/CategoryBox.get_root().get_first_child()
while category != null:
var amount: int = int(category.get_range(1))
if amount == 0:
Expand Down Expand Up @@ -94,17 +94,17 @@ func on_btn_start_pressed():
api.game_start(JSON.stringify(game_data), on_game_start_response)

func on_cancel_pressed():
$RoundCreation.hide()
$CreationMenu.hide()

func on_game_start_response(success: bool):
if !success:
print("failed to create new game!")
$RoundCreation/CreationMenu/Start.disabled = false
$CreationMenu/Start.disabled = false
return
scene_manager.change_scene(self, "question")

func on_play_pressed():
$RoundCreation.show()
$CreationMenu.show()

func on_quit_pressed():
get_tree().quit()
Expand Down

0 comments on commit 584eb39

Please sign in to comment.