Skip to content

Commit

Permalink
MRU: add an option for UI in mirrors, support new UI layer
Browse files Browse the repository at this point in the history
  • Loading branch information
knah committed Dec 10, 2021
1 parent 69e496c commit 0e0d6c2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions IntegrityCheckGenerator/IntegrityCheckGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public void Execute(GeneratorExecutionContext context)
generatedCode.AppendLine(" catch (BadImageFormatException) {}");
generatedCode.AppendLine(" finally { CheckDummyThree(); }");
generatedCode.AppendLine(" RanCheck3 = true;");
generatedCode.AppendLine(" OnSceneWasLoaded2(buildIndex, sceneName);");
generatedCode.AppendLine("}");

generatedCode.AppendLine($"protected {modTypeName}() {{");
Expand Down
2 changes: 1 addition & 1 deletion MirrorResolutionUnlimiter/MirrorResolutionUnlimiter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<UseAltLibs>true</UseAltLibs>
<AssemblyVersion>1.1.3.0</AssemblyVersion>
<AssemblyVersion>1.1.4.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\UIExpansionKit\UIExpansionKit.csproj">
Expand Down
5 changes: 4 additions & 1 deletion MirrorResolutionUnlimiter/MirrorResolutionUnlimiterMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using UnityEngine;
using VRC.SDKBase;

[assembly:MelonInfo(typeof(MirrorResolutionUnlimiterMod), "MirrorResolutionUnlimiter", "1.1.3", "knah", "https://github.com/knah/VRCMods")]
[assembly:MelonInfo(typeof(MirrorResolutionUnlimiterMod), "MirrorResolutionUnlimiter", "1.1.4", "knah", "https://github.com/knah/VRCMods")]
[assembly:MelonGame("VRChat", "VRChat")]
[assembly:MelonOptionalDependencies("UIExpansionKit")]

Expand All @@ -27,6 +27,7 @@ internal partial class MirrorResolutionUnlimiterMod : MelonMod
private static bool ourAllMirrorsAuto = false;
private static int ourMirrorMsaa = 0;
private static MelonPreferences_Entry<bool> ourMsaaIsUpperLimit;
internal static MelonPreferences_Entry<bool> UiInMirrors;

private MelonPreferences_Entry<string> myPixelLightsSetting;

Expand Down Expand Up @@ -59,6 +60,8 @@ public override void OnApplicationStart()

ourMsaaIsUpperLimit = category.CreateEntry("MsaaIsUpperLimit", true, "Mirror MSAA setting is upper limit (otherwise static)");

UiInMirrors = category.CreateEntry("UiInMirrors", false, "Include UI in mirrors when using Optimize/Beautify buttons");

HarmonyInstance.Patch(
AccessTools.Method(typeof(VRC_MirrorReflection), nameof(VRC_MirrorReflection.GetReflectionData)),
prefix: new HarmonyMethod(typeof(MirrorResolutionUnlimiterMod), nameof(GetReflectionData)));
Expand Down
10 changes: 8 additions & 2 deletions MirrorResolutionUnlimiter/UiExtensionsAddon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class UiExtensionsAddon
private static int PlayerLocalLayer = 1 << 10;
private static int UiLayer = 1 << 5;
private static int UiMenuLayer = 1 << 12;
private static int UiInternalLayer = 1 << 19;
private static int MirrorReflectionLayer = 1 << 18;

[MethodImpl(MethodImplOptions.NoInlining)]
Expand All @@ -28,14 +29,19 @@ private static void BeautifyMirrors()
{
foreach (var vrcMirrorReflection in Object.FindObjectsOfType<VRC_MirrorReflection>())
if (vrcMirrorReflection.isActiveAndEnabled)
vrcMirrorReflection.m_ReflectLayers = -1 & ~UiLayer & ~UiMenuLayer & ~PlayerLocalLayer;
if (MirrorResolutionUnlimiterMod.UiInMirrors.Value)
vrcMirrorReflection.m_ReflectLayers = -1 & ~PlayerLocalLayer;
else
vrcMirrorReflection.m_ReflectLayers =
-1 & ~UiLayer & ~UiMenuLayer & ~PlayerLocalLayer & ~UiInternalLayer;

}

private static void OptimizeMirrors()
{
foreach (var vrcMirrorReflection in Object.FindObjectsOfType<VRC_MirrorReflection>())
if (vrcMirrorReflection.isActiveAndEnabled)
vrcMirrorReflection.m_ReflectLayers = PlayerLayer | MirrorReflectionLayer;
vrcMirrorReflection.m_ReflectLayers = PlayerLayer | MirrorReflectionLayer | (MirrorResolutionUnlimiterMod.UiInMirrors.Value ? UiMenuLayer | UiInternalLayer | UiLayer : 0);
}
}
}
1 change: 1 addition & 0 deletions ReleaseChangelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Read the [Malicious Mods and you](https://github.com/knah/VRCMods/blob/master/Ma

Changes:
* Advanced Safety: added protection for uncommon skid crashes (contributed by Requi and Ben)
* Mirror Resolution Unlimiter: added an option to show UI in mirrors when using Optimize/Beautify buttons, support new UI layer
* UI Expansion Kit: added APIs to dynamically show or hide mod settings entries
* UI Expansion Kit: fixed compatibility with build 1160

Expand Down

0 comments on commit 0e0d6c2

Please sign in to comment.