Skip to content

Commit

Permalink
Launcher works for steam and epic now
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed Dec 24, 2024
1 parent 87ff106 commit a19885f
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions WinchLauncher/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ internal static class Launcher
{
public static void Main(string[] args)
{
StartGame(args[0]);
StartGame();
}

/// <summary>
/// Adapted from OWML https://github.com/ow-mods/owml/blob/master/src/OWML.Launcher/App.cs
/// </summary>
/// <param name="gamePath"></param>
public static void StartGame(string gamePath)
public static void StartGame()
{
string gamePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

var dllPath = Path.Combine(gamePath, "DREDGE_Data/Managed/Assembly-CSharp.dll");

void StartGameViaExe() => Process.Start(Path.Combine(gamePath, "DREDGE.exe"));
Expand All @@ -25,27 +27,52 @@ public static void StartGame(string gamePath)
{
assembly = Assembly.LoadFrom(dllPath);
}
catch
catch (Exception e)
{
Console.WriteLine(e.Message);
StartGameViaExe();
return;
}

var types = assembly.GetTypes();
var isEpic = types.Any(x => x.Name == "EpicEntitlementRetriever");
var isSteam = types.Any(x => x.Name == "SteamEntitlementRetriever");

if (isEpic && !isSteam)
{
Process.Start("com.epicgames.launcher://apps/8b454b47f5544fc6829cf0fed42ebae0%3Aeac6533129434f98a6b04a81cbcaf357%3A65c25644a2e0444d8766967a008b1d69?action=launch&silent=true");
}
else if (!isEpic && isSteam)
try
{
Process.Start("steam://rungameid/1562430");
var types = assembly.GetTypes().Select(x => x.Name).ToList();
types.Sort();
var isEpic = types.Any(x => x == "EOSScreenshotStrategy");
var isSteam = types.Any(x => x == "SteamEntitlementStrategy");

foreach (var type in types)
{
Console.WriteLine(type);
}

if (isEpic && !isSteam)
{
Console.WriteLine("Identified as Epic install");

Process.Start(new ProcessStartInfo("com.epicgames.launcher://apps/8b454b47f5544fc6829cf0fed42ebae0%3Aeac6533129434f98a6b04a81cbcaf357%3A65c25644a2e0444d8766967a008b1d69?action=launch&silent=true") { UseShellExecute = true });
}
else if (!isEpic && isSteam)
{
Console.WriteLine("Identified as Steam install");

Process.Start(new ProcessStartInfo("steam://rungameid/1562430") { UseShellExecute = true });
}
else
{
Console.WriteLine("Couldn't identify vendor");

StartGameViaExe();
}
}
else
catch (Exception e)
{
Console.WriteLine(e.Message);
StartGameViaExe();
}

// Keep the window open until the user presses a key
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}

0 comments on commit a19885f

Please sign in to comment.