diff --git a/Intersect.Client/Interface/Menu/LoginWindow.cs b/Intersect.Client/Interface/Menu/LoginWindow.cs index d200df3a37..53e2fbde6b 100644 --- a/Intersect.Client/Interface/Menu/LoginWindow.cs +++ b/Intersect.Client/Interface/Menu/LoginWindow.cs @@ -53,8 +53,6 @@ public partial class LoginWindow : IMainMenuWindow private bool mUseSavedPass; - private Button mDiscordButton; // Discord button - //Init public LoginWindow(Canvas parent, MainMenu mainMenu) { @@ -123,13 +121,6 @@ public LoginWindow(Canvas parent, MainMenu mainMenu) }; mBackBtn.Clicked += BackBtn_Clicked; - // Discord Button - mDiscordButton = new Button(mLoginWindow, "DiscordButton") - { - Text = "Discord", // Button text - }; - mDiscordButton.Clicked += DiscordButton_Clicked; - LoadCredentials(); mLoginWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString()); @@ -234,54 +225,6 @@ void LoginBtn_Clicked(Base sender, ClickedEventArgs arguments) TryLogin(); } - void DiscordButton_Clicked(Base sender, ClickedEventArgs arguments) - { - try - { - // Spróbuj otworzyć link za pomocą odpowiedniego polecenia dla danego systemu operacyjnego - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - System.Diagnostics.Process.Start(new ProcessStartInfo - { - FileName = "cmd", - Arguments = $"/c start https://discord.gg/ztKp93zvzb", - UseShellExecute = false, - CreateNoWindow = true - }); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - System.Diagnostics.Process.Start(new ProcessStartInfo - { - FileName = "xdg-open", - Arguments = $"\"https://discord.gg/ztKp93zvzb\"", - UseShellExecute = false, - CreateNoWindow = true - }); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - System.Diagnostics.Process.Start(new ProcessStartInfo - { - FileName = "open", - Arguments = $"\"https://discord.gg/ztKp93zvzb\"", - UseShellExecute = false, - CreateNoWindow = true - }); - } - else - { - // Obsługa błędu dla nieobsługiwanego systemu operacyjnego - Console.WriteLine("Unsupported operating system."); - } - } - catch (Exception ex) - { - // Obsłużanie błędu, jeśli nie udało się otworzyć linku - Console.WriteLine($"Error opening Discord link: {ex.Message}"); - } - } - public void TryLogin() { if (Globals.WaitingOnServer) diff --git a/Intersect.Client/Interface/Menu/MainMenuWindow.cs b/Intersect.Client/Interface/Menu/MainMenuWindow.cs index da6c0ab9bd..b3dbdfbdd9 100644 --- a/Intersect.Client/Interface/Menu/MainMenuWindow.cs +++ b/Intersect.Client/Interface/Menu/MainMenuWindow.cs @@ -1,3 +1,5 @@ +using System.Diagnostics; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using Intersect.Client.Core; @@ -20,6 +22,7 @@ public partial class MainMenuWindow : Window private readonly Button _buttonRegister; private readonly Button _buttonSettings; private readonly Button _buttonStart; + private readonly Button _buttonDiscord; private readonly MainMenu _mainMenu; // ReSharper disable once SuggestBaseTypeForParameterInConstructor @@ -77,8 +80,16 @@ public MainMenuWindow(Canvas canvas, MainMenu mainMenu) : base(canvas, Strings.M Text = Strings.MainMenu.Start, }; _buttonStart.Clicked += ButtonStartOnClicked; + + _buttonDiscord = new Button(this, nameof(_buttonDiscord)) + { + IsTabable = true, + Text = "Discord", // Tekst przycisku Discord + }; + _buttonDiscord.Clicked += ButtonDiscordOnClicked; } + private void ButtonCreditsOnClicked(Base sender, ClickedEventArgs arguments) => _mainMenu.SwitchToWindow(); @@ -178,7 +189,53 @@ private void ButtonStartOnClicked(Base sender, ClickedEventArgs arguments) const string singleplayer = "singleplayer"; PacketSender.SendLogin(singleplayer, Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(singleplayer)))); } - + void ButtonDiscordOnClicked(Base sender, ClickedEventArgs arguments) + { + try + { + // Spróbuj otworzyć link za pomocą odpowiedniego polecenia dla danego systemu operacyjnego + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "cmd", + Arguments = $"/c start https://discord.gg/ztKp93zvzb", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "xdg-open", + Arguments = $"\"https://discord.gg/ztKp93zvzb\"", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "open", + Arguments = $"\"https://discord.gg/ztKp93zvzb\"", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else + { + // Obsługa błędu dla nieobsługiwanego systemu operacyjnego + Console.WriteLine("Unsupported operating system."); + } + } + catch (Exception ex) + { + // Obsłużanie błędu, jeśli nie udało się otworzyć linku + Console.WriteLine($"Error opening Discord link: {ex.Message}"); + } + } internal void Reset() { _buttonSettings.Show();