private void DebugCheck()
        {
            if (!MelonDebug.IsEnabled() || hasWarned)
            {
                return;
            }
            hasWarned = true;

            PatchInfo patchInfo = Original.GetPatchInfo();

            Patch basePatch = patchInfo.prefixes.Count() > 0 ? patchInfo.prefixes.First()
                : patchInfo.postfixes.Count() > 0 ? patchInfo.postfixes.First()
                : patchInfo.transpilers.Count() > 0 ? patchInfo.transpilers.First()
                : patchInfo.finalizers.Count() > 0 ? patchInfo.finalizers.First() : null;

            MelonLogger.Instance loggerInstance = FindMelon(melon => basePatch != null && melon.HarmonyInstance.Id.Equals(basePatch.owner));
            if (loggerInstance == null && basePatch != null)
            {
                // Patching using a custom Harmony instance; try to infer the melon assembly from the container type, prefix, postfix, or transpiler.
                Assembly melonAssembly = basePatch.PatchMethod.DeclaringType?.Assembly;
                if (melonAssembly != null)
                {
                    loggerInstance = FindMelon(melon => melon.Assembly == melonAssembly);
                }
            }

            WarnIfHasTranspiler(patchInfo, loggerInstance);
            WarnIfOriginalMethodIsInlined(loggerInstance);
        }
Esempio n. 2
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("DisableControllerOverlay", ConsoleColor.DarkYellow);

            cat = MelonPreferences.CreateCategory("DisableControllerOverlay", "DisableControllerOverlay");
            disableToolTipsOnLoad = MelonPreferences.CreateEntry("DisableControllerOverlay", nameof(disableToolTipsOnLoad), true, "Disable Controller Tooltips on Game Load");
            disableToolTips       = MelonPreferences.CreateEntry("DisableControllerOverlay", nameof(disableToolTips), true, "Disable Controller Tooltips");
            disableMeshOnly       = MelonPreferences.CreateEntry("DisableControllerOverlay", nameof(disableMeshOnly), true, "Disable Controller Mesh Only");

            disableToolTips.OnValueChanged += disableChange;
            disableMeshOnly.OnValueChanged += disableChange;

            var toolTipsMenu = ExpansionKitApi.CreateCustomQuickMenuPage(LayoutDescriptionCustom.QuickMenu1Column5Row);

            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UiElementsQuickMenu).AddSimpleButton("Controller Tooltips", () => toolTipsMenu.Show());
            toolTipsMenu.AddLabel("Controller Tooltips");
            toolTipsMenu.AddToggleButton("Disable Controller Tooltips", (action) =>
            {
                disableToolTips.Value = !disableToolTips.Value;
            }, () => disableToolTips.Value);
            toolTipsMenu.AddToggleButton("Disable Controller Mesh Only", (action) =>
            {
                disableMeshOnly.Value = !disableMeshOnly.Value;
            }, () => disableMeshOnly.Value);
            toolTipsMenu.AddToggleButton("Disable on Game Load", (action) =>
            {
                disableToolTipsOnLoad.Value = !disableToolTipsOnLoad.Value;
            }, () => disableToolTipsOnLoad.Value);
            toolTipsMenu.AddSimpleButton("Close", () => toolTipsMenu.Hide());
        }
        private static MelonLogger.Instance FindMelon(Predicate <MelonBase> criterion)
        {
            MelonLogger.Instance loggerInstance = null;

            LemonEnumerator <MelonPlugin> PluginEnumerator = new LemonEnumerator <MelonPlugin>(MelonHandler._Plugins.ToArray());

            while (PluginEnumerator.MoveNext())
            {
                if (criterion(PluginEnumerator.Current))
                {
                    loggerInstance = PluginEnumerator.Current.LoggerInstance;
                    break;
                }
            }

            if (loggerInstance == null)
            {
                LemonEnumerator <MelonMod> ModEnumerator = new LemonEnumerator <MelonMod>(MelonHandler._Mods.ToArray());
                while (ModEnumerator.MoveNext())
                {
                    if (criterion(ModEnumerator.Current))
                    {
                        loggerInstance = ModEnumerator.Current.LoggerInstance;
                        break;
                    }
                }
            }

            return(loggerInstance);
        }
