Пример #1
0
 private void Log(string message, bool isDebug = false)
 {
     if (isDebug)
     {
         Logger.Msg(ConsoleColor.Green, message);
         return;
     }
     Logger.Msg(message);
 }
Пример #2
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();
            }
        }
Пример #3
0
 public override void OnApplicationStart()
 {
     ModCategory     = MelonPreferences.CreateCategory("CustomConsoleTitle", "CustomConsoleTitle");
     CustomTitleText = ModCategory.CreateEntry("TitleText", "Being a Cutie!", "Title Text",
                                               "Text to show on the Console Window Title");
     _titleString  = GetFormattedTitleText();
     Console.Title = string.Format(_titleString);
     Logger.Msg($"Set console title to: {_titleString}");
 }
Пример #4
0
        public IEnumerator OnLoad()
        {
            Logger.Msg("Adding QM listener...."); //From https://github.com/tetra-fox/QMFreeze/blob/master/QMFreeze/Mod.cs
            while (GameObject.Find("/UserInterface")?.transform.Find("Canvas_QuickMenu(Clone)/Container/Window/MicButton") == null)
            {
                yield return(new WaitForSeconds(1f));
            }
            EnableDisableListener listener = GameObject.Find("/UserInterface")?.transform.Find("Canvas_QuickMenu(Clone)/Container/Window/MicButton").gameObject
                                             .AddComponent <EnableDisableListener>();

            listener.OnEnabled  += delegate { QMopen(); };
            listener.OnDisabled += delegate { QMclosed(); };

            string vrCamPath      = "_Application/TrackingVolume/TrackingSteam(Clone)/SteamCamera/[CameraRig]/Neck/Camera (eye)/StackedCamera : Cam_InternalUI";
            string desktopCamPath = "_Application/TrackingVolume/TrackingSteam(Clone)/SteamCamera/[CameraRig]/Neck/Camera (head)/Camera (eye)/StackedCamera : Cam_InternalUI";

            try
            {
                if (GameObject.Find(vrCamPath) != null)
                {
                    UIcamera = GameObject.Find(vrCamPath).GetComponent <Camera>();
                }
                else
                {
                    UIcamera = GameObject.Find(desktopCamPath).GetComponent <Camera>();
                }
            }
            catch (System.Exception ex) { Logger.Error($"Error finding UI Camera\n" + ex.ToString()); }

            Logger.Msg("Initialized QM listener + UICam Found!");
        }
Пример #5
0
 public IEnumerator OnLoad()
 {
     if (!disableToolTipsOnLoad.Value)
     {
         yield break;
     }
     Logger.Msg("Waiting for QM first open");
     //while (GameObject.Find("_Application/TrackingVolume/TrackingSteam(Clone)/SteamCamera/[CameraRig]/Controller (left)") == null)
     while (GameObject.Find("/UserInterface/Canvas_QuickMenu(Clone)/Container/Window/MicButton") == null) //Why wait for the MicButton, because I use this in other mods so I only need to fix one thing if it breaks in the future! Also you can't open the camera without going through the QM
     {
         yield return(new WaitForSeconds(1f));                                                            //Also because before if we checked for the Controller container to init, and people started their controllers after starting the game, it wouldn't disable their overlays, cause they hadn't been created yet. I assume now people would have their controllers on before opening the QM
     }
     Logger.Msg("QM Opened | Controllers Disabled");
     disableToolTips.Value = true;
     ToggleToolTips(false);
 }
Пример #6
0
        private unsafe static bool PatchMonoExport()
        {
            IntPtr monolib = MonoLibrary.GetLibPtr();

            if (monolib == IntPtr.Zero)
            {
                return(false);
            }

            NativeLibrary monoLibrary = new NativeLibrary(monolib);
            IntPtr        export      = monoLibrary.GetExport("mono_unity_get_unitytls_interface");

            if (export == IntPtr.Zero)
            {
                Logger.Error("Failed to find mono_unity_get_unitytls_interface! This should never happen...");
                return(false);
            }

            Logger.Msg("Patching mono_unity_get_unitytls_interface...");
            MethodInfo patch    = typeof(Il2CppUnityTls_Module).GetMethod("GetUnityTlsInterface", BindingFlags.NonPublic | BindingFlags.Static);
            IntPtr     patchptr = patch.MethodHandle.GetFunctionPointer();

            MelonUtils.NativeHookAttach((IntPtr)(&export), patchptr);

            return(true);
        }
