From d688eaf9c6da235ca769f4c47b0e6ce0ef878a46 Mon Sep 17 00:00:00 2001 From: Sch1nken Date: Tue, 19 Mar 2024 23:16:29 +0100 Subject: [PATCH] Refactoring UI and Tile logic (to allow for Hotseat/LAN/Online multiplayer) --- Game.tscn | 2 + Globals/GameData.gd | 7 +- Globals/GameEvents.gd | 3 + InsectButton.gd | 34 ++++--- InsectTiles/InsectTile.tscn | 2 +- LANConnectMenu.gd | 67 +++++++++++++ LANConnectMenu.tscn | 119 +++++++++++++++++++++++ Multiplayer/Multiplayer.tscn | 2 - TestRot.gd | 31 ++++++ TestUI.gd | 27 ++++++ UI/Table/Table.gd | 16 ++++ UI/Table/Table.tscn | 33 +++++++ UI/Table/TableCell.tscn | 10 ++ UI/Table/TableRow.tscn | 24 +++++ main_menu.gd | 5 + main_menu.tscn | 50 +++++++++- testmenu.tscn | 176 +++++++++++++++++++++++++++++++++++ 17 files changed, 591 insertions(+), 17 deletions(-) create mode 100644 LANConnectMenu.gd create mode 100644 LANConnectMenu.tscn create mode 100644 TestRot.gd create mode 100644 TestUI.gd create mode 100644 UI/Table/Table.gd create mode 100644 UI/Table/Table.tscn create mode 100644 UI/Table/TableCell.tscn create mode 100644 UI/Table/TableRow.tscn create mode 100644 testmenu.tscn diff --git a/Game.tscn b/Game.tscn index 2a17381..8a13d20 100644 --- a/Game.tscn +++ b/Game.tscn @@ -282,4 +282,6 @@ horizontal_alignment = 1 layout_mode = 2 text = "Back to menu" +[node name="PauseMenu" type="CanvasLayer" parent="."] + [connection signal="pressed" from="GameOverMenu/Control/PanelContainer/VBoxContainer/Button" to="GameOverMenu" method="_on_button_pressed"] diff --git a/Globals/GameData.gd b/Globals/GameData.gd index b2562b5..6a7d5da 100644 --- a/Globals/GameData.gd +++ b/Globals/GameData.gd @@ -2,16 +2,21 @@ extends Node const WEBSOCKET_ENDPOINT: String = "wss://dev.bytesandpieces.xyz:9088" -var is_player_black: bool = true +var is_hot_seat: bool = false + +var is_player_black: bool = false var debug: bool = false var allow_selecting_in_stack: bool = false var lobby_code: String = "" var has_bee_been_placed: bool = false +var bees_placed: Dictionary = {} var disconnect_reason: String = "" func reset() -> void: + is_hot_seat = false has_bee_been_placed = false disconnect_reason = "" + bees_placed = {} diff --git a/Globals/GameEvents.gd b/Globals/GameEvents.gd index 85641d5..6b9a51e 100644 --- a/Globals/GameEvents.gd +++ b/Globals/GameEvents.gd @@ -20,3 +20,6 @@ signal turn_ended(turn_num, map) signal game_started signal game_over(black_lost, white_lost) + +# Menu +signal switch_to_menu(from, to) diff --git a/InsectButton.gd b/InsectButton.gd index 4a9a0f5..ede11b2 100644 --- a/InsectButton.gd +++ b/InsectButton.gd @@ -24,8 +24,8 @@ var is_blacks_turn: bool = false var should_disable: bool = false -func is_players_turn() -> bool: - return is_blacks_turn == GameData.is_player_black or GameData.debug +func is_players_turn() -> bool: + return is_blacks_turn == is_black or GameData.debug func update_color(_is_black: bool) -> void: is_black = _is_black @@ -37,7 +37,10 @@ func update_color(_is_black: bool) -> void: update_tile_count_display() insect_icon.texture = insect_resource.ui_texture - if is_black != GameData.is_player_black and not GameData.debug: + if GameData.is_hot_seat: + return + + if is_black != is_blacks_turn and not GameData.debug: disabled = true return @@ -110,8 +113,8 @@ func _ready() -> void: func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> void: is_blacks_turn = _is_blacks_turn should_disable = false - if turn_num >= 7 and not GameData.has_bee_been_placed: - if GameData.is_player_black == is_blacks_turn: + if turn_num >= 7 and not GameData.bees_placed.has(is_black): #has_bee_been_placed: + if is_black == is_blacks_turn: # if not bee has been placed for this player # lock all buttons except the bee if is_same(BEE, insect_resource): @@ -120,8 +123,7 @@ func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> voi else: #lock should_disable = true - - + refresh_state() func _on_insect_tile_deselected(tile: InsectTile) -> void: @@ -138,15 +140,16 @@ func _on_insect_selected(button: InsectButton, _is_black: bool) -> void: disable() func hover() -> void: - if GameData.is_player_black != is_black and not GameData.debug: - return + + #if is_blacks_turn != is_black and not GameData.debug: + # return var tween = get_tree().create_tween() tween.tween_property(hex, "position", Vector2(0, -16), 0.1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING) func unhover() -> void: - if GameData.is_player_black != is_black and not GameData.debug: - return + #if is_blacks_turn != is_black and not GameData.debug: + # return var tween = get_tree().create_tween() tween.tween_property(hex, "position", Vector2(0, 0), 0.25).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING) @@ -164,10 +167,17 @@ func _on_mouse_exited(): unhover() func _on_pressed(): + # We can only press under these conditions + # Check if its the currents player turn (is black) + # If hotseat: we're done + # If multiplayer: Check if GameData.is_player_black is correct, this prevents + # the other player from using this button on their game instance + + #GameData.is_hot_seat if is_empty(): return - if GameData.is_player_black != is_black and not GameData.debug: + if not is_blacks_turn == is_black and not GameData.debug: return if not is_players_turn(): diff --git a/InsectTiles/InsectTile.tscn b/InsectTiles/InsectTile.tscn index 5424783..5f35884 100644 --- a/InsectTiles/InsectTile.tscn +++ b/InsectTiles/InsectTile.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://c806afvtbie0n"] +[gd_scene load_steps=7 format=3 uid="uid://dxwngv0xmk3vy"] [ext_resource type="Script" path="res://Tile/Tile.gd" id="1_b68ym"] [ext_resource type="ArrayMesh" uid="uid://dsbshu53k588h" path="res://hexagon_small.res" id="2_vm00h"] diff --git a/LANConnectMenu.gd b/LANConnectMenu.gd new file mode 100644 index 0000000..039bbfd --- /dev/null +++ b/LANConnectMenu.gd @@ -0,0 +1,67 @@ +extends Control + +@onready var host_button: Button = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/HostButton +@onready var connect_button = $PanelContainer/MarginContainer/VBoxContainer/ConnectButton +@onready var stop_hosting_button = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/StopHostingButton + +@onready var ip_input = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/IPInput +@onready var port_input = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/PortInput +@onready var name_input = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/NameInput + +@onready var game_list = $PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/PanelContainer/GameList + +@onready var broadcast_timer = $BroadcastTimer + +var hosting: bool = false + +var send_socket: PacketPeerUDP = PacketPeerUDP.new() + +var server_socket: UDPServer = UDPServer.new() + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func update_buttons() -> void: + host_button.disabled = hosting or name_input.text.is_empty() + connect_button.disabled = hosting or name_input.text.is_empty() or ip_input.text.is_empty() or port_input.text.is_empty() + +func _on_line_edit_text_changed(new_text: String): + update_buttons() + +func _on_ip_input_text_changed(new_text): + update_buttons() + +func _on_port_input_text_changed(new_text): + update_buttons() + + +func _on_host_button_pressed(): + hosting = true + host_button.visible = false + stop_hosting_button.visible = true + broadcast_timer.start() + update_buttons() + + +func _on_stop_hosting_button_pressed(): + hosting = false + stop_hosting_button.visible = false + host_button.visible = true + broadcast_timer.stop() + update_buttons() + + +func _on_broadcast_timer_timeout(): + var send_socket = PacketPeerUDP.new() + send_socket.set_broadcast_enabled(true) + send_socket.set_dest_address("255.255.255.255", 27474) + + var dat = name_input.text.to_utf8_buffer() + + send_socket.put_packet(dat) diff --git a/LANConnectMenu.tscn b/LANConnectMenu.tscn new file mode 100644 index 0000000..41548d0 --- /dev/null +++ b/LANConnectMenu.tscn @@ -0,0 +1,119 @@ +[gd_scene load_steps=2 format=3 uid="uid://swe8j0gmisq5"] + +[ext_resource type="Script" path="res://LANConnectMenu.gd" id="1_bcuur"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_bcuur") + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -316.5 +offset_top = -84.0 +offset_right = 316.5 +offset_bottom = 84.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="HBoxContainer2" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +text = "Playername:" + +[node name="NameInput" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +theme_override_constants/minimum_character_width = 16 +placeholder_text = "Name" +max_length = 16 + +[node name="HostButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +disabled = true +text = "Host Game" + +[node name="StopHostingButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2"] +visible = false +layout_mode = 2 +text = "Stop Hosting" + +[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 200) +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 +vertical_scroll_mode = 2 + +[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="GameList" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/PanelContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="LobbyCodeLabel" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "IP-Address: " + +[node name="IPInput" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_constants/minimum_character_width = 15 +max_length = 32 +shortcut_keys_enabled = false + +[node name="LobbyCodePort" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Port: " + +[node name="PortInput" type="LineEdit" parent="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_constants/minimum_character_width = 15 +max_length = 32 +shortcut_keys_enabled = false + +[node name="ConnectButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +disabled = true +text = "Join Game" + +[node name="BackButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Back to menu" + +[node name="BroadcastTimer" type="Timer" parent="."] + +[connection signal="text_changed" from="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/NameInput" to="." method="_on_line_edit_text_changed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/HostButton" to="." method="_on_host_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/StopHostingButton" to="." method="_on_stop_hosting_button_pressed"] +[connection signal="text_changed" from="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/IPInput" to="." method="_on_ip_input_text_changed"] +[connection signal="text_changed" from="PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/PortInput" to="." method="_on_port_input_text_changed"] +[connection signal="timeout" from="BroadcastTimer" to="." method="_on_broadcast_timer_timeout"] diff --git a/Multiplayer/Multiplayer.tscn b/Multiplayer/Multiplayer.tscn index e7a6590..6667470 100644 --- a/Multiplayer/Multiplayer.tscn +++ b/Multiplayer/Multiplayer.tscn @@ -41,7 +41,5 @@ text = "Start Game" layout_mode = 2 text = "Back to menu" -[node name="PauseMenu" type="CanvasLayer" parent="."] - [connection signal="pressed" from="LobbyInfo/PanelContainer/VBoxContainer/StartGameButton" to="." method="_on_start_game_button_pressed"] [connection signal="pressed" from="LobbyInfo/PanelContainer/VBoxContainer/Button" to="LobbyInfo" method="_on_button_pressed"] diff --git a/TestRot.gd b/TestRot.gd new file mode 100644 index 0000000..09236ef --- /dev/null +++ b/TestRot.gd @@ -0,0 +1,31 @@ +extends Control + +@onready var current_menu: Control = $Level0Main/MainMenu + +@onready var level_2 = $Level2 + +# Called when the node enters the scene tree for the first time. +func _ready(): + GameEvents.switch_to_menu.connect(_on_switch_to_menu) + +func _on_switch_to_menu(from: Control, to: Control) -> void: + var level: int = to.get_parent().get_meta("level") + + var tween = get_tree().create_tween() + tween.set_parallel() + tween.tween_property(from, "modulate", Color(1.0, 1.0, 1.0, 0.0), 0.35).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(to, "modulate", Color(1.0, 1.0, 1.0, 1.0), 0.35).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(self, "rotation", - level * deg_to_rad(60.0), 0.75).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if Input.is_action_just_pressed("place_tile"): + GameEvents.switch_to_menu.emit(current_menu, $Level1/MultiplayerJoin) + + if Input.is_action_just_pressed("deselect_tile"): + GameEvents.switch_to_menu.emit($Level1/MultiplayerJoin, current_menu) + + #tween.tween_property(self, "rotation", rots[(rots.size()-1) - current_rot_index], 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO) + #current_rot_index = (rots.size()-1) - current_rot_index + #rotation += 2.0*PI / 6.0 + pass diff --git a/TestUI.gd b/TestUI.gd new file mode 100644 index 0000000..f37cbcd --- /dev/null +++ b/TestUI.gd @@ -0,0 +1,27 @@ +extends TextureButton + + + +# Called when the node enters the scene tree for the first time. +func _ready(): + #position.x = 500 + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_mouse_entered(): + var tween = get_tree().create_tween() + + tween.tween_property(self, "position:x", 64, 0.5) + + + + +func _on_mouse_exited(): + var tween = get_tree().create_tween() + + tween.tween_property(self, "position:x", 0, 0.5) diff --git a/UI/Table/Table.gd b/UI/Table/Table.gd new file mode 100644 index 0000000..49e223b --- /dev/null +++ b/UI/Table/Table.gd @@ -0,0 +1,16 @@ +extends Control + +func add_row(data: ) -> void: + pass + +func clear() -> void: + pass + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/UI/Table/Table.tscn b/UI/Table/Table.tscn new file mode 100644 index 0000000..1eef441 --- /dev/null +++ b/UI/Table/Table.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=3 format=3 uid="uid://sj0wiqp14xy3"] + +[ext_resource type="PackedScene" uid="uid://bxettgjh1rv56" path="res://UI/Table/TableRow.tscn" id="1_dfhso"] +[ext_resource type="Script" path="res://UI/Table/Table.gd" id="1_xdpje"] + +[node name="Table" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_xdpje") + +[node name="Rows" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TableRow" parent="Rows" instance=ExtResource("1_dfhso")] +layout_mode = 2 + +[node name="TableRow2" parent="Rows" instance=ExtResource("1_dfhso")] +layout_mode = 2 + +[node name="TableRow3" parent="Rows" instance=ExtResource("1_dfhso")] +layout_mode = 2 + +[node name="TableRow4" parent="Rows" instance=ExtResource("1_dfhso")] +layout_mode = 2 diff --git a/UI/Table/TableCell.tscn b/UI/Table/TableCell.tscn new file mode 100644 index 0000000..884d4f5 --- /dev/null +++ b/UI/Table/TableCell.tscn @@ -0,0 +1,10 @@ +[gd_scene format=3 uid="uid://q8sqr5lw2w1i"] + +[node name="TableCell" type="Label"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 diff --git a/UI/Table/TableRow.tscn b/UI/Table/TableRow.tscn new file mode 100644 index 0000000..b3389bf --- /dev/null +++ b/UI/Table/TableRow.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://bxettgjh1rv56"] + +[ext_resource type="PackedScene" uid="uid://q8sqr5lw2w1i" path="res://UI/Table/TableCell.tscn" id="1_e1426"] + +[node name="TableRow" type="HBoxContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="TableCell" parent="." instance=ExtResource("1_e1426")] +layout_mode = 2 +text = "Playername" + +[node name="TableCell2" parent="." instance=ExtResource("1_e1426")] +layout_mode = 2 +text = "255.255.255.255" + +[node name="TableCell3" parent="." instance=ExtResource("1_e1426")] +layout_mode = 2 +text = "65535" diff --git a/main_menu.gd b/main_menu.gd index f5df9f9..8c09806 100644 --- a/main_menu.gd +++ b/main_menu.gd @@ -1,7 +1,12 @@ extends Control +@onready var exit_button = $PanelContainer/MarginContainer/VBoxContainer/ExitButton + # Called when the node enters the scene tree for the first time. func _ready() -> void: + if OS.has_feature("web"): + exit_button.visible = false + WSClient.lobby_joined.connect(_on_lobby_joined) GameData.reset() diff --git a/main_menu.tscn b/main_menu.tscn index af51575..1ab5621 100644 --- a/main_menu.tscn +++ b/main_menu.tscn @@ -40,23 +40,66 @@ theme_override_constants/margin_bottom = 15 layout_mode = 2 theme_override_constants/separation = 15 +[node name="Label2" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Singleplayer" + [node name="HostButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Host Game" [node name="JoinButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Join Game" +[node name="SingleplayerButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +disabled = true +text = "Singleplayer" + +[node name="HSeparator2" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Multiplayer" + +[node name="LocalButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Local (Hotseat)" + +[node name="OnlineButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Online" + +[node name="LANButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +disabled = true +text = "LAN" + +[node name="HSeparator" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="SettingsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +disabled = true +text = "Settings" + +[node name="HSeparator3" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + [node name="RulesButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 -text = "Rules (Opens Web Browser)" +text = "Rules" [node name="ExitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 text = "Exit" [node name="DisconnectInfo" type="Control" parent="."] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -96,6 +139,11 @@ text = "Ok" [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/HostButton" to="." method="_on_host_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/JoinButton" to="." method="_on_join_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/SingleplayerButton" to="." method="_on_rules_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/LocalButton" to="." method="_on_rules_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/OnlineButton" to="." method="_on_rules_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/LANButton" to="." method="_on_rules_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/SettingsButton" to="." method="_on_rules_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/RulesButton" to="." method="_on_rules_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"] [connection signal="pressed" from="DisconnectInfo/PanelContainer/MarginContainer/VBoxContainer/Button" to="DisconnectInfo" method="_on_button_pressed"] diff --git a/testmenu.tscn b/testmenu.tscn new file mode 100644 index 0000000..770f75d --- /dev/null +++ b/testmenu.tscn @@ -0,0 +1,176 @@ +[gd_scene load_steps=3 format=3 uid="uid://c17svupm3ctqe"] + +[ext_resource type="Script" path="res://TestRot.gd" id="1_86fiq"] +[ext_resource type="Texture2D" uid="uid://d2i5vboeyq8qx" path="res://UI/hex_white.svg" id="1_hmexp"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Control" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +pivot_offset = Vector2(25.6, 25.6) +script = ExtResource("1_86fiq") + +[node name="CornerRect" type="Control" parent="Control"] +layout_mode = 1 +anchors_preset = 0 +offset_right = 64.0 +offset_bottom = 64.0 +scale = Vector2(0.1, 0.1) + +[node name="TextureRect" type="TextureRect" parent="Control/CornerRect"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +texture = ExtResource("1_hmexp") + +[node name="Level0Main" type="Control" parent="Control"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 +metadata/level = 0 + +[node name="MainMenu" type="Control" parent="Control/Level0Main"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Center" type="Control" parent="Control/Level0Main/MainMenu"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PanelContainer" type="PanelContainer" parent="Control/Level0Main/MainMenu/Center"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -125.5 +offset_top = -99.5 +offset_right = 125.5 +offset_bottom = 99.5 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Control/Level0Main/MainMenu/Center/PanelContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="VBoxContainer" type="VBoxContainer" parent="Control/Level0Main/MainMenu/Center/PanelContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="HostButton" type="Button" parent="Control/Level0Main/MainMenu/Center/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Host Game" + +[node name="JoinButton" type="Button" parent="Control/Level0Main/MainMenu/Center/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Join Game" + +[node name="RulesButton" type="Button" parent="Control/Level0Main/MainMenu/Center/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Rules (Opens Web Browser)" + +[node name="ExitButton" type="Button" parent="Control/Level0Main/MainMenu/Center/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Exit" + +[node name="Level1" type="Control" parent="Control"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +rotation = 1.0472 +metadata/level = 1 + +[node name="MultiplayerJoin" type="Control" parent="Control/Level1"] +modulate = Color(1, 1, 1, 0) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PanelContainer" type="PanelContainer" parent="Control/Level1/MultiplayerJoin"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -115.0 +offset_top = -76.5 +offset_right = 115.0 +offset_bottom = 76.5 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Control/Level1/MultiplayerJoin/PanelContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="VBoxContainer" type="VBoxContainer" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="HBoxContainer" type="HBoxContainer" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="LobbyCodeLabel" type="Label" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Lobby-Code: " + +[node name="LobbyCodeInput" type="LineEdit" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_override_constants/minimum_character_width = 6 +max_length = 6 +shortcut_keys_enabled = false + +[node name="ConnectButton" type="Button" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Connect" + +[node name="BackButton" type="Button" parent="Control/Level1/MultiplayerJoin/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Back to menu"