Skip to content

Commit

Permalink
Discord Button
Browse files Browse the repository at this point in the history
  • Loading branch information
cydyn committed Feb 28, 2024
1 parent c14f213 commit 240abde
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions Intersect.Client/Interface/Menu/LoginWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Security.Cryptography;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;

using Intersect.Client.Core;
Expand Down Expand Up @@ -51,6 +52,8 @@ public partial class LoginWindow : IMainMenuWindow

private bool mUseSavedPass;

private Button mDiscordButton; // Discord button

//Init
public LoginWindow(Canvas parent, MainMenu mainMenu)
{
Expand Down Expand Up @@ -119,6 +122,13 @@ 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());
Expand Down Expand Up @@ -223,6 +233,25 @@ void LoginBtn_Clicked(Base sender, ClickedEventArgs arguments)
TryLogin();
}

void DiscordButton_Clicked(Base sender, ClickedEventArgs arguments)
{
try
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "cmd",
Arguments = $"/c start https://discord.com/",
UseShellExecute = false,
CreateNoWindow = true
});
}
catch (Exception ex)
{
// Error if it doesn't open the link
Console.WriteLine($"Error opening Discord link: {ex.Message}");
}
}

public void TryLogin()
{
if (Globals.WaitingOnServer)
Expand Down Expand Up @@ -310,4 +339,4 @@ private void SaveCredentials()

}

}
}

0 comments on commit 240abde

Please sign in to comment.