diff --git a/assets/sprites/rpi.png b/assets/sprites/rpi.png new file mode 100644 index 0000000..a0cc0aa Binary files /dev/null and b/assets/sprites/rpi.png differ diff --git a/assets/sprites/rpi.png.import b/assets/sprites/rpi.png.import new file mode 100644 index 0000000..8e8f67c --- /dev/null +++ b/assets/sprites/rpi.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://uritd4ygetrk" +path="res://.godot/imported/rpi.png-0f0faa9ccfa1d0b656d9c381bb4a7a6d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/rpi.png" +dest_files=["res://.godot/imported/rpi.png-0f0faa9ccfa1d0b656d9c381bb4a7a6d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/theme.tres b/assets/theme.tres new file mode 100644 index 0000000..ac89a53 --- /dev/null +++ b/assets/theme.tres @@ -0,0 +1,6 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://bbgxacei1vwba"] + +[ext_resource type="FontFile" uid="uid://c3jmev24lo6ci" path="res://assets/fonts/PixelOperator8.ttf" id="1_5x3i2"] + +[resource] +default_font = ExtResource("1_5x3i2") diff --git a/scenes/board_screen.tscn b/scenes/board_screen.tscn index ed6e0f9..da3faa5 100644 --- a/scenes/board_screen.tscn +++ b/scenes/board_screen.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=16 format=3 uid="uid://m542qwlp7hl7"] +[gd_scene load_steps=17 format=3 uid="uid://m542qwlp7hl7"] [ext_resource type="Script" uid="uid://dg5jt0o0r0v3r" path="res://scripts/BoardScreen.cs" id="1_b3w8x"] [ext_resource type="AudioStream" uid="uid://crxjuk1vyq331" path="res://assets/sfx/game_end.ogg" id="2_kseed"] [ext_resource type="Texture2D" uid="uid://dlx02qat7j6lf" path="res://assets/sprites/AssetTileset.png" id="3_1tlhv"] +[ext_resource type="Theme" uid="uid://bbgxacei1vwba" path="res://assets/theme.tres" id="3_3louw"] [ext_resource type="FontFile" uid="uid://c3jmev24lo6ci" path="res://assets/fonts/PixelOperator8.ttf" id="3_rjcmr"] [ext_resource type="Texture2D" uid="uid://ckmfi0cjgxgyk" path="res://assets/sprites/RedChip.png" id="4_1hrcj"] [ext_resource type="Texture2D" uid="uid://qy30emdgrk7o" path="res://assets/sprites/YellowChip.png" id="5_i2o8i"] @@ -36,6 +37,7 @@ region = Rect2(112, 32, 16, 16) [node name="BoardScreen" type="Node2D"] script = ExtResource("1_b3w8x") endingSfx = ExtResource("2_kseed") +theme = ExtResource("3_3louw") [node name="Floor Collider" type="StaticBody2D" parent="."] position = Vector2(0, 200) diff --git a/scenes/bracket_view.tscn b/scenes/bracket_view.tscn index 305c1b4..60368fc 100644 --- a/scenes/bracket_view.tscn +++ b/scenes/bracket_view.tscn @@ -1,10 +1,22 @@ -[gd_scene load_steps=5 format=3 uid="uid://rl33x81cxlh0"] +[gd_scene load_steps=8 format=3 uid="uid://rl33x81cxlh0"] +[ext_resource type="Theme" uid="uid://bbgxacei1vwba" path="res://assets/theme.tres" id="1_as653"] [ext_resource type="Script" uid="uid://dm25u0a2lqk2x" path="res://scripts/BracketScene.cs" id="1_dvj3m"] [ext_resource type="Texture2D" uid="uid://da13ksuf4vkqe" path="res://assets/sprites/observe.png" id="2_mbqc8"] [ext_resource type="Texture2D" uid="uid://stk7umv2ppss" path="res://assets/sprites/cancel.png" id="3_as653"] [ext_resource type="Script" uid="uid://1y72woiynf31" path="res://scripts/AdminControls.cs" id="4_mbqc8"] +[sub_resource type="Gradient" id="Gradient_wu84c"] +colors = PackedColorArray(0, 0.07058824, 0.101960786, 1, 0.39215687, 0.39215687, 0.39215687, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_as653"] +gradient = SubResource("Gradient_wu84c") +width = 1024 +height = 1024 +fill_from = Vector2(0.5, 1) +fill_to = Vector2(0.5, 0) +metadata/_snap_enabled = true + [node name="BracketView" type="Control" node_paths=PackedStringArray("Players", "Matches")] layout_mode = 3 anchors_preset = 15 @@ -12,12 +24,24 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_as653") script = ExtResource("1_dvj3m") Players = NodePath("HBoxContainer/PlayerList") Matches = NodePath("HBoxContainer/MatchList") WatchButton = ExtResource("2_mbqc8") TerminateKickButton = ExtResource("3_as653") +[node name="Background" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -152.0 +offset_bottom = 152.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_as653") + [node name="ColorRect" type="ColorRect" parent="."] custom_minimum_size = Vector2(0, 36) layout_mode = 1 @@ -26,7 +50,7 @@ anchor_right = 1.0 grow_horizontal = 2 color = Color(0.13319641, 0.13319641, 0.13319638, 1) -[node name="AdminControls" type="HBoxContainer" parent="ColorRect" node_paths=PackedStringArray("BecomeAdmin", "StartTournament", "Label", "Timeout")] +[node name="AdminControls" type="HBoxContainer" parent="ColorRect" node_paths=PackedStringArray("BecomeAdmin", "StartTournament", "CancelTournament", "Label", "Timeout")] custom_minimum_size = Vector2(0, 36) layout_mode = 1 anchors_preset = 10 @@ -36,6 +60,7 @@ grow_horizontal = 2 script = ExtResource("4_mbqc8") BecomeAdmin = NodePath("BecomeAdmin") StartTournament = NodePath("StartTournament") +CancelTournament = NodePath("CancelTournament") Label = NodePath("Label") Timeout = NodePath("HSlider") @@ -47,6 +72,10 @@ text = "Become Admin" layout_mode = 2 text = "Start Tournament" +[node name="CancelTournament" type="Button" parent="ColorRect/AdminControls"] +layout_mode = 2 +text = "Cancel Tournament" + [node name="Label" type="Label" parent="ColorRect/AdminControls"] layout_mode = 2 text = "Wait To Move: 5.0s " diff --git a/scenes/game.tscn b/scenes/game.tscn index 51279da..0b1f28f 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,10 +1,33 @@ -[gd_scene load_steps=3 format=3 uid="uid://cr8fi0e4r88s8"] +[gd_scene load_steps=5 format=3 uid="uid://cr8fi0e4r88s8"] [ext_resource type="PackedScene" uid="uid://cct663hb47yka" path="res://scenes/create_join_room.tscn" id="1_yqjtg"] [ext_resource type="PackedScene" uid="uid://m542qwlp7hl7" path="res://scenes/board_screen.tscn" id="2_lnu2h"] +[sub_resource type="Gradient" id="Gradient_wu84c"] +colors = PackedColorArray(0, 0.07058824, 0.101960786, 1, 0.39215687, 0.39215687, 0.39215687, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_yqjtg"] +gradient = SubResource("Gradient_wu84c") +width = 1024 +height = 1024 +fill_from = Vector2(0.5, 1) +fill_to = Vector2(0.5, 0) +metadata/_snap_enabled = true + [node name="Game" type="Node2D"] +[node name="Background" type="TextureRect" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -659.0 +offset_top = -558.0 +offset_right = 619.0 +offset_bottom = 466.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_yqjtg") + [node name="GameManager" type="Node" parent="."] [node name="Camera2D" type="Camera2D" parent="."] diff --git a/scenes/main_menu.tscn b/scenes/main_menu.tscn index 95ed999..74986d0 100644 --- a/scenes/main_menu.tscn +++ b/scenes/main_menu.tscn @@ -1,7 +1,20 @@ -[gd_scene load_steps=3 format=3 uid="uid://dcx5nvs0pa7me"] +[gd_scene load_steps=7 format=3 uid="uid://dcx5nvs0pa7me"] [ext_resource type="Script" uid="uid://bk22f71oximjk" path="res://scripts/AddressUI.cs" id="1_l6cm7"] +[ext_resource type="Theme" uid="uid://bbgxacei1vwba" path="res://assets/theme.tres" id="1_wu84c"] [ext_resource type="Script" uid="uid://cpjbiqn26khck" path="res://scripts/ConnectButtonUI.cs" id="2_ekxnf"] +[ext_resource type="Texture2D" uid="uid://uritd4ygetrk" path="res://assets/sprites/rpi.png" id="3_bqqt6"] + +[sub_resource type="Gradient" id="Gradient_wu84c"] +colors = PackedColorArray(0, 0.07058824, 0.101960786, 1, 0.39215687, 0.39215687, 0.39215687, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_yqjtg"] +gradient = SubResource("Gradient_wu84c") +width = 1024 +height = 1024 +fill_from = Vector2(0.5, 1) +fill_to = Vector2(0.5, 0) +metadata/_snap_enabled = true [node name="Control" type="Control"] layout_mode = 3 @@ -11,6 +24,63 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +[node name="Background" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_yqjtg") + +[node name="RPI Minds and Machines" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -193.5 +offset_top = 128.0 +offset_right = 193.5 +offset_bottom = 152.0 +grow_horizontal = 2 +theme = ExtResource("1_wu84c") +theme_type_variation = &"HeaderMedium" +text = "RPI Minds & Machines" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Connect" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -100.0 +offset_top = 200.0 +offset_right = 68.00122 +offset_bottom = 229.0 +grow_horizontal = 2 +theme = ExtResource("1_wu84c") +theme_type_variation = &"HeaderLarge" +theme_override_colors/font_outline_color = Color(0, 0, 0, 1) +theme_override_constants/outline_size = 16 +text = "Connect" + +[node name="4" type="Label" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = 78.0 +offset_top = 200.0 +offset_right = 118.00116 +offset_bottom = 229.0 +grow_horizontal = 2 +theme = ExtResource("1_wu84c") +theme_type_variation = &"HeaderLarge" +theme_override_colors/font_color = Color(1, 0, 0, 1) +theme_override_constants/outline_size = 16 +text = "4" + [node name="Address" type="TextEdit" parent="."] layout_mode = 1 anchors_preset = 8 @@ -24,10 +94,13 @@ offset_right = 250.0 offset_bottom = 20.0 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_wu84c") placeholder_text = "Server Address" +emoji_menu_enabled = false +scroll_smooth = true script = ExtResource("1_l6cm7") -[node name="Button" type="Button" parent="." node_paths=PackedStringArray("AddressUi", "ErrorLabel")] +[node name="Button" type="Button" parent="." node_paths=PackedStringArray("AddressField", "ErrorLabel")] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -40,9 +113,10 @@ offset_right = 250.0 offset_bottom = 67.25 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_wu84c") text = "Connect" script = ExtResource("2_ekxnf") -AddressUi = NodePath("../Address") +AddressField = NodePath("../Address") ErrorLabel = NodePath("../Label") [node name="Label" type="Label" parent="."] @@ -58,4 +132,17 @@ offset_right = 68.5 offset_bottom = 98.149994 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_wu84c") theme_override_colors/font_color = Color(1, 0, 0, 1) + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_left = 5.0 +offset_top = -69.0 +offset_right = 69.0 +offset_bottom = -5.0 +grow_vertical = 0 +texture = ExtResource("3_bqqt6") diff --git a/scripts/AdminControls.cs b/scripts/AdminControls.cs index 7fbd74f..db1129c 100644 --- a/scripts/AdminControls.cs +++ b/scripts/AdminControls.cs @@ -1,29 +1,31 @@ using Godot; -using System; -using System.Collections.Generic; public partial class AdminControls : HBoxContainer { [Export] public Button BecomeAdmin; [Export] public Button StartTournament; + [Export] public Button CancelTournament; [Export] public Label Label; [Export] public Slider Timeout; public override void _Ready() { Connection.Instance.OnBecomeAdmin += OnBecomeAdmin; - Connection.Instance.OnTournamentEnd += OnEndTournament; + Connection.Instance.OnTournamentEnd += _ => StartTournament.Show(); + Connection.Instance.OnStartTournamentAck += () => StartTournament.Hide(); - StartTournament.Pressed += StartTournamentCommand; - if (!Connection.Instance.IsAdmin || Connection.Instance.ActiveTournament) - { - StartTournament.Hide(); - } - + StartTournament.Pressed += () => Connection.Instance.StartTournament(); + CancelTournament.Pressed += () => Connection.Instance.CancelTournament(); if (!Connection.Instance.IsAdmin) { + StartTournament.Hide(); + CancelTournament.Hide(); Label.Hide(); Timeout.Hide(); + } + else if (Connection.Instance.ActiveTournament) + { + StartTournament.Hide(); } Timeout.Value = Connection.Instance.CurrentWaitTimeout; @@ -51,23 +53,12 @@ public partial class AdminControls : HBoxContainer public override void _ExitTree() { Connection.Instance.OnBecomeAdmin -= OnBecomeAdmin; - Connection.Instance.OnTournamentEnd -= OnEndTournament; - } - - private void StartTournamentCommand() - { - Connection.Instance.StartTournament(); - } - - private void OnEndTournament(List<(string, int)> playerScoreboard) - { - StartTournament.Show(); - ShowTournamentScoreboard(playerScoreboard); } private void ShowAuthPopup() { var authWindow = new Window(); + authWindow.Theme = GD.Load("res://assets/theme.tres"); authWindow.AlwaysOnTop = true; authWindow.MaximizeDisabled = true; authWindow.Unresizable = true; @@ -106,39 +97,6 @@ public partial class AdminControls : HBoxContainer GetTree().Root.AddChild(authWindow); } - private void ShowTournamentScoreboard(List<(string, int)> playerScoreboard) - { - var scoreboardWindow = new Window(); - scoreboardWindow.AlwaysOnTop = true; - scoreboardWindow.MaximizeDisabled = true; - scoreboardWindow.Unresizable = true; - scoreboardWindow.InitialPosition = Window.WindowInitialPosition.CenterMainWindowScreen; - scoreboardWindow.Size = new Vector2I(256, 512); - scoreboardWindow.CloseRequested += () => - { - GetTree().Root.RemoveChild(scoreboardWindow); - }; - - var tree = new Tree(); - tree.HideRoot = true; - tree.Columns = 2; - tree.ColumnTitlesVisible = true; - tree.SetColumnTitle(0, "Player"); - tree.SetColumnTitle(1, "Score"); - var root = tree.CreateItem(); - - foreach ((string, int) entry in playerScoreboard) - { - var item = tree.CreateItem(root); - item.SetText(0, entry.Item1); - item.SetText(1, entry.Item2.ToString()); - } - - scoreboardWindow.AddChild(tree); - - GetTree().Root.AddChild(scoreboardWindow); - } - private void OnBecomeAdmin() { BecomeAdmin.Hide(); @@ -146,6 +104,10 @@ public partial class AdminControls : HBoxContainer { StartTournament.Show(); } + else + { + CancelTournament.Show(); + } Label.Show(); Timeout.Show(); } diff --git a/scripts/BoardScreen.cs b/scripts/BoardScreen.cs index db8e3c6..2b1db82 100644 --- a/scripts/BoardScreen.cs +++ b/scripts/BoardScreen.cs @@ -1,5 +1,4 @@ using Godot; -using System; using System.Collections.Generic; using System.Linq; @@ -7,6 +6,7 @@ public partial class BoardScreen : Node2D { [Export] private AudioStream endingSfx; + [Export] private Theme theme; private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn"; private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn"; @@ -30,6 +30,10 @@ public partial class BoardScreen : Node2D private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left + private bool _lastMove = false; + private float _lastMoveTimer = 2.5f; + private string _winner = ""; + // Called when the node enters the scene tree for the first time. public override void _Ready() { // Node initialization @@ -62,11 +66,12 @@ public partial class BoardScreen : Node2D player2Card.GetNode