Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
support for ML 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Korty (Lily) committed Jun 10, 2021
1 parent bbd3e9e commit a4bd255
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
47 changes: 35 additions & 12 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using UnityEngine;
using System;
using System.Collections;
using System.Reflection;
using System.Linq;
using UnityEngine.UI;
using UIExpansionKit.API;
using System.Windows.Forms;
Expand All @@ -13,10 +15,10 @@ namespace ActiveBackground
public static class BuildInfo
{
public const string Name = "ActiveBackground";
public const string Author = "Korty (Lily)";
public const string Author = "Lily";
public const string Company = null;
public const string Version = "1.0.0";
public const string DownloadLink = "https://github.com/KortyBoi/ActiveBackground";
public const string Version = "1.0.1";
public const string DownloadLink = "https://github.com/MintLily/ActiveBackground";
public const string Description = "Add an Active Blur to your menu's background.";
}

Expand All @@ -36,22 +38,20 @@ public class Main : MelonMod
isDebug = true;
MelonLogger.Msg("Debug mode is active");
}


if (typeof(MelonMod).GetMethod("VRChat_OnUiManagerInit") == null)
MelonCoroutines.Start(GetAssembly());

melon = MelonPreferences.CreateCategory(BuildInfo.Name, BuildInfo.Name);
enabled = (MelonPreferences_Entry<bool>)melon.CreateEntry("enabled", true, "Apply Background Blur Effects");
altBlur = (MelonPreferences_Entry<bool>)melon.CreateEntry("useAlternativeBlur", false, "Use alternate blur (VR Blur Shader)\n(No affect in VR)");

ResourceManager.Init();
MelonLogger.Msg("Initialized!");
}

public override void VRChat_OnUiManagerInit()
{
ResourceManager.Init();

MelonCoroutines.Start(DelayedAction());
}
private void OnUiManagerInit() => MelonCoroutines.Start(DelayedAction());

public override void OnPreferencesSaved() { MelonCoroutines.Start(Setup()); }
public override void OnPreferencesSaved() => MelonCoroutines.Start(Setup());

public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
Expand Down Expand Up @@ -116,5 +116,28 @@ private IEnumerator Setup()
}
yield break;
}

private IEnumerator GetAssembly()
{
Assembly assemblyCSharp = null;
while (true) {
assemblyCSharp = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(assembly => assembly.GetName().Name == "Assembly-CSharp");
if (assemblyCSharp == null)
yield return null;
else
break;
}

MelonCoroutines.Start(WaitForUiManagerInit(assemblyCSharp));
}

private IEnumerator WaitForUiManagerInit(Assembly assemblyCSharp)
{
Type vrcUiManager = assemblyCSharp.GetType("VRCUiManager");
PropertyInfo uiManagerSingleton = vrcUiManager.GetProperties().First(pi => pi.PropertyType == vrcUiManager);
while (uiManagerSingleton.GetValue(null) == null)
yield return null;
OnUiManagerInit();
}
}
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Need to install MelonLoader?<br>
Click [this link](https://melonwiki.xyz/) to get started!

### Prerequisites
MelonLoader: v0.3.0 (Alpha)<br>
Game: VRChat Build 1069+
MelonLoader: v0.4.0 (Alpha)<br>
Game: VRChat Build 1102+

### Optional Prerequisites
[UIExpansionKit](https://github.com/knah/VRCMods)

### MelonPreferences (Default Values)
```
```ini
[ActiveBackground]
enabled = true
```
Expand All @@ -27,5 +27,8 @@ Toggle on/off in-game without restarting with [UIExpansionKit](https://github.co
![Preview QuickMenu](https://kortyboi.com/img/upload/VRChat_rWYlYdetQz.jpg)

# Change Log
### v1.0.1
* Updated to Support MelonLoader v0.4.0

### v1.0.0
* Initial Release<br>

0 comments on commit a4bd255

Please sign in to comment.