From 1f1a3c0cb19b247e29f119eeb0c47ec750ad927c Mon Sep 17 00:00:00 2001 From: lodicolo Date: Sat, 3 Aug 2024 10:16:20 -0400 Subject: [PATCH] chore: cleanup formatting (#2369) --- .editorconfig | 6 + .../Interface/Game/Admin/AdminWindow.cs | 184 +++++++++++++----- .../Interface/Game/Admin/BanMuteBox.cs | 99 +++++++--- .../Interface/Game/AnnouncementWindow.cs | 2 +- .../Interface/Game/EventWindow.cs | 48 ++--- .../Interface/Menu/CreateCharacterWindow.cs | 49 ++--- .../Interface/Menu/CreditsWindow.cs | 14 +- .../Interface/Menu/LoginWindow.cs | 61 ++++-- .../Interface/Menu/RegistrationWindow.cs | 34 ++-- 9 files changed, 332 insertions(+), 165 deletions(-) diff --git a/.editorconfig b/.editorconfig index 98b70c5bfc..338fcaf3c1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -136,7 +136,13 @@ csharp_preserve_single_line_blocks = true csharp_style_namespace_declarations = file_scoped:silent # ReSharper properties +resharper_csharp_wrap_after_invocation_lpar = true +resharper_csharp_wrap_arguments_style = chop_if_long +resharper_csharp_wrap_before_invocation_rpar = true +resharper_keep_existing_invocation_parens_arrangement = false +resharper_max_invocation_arguments_on_line = 3 resharper_place_expr_property_on_single_line = true +resharper_place_simple_initializer_on_single_line = false resharper_trailing_comma_in_multiline_lists = true resharper_wrap_array_initializer_style = chop_if_long ############################### diff --git a/Intersect.Client/Interface/Game/Admin/AdminWindow.cs b/Intersect.Client/Interface/Game/Admin/AdminWindow.cs index 0f50343746..606fa62e6a 100644 --- a/Intersect.Client/Interface/Game/Admin/AdminWindow.cs +++ b/Intersect.Client/Interface/Game/Admin/AdminWindow.cs @@ -25,29 +25,43 @@ public partial class AdminWindow : WindowControl private readonly CheckBox _checkboxChronological; private TreeControl? _mapList; - public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, false, nameof(AdminWindow)) + public AdminWindow(Base gameCanvas) : base( + gameCanvas, + Strings.Admin.Title, + false, + nameof(AdminWindow) + ) { DisableResizing(); Margin = Margin.Zero; Padding = Padding.Zero; // Name label and textbox - _ = new Label(this, "LabelName") { Text = Strings.Admin.Name }; + _ = new Label(this, "LabelName") + { + Text = Strings.Admin.Name, + }; _textboxName = new TextBox(this, "TextboxName"); Interface.FocusElements.Add(_textboxName); // Access label, dropdown and set power button - _ = new Label(this, "LabelAccess") { Text = Strings.Admin.Access }; + _ = new Label(this, "LabelAccess") + { + Text = Strings.Admin.Access, + }; _dropdownAccess = new ComboBox(this, "DropdownAccess"); - _ = _dropdownAccess.AddItem(label: Strings.Admin.Access0, userData: "None"); - _ = _dropdownAccess.AddItem(label: Strings.Admin.Access1, userData: "Moderator"); - _ = _dropdownAccess.AddItem(label: Strings.Admin.Access2, userData: "Admin"); - var buttonSetPower = new Button(this, "ButtonSetPower") { Text = Strings.Admin.SetPower }; + _ = _dropdownAccess.AddItem(Strings.Admin.Access0, userData: "None"); + _ = _dropdownAccess.AddItem(Strings.Admin.Access1, userData: "Moderator"); + _ = _dropdownAccess.AddItem(Strings.Admin.Access2, userData: "Admin"); + var buttonSetPower = new Button(this, "ButtonSetPower") + { + Text = Strings.Admin.SetPower, + }; buttonSetPower.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) { - string? power = _dropdownAccess.SelectedItem.UserData.ToString(); + var power = _dropdownAccess.SelectedItem.UserData.ToString(); if (!string.IsNullOrEmpty(power) && power.Trim().Length > 0) { PacketSender.SendAdminAction(new SetAccessAction(_textboxName.Text, power)); @@ -56,8 +70,12 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; #region Quick Admin Actions + // Warp to me admin action - var buttonWarpToMe = new Button(this, "ButtonWarpToMe") { Text = Strings.Admin.Warp2Me }; + var buttonWarpToMe = new Button(this, "ButtonWarpToMe") + { + Text = Strings.Admin.Warp2Me, + }; buttonWarpToMe.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -67,7 +85,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; // Warp to player admin action - var buttonWarpMeTo = new Button(this, "ButtonWarpMeTo") { Text = Strings.Admin.WarpMe2 }; + var buttonWarpMeTo = new Button(this, "ButtonWarpMeTo") + { + Text = Strings.Admin.WarpMe2, + }; buttonWarpMeTo.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -77,7 +98,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; // Warp to overworld admin action - var buttonOverworldReturn = new Button(this, "ButtonOverworldReturn") { Text = Strings.Admin.OverworldReturn }; + var buttonOverworldReturn = new Button(this, "ButtonOverworldReturn") + { + Text = Strings.Admin.OverworldReturn, + }; buttonOverworldReturn.Clicked += (s, e) => { if (!string.IsNullOrEmpty(_textboxName.Text)) @@ -87,7 +111,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; // Kick player admin action - var buttonKick = new Button(this, "ButtonKick") { Text = Strings.Admin.Kick }; + var buttonKick = new Button(this, "ButtonKick") + { + Text = Strings.Admin.Kick, + }; buttonKick.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -97,7 +124,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; // Kill player admin action - var buttonKill = new Button(this, "ButtonKill") { Text = Strings.Admin.Kill }; + var buttonKill = new Button(this, "ButtonKill") + { + Text = Strings.Admin.Kill, + }; buttonKill.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -107,45 +137,62 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals }; // Ban and Unban player admin actions - var buttonBan = new Button(this, "ButtonBan") { Text = Strings.Admin.Ban }; + var buttonBan = new Button(this, "ButtonBan") + { + Text = Strings.Admin.Ban, + }; buttonBan.Clicked += banButton_Clicked; - var buttonUnban = new Button(this, "ButtonUnban") { Text = Strings.Admin.Unban }; + var buttonUnban = new Button(this, "ButtonUnban") + { + Text = Strings.Admin.Unban, + }; buttonUnban.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) { _ = new InputBox( - title: Strings.Admin.UnbanCaption.ToString(_textboxName.Text), - prompt: Strings.Admin.UnbanPrompt.ToString(_textboxName.Text), - inputType: InputBox.InputType.YesNo, - onSuccess: (s, e) => PacketSender.SendAdminAction(new UnbanAction(_textboxName.Text)) + Strings.Admin.UnbanCaption.ToString(_textboxName.Text), + Strings.Admin.UnbanPrompt.ToString(_textboxName.Text), + InputBox.InputType.YesNo, + (s, e) => PacketSender.SendAdminAction(new UnbanAction(_textboxName.Text)) ); } }; // Mute and Unmute player admin actions - var buttonMute = new Button(this, "ButtonMute") { Text = Strings.Admin.Mute }; + var buttonMute = new Button(this, "ButtonMute") + { + Text = Strings.Admin.Mute, + }; buttonMute.Clicked += muteButton_Clicked; - var buttonUnmute = new Button(this, "ButtonUnmute") { Text = Strings.Admin.Unmute }; + var buttonUnmute = new Button(this, "ButtonUnmute") + { + Text = Strings.Admin.Unmute, + }; buttonUnmute.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) { _ = new InputBox( - title: Strings.Admin.UnmuteCaption.ToString(_textboxName.Text), - prompt: Strings.Admin.UnmutePrompt.ToString(_textboxName.Text), - inputType: InputBox.InputType.YesNo, - onSuccess: (s, e) => PacketSender.SendAdminAction(new UnmuteAction(_textboxName.Text)) + Strings.Admin.UnmuteCaption.ToString(_textboxName.Text), + Strings.Admin.UnmutePrompt.ToString(_textboxName.Text), + InputBox.InputType.YesNo, + (s, e) => PacketSender.SendAdminAction(new UnmuteAction(_textboxName.Text)) ); } }; + #endregion Quick Admin Actions #region Change Player Sprite and Face + // Change player sprite admin action - _ = new Label(this, "LabelSprite") { Text = Strings.Admin.Sprite }; + _ = new Label(this, "LabelSprite") + { + Text = Strings.Admin.Sprite, + }; _dropdownSprite = new ComboBox(this, "DropdownSprite"); _ = _dropdownSprite.AddItem(Strings.Admin.None); _dropdownSprite.ItemSelected += _dropdownSprite_ItemSelected; @@ -157,7 +204,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals _ = _dropdownSprite.AddItem(sprite); } - var buttonSetSprite = new Button(this, "ButtonSetSprite") { Text = Strings.Admin.SetSprite }; + var buttonSetSprite = new Button(this, "ButtonSetSprite") + { + Text = Strings.Admin.SetSprite, + }; buttonSetSprite.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -170,7 +220,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals _spritePanel = new ImagePanel(panelSprite); // Change player face admin action - _ = new Label(this, "LabelFace") { Text = Strings.Admin.Face }; + _ = new Label(this, "LabelFace") + { + Text = Strings.Admin.Face, + }; _dropdownFace = new ComboBox(this, "DropdownFace"); _ = _dropdownFace.AddItem(Strings.Admin.None); _dropdownFace.ItemSelected += _dropdownFace_ItemSelected; @@ -182,7 +235,10 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals _ = _dropdownFace.AddItem(face); } - var buttonSetFace = new Button(this, "ButtonSetFace") { Text = Strings.Admin.SetFace }; + var buttonSetFace = new Button(this, "ButtonSetFace") + { + Text = Strings.Admin.SetFace, + }; buttonSetFace.Clicked += (s, e) => { if (_textboxName.Text.Trim().Length > 0) @@ -197,17 +253,26 @@ public AdminWindow(Base gameCanvas) : base(gameCanvas, Strings.Admin.Title, fals #endregion Change Player Sprite and Face // Map list - _ = new Label(this, "LabelMapList") { Text = Strings.Admin.MapList }; + _ = new Label(this, "LabelMapList") + { + Text = Strings.Admin.MapList, + }; _checkboxChronological = new CheckBox(this, "CheckboxChronological"); _checkboxChronological.SetToolTipText(Strings.Admin.ChronologicalTip); _checkboxChronological.CheckChanged += (s, e) => UpdateMapList(); - _ = new Label(this, "LabelChronological") { Text = Strings.Admin.Chronological }; + _ = new Label(this, "LabelChronological") + { + Text = Strings.Admin.Chronological, + }; LoadJsonUi(UI.InGame, Graphics.Renderer?.GetResolutionString(), true); UpdateMapList(); } - public void SetName(string name) => _textboxName.Text = name; + public void SetName(string name) + { + _textboxName.Text = name; + } private void UpdateMapList() { @@ -218,8 +283,13 @@ private void UpdateMapList() Y = 330, Width = Width - 8, Height = 80, - RenderColor = Color.FromArgb(255, 255, 255, 255), - MaximumSize = new Point(4096, 999999) + RenderColor = Color.FromArgb( + 255, + 255, + 255, + 255 + ), + MaximumSize = new Point(4096, 999999), }; AddMapListToTree(MapList.List, null); @@ -266,6 +336,7 @@ private void AddMapListToTree(MapList mapList, TreeNode? parent) } #region Action Handlers + private void banButton_Clicked(Base sender, ClickedEventArgs arguments) { if (string.IsNullOrWhiteSpace(_textboxName.Text)) @@ -280,16 +351,16 @@ private void banButton_Clicked(Base sender, ClickedEventArgs arguments) } _banOrMuteWindow = new BanMuteBox( - title: Strings.Admin.BanCaption.ToString(name), - prompt: Strings.Admin.BanPrompt.ToString(_textboxName.Text), - okayHandler: (s, e) => + Strings.Admin.BanCaption.ToString(name), + Strings.Admin.BanPrompt.ToString(_textboxName.Text), + (s, e) => { PacketSender.SendAdminAction( new BanAction( - name: _textboxName.Text, - durationDays: _banOrMuteWindow?.GetDuration() ?? 0, - reason: _banOrMuteWindow?.GetReason() ?? string.Empty, - banIp: _banOrMuteWindow?.BanIp() ?? false + _textboxName.Text, + _banOrMuteWindow?.GetDuration() ?? 0, + _banOrMuteWindow?.GetReason() ?? string.Empty, + _banOrMuteWindow?.BanIp() ?? false ) ); @@ -312,16 +383,16 @@ private void muteButton_Clicked(Base sender, ClickedEventArgs arguments) } _banOrMuteWindow = new BanMuteBox( - title: Strings.Admin.MuteCaption.ToString(name), - prompt: Strings.Admin.MutePrompt.ToString(_textboxName.Text), - okayHandler: (s, e) => + Strings.Admin.MuteCaption.ToString(name), + Strings.Admin.MutePrompt.ToString(_textboxName.Text), + (s, e) => { PacketSender.SendAdminAction( new MuteAction( - name: _textboxName.Text, - durationDays: _banOrMuteWindow?.GetDuration() ?? 0, - reason: _banOrMuteWindow?.GetReason() ?? string.Empty, - banIp: _banOrMuteWindow?.BanIp() ?? false + _textboxName.Text, + _banOrMuteWindow?.GetDuration() ?? 0, + _banOrMuteWindow?.GetReason() ?? string.Empty, + _banOrMuteWindow?.BanIp() ?? false ) ); @@ -341,7 +412,12 @@ private void _dropdownSprite_ItemSelected(Base sender, ItemSelectedEventArgs arg var textFrameWidth = _spritePanel.Texture.Width / Options.Instance.Sprites.NormalFrames; var textFrameHeight = _spritePanel.Texture.Height / Options.Instance.Sprites.Directions; - _spritePanel.SetTextureRect(0, 0, textFrameWidth, textFrameHeight); + _spritePanel.SetTextureRect( + 0, + 0, + textFrameWidth, + textFrameHeight + ); _ = _spritePanel.SetSize(Math.Min(textFrameWidth, 46), Math.Min(textFrameHeight, 46)); Align.Center(_spritePanel); } @@ -357,7 +433,12 @@ private void _dropdownFace_ItemSelected(Base sender, ItemSelectedEventArgs argum var textFrameWidth = _facePanel.Texture.Width; var textFrameHeight = _facePanel.Texture.Height; - _facePanel.SetTextureRect(0, 0, textFrameWidth, textFrameHeight); + _facePanel.SetTextureRect( + 0, + 0, + textFrameWidth, + textFrameHeight + ); _ = _facePanel.SetSize(Math.Min(textFrameWidth, 46), Math.Min(textFrameHeight, 46)); Align.Center(_facePanel); } @@ -369,5 +450,6 @@ private void tmpNode_Clicked(Base sender, ClickedEventArgs arguments) PacketSender.SendAdminAction(new WarpToMapAction(mapId)); } } + #endregion -} +} \ No newline at end of file diff --git a/Intersect.Client/Interface/Game/Admin/BanMuteBox.cs b/Intersect.Client/Interface/Game/Admin/BanMuteBox.cs index 18b46e832c..e3e88f5378 100644 --- a/Intersect.Client/Interface/Game/Admin/BanMuteBox.cs +++ b/Intersect.Client/Interface/Game/Admin/BanMuteBox.cs @@ -13,21 +13,50 @@ public partial class BanMuteBox : WindowControl private readonly Dictionary _dayCount = new() { - { Strings.BanMute.OneDay, 1 }, - { Strings.BanMute.TwoDays, 2 }, - { Strings.BanMute.ThreeDays, 3 }, - { Strings.BanMute.FourDays, 4 }, - { Strings.BanMute.FiveDays, 5 }, - { Strings.BanMute.OneWeek, 7 }, - { Strings.BanMute.TwoWeeks, 14 }, - { Strings.BanMute.OneMonth, 30 }, - { Strings.BanMute.TwoMonths, 60 }, - { Strings.BanMute.SixMonths, 180 }, - { Strings.BanMute.OneYear, 365 }, - { Strings.BanMute.Forever, 999999 } + { + Strings.BanMute.OneDay, 1 + }, + { + Strings.BanMute.TwoDays, 2 + }, + { + Strings.BanMute.ThreeDays, 3 + }, + { + Strings.BanMute.FourDays, 4 + }, + { + Strings.BanMute.FiveDays, 5 + }, + { + Strings.BanMute.OneWeek, 7 + }, + { + Strings.BanMute.TwoWeeks, 14 + }, + { + Strings.BanMute.OneMonth, 30 + }, + { + Strings.BanMute.TwoMonths, 60 + }, + { + Strings.BanMute.SixMonths, 180 + }, + { + Strings.BanMute.OneYear, 365 + }, + { + Strings.BanMute.Forever, 999999 + }, }; - public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base(Interface.GameUi.GameCanvas, title, true, "BanMuteWindow") + public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base( + Interface.GameUi.GameCanvas, + title, + true, + "BanMuteWindow" + ) { DisableResizing(); Interface.InputBlockingElements.Add(this); @@ -38,34 +67,49 @@ public BanMuteBox(string title, string prompt, EventHandler okayHandler) : base( var richLabelPrompt = new RichLabel(promptContainer); // Reason label - _ = new Label(this, "LabelReason") { Text = Strings.BanMute.Reason }; + _ = new Label(this, "LabelReason") + { + Text = Strings.BanMute.Reason, + }; // Reason textbox _textboxReason = new TextBox(this, "TextboxReason"); Interface.FocusElements.Add(_textboxReason); // Duration label - _ = new Label(this, "LabelDuration") { Text = Strings.BanMute.Duration }; + _ = new Label(this, "LabelDuration") + { + Text = Strings.BanMute.Duration, + }; // Duration combobox _comboboxDuration = new ComboBox(this, "ComboBoxDuration"); foreach (var day in _dayCount) { - _ = _comboboxDuration.AddItem(label: day.Key, userData: day.Value); + _ = _comboboxDuration.AddItem(day.Key, userData: day.Value); } // Include IP checkbox - _checkboxIP = new LabeledCheckBox(this, "CheckboxIp") { Text = Strings.BanMute.IncludeIp }; + _checkboxIP = new LabeledCheckBox(this, "CheckboxIp") + { + Text = Strings.BanMute.IncludeIp, + }; // Ok and Cancel buttons - var buttonOkay = new Button(this, "ButtonOkay") { Text = Strings.BanMute.Okay }; + var buttonOkay = new Button(this, "ButtonOkay") + { + Text = Strings.BanMute.Okay, + }; buttonOkay.Clicked += (s, e) => { okayHandler?.Invoke(this, EventArgs.Empty); Dispose(); }; - var buttonCancel = new Button(this, "ButtonCancel") { Text = Strings.BanMute.Cancel }; + var buttonCancel = new Button(this, "ButtonCancel") + { + Text = Strings.BanMute.Cancel, + }; buttonCancel.Clicked += (s, e) => Dispose(); LoadJsonUi(UI.InGame, Graphics.Renderer?.GetResolutionString(), true); @@ -84,9 +128,18 @@ public override void Dispose() GC.SuppressFinalize(this); } - public int GetDuration() => (int)_comboboxDuration.SelectedItem.UserData; + public int GetDuration() + { + return (int)_comboboxDuration.SelectedItem.UserData; + } - public string GetReason() => _textboxReason.Text; + public string GetReason() + { + return _textboxReason.Text; + } - public bool BanIp() => _checkboxIP.IsChecked; -} + public bool BanIp() + { + return _checkboxIP.IsChecked; + } +} \ No newline at end of file diff --git a/Intersect.Client/Interface/Game/AnnouncementWindow.cs b/Intersect.Client/Interface/Game/AnnouncementWindow.cs index 99f7fc66d3..0ceb324c08 100644 --- a/Intersect.Client/Interface/Game/AnnouncementWindow.cs +++ b/Intersect.Client/Interface/Game/AnnouncementWindow.cs @@ -27,7 +27,7 @@ public AnnouncementWindow(Canvas gameCanvas) : base(gameCanvas, nameof(Announcem } /// - /// Update this control.. + /// Update this control... /// public void Update() { diff --git a/Intersect.Client/Interface/Game/EventWindow.cs b/Intersect.Client/Interface/Game/EventWindow.cs index f8c04b073e..b456ffd43b 100644 --- a/Intersect.Client/Interface/Game/EventWindow.cs +++ b/Intersect.Client/Interface/Game/EventWindow.cs @@ -32,11 +32,11 @@ public partial class EventWindow : ImagePanel private bool _isTypewriting = false; private readonly long _typewriterResponseDelay = ClientConfiguration.Instance.TypewriterResponseDelay; - private Dialog _currentDialog => Globals.EventDialogs[0]; - private bool _hasOneOption => _currentDialog.Opt1.Length > 0; - private bool _hasTwoOptions => _currentDialog.Opt2.Length > 0; - private bool _hasThreeOptions => _currentDialog.Opt3.Length > 0; - private bool _hasFourOptions => _currentDialog.Opt4.Length > 0; + private static Dialog CurrentDialog => Globals.EventDialogs[0]; + private static bool HasOneOption => CurrentDialog.Opt1.Length > 0; + private static bool HasTwoOptions => CurrentDialog.Opt2.Length > 0; + private static bool HasThreeOptions => CurrentDialog.Opt3.Length > 0; + private static bool HasFourOptions => CurrentDialog.Opt4.Length > 0; public EventWindow(Canvas gameCanvas) : base(gameCanvas, nameof(EventWindow)) { @@ -94,9 +94,9 @@ public void Update() // Always show option 1 ("continue" if options empty) _buttonEventResponse1.IsHidden = !_writer.IsDone; - _buttonEventResponse2.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(_currentDialog.Opt2); - _buttonEventResponse3.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(_currentDialog.Opt3); - _buttonEventResponse4.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(_currentDialog.Opt4); + _buttonEventResponse2.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(CurrentDialog.Opt2); + _buttonEventResponse3.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(CurrentDialog.Opt3); + _buttonEventResponse4.IsHidden = !_writer.IsDone || string.IsNullOrEmpty(CurrentDialog.Opt4); _writer.Write(ClientConfiguration.Instance.TypewriterSounds.ElementAtOrDefault(voiceIdx)); if (_writer.IsDone) @@ -124,24 +124,24 @@ public void Update() var responseCount = 0; var maxResponse = 1; - if (_hasOneOption) + if (HasOneOption) { responseCount++; } - if (_hasTwoOptions) + if (HasTwoOptions) { responseCount++; maxResponse++; } - if (_hasThreeOptions) + if (HasThreeOptions) { responseCount++; maxResponse++; } - if (_hasFourOptions) + if (HasFourOptions) { responseCount++; maxResponse++; @@ -152,7 +152,7 @@ public void Update() Name = $"EventDialogWindow_{maxResponse}Response{(maxResponse == 1 ? string.Empty : 's')}"; LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer?.GetResolutionString()); - var faceTex = Globals.ContentManager.GetTexture(TextureType.Face, _currentDialog.Face); + var faceTex = Globals.ContentManager.GetTexture(TextureType.Face, CurrentDialog.Face); _panelEventFace.Texture = faceTex; _panelEventFace.IsHidden = faceTex == null; _areaEventDialog.IsHidden = faceTex == null; @@ -168,23 +168,23 @@ public void Update() } else { - _buttonEventResponse1.IsHidden = !_hasOneOption; - _buttonEventResponse1.SetText(_currentDialog.Opt1); - _buttonEventResponse2.IsHidden = !_hasTwoOptions; - _buttonEventResponse2.SetText(_currentDialog.Opt2); - _buttonEventResponse3.IsHidden = !_hasThreeOptions; - _buttonEventResponse3.SetText(_currentDialog.Opt3); - _buttonEventResponse4.IsHidden = !_hasFourOptions; - _buttonEventResponse4.SetText(_currentDialog.Opt4); + _buttonEventResponse1.IsHidden = !HasOneOption; + _buttonEventResponse1.SetText(CurrentDialog.Opt1); + _buttonEventResponse2.IsHidden = !HasTwoOptions; + _buttonEventResponse2.SetText(CurrentDialog.Opt2); + _buttonEventResponse3.IsHidden = !HasThreeOptions; + _buttonEventResponse3.SetText(CurrentDialog.Opt3); + _buttonEventResponse4.IsHidden = !HasFourOptions; + _buttonEventResponse4.SetText(CurrentDialog.Opt4); } if (faceTex != null) { - ShowDialog(_richLabelEventDialog, _labelEventDialog, _areaEventDialog, _currentDialog.Prompt); + ShowDialog(_richLabelEventDialog, _labelEventDialog, _areaEventDialog, CurrentDialog.Prompt); } else { - ShowDialog(_richLabelEventDialogNoFace, _labelEventDialogNoFace, _areaEventDialogNoFace, _currentDialog.Prompt); + ShowDialog(_richLabelEventDialogNoFace, _labelEventDialogNoFace, _areaEventDialogNoFace, CurrentDialog.Prompt); } } @@ -223,7 +223,7 @@ public void CloseEventResponse(EventResponseType response) return; }; - var eventDialog = _currentDialog; + var eventDialog = CurrentDialog; if (eventDialog.ResponseSent != 0) { return; diff --git a/Intersect.Client/Interface/Menu/CreateCharacterWindow.cs b/Intersect.Client/Interface/Menu/CreateCharacterWindow.cs index d58a574440..7a1c3befda 100644 --- a/Intersect.Client/Interface/Menu/CreateCharacterWindow.cs +++ b/Intersect.Client/Interface/Menu/CreateCharacterWindow.cs @@ -8,6 +8,7 @@ using Intersect.Client.Localization; using Intersect.Client.Networking; using Intersect.GameObjects; +using Intersect.Logging; using Intersect.Utilities; namespace Intersect.Client.Interface.Menu; @@ -54,29 +55,29 @@ public CreateCharacterWindow(Canvas parent, MainMenu mainMenu, SelectCharacterWi }; // Character Name Background - var _charNameBackground = new ImagePanel(this, "CharacterNamePanel"); + var charNameBackground = new ImagePanel(this, "CharacterNamePanel"); // Character Name Label - _ = new Label(_charNameBackground, "CharacterNameLabel") + _ = new Label(charNameBackground, "CharacterNameLabel") { Text = Strings.CharacterCreation.Name }; // Character Name Textbox - _charNameTextbox = new TextBox(_charNameBackground, "CharacterNameField"); + _charNameTextbox = new TextBox(charNameBackground, "CharacterNameField"); _charNameTextbox.SubmitPressed += (sender, e) => TryCreateCharacter(); // Class Background - var _classBackground = new ImagePanel(this, "ClassPanel"); + var classBackground = new ImagePanel(this, "ClassPanel"); // Class Label - _ = new Label(_classBackground, "ClassLabel") + _ = new Label(classBackground, "ClassLabel") { Text = Strings.CharacterCreation.Class }; // Class Combobox - _classCombobox = new ComboBox(_classBackground, "ClassCombobox"); + _classCombobox = new ComboBox(classBackground, "ClassCombobox"); _classCombobox.ItemSelected += classCombobox_ItemSelected; // Hint Label @@ -109,16 +110,16 @@ public CreateCharacterWindow(Canvas parent, MainMenu mainMenu, SelectCharacterWi _prevSpriteButton.Clicked += _prevSpriteButton_Clicked; // Class Background - var _genderBackground = new ImagePanel(this, "GenderPanel"); + var genderBackground = new ImagePanel(this, "GenderPanel"); // Gender Label - _ = new Label(_genderBackground, "GenderLabel") + _ = new Label(genderBackground, "GenderLabel") { Text = Strings.CharacterCreation.Gender }; // Male Checkbox - _chkMale = new LabeledCheckBox(_genderBackground, "MaleCheckbox") + _chkMale = new LabeledCheckBox(genderBackground, "MaleCheckbox") { Text = Strings.CharacterCreation.Male, IsChecked = true @@ -127,7 +128,7 @@ public CreateCharacterWindow(Canvas parent, MainMenu mainMenu, SelectCharacterWi _chkMale.UnChecked += femaleChk_Checked; // Female Checkbox - _chkFemale = new LabeledCheckBox(_genderBackground, "FemaleCheckbox") + _chkFemale = new LabeledCheckBox(genderBackground, "FemaleCheckbox") { Text = Strings.CharacterCreation.Female }; @@ -142,12 +143,12 @@ public CreateCharacterWindow(Canvas parent, MainMenu mainMenu, SelectCharacterWi }; _createButton.Clicked += CreateButton_Clicked; - var _backButton = new Button(this, "BackButton") + var backButton = new Button(this, "BackButton") { Text = Strings.CharacterCreation.Back, IsHidden = true }; - _backButton.Clicked += BackButton_Clicked; + backButton.Clicked += BackButton_Clicked; LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer?.GetResolutionString()); } @@ -158,13 +159,17 @@ public void Init() var classCount = 0; foreach (ClassBase cls in ClassBase.Lookup.Values.Cast()) { - if (!cls.Locked) + if (cls.Locked) { - _ = _classCombobox.AddItem(cls.Name); - classCount++; + continue; } + + _ = _classCombobox.AddItem(cls.Name); + classCount++; } + Log.Debug($"Added {classCount} classes to {nameof(CreateCharacterWindow)}"); + LoadClass(); UpdateDisplay(); } @@ -240,15 +245,11 @@ private void UpdateDisplay() return null; } - foreach (var cls in ClassBase.Lookup) - { - if (_classCombobox.SelectedItem.Text == cls.Value.Name && !((ClassBase)cls.Value).Locked) - { - return (ClassBase)cls.Value; - } - } - - return null; + return ClassBase.Lookup.Values.OfType().FirstOrDefault( + descriptor => + !descriptor.Locked && + string.Equals(_classCombobox.SelectedItem.Text, descriptor.Name, StringComparison.Ordinal) + ); } private void LoadClass() diff --git a/Intersect.Client/Interface/Menu/CreditsWindow.cs b/Intersect.Client/Interface/Menu/CreditsWindow.cs index 505548af97..f8e5f330d0 100644 --- a/Intersect.Client/Interface/Menu/CreditsWindow.cs +++ b/Intersect.Client/Interface/Menu/CreditsWindow.cs @@ -17,15 +17,15 @@ public CreditsWindow(Canvas parent, MainMenu mainMenu) : base(parent, "CreditsWi { _mainMenu = mainMenu; - var _creditsHeader = new Label(this, "CreditsHeader") { Text = Strings.Credits.Title }; + _ = new Label(this, "CreditsHeader") { Text = Strings.Credits.Title }; - var _creditsContent = new ScrollControl(this, "CreditsScrollview"); - _creditsContent.EnableScroll(false, true); + var creditsContent = new ScrollControl(this, "CreditsScrollview"); + creditsContent.EnableScroll(false, true); - _richLabel = new RichLabel(_creditsContent, "CreditsLabel"); + _richLabel = new RichLabel(creditsContent, "CreditsLabel"); - var _btnBack = new Button(this, "BackButton") { Text = Strings.Credits.Back }; - _btnBack.Clicked += BackBtn_Clicked; + var btnBack = new Button(this, "BackButton") { Text = Strings.Credits.Back }; + btnBack.Clicked += BackBtn_Clicked; LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer?.GetResolutionString()); } @@ -55,7 +55,7 @@ public override void Show() Alignment = "center", Size = 12, TextColor = Color.White, - Font = "sourcesansproblack" + Font = "sourcesansproblack", }; credits.Lines.Add(line); diff --git a/Intersect.Client/Interface/Menu/LoginWindow.cs b/Intersect.Client/Interface/Menu/LoginWindow.cs index a0dd702cab..453e6fdd67 100644 --- a/Intersect.Client/Interface/Menu/LoginWindow.cs +++ b/Intersect.Client/Interface/Menu/LoginWindow.cs @@ -18,7 +18,7 @@ public partial class LoginWindow : ImagePanel, IMainMenuWindow private readonly TextBox _txtUsername; private readonly TextBoxPassword _txtPassword; private readonly LabeledCheckBox _chkSavePass; - private readonly Button _btnForgotPasssword; + private readonly Button _btnForgotPassword; private readonly Button _btnLogin; private bool _useSavedPass; private string _savedPass = string.Empty; @@ -30,47 +30,65 @@ public LoginWindow(Canvas parent, MainMenu mainMenu) : base(parent, "LoginWindow _mainMenu = mainMenu; //Menu Header - var _loginHeader = new Label(this, "LoginHeader") { Text = Strings.LoginWindow.Title }; + _ = new Label(this, "LoginHeader") + { + Text = Strings.LoginWindow.Title, + }; //Login Username Label/Textbox - var _usernameBackground = new ImagePanel(this, "UsernamePanel"); - var _usernameLabel = new Label(_usernameBackground, "UsernameLabel") { Text = Strings.LoginWindow.Username }; - _txtUsername = new TextBox(_usernameBackground, "UsernameField"); + var usernameBackground = new ImagePanel(this, "UsernamePanel"); + _ = new Label(usernameBackground, "UsernameLabel") + { + Text = Strings.LoginWindow.Username, + }; + _txtUsername = new TextBox(usernameBackground, "UsernameField"); _txtUsername.SubmitPressed += (s, e) => TryLogin(); _txtUsername.Clicked += _txtUsername_Clicked; //Login Password Label/Textbox - var _passwordBackground = new ImagePanel(this, "PasswordPanel"); - var _passwordLabel = new Label(_passwordBackground, "PasswordLabel") { Text = Strings.LoginWindow.Password }; - _txtPassword = new TextBoxPassword(_passwordBackground, "PasswordField"); + var passwordBackground = new ImagePanel(this, "PasswordPanel"); + _ = new Label(passwordBackground, "PasswordLabel") + { + Text = Strings.LoginWindow.Password, + }; + _txtPassword = new TextBoxPassword(passwordBackground, "PasswordField"); _txtPassword.SubmitPressed += (s, e) => TryLogin(); _txtPassword.TextChanged += _txtPassword_TextChanged; _txtPassword.Clicked += _txtPassword_Clicked; //Login Save Pass Checkbox - _chkSavePass = new LabeledCheckBox(this, "SavePassCheckbox") { Text = Strings.LoginWindow.SavePassword }; + _chkSavePass = new LabeledCheckBox(this, "SavePassCheckbox") + { + Text = Strings.LoginWindow.SavePassword, + }; //Forgot Password Button - _btnForgotPasssword = new Button(this, "ForgotPasswordButton") + _btnForgotPassword = new Button(this, "ForgotPasswordButton") { - IsHidden = true, - Text = Strings.LoginWindow.ForgotPassword, + IsHidden = true, Text = Strings.LoginWindow.ForgotPassword, }; - _btnForgotPasssword.Clicked += _btnForgotPasssword_Clicked; + _btnForgotPassword.Clicked += _btnForgotPassword_Clicked; //Login - Send Login Button - _btnLogin = new Button(this, "LoginButton") { Text = Strings.LoginWindow.Login }; + _btnLogin = new Button(this, "LoginButton") + { + Text = Strings.LoginWindow.Login, + }; _btnLogin.Clicked += (s, e) => TryLogin(); //Login - Back Button - var _btnBack = new Button(this, "BackButton") { Text = Strings.LoginWindow.Back }; - _btnBack.Clicked += _btnBack_Clicked; + var btnBack = new Button(this, "BackButton") + { + Text = Strings.LoginWindow.Back, + }; + btnBack.Clicked += _btnBack_Clicked; LoadCredentials(); LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer?.GetResolutionString()); } #region Input Handling + private void _txtUsername_Clicked(Base sender, ClickedEventArgs arguments) { Globals.InputManager.OpenKeyboard( @@ -97,17 +115,18 @@ private void _txtPassword_Clicked(Base sender, ClickedEventArgs arguments) ); } - private void _btnForgotPasssword_Clicked(Base sender, ClickedEventArgs arguments) + private static void _btnForgotPassword_Clicked(Base sender, ClickedEventArgs arguments) { Interface.MenuUi.MainMenu.NotifyOpenForgotPassword(); } - void _btnBack_Clicked(Base sender, ClickedEventArgs arguments) + private void _btnBack_Clicked(Base sender, ClickedEventArgs arguments) { Hide(); _mainMenu.Show(); Networking.Network.DebounceClose("returning_to_main_menu"); } + #endregion public void Update() @@ -129,9 +148,9 @@ public void Update() public override void Show() { base.Show(); - if (!_btnForgotPasssword.IsHidden) + if (!_btnForgotPassword.IsHidden) { - _btnForgotPasssword.IsHidden = !Options.Instance.SmtpValid; + _btnForgotPassword.IsHidden = !Options.Instance.SmtpValid; } // Set focus to the appropriate elements. @@ -221,4 +240,4 @@ private void SaveCredentials() Globals.Database.SavePreference("Username", username); Globals.Database.SavePreference("Password", password); } -} +} \ No newline at end of file diff --git a/Intersect.Client/Interface/Menu/RegistrationWindow.cs b/Intersect.Client/Interface/Menu/RegistrationWindow.cs index f0def83aef..d56251326a 100644 --- a/Intersect.Client/Interface/Menu/RegistrationWindow.cs +++ b/Intersect.Client/Interface/Menu/RegistrationWindow.cs @@ -32,27 +32,33 @@ public RegistrationWindow(Canvas parent, MainMenu mainMenu) : base(parent, nameo _registrationHeader.SetText(Strings.Registration.Title); //Register Username Label/Textbox - var _usernameContainer = new ImagePanel(this, "UsernamePanel"); - _ = new Label(_usernameContainer, "UsernameLabel") { Text = Strings.Registration.Username }; - _textBoxUsername = new TextBox(_usernameContainer, "UsernameField") { IsTabable = true }; + var usernameContainer = new ImagePanel(this, "UsernamePanel"); + _ = new Label(usernameContainer, "UsernameLabel") + { + Text = Strings.Registration.Username, + }; + _textBoxUsername = new TextBox(usernameContainer, "UsernameField") + { + IsTabable = true, + }; _textBoxUsername.SubmitPressed += (s, e) => TryRegister(); //Register Email Label/Textbox - var _emailContainer = new ImagePanel(this, "EmailPanel"); - _ = new Label(_emailContainer, "EmailLabel") { Text = Strings.Registration.Email }; - _textBoxEmail = new TextBox(_emailContainer, "EmailField") { IsTabable = true }; + var emailContainer = new ImagePanel(this, "EmailPanel"); + _ = new Label(emailContainer, "EmailLabel") { Text = Strings.Registration.Email }; + _textBoxEmail = new TextBox(emailContainer, "EmailField") { IsTabable = true }; _textBoxEmail.SubmitPressed += (s, e) => TryRegister(); //Register Password Label/Textbox - var _passwordContainer = new ImagePanel(this, "Password1Panel"); - _ = new Label(_passwordContainer, "Password1Label") { Text = Strings.Registration.Password }; - _textBoxPassword = new TextBoxPassword(_passwordContainer, "Password1Field") { IsTabable = true }; + var passwordContainer = new ImagePanel(this, "Password1Panel"); + _ = new Label(passwordContainer, "Password1Label") { Text = Strings.Registration.Password }; + _textBoxPassword = new TextBoxPassword(passwordContainer, "Password1Field") { IsTabable = true }; _textBoxPassword.SubmitPressed += (s, e) => TryRegister(); //Register Confirm Password Label/Textbox - var _confirmPasswordContainer = new ImagePanel(this, "Password2Panel"); - _ = new Label(_confirmPasswordContainer, "Password2Label") { Text = Strings.Registration.ConfirmPassword }; - _textBoxConfirmPassword = new TextBoxPassword(_confirmPasswordContainer, "Password2Field") { IsTabable = true }; + var confirmPasswordContainer = new ImagePanel(this, "Password2Panel"); + _ = new Label(confirmPasswordContainer, "Password2Label") { Text = Strings.Registration.ConfirmPassword }; + _textBoxConfirmPassword = new TextBoxPassword(confirmPasswordContainer, "Password2Field") { IsTabable = true }; _textBoxConfirmPassword.SubmitPressed += (s, e) => TryRegister(); //Register - Send Registration Button @@ -60,8 +66,8 @@ public RegistrationWindow(Canvas parent, MainMenu mainMenu) : base(parent, nameo _buttonRegister.Clicked += (s, e) => TryRegister(); //Register - Back Button - var _buttonBack = new Button(this, "BackButton") { Text = Strings.Registration.Back }; - _buttonBack.Clicked += (s, e) => + var buttonBack = new Button(this, "BackButton") { Text = Strings.Registration.Back }; + buttonBack.Clicked += (s, e) => { Hide(); _mainMenu.Show();