Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 9f56971

Browse files
committed
Added support for ReMod.Core.Updater plugin.
1 parent f6dbeb1 commit 9f56971

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

ReMod.Core

ReModCE.Loader/ReMod.Loader.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class BuildInfo
1818
public const string Name = "ReModCE";
1919
public const string Author = "Requi, FenrixTheFox, Xaiver, Potato, Psychloor";
2020
public const string Company = null;
21-
public const string Version = "1.0.0.5";
21+
public const string Version = "1.0.0.6";
2222
public const string DownloadLink = "https://github.com/RequiDev/ReModCE/releases/latest/";
2323
}
2424

@@ -47,7 +47,7 @@ public class ReLoader : MelonMod
4747
private Action<int, string> _onSceneWasLoaded;
4848
private Action<int, string> _onSceneWasInitialized;
4949

50-
private MelonPreferences_Entry<bool> _paranoidMode;
50+
private readonly MelonPreferences_Entry<bool> _paranoidMode;
5151

5252
public ReLoader()
5353
{
@@ -58,6 +58,10 @@ public ReLoader()
5858
"If enabled ReModCE will not automatically download the latest version from GitHub. Manual update will be required.",
5959
true);
6060

61+
// check for ReMod.Core.Updater plugin before attempting to load ReMod.Core
62+
if (MelonHandler.Plugins.Any(p => p.Info.Name == "ReMod.Core.Updater"))
63+
return;
64+
6165
ReLogger.Msg($"Loading ReMod.Core early so other mods don't break me...");
6266
DownloadFromGitHub("ReMod.Core", out _);
6367
}
@@ -205,10 +209,17 @@ private void DownloadFromGitHub(string fileName, out Assembly loadedAssembly)
205209
{
206210
using var sha256 = SHA256.Create();
207211

208-
byte[] bytes = null;
212+
// delete files saved in old path
209213
if (File.Exists($"{fileName}.dll"))
210214
{
211-
bytes = File.ReadAllBytes($"{fileName}.dll");
215+
File.Delete($"{fileName}.dll");
216+
}
217+
218+
byte[] bytes = null;
219+
var path = Path.Combine("UserLibs", $"{fileName}.dll");
220+
if (File.Exists(path))
221+
{
222+
bytes = File.ReadAllBytes(path);
212223
}
213224

214225
using var wc = new WebClient
@@ -242,7 +253,7 @@ private void DownloadFromGitHub(string fileName, out Assembly loadedAssembly)
242253
bytes = latestBytes;
243254
try
244255
{
245-
File.WriteAllBytes($"{fileName}.dll", bytes);
256+
File.WriteAllBytes(path, bytes);
246257
}
247258
catch (IOException e)
248259
{
@@ -268,7 +279,7 @@ private void DownloadFromGitHub(string fileName, out Assembly loadedAssembly)
268279
bytes = latestBytes;
269280
try
270281
{
271-
File.WriteAllBytes($"{fileName}.dll", bytes);
282+
File.WriteAllBytes(path, bytes);
272283
}
273284
catch (IOException e)
274285
{

ReModCE/Components/AvatarFavoritesComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private void InitializeNetworkClient()
113113
var vrHeadset = XRDevice.isPresent ? XRDevice.model : "Desktop";
114114
vrHeadset = vrHeadset.Replace(' ', '_');
115115

116-
_userAgent = $"{BuildInfo.Name}/{vrHeadset}.{BuildInfo.Version} (Windows NT 10.0; Win64; x64)";
116+
_userAgent = $"{BuildInfo.Name}/{vrHeadset}.{BuildInfo.Version} ({SystemInfo.operatingSystem})";
117117

118118
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(_userAgent);
119119
}

ReModCE/ReModCE.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
</ItemGroup>
220220

221221
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(TargetFramework)' == 'net472' And ('$(CopyToVrc)'=='true') And (Exists('$(VRCPath)'))">
222-
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(VRCPath)" />
223-
<Message Text="Copied $(TargetFileName) to $(VRCPath)" Importance="high" />
222+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(VRCPath)\UserLibs" />
223+
<Message Text="Copied $(TargetFileName) to $(VRCPath)\UserLibs" Importance="high" />
224224
</Target>
225225
</Project>

0 commit comments

Comments
 (0)