From 3b3fd4768f7deeca84b9a3878f4c45e7aaad70c9 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 5 Dec 2023 16:29:33 -0500 Subject: [PATCH] Make it work with the manager, add funding button --- .github/FUNDING.yml | 2 ++ DredgeVR/DredgeVR.csproj | 12 ++++-------- DredgeVR/Helpers/FileHelper.cs | 35 ++++++++++++++++++++++++++++++++++ DredgeVR/Loader.cs | 20 +++++++++++++++++-- DredgeVR/mod_meta.json | 5 +++-- 5 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 DredgeVR/Helpers/FileHelper.cs diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a7fb7ac --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +patreon: xen42 +custom: ["https://paypal.me/xen42"] \ No newline at end of file diff --git a/DredgeVR/DredgeVR.csproj b/DredgeVR/DredgeVR.csproj index e20c5c3..281d114 100644 --- a/DredgeVR/DredgeVR.csproj +++ b/DredgeVR/DredgeVR.csproj @@ -12,7 +12,7 @@ false x86 net48 - default + latest true false false @@ -25,6 +25,9 @@ Always + + Always + @@ -37,11 +40,4 @@ - - - - - - - diff --git a/DredgeVR/Helpers/FileHelper.cs b/DredgeVR/Helpers/FileHelper.cs new file mode 100644 index 0000000..3ed6d56 --- /dev/null +++ b/DredgeVR/Helpers/FileHelper.cs @@ -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); + } + } +} diff --git a/DredgeVR/Loader.cs b/DredgeVR/Loader.cs index 5418d4f..a3f2809 100644 --- a/DredgeVR/Loader.cs +++ b/DredgeVR/Loader.cs @@ -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(); @@ -26,6 +35,14 @@ public static void Initialize() new Harmony("DredgeVR").PatchAll(); } + /// + /// This runs when the assembly is loaded + /// + public static void Preload() + { + FileHelper.Copy(Path.Combine(DredgeVRFolder, "CopyToGame"), Path.Combine(DredgeFolder, "DREDGE_Data")); + } + private static void SetUpXr() { SteamVR_Actions.PreInitialize(); @@ -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", diff --git a/DredgeVR/mod_meta.json b/DredgeVR/mod_meta.json index 93702dd..46662e7 100644 --- a/DredgeVR/mod_meta.json +++ b/DredgeVR/mod_meta.json @@ -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" }