Пример #7
0
        // Wait for Ui Init so XRDevice.isPresent is defined
        public override void OnApplicationStart()
        {
            _logger    = LoggerInstance;
            _hInstance = HarmonyInstance;

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Пример #8
0
        public override void OnApplicationStart()
        {
            _logger = LoggerInstance;

            ClassInjector.RegisterTypeInIl2Cpp <EnableDisableListener>();

            WaitForUiInit();

            _logger.Msg("Successfully loaded!");
        }
Пример #9
0
        private unsafe static bool PatchExports()
        {
            IntPtr monolib = MonoLibrary.GetLibPtr();

            if (monolib == IntPtr.Zero)
            {
                Logger.Warning("Unable to find Mono Library Pointer!");
                return(false);
            }

            NativeLibrary monoLibrary = new NativeLibrary(monolib);
            IntPtr        mono_export = monoLibrary.GetExport("mono_unity_get_unitytls_interface");

            if (mono_export == IntPtr.Zero)
            {
                Logger.Warning("Unable to find Mono's mono_unity_get_unitytls_interface Export!");
                return(false);
            }

            NativeLibrary il2cppLibrary = NativeLibrary.Load(Path.Combine(MelonUtils.GameDirectory, "GameAssembly.dll"));
            IntPtr        il2cpp_export = il2cppLibrary.GetExport("il2cpp_unity_install_unitytls_interface");

            if (il2cpp_export == IntPtr.Zero)
            {
                Logger.Warning("Unable to find Il2Cpp's il2cpp_unity_install_unitytls_interface Export!");
                return(false);
            }

            Logger.Msg("Patching mono_unity_get_unitytls_interface...");
            MelonUtils.NativeHookAttach((IntPtr)(&mono_export), typeof(Il2CppUnityTls_Module).GetMethod("GetUnityTlsInterface", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer());

            Logger.Msg("Patching il2cpp_unity_install_unitytls_interface...");
            MelonUtils.NativeHookAttach((IntPtr)(&il2cpp_export), typeof(Il2CppUnityTls_Module).GetMethod("SetUnityTlsInterface", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer());
            OriginalSetUnityTlsInterface = (dSetUnityTlsInterface)Marshal.GetDelegateForFunctionPointer(il2cpp_export, typeof(dSetUnityTlsInterface));

            return(true);
        }
Пример #10
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!");
        }
Пример #11
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!");
        }
Пример #12
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!");
        }
Пример #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!");
        }
Пример #14
0
        public unsafe override void Setup()
        {
            if (!PatchMonoExport())
            {
                Logger.Error("Web Connection based C# Methods may not work as intended.");
                return;
            }

            if (!PatchIl2CppExport())
            {
                Logger.Error("Web Connection based C# Methods may not work as intended.");
                return;
            }

            IntPtr unityplayer = GetUnityPlayerModule(out int unityplayer_size);

            if (unityplayer == IntPtr.Zero)
            {
                return;
            }

            IntPtr[] ptrs = null;
            if (MelonUtils.IsGame32Bit())
            {
                ptrs = CppUtils.SigscanAll(unityplayer, unityplayer_size, "A1 ?? ?? ?? ?? 85 C0 0F 85 68 01 00 00 A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? B8 ?? ?? ?? ?? C7 05");
            }
            else
            {
                ptrs = CppUtils.SigscanAll(unityplayer, unityplayer_size, "48 8B 0D ?? ?? ?? ?? 48 85 C9 0F 85 DC 01 00 00 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 89 05");
            }

            if (ptrs.Length <= 0)
            {
                if (MelonUtils.IsGame32Bit())
                {
                    ptrs = CppUtils.SigscanAll(unityplayer, unityplayer_size, "A1 ?? ?? ?? ?? 8B 0D ?? ?? ?? ?? 85 C0 0F 85 68 01 00 00 A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? A3 ?? ?? ?? ?? B8 ?? ?? ?? ?? C7 05");
                }
                else
                {
                    ptrs = CppUtils.SigscanAll(unityplayer, unityplayer_size, "48 8B 0D ?? ?? ?? ?? 48 8B 15 ?? ?? ?? ?? 48 85 C9 0F 85 DC 01 00 00 48 8B 05 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 48 89 05 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 89 05");
                }
            }

            if (ptrs.Length <= 0)
            {
                Logger.Error("InstallUnityTlsInterface was not found!");
                Logger.Error("Web Connection based C# Methods may not work as intended.");
                return;
            }

            foreach (IntPtr ptr in ptrs)
            {
                byte *i = (byte *)ptr.ToPointer();
                if (*i == 0 || (*i & 0xF) == 0xF)
                {
                    continue;
                }
                Logger.Msg("Calling InstallUnityTlsInterface...");
                dInstallUnityTlsInterface installUnityTlsInterface = (dInstallUnityTlsInterface)Marshal.GetDelegateForFunctionPointer(ptr, typeof(dInstallUnityTlsInterface));
                installUnityTlsInterface();
                break;
            }
        }
Пример #15
0
 private void AddToQM()
 {
     Logger.Msg($"Adding QM button");
     ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddToggleButton("Immobilize", (action) =>
     {
         imState       = action;
         qmButtOveride = action;
         Utils.SetImmobilize(action);
     }, () => false, (button) => { buttonQM = button; button.gameObject.SetActive(buttonEnabled.Value); });
     ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddToggleButton("Immobilize Auto Toggle", (action) =>
     {
         movementToggle.Value = action;
     }, () => movementToggle.Value, (button) => { buttonQMAuto = button; button.gameObject.SetActive(autoButtonEnabled.Value || movementToggle.Value); });
 }