Skip to content

Commit

Permalink
rename private methods
Browse files Browse the repository at this point in the history
  • Loading branch information
WeylonSantana committed Aug 1, 2024
1 parent 340c982 commit fa17a14
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions Intersect.Client/Interface/Menu/MainMenuWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M
IsTabable = true,
Text = Strings.MainMenu.Credits,
};
_buttonCredits.Clicked += ButtonCreditsOnClicked;
_buttonCredits.Clicked += _buttonCredits_Clicked;

_buttonExit = new Button(this, nameof(_buttonExit))
{
IsTabable = true,
Text = Strings.MainMenu.Exit,
};
_buttonExit.Clicked += ButtonExitOnClicked;
_buttonExit.Clicked += _buttonExit_Clicked;

_buttonLogin = new Button(this, nameof(_buttonLogin))
{
Expand All @@ -48,7 +48,7 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M
IsTabable = true,
Text = Strings.MainMenu.Login,
};
_buttonLogin.Clicked += ButtonLoginOnClicked;
_buttonLogin.Clicked += _buttonLogin_Clicked;

_buttonRegister = new Button(this, nameof(_buttonRegister))
{
Expand All @@ -57,14 +57,14 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M
IsTabable = true,
Text = Strings.MainMenu.Register,
};
_buttonRegister.Clicked += ButtonRegisterOnClicked;
_buttonRegister.Clicked += _buttonRegister_Clicked;

_buttonSettings = new Button(this, nameof(_buttonSettings))
{
IsTabable = true,
Text = Strings.MainMenu.Settings,
};
_buttonSettings.Clicked += ButtonSettingsOnClicked;
_buttonSettings.Clicked += _buttonSettings_Clicked;

if (!string.IsNullOrEmpty(Strings.MainMenu.SettingsTooltip))
{
Expand All @@ -77,20 +77,20 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M
IsVisible = ClientContext.IsSinglePlayer,
Text = Strings.MainMenu.Start,
};
_buttonStart.Clicked += ButtonStartOnClicked;
_buttonStart.Clicked += _buttonStart_Clicked;
}

private void ButtonCreditsOnClicked(Base sender, ClickedEventArgs arguments) => _mainMenu.SwitchToWindow<CreditsWindow>();
private void _buttonCredits_Clicked(Base sender, ClickedEventArgs arguments) => _mainMenu.SwitchToWindow<CreditsWindow>();

private static void ButtonExitOnClicked(Base sender, ClickedEventArgs arguments)
private static void _buttonExit_Clicked(Base sender, ClickedEventArgs arguments)
{
Log.Info("User clicked exit button.");
Globals.IsRunning = false;
}

#region Login

