Skip to content

Commit

Permalink
Make it work with the manager, add funding button
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed Dec 5, 2023
1 parent f1e3359 commit 3b3fd47
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patreon: xen42
custom: ["https://paypal.me/xen42"]
12 changes: 4 additions & 8 deletions DredgeVR/DredgeVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<PlatformTarget>x86</PlatformTarget>
<TargetFramework>net48</TargetFramework>
<LangVersion>default</LangVersion>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
Expand All @@ -25,6 +25,9 @@
<None Include="AssetBundles/**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="CopyToGame/**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DredgeVR.csproj.user" />
</ItemGroup>

Expand All @@ -37,11 +40,4 @@
<Reference Include="../dlls/*" />
</ItemGroup>

<ItemGroup>
<Compile Remove="VRCamera\NewFolder\**" />
<EmbeddedResource Remove="VRCamera\NewFolder\**" />
<None Remove="VRCamera\NewFolder\**" />
<Reference Remove="VRCamera\NewFolder\**" />
</ItemGroup>

</Project>
35 changes: 35 additions & 0 deletions DredgeVR/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.IO;

namespace DredgeVR.Helpers;

public static class FileHelper
{
public static void Copy(string sourceDirectory, string targetDirectory)
{
DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);

CopyAll(diSource, diTarget);
}

public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
Directory.CreateDirectory(target.FullName);

// Copy each file into the new directory.
foreach (FileInfo fi in source.GetFiles())
{
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
}

// Copy each subdirectory using recursion.
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir =
target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
}
20 changes: 18 additions & 2 deletions DredgeVR/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
using UnityEngine;
using UnityEngine.XR.Management;
using Valve.VR;
using System.Runtime.CompilerServices;

namespace DredgeVR
{
public class Loader
{
// Confuses me that the mod dll counts as the executing assembly
// Might change if we were using a different mod loader
// Should update Winch to provide these paths if it doesn't already
public static string DredgeVRFolder => Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;

// Bit hacky but eh
public static string DredgeFolder => Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.FullName;

public static void Initialize()
{
OptionsManager.Load();
Expand All @@ -26,6 +35,14 @@ public static void Initialize()
new Harmony("DredgeVR").PatchAll();
}

/// <summary>
/// This runs when the assembly is loaded
/// </summary>
public static void Preload()
{
FileHelper.Copy(Path.Combine(DredgeVRFolder, "CopyToGame"), Path.Combine(DredgeFolder, "DREDGE_Data"));
}

private static void SetUpXr()
{
SteamVR_Actions.PreInitialize();
Expand Down Expand Up @@ -54,8 +71,7 @@ private static void SetUpXr()
// SteamVR_Settings.instance.pauseGameWhenDashboardVisible = true;

// Makes it so that Dredge appears as a VR game in your Steam Home
var dredgeFolder = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.FullName;
var manifestPath = Path.Combine(dredgeFolder, @"DREDGE_Data\StreamingAssets\dredge.vrmanifest");
var manifestPath = Path.Combine(DredgeFolder, @"DREDGE_Data\StreamingAssets\dredge.vrmanifest");
ApplicationManifestHelper.UpdateManifest(manifestPath,
"steam.app.1562430",
"https://steamcdn-a.akamaihd.net/steam/apps/1562430/header.jpg",
Expand Down
5 changes: 3 additions & 2 deletions DredgeVR/mod_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ModGUID": "xen.DredgeVR",
"Version": "0.2.0",
"ModAssembly": "DredgeVR.dll",
"MinWinchVersion": "0.2.3",
"Entrypoint": "DredgeVR.Loader/Initialize"
"MinWinchVersion": "0.3.0",
"Entrypoint": "DredgeVR.Loader/Initialize",
"Preload": "DredgeVR.Loader/Preload"
}

0 comments on commit 3b3fd47

Please sign in to comment.