Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.6.0 #37

Merged
merged 14 commits into from
Dec 26, 2024
20 changes: 15 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ on:
jobs:
build:
name: Create artifacts
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'

- name: Build Winch
shell: bash
run: dotnet build -c ${{ inputs.build_type }}

- name: Copy WinchConsole into Winch folder
shell: bash
run: |
cp -r WinchConsole/bin/* Winch/bin/

- name: Copy WinchLauncher into Winch folder
shell: bash
run: |
cp -r WinchLauncher/bin/* Winch/bin/

- name: Upload Winch Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Winch
path: Winch/bin

- name: Move Example Mods
shell: bash
run: |
for mod in DisasterButton ExampleItems IntroSkipper
do
Expand All @@ -42,7 +52,7 @@ jobs:
done

- name: Upload Example Mod Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Winch Examples
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get version
id: version
uses: notiz-dev/github-action-json-property@release
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Set up nuget
uses: NuGet/[email protected]
- name: Download Winch Asset
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Winch
path: Winch/bin
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download Winch Asset
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Winch
path: Winch
Expand All @@ -46,7 +46,7 @@ jobs:
cd ..

- name: Download Example Mods
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Winch Examples
path: Examples
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get version
id: version
uses: notiz-dev/github-action-json-property@release
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Set up nuget
uses: NuGet/[email protected]
- name: Download Winch Asset
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Winch
path: Winch/bin
Expand Down
10 changes: 8 additions & 2 deletions Winch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DisasterButton", "Winch.Exa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleItems", "Winch.Examples\ExampleItems\ExampleItems.csproj", "{C112288E-E993-44F3-B7B0-FB4BD37F18EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinchConsole", "WinchConsole\WinchConsole.csproj", "{D5CFABA9-FA58-474F-A394-E197BDF38FDD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinchConsole", "WinchConsole\WinchConsole.csproj", "{D5CFABA9-FA58-474F-A394-E197BDF38FDD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinchCommon", "WinchCommon\WinchCommon.csproj", "{EF5F69E6-FD4D-4314-B187-A89D00BF9355}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinchCommon", "WinchCommon\WinchCommon.csproj", "{EF5F69E6-FD4D-4314-B187-A89D00BF9355}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinchLauncher", "WinchLauncher\WinchLauncher.csproj", "{45CB6021-0D96-4231-9F53-4C73597998D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -45,6 +47,10 @@ Global
{EF5F69E6-FD4D-4314-B187-A89D00BF9355}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF5F69E6-FD4D-4314-B187-A89D00BF9355}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF5F69E6-FD4D-4314-B187-A89D00BF9355}.Release|Any CPU.Build.0 = Release|Any CPU
{45CB6021-0D96-4231-9F53-4C73597998D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45CB6021-0D96-4231-9F53-4C73597998D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45CB6021-0D96-4231-9F53-4C73597998D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45CB6021-0D96-4231-9F53-4C73597998D8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Winch/mod_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"Name": "Winch",
"Author": "Hacktix",
"ModGUID": "hacktix.winch",
"Version": "0.5.3"
"Version": "0.6.0"
}
109 changes: 109 additions & 0 deletions WinchLauncher/Launcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace WinchLauncher;

internal static class Launcher
{
public static void Main(string[] args)
{
StartGame();

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

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

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

void StartGameViaExe()
{
Console.WriteLine("Defaulting to running exe. If you bought DREDGE on Epic Games this will not work. Run the game from there directly");
Process.Start(Path.Combine(gamePath, "DREDGE.exe"));
}

bool isEpic = false, isSteam = false;

Assembly assembly = null;
try
{
assembly = Assembly.LoadFrom(dllPath);
}
catch (Exception e)
{
Console.WriteLine("Failed to load assembly: " + e.Message);
StartGameViaExe();
return;
}

try
{
List<string> types;
try
{
types = assembly.GetExportedTypes().Select(x => x.Name).ToList();
}
catch (ReflectionTypeLoadException ex)
{
Console.WriteLine("Only partially loaded assembly: " + ex.Message);

// Apparently this can happen
types = ex.Types.Where(x => x != null).Select(x => x.Name).ToList();
}

types.Sort();
isEpic = types.Any(x => x == "EOSScreenshotStrategy");
isSteam = types.Any(x => x == "SteamEntitlementStrategy");

foreach (var type in types)
{
Console.WriteLine(type);
}
}
catch (Exception e)
{
Console.WriteLine("Failed to load types from assembly: " + e.Message);
StartGameViaExe();
return;
}

try
{
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();
}
}
catch (Exception e)
{
Console.WriteLine("Failed to start process: " + e.Message);
StartGameViaExe();
return;
}
}
}
15 changes: 15 additions & 0 deletions WinchLauncher/WinchLauncher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

<ItemGroup>
<None Include="WinchLauncher.csproj.user" />
</ItemGroup>

</Project>
Loading