Esempio n. 4
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("NearClipPlaneAdj", ConsoleColor.DarkYellow);

            MelonPreferences.CreateCategory("NearClipAdj", "NearClipPlane Adjuster");
            changeClipOnLoad = MelonPreferences.CreateEntry <bool>("NearClipAdj", "changeClipOnLoad", true, "Change NearClip on world load");
            UIX_butts_QM     = MelonPreferences.CreateEntry("NearClipAdj", "UIX_butts_QM", true, "Place buttons in Settings QM instead of Settings Big Menu");
            keybindsEnabled  = MelonPreferences.CreateEntry <bool>("NearClipAdj", "Keyboard", true, "Keyboard Shortcuts: '[' - 0.0001, ']' - 0.05");

            changeUIcam    = MelonPreferences.CreateEntry <bool>("NearClipAdj", "changeUIcam", true, "Change UI Camera Nearclip");
            smallerDefault = MelonPreferences.CreateEntry <bool>("NearClipAdj", "SmallerDefault", false, "Smaller Default Nearclip on World Change - 0.001 vs 0.01");
            raiseNearClip  = MelonPreferences.CreateEntry <bool>("NearClipAdj", "RaiseOnQuickMenu", false, "If using smaller Default Nearclip (0.001) raise to 0.01 when Quick Menu opens.");

            AMAPI_en               = MelonPreferences.CreateEntry <bool>("NearClipAdj", "AMAPI_en", true, "Action Menu API Support (Requires Restart)");
            amapi_ModsFolder       = MelonPreferences.CreateEntry("NearClipAdj", "amapi_ModsFolder", false, "Place Action Menu in 'Mods' Sub Menu instead of 'Config' menu (Restert Required)");
            defaultChangeBlackList = MelonPreferences.CreateEntry("NearClipAdj", "defaultChangeBlackList", true, "Check a blacklist for worlds to not auto change the NearClip on (Restart Required to Enable)");

            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("Nearplane-0.05", (() => ChangeNearClipPlane(.05f, true)), (butt) => { n05 = butt; butt.SetActive(!UIX_butts_QM.Value); });
            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("Nearplane-0.01", (() => ChangeNearClipPlane(.01f, true)), (butt) => { n01 = butt; butt.SetActive(!UIX_butts_QM.Value); });
            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("Nearplane-0.001", (() => ChangeNearClipPlane(.001f, true)), (butt) => { n001 = butt; butt.SetActive(!UIX_butts_QM.Value); });
            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("Nearplane-0.0001", (() => ChangeNearClipPlane(.0001f, true)), (butt) => { n0001 = butt; butt.SetActive(!UIX_butts_QM.Value); });

            var clips = new float[] {
                .05f,
                .01f,
                .001f,
                .0001f,
            };

            var Menu = ExpansionKitApi.CreateCustomQuickMenuPage(LayoutDescriptionCustom.QuickMenu1Column6Row);

            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UiElementsQuickMenu).AddSimpleButton("Near Clipping Plane Distance", () => Menu.Show(), (butt) => { QMbutt = butt; butt.SetActive(UIX_butts_QM.Value); });
            Menu.AddLabel("Near Clipping Plane Distance");
            foreach (var clip in clips)
            {
                Menu.AddSimpleButton($"Nearplane-{clip}", (() => ChangeNearClipPlane(clip, true)));
            }
            Menu.AddSimpleButton("Close", () => Menu.Hide());

            Logger.Msg("Registering components...");
            ClassInjector.RegisterTypeInIl2Cpp <EnableDisableListener>();
            MelonCoroutines.Start(OnLoad());

            if (MelonHandler.Mods.Any(m => m.Info.Name == "ActionMenuApi") && AMAPI_en.Value)
            {
                CustomActionMenu.InitUi();
            }
            else
            {
                Logger.Msg("ActionMenuApi is missing, or setting is toggled off in Mod Settings - Not adding controls to ActionMenu");
            }

            if (defaultChangeBlackList.Value)
            {
                GetBlackList();
            }
        }