private void ButtonLoginOnClicked(Base sender, ClickedEventArgs arguments)
private void _buttonLogin_Clicked(Base sender, ClickedEventArgs arguments)
{
if (Networking.Network.InterruptDisconnectsIfConnected())
{
Expand All @@ -99,40 +99,40 @@ private void ButtonLoginOnClicked(Base sender, ClickedEventArgs arguments)
else
{
_buttonLogin.IsDisabled = Globals.WaitingOnServer;
AddLoginEvents();
_addLoginEvents();
Networking.Network.TryConnect();
}
}

private void AddLoginEvents()
private void _addLoginEvents()
{
MainMenu.ReceivedConfiguration += LoginConnected;
Networking.Network.Socket.ConnectionFailed += LoginConnectionFailed;
Networking.Network.Socket.Disconnected += LoginDisconnected;
MainMenu.ReceivedConfiguration += _loginConnected;
Networking.Network.Socket.ConnectionFailed += _loginConnectionFailed;
Networking.Network.Socket.Disconnected += _loginDisconnected;
}

private void RemoveLoginEvents()
private void _removeLoginEvents()
{
MainMenu.ReceivedConfiguration -= LoginConnected;
Networking.Network.Socket.ConnectionFailed -= LoginConnectionFailed;
Networking.Network.Socket.Disconnected -= LoginDisconnected;
MainMenu.ReceivedConfiguration -= _loginConnected;
Networking.Network.Socket.ConnectionFailed -= _loginConnectionFailed;
Networking.Network.Socket.Disconnected -= _loginDisconnected;
}

private void LoginConnectionFailed(INetworkLayerInterface nli, ConnectionEventArgs args, bool denied) => RemoveLoginEvents();
private void _loginConnectionFailed(INetworkLayerInterface nli, ConnectionEventArgs args, bool denied) => _removeLoginEvents();

private void LoginDisconnected(INetworkLayerInterface nli, ConnectionEventArgs args) => RemoveLoginEvents();
private void _loginDisconnected(INetworkLayerInterface nli, ConnectionEventArgs args) => _removeLoginEvents();

private void LoginConnected(object? sender, EventArgs eventArgs)
private void _loginConnected(object? sender, EventArgs eventArgs)
{
RemoveLoginEvents();
_removeLoginEvents();
_mainMenu.SwitchToWindow<LoginWindow>();
}

#endregion Login

#region Register

private void ButtonRegisterOnClicked(Base sender, ClickedEventArgs arguments)
private void _buttonRegister_Clicked(Base sender, ClickedEventArgs arguments)
{
if (Networking.Network.InterruptDisconnectsIfConnected())
{
Expand All @@ -141,40 +141,40 @@ private void ButtonRegisterOnClicked(Base sender, ClickedEventArgs arguments)
else
{
_buttonRegister.IsDisabled = Globals.WaitingOnServer;
AddRegisterEvents();
_addRegisterEvents();
Networking.Network.TryConnect();
}
}

private void AddRegisterEvents()
private void _addRegisterEvents()
{
MainMenu.ReceivedConfiguration += RegisterConnected;
Networking.Network.Socket.ConnectionFailed += RegisterConnectionFailed;
Networking.Network.Socket.Disconnected += RegisterDisconnected;
MainMenu.ReceivedConfiguration += _registerConnected;
Networking.Network.Socket.ConnectionFailed += _registerConnectionFailed;
Networking.Network.Socket.Disconnected += _registerDisconnected;
}

private void RemoveRegisterEvents()
private void _removeRegisterEvents()
{
MainMenu.ReceivedConfiguration -= RegisterConnected;
Networking.Network.Socket.ConnectionFailed -= RegisterConnectionFailed;
Networking.Network.Socket.Disconnected -= RegisterDisconnected;
MainMenu.ReceivedConfiguration -= _registerConnected;
Networking.Network.Socket.ConnectionFailed -= _registerConnectionFailed;
Networking.Network.Socket.Disconnected -= _registerDisconnected;
}

private void RegisterConnectionFailed(INetworkLayerInterface nli, ConnectionEventArgs args, bool denied) => RemoveRegisterEvents();
private void _registerConnectionFailed(INetworkLayerInterface nli, ConnectionEventArgs args, bool denied) => _removeRegisterEvents();

private void RegisterDisconnected(INetworkLayerInterface nli, ConnectionEventArgs args) => RemoveRegisterEvents();
private void _registerDisconnected(INetworkLayerInterface nli, ConnectionEventArgs args) => _removeRegisterEvents();

private void RegisterConnected(object? sender, EventArgs eventArgs)
private void _registerConnected(object? sender, EventArgs eventArgs)
{
RemoveRegisterEvents();
_removeRegisterEvents();
_mainMenu.SwitchToWindow<RegisterWindow>();
}

#endregion Register

private void ButtonSettingsOnClicked(Base sender, ClickedEventArgs arguments) => _mainMenu.SettingsButton_Clicked();
private void _buttonSettings_Clicked(Base sender, ClickedEventArgs arguments) => _mainMenu.SettingsButton_Clicked();

private void ButtonStartOnClicked(Base sender, ClickedEventArgs arguments)
private void _buttonStart_Clicked(Base sender, ClickedEventArgs arguments)
{
Hide();
Networking.Network.TryConnect();
Expand Down

0 comments on commit fa17a14

Please sign in to comment.