Esempio n. 1
0
        public override void VRChat_OnUiManagerInit()
        {
            MelonLogger.Log("BTK Standalone: Self Portrait - Starting Up");

            if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("BTKCompanionLoader", StringComparison.OrdinalIgnoreCase)))
            {
                MelonLogger.Log("Hold on a sec! Looks like you've got BTKCompanion installed, this mod is built in and not needed!");
                MelonLogger.LogError("BTKSASelfPortrait has not started up! (BTKCompanion Running)");
                return;
            }

            instance = this;

            harmony = HarmonyInstance.Create("BTKStandaloneSP");

            MelonPrefs.RegisterCategory(settingsCategory, "BTKSA Self Portrait");
            MelonPrefs.RegisterFloat(settingsCategory, prefsCameraDistance, 0.7f, "Camera Distance");
            MelonPrefs.RegisterInt(settingsCategory, prefsUIAlpha, 70, "UI Display Alpha Percentage");
            MelonPrefs.RegisterBool(settingsCategory, prefsUIFlip, true, "Flip Display (Matches mirrors)");
            MelonPrefs.RegisterBool(settingsCategory, prefsReflectOtherPlayers, false, "Reflect Other Players");
            MelonPrefs.RegisterFloat(settingsCategory, prefsFarClippingDist, 5f, "Camera Cutoff Distance");

            ExpansionKitApi.RegisterSimpleMenuButton(ExpandedMenu.QuickMenu, "Toggle Self Portrait", toggleSelfPortrait);

            //Using FadeTo hook to determine when world is pretty much loaded
            //Hooking FadeTo for world join late event
            foreach (MethodInfo method in typeof(VRCUiBackgroundFade).GetMethods(BindingFlags.Public | BindingFlags.Instance))
            {
                if (method.Name.Contains("Method_Public_Void_Single_Action") && !method.Name.Contains("PDM"))
                {
                    Log($"Found target fadeTo method, patching! ({method.Name})", true);
                    harmony.Patch(method, null, new HarmonyMethod(typeof(BTKSASelfPortrait).GetMethod("OnFade", BindingFlags.Static | BindingFlags.Public)));
                }
            }

            loadAssets();

            cameraEye  = GameObject.Find("Camera (eye)");
            hudContent = GameObject.Find("/UserInterface/UnscaledUI/HudContent");
        }
Esempio n. 2
0
        public void UiManagerInit()
        {
            MelonLogger.Msg("BTK Standalone: Self Portrait - Starting Up");

            if (MelonHandler.Mods.Any(x => x.Info.Name.Equals("BTKCompanionLoader", StringComparison.OrdinalIgnoreCase)))
            {
                MelonLogger.Msg("Hold on a sec! Looks like you've got BTKCompanion installed, this mod is built in and not needed!");
                MelonLogger.Error("BTKSASelfPortrait has not started up! (BTKCompanion Running)");
                return;
            }

            Instance = this;

            MelonPreferences.CreateCategory(SettingsCategory, "BTKSA Self Portrait");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsCameraDistance, 0.7f, "Camera Distance");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsUIAlpha, 70, "UI Display Alpha Percentage");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsUIFlip, true, "Flip Display (Matches mirrors)");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsReflectOtherPlayers, false, "Reflect Other Players");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsFarClippingDist, 5f, "Camera Cutoff Distance");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsPosX, 300f, "UI Position X");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsPosY, -250f, "UI Position Y");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsScaleX, 0.4f, "UI Scale X");
            MelonPreferences.CreateEntry(SettingsCategory, PrefsScaleY, 0.47f, "UI Scale Y");

            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddSimpleButton("Toggle Self Portrait", ToggleSelfPortrait);

            //Apply patches
            applyPatches(typeof(FadePatches));

            LoadAssets();

            _cameraEye  = GameObject.Find("Camera (eye)");
            _hudContent = GameObject.Find("/UserInterface/UnscaledUI/HudContent");

            OnPreferencesSaved();
        }