Skip to content

Commit

Permalink
v2.0 (3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitl committed Nov 13, 2020
1 parent ecb7f84 commit 61de6a1
Show file tree
Hide file tree
Showing 8 changed files with 12,743 additions and 12,722 deletions.
69 changes: 41 additions & 28 deletions GENESYSLauncher/GENESYSLauncher/LauncherForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 48 additions & 24 deletions GENESYSLauncher/GENESYSLauncher/LauncherForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace GENESYSLauncher
#region LauncherForm
public partial class LauncherForm : Form
{
public Discord.Discord discord;
public Thread discordThread;
public bool continueDiscordThreadLoop;
public bool continueDiscordThreadLoop;
public bool init = true;

#region Constructor
public LauncherForm()
Expand All @@ -28,10 +28,12 @@ public LauncherForm()
void MainFormLoad(object sender, EventArgs e)
{
#region core launcher settings
label20.Text = Settings.ReadString("Version");
label20.Text = "v" + Properties.Settings.Default.Version.ToString();
var versionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);
label21.Text = Settings.ReadString("Version") + "." + versionInfo.ProductBuildPart.ToString() + "." + versionInfo.ProductPrivatePart.ToString();
label21.Text = label20.Text + "." + versionInfo.ProductBuildPart.ToString() + "." + versionInfo.ProductPrivatePart.ToString();
checkBox5.Checked = Settings.ReadBool("CloseWhenGameLaunches");
checkBox3.Checked = Settings.ReadBool("DiscordIntegration");
tabControl1.SelectedIndex = Properties.Settings.Default.LastSelectedTabIndex;
#endregion

#region hl2 survivor load settings
Expand All @@ -55,6 +57,8 @@ void MainFormLoad(object sender, EventArgs e)
button10.Visible = true;
button11.Visible = true;
button12.Visible = true;
#else
tabControl1.Height = 305;
#endif

//check for the games.
Expand All @@ -71,18 +75,21 @@ void MainFormLoad(object sender, EventArgs e)
Close();
}

switchImage();
init = false;

try
{
// Discord Functionality
if (File.Exists(GlobalVars.DiscordDllPath))
if (File.Exists(GlobalVars.DiscordDllPath) && Properties.Settings.Default.DiscordIntegration)
{
Console.WriteLine("DISCORD: Loaded!");
discord = new Discord.Discord(Properties.Settings.Default.DiscordAppID, (System.UInt64)Discord.CreateFlags.NoRequireDiscord);
discord.SetLogHook(Discord.LogLevel.Debug, (level, message) =>
GlobalVars.discord = new Discord.Discord(Properties.Settings.Default.DiscordAppID, (System.UInt64)Discord.CreateFlags.NoRequireDiscord);
GlobalVars.discord.SetLogHook(Discord.LogLevel.Debug, (level, message) =>
{
Console.WriteLine("Log[{0}] {1}", level, message);
});
Launcher.UpdateActivity(discord, Launcher.GameType.None);
Launcher.UpdateActivity(Launcher.GameType.None);

// Pump the event look to ensure all callbacks continue to get fired.
//https://stackoverflow.com/questions/17142842/infinite-while-loop-with-form-application-c-sharp
Expand All @@ -93,13 +100,13 @@ void MainFormLoad(object sender, EventArgs e)
{
while (continueDiscordThreadLoop)
{
discord.RunCallbacks();
GlobalVars.discord.RunCallbacks();
Thread.Sleep(1000 / 60);
}
}
finally
{
discord.Dispose();
GlobalVars.discord.Dispose();
}
});
discordThread.IsBackground = true;
Expand All @@ -118,12 +125,29 @@ void CheckBox5CheckedChanged(object sender, EventArgs e)
Settings.WriteBool("CloseWhenGameLaunches", checkBox5.Checked);
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (!init)
{
Settings.WriteBool("DiscordIntegration", checkBox3.Checked);
MessageBox.Show("The launcher will now restart to apply this setting.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Restart();
}
}

void TabControl1IndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage1)
{
switchImage();
Properties.Settings.Default.LastSelectedTabIndex = tabControl1.SelectedIndex;
Properties.Settings.Default.Save();
}

void switchImage()
{
if (tabControl1.SelectedTab == tabPage1)
{
pictureBox1.Image = imageList3.Images[0];
}
}
else if (tabControl1.SelectedTab == tabPage2)
{
pictureBox1.Image = imageList3.Images[1];
Expand All @@ -138,8 +162,8 @@ void TabControl1IndexChanged(object sender, EventArgs e)

#region HL2 Survivor

//hl2 survivor launch options
void TextBox4TextChanged(object sender, EventArgs e)
//hl2 survivor launch options
void TextBox4TextChanged(object sender, EventArgs e)
{
Settings.WriteString("HL2S_LaunchOptions", textBox4.Text);
}
Expand Down Expand Up @@ -198,7 +222,7 @@ void Button3Click(object sender, EventArgs e)
//hl2 survivor launch button
void Button1Click(object sender, EventArgs e)
{
Launcher.LaunchGame(Launcher.GameType.HL2S, discord);
Launcher.LaunchGame(Launcher.GameType.HL2S);

if (Settings.ReadBool("CloseWhenGameLaunches"))
{
Expand All @@ -219,7 +243,7 @@ void TextBox7TextChanged(object sender, EventArgs e)
//cyber diver launch
void Button6Click(object sender, EventArgs e)
{
Launcher.LaunchGame(Launcher.GameType.CyberDiver, discord);
Launcher.LaunchGame(Launcher.GameType.CyberDiver);

if (Settings.ReadBool("CloseWhenGameLaunches"))
{
Expand All @@ -240,7 +264,7 @@ void TextBox6TextChanged(object sender, EventArgs e)
// l4d survivors launch
void Button7Click(object sender, EventArgs e)
{
Launcher.LaunchGame(Launcher.GameType.L4DS, discord);
Launcher.LaunchGame(Launcher.GameType.L4DS);

if (Settings.ReadBool("CloseWhenGameLaunches"))
{
Expand Down Expand Up @@ -282,23 +306,23 @@ private void button5_Click(object sender, EventArgs e)

private void button9_Click(object sender, EventArgs e)
{
Launcher.LaunchGame_Debug(Launcher.GameType.CyberDiver, discord);
Launcher.LaunchGame_Debug(Launcher.GameType.CyberDiver);
}

private void button10_Click(object sender, EventArgs e)
{
Launcher.LaunchGame_Debug(Launcher.GameType.HL2S, discord);
Launcher.LaunchGame_Debug(Launcher.GameType.HL2S);
}

private void button11_Click(object sender, EventArgs e)
{
Launcher.LaunchGame_Debug(Launcher.GameType.L4DS, discord);
Launcher.LaunchGame_Debug(Launcher.GameType.L4DS);
}
private void button12_Click(object sender, EventArgs e)
{
Launcher.LaunchGame_Debug(Launcher.GameType.None, discord);
Launcher.LaunchGame_Debug(Launcher.GameType.None);
}
#endregion
}
#endregion
}
#endregion
}
Loading

0 comments on commit 61de6a1

Please sign in to comment.