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

Commit

Permalink
Made ReMod.Core load as early as possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
RequiDev committed Apr 30, 2022
1 parent 5043f4d commit d8ef461
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ReModCE.Loader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
[assembly: AssemblyFileVersion(ReModCE.Loader.BuildInfo.Version)]

[assembly: MelonInfo(typeof(ReLoader), ReModCE.Loader.BuildInfo.Name, ReModCE.Loader.BuildInfo.Version, ReModCE.Loader.BuildInfo.Author, ReModCE.Loader.BuildInfo.DownloadLink)]
[assembly: MelonGame("VRChat", "VRChat")]
[assembly: MelonPriority(int.MinValue)]

// Create and Setup a MelonModGame to mark a Mod as Universal or Compatible with specific Games.
// If no MelonModGameAttribute is found or any of the Values for any MelonModGame on the Mod is null or empty it will be assumed the Mod is Universal.
Expand Down
33 changes: 20 additions & 13 deletions ReModCE.Loader/ReLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ namespace ReModCE.Loader
/// <summary>
/// Logger class that forwards all logging to MelonLoader through the ReModCE Loader so the colors are set up properly.
/// </summary>
public static class ReLogger
public class ReLogger
{
public static void Msg(string txt) => MelonLogger.Msg(txt);
public static void Msg(string txt, params object[] args) => MelonLogger.Msg(txt, args);
public static void Msg(object obj) => MelonLogger.Msg(obj);
public static void Msg(ConsoleColor txtcolor, string txt) => MelonLogger.Msg(txtcolor, txt);
public static void Msg(ConsoleColor txtcolor, string txt, params object[] args) => MelonLogger.Msg(txtcolor, txt, args);
public static void Msg(ConsoleColor txtcolor, object obj) => MelonLogger.Msg(txtcolor, obj);
private static MelonLogger.Instance _instance;

public static void Warning(string txt) => MelonLogger.Warning(txt);
public static void Warning(string txt, params object[] args) => MelonLogger.Warning(txt, args);
public static void Warning(object obj) => MelonLogger.Warning(obj);
public ReLogger(MelonLogger.Instance instance)
{
_instance = instance;
}

public static void Error(string txt) => MelonLogger.Error(txt);
public static void Error(string txt, params object[] args) => MelonLogger.Error(txt, args);
public static void Error(object obj) => MelonLogger.Error(obj);
public static void Msg(string txt) => _instance.Msg(txt);
public static void Msg(string txt, params object[] args) => _instance.Msg(txt, args);
public static void Msg(object obj) => _instance.Msg(obj);
public static void Msg(ConsoleColor txtcolor, string txt) => _instance.Msg(txtcolor, txt);
public static void Msg(ConsoleColor txtcolor, string txt, params object[] args) => _instance.Msg(txtcolor, txt, args);
public static void Msg(ConsoleColor txtcolor, object obj) => _instance.Msg(txtcolor, obj);

public static void Warning(string txt) => _instance.Warning(txt);
public static void Warning(string txt, params object[] args) => _instance.Warning(txt, args);
public static void Warning(object obj) => _instance.Warning(obj);

public static void Error(string txt) => _instance.Error(txt);
public static void Error(string txt, params object[] args) => _instance.Error(txt, args);
public static void Error(object obj) => _instance.Error(obj);
}
}
16 changes: 13 additions & 3 deletions ReModCE.Loader/ReMod.Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class BuildInfo
public const string Name = "ReModCE";
public const string Author = "Requi, FenrixTheFox, Xaiver, Potato, Psychloor";
public const string Company = null;
public const string Version = "1.0.0.4";
public const string Version = "1.0.0.5";
public const string DownloadLink = "https://github.com/RequiDev/ReModCE/releases/latest/";
}

Expand All @@ -31,6 +31,8 @@ internal static class GitHubInfo

public class ReLoader : MelonMod
{
private ReLogger _logger;

private Action _onApplicationStart;
private Action _onUiManagerInit;
private Action _onUiManagerInitEarly;
Expand All @@ -46,14 +48,22 @@ public class ReLoader : MelonMod
private Action<int, string> _onSceneWasInitialized;

private MelonPreferences_Entry<bool> _paranoidMode;
public override void OnApplicationStart()

public ReLoader()
{
_logger = new ReLogger(new MelonLogger.Instance("ReModCE"));

var category = MelonPreferences.CreateCategory("ReModCE");
_paranoidMode = category.CreateEntry("ParanoidMode", false, "Paranoid Mode",
"If enabled ReModCE will not automatically download the latest version from GitHub. Manual update will be required.",
true);


ReLogger.Msg($"Loading ReMod.Core early so other mods don't break me...");
DownloadFromGitHub("ReMod.Core", out _);
}

public override void OnApplicationStart()
{
DownloadFromGitHub("ReModCE", out var assembly);

if (assembly == null)
Expand Down

0 comments on commit d8ef461

Please sign in to comment.