Exemple #1
0
 private static void WaitForUiInit()
 {
     if (_isUsingUix)
     {
         typeof(UIXManager).GetMethod(nameof(UIXManager.OnApplicationStart)) !.Invoke(null, null);
     }
     else
     {
         _logger.Warning("UiExpansionKit (UIX) was not detected. Using coroutine to wait for UiInit. Please consider installing UIX.");
         _logger.Warning("This also means that the function to change fullscreen resolution will only be usable by changing MelonPrefs directly at the file.");
         _logger.Warning("Again, please consider installing UIX.");
Exemple #2
0
 private void CreatePasteButton()
 {
     try {
         // Hey skids, if you're gonna take this and add to your mod, at least give me some credit. Much appreciated!
         _keybardPasteButton = Object.Instantiate(GameObject.Find("/UserInterface/MenuContent/Popups/InputPopup/ButtonLeft"),
                                                  VRCUiPopupManager.field_Public_VRCUiPopupInput_0.transform);
         _keybardPasteButton.GetComponent <RectTransform>().anchoredPosition = new Vector2(335f, -275f);
         _keybardPasteButton.GetComponentInChildren <Text>().text            = "Paste";
         _keybardPasteButton.name = "KeyboardPasteButton";
         _keybardPasteButton.GetComponent <Button>().onClick        = new Button.ButtonClickedEvent();
         _keybardPasteButton.GetComponent <Button>().m_Interactable = true;
         _keybardPasteButton.GetComponent <Button>().onClick.AddListener(new Action(() => {
             try {
                 if (GUIUtility.systemCopyBuffer.Length < 256)
                 {
                     GameObject.Find("UserInterface/MenuContent/Popups/InputPopup/InputField").GetComponent <InputField>().text = GUIUtility.systemCopyBuffer;
                 }
                 else
                 {
                     Logger.Warning("You cannot paste something more than 256 characters long in the keyboard.");
                 }
             }
             catch (Exception e) {
                 Logger.Error($"An error has occurred:\n{e}");
             }
         }));
         Log("Created the paste button.", _isDebug);
     }
     catch (Exception e) {
         Logger.Error($"Paste:\n{e}");
     }
 }
Exemple #3
0
 private static void WaitForUiInit()
 {
     if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("UI Expansion Kit")))
     {
         typeof(UIXManager).GetMethod(nameof(UIXManager.OnApplicationStart)) !.Invoke(null, null);
     }
     else
     {
         _logger.Warning("UiExpansionKit (UIX) was not detected. Using coroutine to wait for UiInit. Please consider installing UIX.");
Exemple #4
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);
        }
        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);
            }
        }
Exemple #6
0
        private static void Integrations()
        {
            if (_amapiIntegration.Value)
            {
                if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("ActionMenuApi")))
                {
                    Assets.OnApplicationStart();
                    _isUsingAmapi = true;
                }
                else
                {
                    Logger.Warning("For a better experience, please consider installing ActionMenuApi.");
                }
            }
            else
            {
                Logger.Warning("Integration with ActionMenuApi has been deactivated on Settings.");
            }

            if (_uixIntegration.Value)
            {
                if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("UI Expansion Kit")))
                {
                    typeof(UIXManager).GetMethod("OnApplicationStart") !.Invoke(null, null);
                    _isUsingUix = true;
                }
                else
                {
                    Logger.Warning("For a better experience, please consider installing UIExpansionKit.");
                }
            }
            else
            {
                Logger.Warning("Integration with UIExpansionKit has been deactivated on Settings.");
            }

            if (!_amapiIntegration.Value && !_uixIntegration.Value)
            {
                Logger.Warning("Both integrations (Action Menu and UiExpansionKit) have been deactivated. " +
                               "The mod cannot run without those, therefore, expect it to fail. If this was not intended, " +
                               "please consider activating at least one of the integrations on Settings.");
            }

            if (!_isUsingAmapi && !_isUsingUix)
            {
                Logger.Error("Failed to load both integrations with UIExpansionKit and ActionMenuApi! The mod will not be loaded.");
            }
            else if (!_isUsingUix)
            {
                Logger.Warning("Using coroutine to wait for UiInit.");
        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);
            }
        }