Esempio n. 5
0
        // Wait for Ui Init so XRDevice.isPresent is defined
        public override void OnApplicationStart()
        {
            _logger    = LoggerInstance;
            _hInstance = HarmonyInstance;

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Esempio n. 6
0
        public override void OnApplicationStart()
        {
            _logger = LoggerInstance;

            ClassInjector.RegisterTypeInIl2Cpp <EnableDisableListener>();

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Esempio n. 7
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("CameraResChanger");

            cat                = MelonPreferences.CreateCategory("CamResChange", "Camera Res Changer");
            LargerSizes        = MelonPreferences.CreateEntry("CamResChange", nameof(LargerSizes), true, "Enable Sizes > 8k (Needs 'Lag Free Screenshots') - This may break/work with new VRC versions, test when the game updates");
            AdjustSizeAtLaunch = MelonPreferences.CreateEntry("CamResChange", nameof(AdjustSizeAtLaunch), false, "Adjust Camera res at game launch");
            DefaultSize        = MelonPreferences.CreateEntry("CamResChange", nameof(DefaultSize), "4k", "Camera res for Adjust at Launch");
            ExpansionKitApi.RegisterSettingAsStringEnum("CamResChange",
                                                        nameof(DefaultSize),
                                                        new[]
Esempio n. 8
0
        public override void OnApplicationStart()
        {
            Logger = LoggerInstance;

            MelonPreferences.CreateCategory("TrackingRotator", "Tracking Rotator");
            _uixIntegration             = MelonPreferences.CreateEntry("TrackingRotator", nameof(_uixIntegration), true, "Integrate with UiExpansionKit?");
            _amapiIntegration           = MelonPreferences.CreateEntry("TrackingRotator", nameof(_amapiIntegration), true, "Integrate with Action Menu?");
            _rotationValue              = MelonPreferences.CreateEntry("TrackingRotator", nameof(_rotationValue), 22.5f, "Rotation value");
            _highPrecisionRotationValue = MelonPreferences.CreateEntry("TrackingRotator", nameof(_highPrecisionRotationValue), 1f, "High precision rotation value");
            _resetRotationOnSceneChange = MelonPreferences.CreateEntry("TrackingRotator", nameof(_resetRotationOnSceneChange), false, "Reset rotation when a new world loads");

            Integrations();

            Logger.Msg("Successfully loaded!");
        }
Esempio n. 9
0
        public override void OnApplicationStart()
        {
            _logger     = LoggerInstance;
            _isUsingUix = MelonHandler.Mods.Any(x => x.Info.Name.Equals("UI Expansion Kit"));

            // Set preferences
            MelonPreferences.CreateCategory("ToggleFullScreen", "Toggle FullScreen");
            _fsResolution = MelonPreferences.CreateEntry("ToggleFullScreen", "FSResolution", "Maximum", "FullScreen Resolution");
            _previous     = new Resolution {
                width = Screen.width, height = Screen.height
            };
            CheckAndUpdateResolutions();

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Esempio n. 10
0
        public override void OnApplicationStart()
        {
            Logger    = LoggerInstance;
            HInstance = HarmonyInstance;

            ClassInjector.RegisterTypeInIl2Cpp <PortalPtr>();
            ClassInjector.RegisterTypeInIl2Cpp <EnableDisableListener>();
            MelonPreferences.CreateCategory("BetterPortalPlacement", "BetterPortalPlacement Settings");
            IsModOn = MelonPreferences.CreateEntry("BetterPortalPlacement", nameof(IsModOn), true, "Enable BetterPortalPlacement");
            UseConfirmationPopup = MelonPreferences.CreateEntry("BetterPortalPlacement", nameof(UseConfirmationPopup), false, "Use confirmation popup when dropping portal?");
            IsOnlyOnError        = MelonPreferences.CreateEntry("BetterPortalPlacement", nameof(IsOnlyOnError), false, "Use only on error?");
            Patches.ApplyPatches();

            WaitForUiInit();

            Logger.Msg("Successfully loaded!");
        }
Esempio n. 11
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("LocalLightMod");

            cat = MelonPreferences.CreateCategory(catagory, "Local Light Mod");

            loadDefaults  = MelonPreferences.CreateEntry(catagory, nameof(loadDefaults), false, "Load Slot 1 as Default");
            textureLights = MelonPreferences.CreateEntry(catagory, nameof(textureLights), true, "Texture Lights with Name");

            savedPrefs  = MelonPreferences.CreateEntry(catagory, nameof(savedPrefs), "1,False,True,Point,10.,30.,1,1,1,1.,1.,Hard,1.,N/A,False;2,False,True,Point,10.,30.,1,1,1,1.,1.,Hard,1.,N/A,False;3,False,True,Point,10.,30.,1,1,1,1.,1.,Hard,1.,N/A,False;4,False,True,Point,10.,30.,1,1,1,1.,1.,Hard,1.,N/A,False;5,False,True,Point,10.,30.,1,1,1,1.,1.,Hard,1.,N/A,False", "saved perfs", "", true);
            savedColors = MelonPreferences.CreateEntry(catagory, nameof(savedColors), "1,0.0,0.0,0.0;2,0.0,0.0,0.0;3,0.0,0.0,0.0;4,0.0,0.0,0.0;5,0.0,0.0,0.0;6,0.0,0.0,0.0", "saved colors", "", true);

            UIX.SetupUI();
            if (loadDefaults.Value)
            {
                SaveSlots.LoadDefaultSlot();
            }
        }
        private void WarnIfHasTranspiler(PatchInfo patchInfo, MelonLogger.Instance loggerInstance)
        {
            if (patchInfo.transpilers.Length <= 0)
            {
                return;
            }
            string txt = $"Harmony: Method {Original.FullDescription()} will only have its Unhollowed IL available to Transpilers, " +
                         "suggesting you either don't use any Transpilers when Patching this Method or ignore this Warning if modifying the Unhollowed IL is your goal.";

            if (loggerInstance != null)
            {
                loggerInstance.Warning(txt);
            }
            else
            {
                MelonLogger.Warning(txt);
            }
        }
Esempio n. 13
0
        public override void OnApplicationStart()
        {
            _logger    = LoggerInstance;
            _hInstance = HarmonyInstance;
            MelonPreferences.CreateCategory("BetterSteadycam", "BetterSteadycam Settings");
            _fieldOfView           = MelonPreferences.CreateEntry("BetterSteadycam", nameof(_fieldOfView), 60f, "Field of view (FOV)");
            _smoothing             = MelonPreferences.CreateEntry("BetterSteadycam", nameof(_smoothing), true, "Smoothing");
            _smoothingValue        = MelonPreferences.CreateEntry("BetterSteadycam", nameof(_smoothingValue), 5f, "Smoothing value");
            _renderUi              = MelonPreferences.CreateEntry("BetterSteadycam", nameof(_renderUi), true, "Render UI");
            _enableButtonOnDesktop = MelonPreferences.CreateEntry("BetterSteadycam", nameof(_enableButtonOnDesktop), true, "Enable button on desktop");
            LoadPreferences();

            _hInstance.Patch(typeof(FPVCameraController).GetMethod(nameof(FPVCameraController.Update)),
                             new HarmonyMethod(typeof(Main).GetMethod(nameof(FpvCameraControllerUpdatePatch), BindingFlags.NonPublic | BindingFlags.Static)));

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Esempio n. 14
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("ImmobilizePlayerMod");

            MelonPreferences.CreateCategory("ImPlaMod", "Immobilize Player Mod");
            buttonEnabled        = MelonPreferences.CreateEntry <bool>("ImPlaMod", "QuickMenuButton", true, "Put Button on Quick Menu");
            movementToggle       = MelonPreferences.CreateEntry <bool>("ImPlaMod", "MovementToggle", false, "Auto toggle if not moving | Only will trigger if using VR");
            autoButtonEnabled    = MelonPreferences.CreateEntry <bool>("ImPlaMod", "autoButtonEnabled", true, "Put Auto Toggle Button on Quick Menu");
            allowAutoForNonFBT   = MelonPreferences.CreateEntry <bool>("ImPlaMod", "allowAutoForNonFBT", false, "-Auto- Allow for half body VR players");
            allowAutoForFBTnoIKT = MelonPreferences.CreateEntry <bool>("ImPlaMod", "allowAutoForFBTnoIKT", false, "-Auto- Allow for FBT players without IKTweaks (Not recommened, will cause Chest bone issues)");
            deadZone             = MelonPreferences.CreateEntry <float>("ImPlaMod", "DeadZone", 0.03f, "-Auto- Deadzone for Movement detection");
            delay        = MelonPreferences.CreateEntry <float>("ImPlaMod", "delay", .001f, "-Auto- Delay between checks");
            settleBefore = MelonPreferences.CreateEntry <bool>("ImPlaMod", "settleBefore", true, "-Auto- Settle for X seconds before Immobilizing");
            settleTime   = MelonPreferences.CreateEntry <float>("ImPlaMod", "settleTime", 3f, "-Auto- Time to wait for settling");

            debug    = MelonPreferences.CreateEntry <bool>("ImPlaMod", "debug", false, "Debug messages in Console");
            debugHUD = MelonPreferences.CreateEntry <bool>("ImPlaMod", "debugHUD", false, "Debug HUD");

            movementToggle.OnValueChanged += OnValueChange;

            AddToQM();
            MelonCoroutines.Start(WaitForQM());

            MethodsResolver.ResolveMethods();
            // Patches - https://github.com/SDraw/ml_mods/blob/af8eb07bd810067b968f0d21bb1dacf0be89d8b3/ml_clv/Main.cs#L28
            if (MethodsResolver.PrepareForCalibration != null)
            {
                HarmonyInstance.Patch(MethodsResolver.PrepareForCalibration, null, new HarmonyLib.HarmonyMethod(typeof(Main), nameof(VRCTrackingManager_PrepareForCalibration)));
            }
            if (MethodsResolver.RestoreTrackingAfterCalibration != null)
            {
                HarmonyInstance.Patch(MethodsResolver.RestoreTrackingAfterCalibration, null, new HarmonyLib.HarmonyMethod(typeof(Main), nameof(VRCTrackingManager_RestoreTrackingAfterCalibration)));
            }
            if (MethodsResolver.IKTweaks_Calibrate != null)
            {
                HarmonyInstance.Patch(MethodsResolver.IKTweaks_Calibrate, new HarmonyLib.HarmonyMethod(typeof(Main), nameof(VRCTrackingManager_PrepareForCalibration)), null);
            }
            if (MethodsResolver.IKTweaks_ApplyStoredCalibration != null)
            {
                HarmonyInstance.Patch(MethodsResolver.IKTweaks_ApplyStoredCalibration, new HarmonyLib.HarmonyMethod(typeof(Main), nameof(VRCTrackingManager_RestoreTrackingAfterCalibration)), null);
            }
        }
        private void WarnIfOriginalMethodIsInlined(MelonLogger.Instance loggerInstance)
        {
            int callerCount = UnhollowerSupport.GetIl2CppMethodCallerCount(Original) ?? -1;

            if (callerCount > 0 ||
                UnityMagicMethods.IsUnityMagicMethod(Original))
            {
                return;
            }
            string txt = $"Harmony: Method {Original.FullDescription()} does not appear to get called directly from anywhere, " +
                         "suggesting it may have been inlined and your patch may not be called.";

            if (loggerInstance != null)
            {
                loggerInstance.Warning(txt);
            }
            else
            {
                MelonLogger.Warning(txt);
            }
        }
Esempio n. 16
0
        public override void OnApplicationStart()
        {
            Logger = new MelonLogger.Instance("FLuxMod", ConsoleColor.DarkRed);

            cat = MelonPreferences.CreateCategory("FLuxMod", "FLuxMod");
            amapi_ModsFolder = MelonPreferences.CreateEntry("FLuxMod", nameof(amapi_ModsFolder), "Options", "Folder in radial menun to place Sub Menu in (Restart Required)");

            flux_HDRClamp = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_HDRClamp), .222f, "HDRClamp (0-1)"); //.778
            flux_Hue      = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_Hue), .102f, "Hue (0-1)");

            flux_Colorize   = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_Colorize), .75f, "Colorize (0-1)"); //.25
            flux_Brightness = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_Brightness), .623f, "Brightness (0-1)");
            flux_Desat      = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_Desat), .255f, "Desaturation (0-1)");

            flux_scale = MelonPreferences.CreateEntry("FLuxMod", nameof(flux_scale), 1f, "Scale of sphere around vision");

            slot1Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot1Name), "Default", "Slot 1 Name");
            slot2Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot2Name), "No Bloom", "Slot 2 Name");
            slot3Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot3Name), "HDR Only", "Slot 3 Name");
            slot4Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot4Name), "Dim", "Slot 4 Name");
            slot5Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot5Name), "Sleep", "Slot 5 Name");
            slot6Name  = MelonPreferences.CreateEntry("FLuxMod", nameof(slot6Name), "SlotName", "Slot 6 Name");
            savedPrefs = MelonPreferences.CreateEntry("FLuxMod", nameof(savedPrefs), "1,0.222,0.102,0.75,0.623,0.255;2,0,0.102,0,1,0;3,0.5,0.102,0,1,0;4,0.5,0.102,0,0.75,0.15;5,0.5,0.102,0,0.10,0.25;6,0.222,0.102,0.75,0.623,0.255", "savedPrefs", "", true);

            if (MelonHandler.Mods.Any(m => m.Info.Name == "UI Expansion Kit"))
            {
                UIX.UIXinit();
            }

            loadAssets();

            flux_HDRClamp.OnValueChanged   += OnValueChange;
            flux_Hue.OnValueChanged        += OnValueChange;
            flux_Colorize.OnValueChanged   += OnValueChange;
            flux_Brightness.OnValueChanged += OnValueChange;
            flux_Desat.OnValueChanged      += OnValueChange;
            flux_scale.OnValueChanged      += OnValueChange;

            CustomActionMenu.InitUi();
        }