Skip to content

Commit

Permalink
Redid validation check. Fixed stability issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitl committed Nov 19, 2020
1 parent 595d018 commit ec49ed2
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 56 deletions.
6 changes: 6 additions & 0 deletions GENESYSLauncher/GENESYSLauncher/GENESYSLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
Expand Down
45 changes: 19 additions & 26 deletions GENESYSLauncher/GENESYSLauncher/LauncherForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,26 @@ void MainFormLoad(object sender, EventArgs e)
}
else
{
if (!Launcher.IsSteamAppInstalled(243730) || !Launcher.IsSteamAppInstalled(243750) || !Launcher.IsSteamAppInstalled(220))
if (!GlobalVars.HL2SAvail)
{
MessageBox.Show("You must own and install a copy of Half-Life 2 or the Source SDK 2013 Base Singleplayer or Multiplayer in order to run " + Launcher.CreateGame(Launcher.GameType.HL2S).Name, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
tabControl1.TabPages.Remove(tabPage1);
}
}

bool cdv1Available = Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_00).ValidateGamePath();
if (!cdv1Available)
bool cdv1Available = Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_00).ValidateGamePath();
bool cdv12Available = Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_20j).ValidateGamePath();
if (!cdv1Available)
{
bool cdv12Available = Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_20j).ValidateGamePath();
if (!cdv12Available)
{
tabControl1.TabPages.Remove(tabPage2);
}
else
{
if (!Launcher.IsSteamAppInstalled(243730) || !Launcher.IsSteamAppInstalled(243750) || (!Launcher.IsSteamAppInstalled(220) && !Launcher.IsSteamAppInstalled(380) && !Launcher.IsSteamAppInstalled(420)))
{
MessageBox.Show("You must own and install a copy of Half-Life 2, Half-Life 2 Episode One, and Half-Life 2 Episode Two, or the Source SDK 2013 Base Singleplayer or Multiplayer in order to run " + Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_20j).Name, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
tabControl1.TabPages.Remove(tabPage2);
}
}
}
else

if (cdv1Available || cdv12Available)
{
if (!Launcher.IsSteamAppInstalled(243730) || !Launcher.IsSteamAppInstalled(243750) || (!Launcher.IsSteamAppInstalled(220) && !Launcher.IsSteamAppInstalled(380) && !Launcher.IsSteamAppInstalled(420)))
if (!GlobalVars.CDAvail)
{
MessageBox.Show("You must own and install a copy of Half-Life 2, Half-Life 2 Episode One, and Half-Life 2 Episode Two, or the Source SDK 2013 Base Singleplayer or Multiplayer in order to run " + Launcher.CreateGame(Launcher.GameType.CyberDiver_v1_00).Name, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
tabControl1.TabPages.Remove(tabPage2);
}
}
Expand All @@ -139,19 +130,20 @@ void MainFormLoad(object sender, EventArgs e)
}
else
{
if (!Launcher.IsSteamAppInstalled(550))
if (!GlobalVars.L4DSAvail)
{
MessageBox.Show("You must own and install a copy of Left 4 Dead 2 in order to run " + Launcher.CreateGame(Launcher.GameType.L4DS).Name, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
tabControl1.TabPages.Remove(tabPage3);
}
}

if (tabControl1.TabPages.Count <= 0)
{
MessageBox.Show("There are no GENESYS games installed. The launcher will now close.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("There are no GENESYS games installed or there are no valid requirements. The launcher will now close.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
}

tabControl1.TabPages[0].Select();

switchImage();
GlobalVars.isConsole = false;
init = false;
Expand All @@ -161,17 +153,18 @@ void MainFormLoad(object sender, EventArgs e)
// Discord Functionality
if (File.Exists(GlobalVars.DiscordDllPath) && Properties.Settings.Default.DiscordIntegration)
{
Console.WriteLine("DISCORD: Loaded!");
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);
});

// 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
continueDiscordThreadLoop = true;
discordThread = new Thread(() =>
{
Console.WriteLine("DISCORD: Loaded!");
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(Launcher.GameType.None);

try
Expand All @@ -193,7 +186,6 @@ void MainFormLoad(object sender, EventArgs e)
}
catch (Exception)
{

}
}

Expand All @@ -218,6 +210,7 @@ void TabControl1IndexChanged(object sender, EventArgs e)
switchImage();
Properties.Settings.Default.LastSelectedTabIndex = tabControl1.SelectedIndex;
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
}

void switchImage()
Expand Down
54 changes: 47 additions & 7 deletions GENESYSLauncher/GENESYSLauncher/LauncherFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public static void WriteString(string setting, string value)
{
Properties.Settings.Default[setting] = value;
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
}

public static void WriteBool(string setting, bool value)
{
Properties.Settings.Default[setting] = value;
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
}
}

Expand Down Expand Up @@ -342,7 +344,14 @@ public static void LaunchGame(GameType gameToLaunch)

if (gameClass.ValidateGamePath())
{
UpdateActivity(gameToLaunch);
try
{
UpdateActivity(gameToLaunch);
}
catch (Exception)
{

}
var processInfo = new ProcessStartInfo();
processInfo.WorkingDirectory = Path.GetDirectoryName(gameClass.GetGamePath());
processInfo.FileName = gameClass.EXEName;
Expand Down Expand Up @@ -391,11 +400,39 @@ public static long UnixTimeNow()
return (long)timeSpan.TotalSeconds;
}

public static bool IsSteamAppInstalled(int steamappid)
public static bool IsSteamAppInstalled(string GameFolder)
{
if (Directory.Exists(Settings.ReadString("SteamAppsDir") + "\\" + GameFolder))
{
return true;
}
else
{
return false;
}
}

public static bool CheckFolders(string[] folders)
{
string path = @"HKEY_CURRENT_USER\Software\Valve\Steam\Apps\" + steamappid.ToString();
var isInstalled = Registry.GetValue(path, "Installed", null);
return isInstalled != null;
int folderNum = folders.Length;
int validFolderNum = 0;

foreach (string s in folders)
{
if (IsSteamAppInstalled(s))
{
validFolderNum++;
}
}

if (validFolderNum == folderNum)
{
return true;
}
else
{
return false;
}
}
}

Expand Down Expand Up @@ -522,7 +559,10 @@ public static class GlobalVars
public static Discord.Discord discord = null;
public static bool isConsole = true;
public static bool isDebug = false;
public static bool CDAvail = false;
public static bool HL2SAvail = false;
public static bool L4DSAvail = false;
}
#endregion

#endregion
}
Loading

0 comments on commit ec49ed2

Please sign in to comment.