From 42035558fa81479d2414a68398357f2895d2b521 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Wed, 4 Feb 2026 09:47:06 -0500 Subject: [PATCH] misc: more formatting changes --- scripts/AddressUI.cs | 4 +- scripts/AdminControls.cs | 270 +++++++++++++++++-------------------- scripts/BackButton.cs | 6 +- scripts/BoardScreen.cs | 22 +-- scripts/BracketScene.cs | 14 +- scripts/ConnectButtonUI.cs | 11 +- scripts/Connection.cs | 98 ++++---------- scripts/PlayerData.cs | 12 +- scripts/TournamentType.cs | 3 +- 9 files changed, 179 insertions(+), 261 deletions(-) diff --git a/scripts/AddressUI.cs b/scripts/AddressUI.cs index b4775b6..6e0f1f3 100644 --- a/scripts/AddressUI.cs +++ b/scripts/AddressUI.cs @@ -2,7 +2,5 @@ using Godot; using System; public partial class AddressUI : TextEdit { - public override void _Ready() { - Text = Connection.WS_DEFAULT_ADDRESS; - } + public override void _Ready() { Text = Connection.WS_DEFAULT_ADDRESS; } } \ No newline at end of file diff --git a/scripts/AdminControls.cs b/scripts/AdminControls.cs index a1358f2..7f39d43 100644 --- a/scripts/AdminControls.cs +++ b/scripts/AdminControls.cs @@ -1,151 +1,133 @@ using Godot; -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 += UpdateUI; - Connection.Instance.OnTournamentEnd += UpdateUI; - Connection.Instance.OnStartTournament += UpdateUI; - Connection.Instance.OnCancelTournamentAck += UpdateUI; - Connection.Instance.OnGetDataAcks += UpdateUI; - Connection.Instance.OnSetDataAcks += UpdateUI; - - StartTournament.Pressed += () => Connection.Instance.StartTournament(); - CancelTournament.Pressed += () => Connection.Instance.CancelTournament(); - - UpdateUI(); - - Timeout.ValueChanged += value => - { - Connection.Instance.SetMoveWait((float)value); - var time = Connection.Instance.CurrentWaitTimeout.ToString(); - if (time.Length > 3) - { - time = time.Substring(0, 3); - } - Label.Text = "Wait To Move: " + time + "s "; - }; - - BecomeAdmin.Pressed += showAuthPopup; - } - - public override void _ExitTree() - { - Connection.Instance.OnBecomeAdmin -= UpdateUI; - Connection.Instance.OnTournamentEnd -= UpdateUI; - Connection.Instance.OnStartTournament -= UpdateUI; - Connection.Instance.OnCancelTournamentAck -= UpdateUI; - Connection.Instance.OnGetDataAcks -= UpdateUI; - Connection.Instance.OnSetDataAcks -= UpdateUI; - } +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; - private void UpdateUI() - { - if (!Connection.Instance.IsAdmin) - { - BecomeAdmin.Show(); - StartTournament.Hide(); - CancelTournament.Hide(); - Label.Hide(); - Timeout.Hide(); - } - else - { - BecomeAdmin.Hide(); - Label.Show(); - Timeout.Show(); - } + public override void _Ready() { + Connection.Instance.OnBecomeAdmin += UpdateUI; + Connection.Instance.OnTournamentEnd += UpdateUI; + Connection.Instance.OnStartTournament += UpdateUI; + Connection.Instance.OnCancelTournamentAck += UpdateUI; + Connection.Instance.OnGetDataAcks += UpdateUI; + Connection.Instance.OnSetDataAcks += UpdateUI; - if (Connection.Instance.IsAdmin && Connection.Instance.DemoMode) - { - StartTournament.Hide(); - CancelTournament.Hide(); - } - else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament != TournamentType.None) - { - StartTournament.Hide(); - CancelTournament.Show(); - } - else if (Connection.Instance.IsAdmin) - { - StartTournament.Show(); - CancelTournament.Hide(); - } + StartTournament.Pressed += () => Connection.Instance.StartTournament(); + CancelTournament.Pressed += () => Connection.Instance.CancelTournament(); - Timeout.Value = Connection.Instance.CurrentWaitTimeout; - var time = Connection.Instance.CurrentWaitTimeout.ToString(); - if (time.Length > 3) - { - time = time.Substring(0, 3); - } - - Label.Text = "Wait To Move: " + time + "s "; - } + UpdateUI(); - private void showAuthPopup() - { - var authWindow = new Window(); - authWindow.Theme = GD.Load("res://assets/theme.tres"); - authWindow.AlwaysOnTop = true; - authWindow.MaximizeDisabled = true; - authWindow.Unresizable = true; - authWindow.InitialPosition = Window.WindowInitialPosition.CenterMainWindowScreen; - authWindow.Size = new Vector2I(256, 128); - authWindow.CloseRequested += () => - { - GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); - }; - - var vbox = new VBoxContainer(); - vbox.LayoutMode = 1; - vbox.AnchorBottom = 1.0f; - vbox.AnchorRight = 1.0f; - vbox.GrowHorizontal = GrowDirection.Both; - vbox.GrowVertical = GrowDirection.Both; - vbox.Alignment = AlignmentMode.Center; - - var passwordBox = new TextEdit(); - passwordBox.PlaceholderText = "Password"; - passwordBox.SetCustomMinimumSize(new Vector2(32, 32)); - - passwordBox.GuiInput += e => - { - if (passwordBox.HasFocus() && e is InputEventKey inputEventKey && inputEventKey.IsPressed()) - { - if (inputEventKey.KeyLabel == Key.Enter) - { - Connection.Instance.AdminAuth(passwordBox.Text); - GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); - GetViewport().SetInputAsHandled(); - } + Timeout.ValueChanged += value => + { + Connection.Instance.SetMoveWait((float)value); + var time = Connection.Instance.CurrentWaitTimeout.ToString(); + if (time.Length > 3) { + time = time.Substring(0, 3); + } + Label.Text = "Wait To Move: " + time + "s "; + }; - if (inputEventKey.KeyLabel == Key.Space) - { - GetViewport().SetInputAsHandled(); - } - } - }; - - var button = new Button(); - button.Text = "Login"; - button.Pressed += () => - { - Connection.Instance.AdminAuth(passwordBox.Text); - GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); - }; - - vbox.AddChild(passwordBox); - vbox.AddChild(button); - - authWindow.AddChild(vbox); - - GetTree().Root.AddChild(authWindow); - } -} + BecomeAdmin.Pressed += showAuthPopup; + } + + public override void _ExitTree() { + Connection.Instance.OnBecomeAdmin -= UpdateUI; + Connection.Instance.OnTournamentEnd -= UpdateUI; + Connection.Instance.OnStartTournament -= UpdateUI; + Connection.Instance.OnCancelTournamentAck -= UpdateUI; + Connection.Instance.OnGetDataAcks -= UpdateUI; + Connection.Instance.OnSetDataAcks -= UpdateUI; + } + + private void UpdateUI() { + if (!Connection.Instance.IsAdmin) { + BecomeAdmin.Show(); + StartTournament.Hide(); + CancelTournament.Hide(); + Label.Hide(); + Timeout.Hide(); + } else { + BecomeAdmin.Hide(); + Label.Show(); + Timeout.Show(); + } + + if (Connection.Instance.IsAdmin && Connection.Instance.DemoMode) { + StartTournament.Hide(); + CancelTournament.Hide(); + } else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament != TournamentType.None) { + StartTournament.Hide(); + CancelTournament.Show(); + } else if (Connection.Instance.IsAdmin) { + StartTournament.Show(); + CancelTournament.Hide(); + } + + Timeout.Value = Connection.Instance.CurrentWaitTimeout; + var time = Connection.Instance.CurrentWaitTimeout.ToString(); + if (time.Length > 3) { + time = time.Substring(0, 3); + } + + Label.Text = "Wait To Move: " + time + "s "; + } + + private void showAuthPopup() { + var authWindow = new Window(); + authWindow.Theme = GD.Load("res://assets/theme.tres"); + authWindow.AlwaysOnTop = true; + authWindow.MaximizeDisabled = true; + authWindow.Unresizable = true; + authWindow.InitialPosition = Window.WindowInitialPosition.CenterMainWindowScreen; + authWindow.Size = new Vector2I(256, 128); + authWindow.CloseRequested += () => + { + GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); + }; + + var vbox = new VBoxContainer(); + vbox.LayoutMode = 1; + vbox.AnchorBottom = 1.0f; + vbox.AnchorRight = 1.0f; + vbox.GrowHorizontal = GrowDirection.Both; + vbox.GrowVertical = GrowDirection.Both; + vbox.Alignment = AlignmentMode.Center; + + var passwordBox = new TextEdit(); + passwordBox.PlaceholderText = "Password"; + passwordBox.SetCustomMinimumSize(new Vector2(32, 32)); + + passwordBox.GuiInput += e => + { + if (passwordBox.HasFocus() && e is InputEventKey inputEventKey && inputEventKey.IsPressed()) { + if (inputEventKey.KeyLabel == Key.Enter) { + Connection.Instance.AdminAuth(passwordBox.Text); + GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); + GetViewport().SetInputAsHandled(); + } + + if (inputEventKey.KeyLabel == Key.Space) { + GetViewport().SetInputAsHandled(); + } + } + }; + + var button = new Button(); + button.Text = "Login"; + button.Pressed += () => + { + Connection.Instance.AdminAuth(passwordBox.Text); + GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow); + }; + + vbox.AddChild(passwordBox); + vbox.AddChild(button); + + authWindow.AddChild(vbox); + + GetTree().Root.AddChild(authWindow); + } +} \ No newline at end of file diff --git a/scripts/BackButton.cs b/scripts/BackButton.cs index 0e88d01..8be710e 100644 --- a/scripts/BackButton.cs +++ b/scripts/BackButton.cs @@ -5,11 +5,9 @@ public partial class BackButton : TextureButton { private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn"; public override void _Pressed() { - TransitionToBracket(); + transitionToBracket(); base._Pressed(); } - private void TransitionToBracket() { - GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); - } + private void transitionToBracket() { GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); } } \ No newline at end of file diff --git a/scripts/BoardScreen.cs b/scripts/BoardScreen.cs index cae6ac5..d90804d 100644 --- a/scripts/BoardScreen.cs +++ b/scripts/BoardScreen.cs @@ -52,12 +52,10 @@ public partial class BoardScreen : Node2D { if (Connection.Instance.PreviousMoves.Count == 0) { player1Card.GetNode