Exemplo n.º 1
0
        private void AddUserSpecificVolume()
        {
            if (!ModPrefs.GetBool("vrcextended", "userSpecificVolume"))
            {
                return;
            }
            if (VRCEUi.UserInfoScreen == null)
            {
                ExtendedLogger.LogError("Failed to find UserInfo screen!");
                return;
            }

            // -550 - 250f, 230f - 280f
            volVoice  = new VRCEUiVolumeControl("volumeVoice", new Vector2(-620f, -230f), "Voice", 1f, VRCEUi.UserInfoScreen.transform);
            volAvatar = new VRCEUiVolumeControl("volumeAvatar", new Vector2(-290f, -230f), "Avatar", 1f, VRCEUi.UserInfoScreen.transform);
            if (!volVoice.Success || !volAvatar.Success)
            {
                ExtendedLogger.LogError("Failed to create volume sliders on UserInfo!");
                return;
            }

            // Setup volume events
            volVoice.Slider.onValueChanged.AddListener(delegate(float volume)
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ExtendedUser user = ExtendedServer.Users.FirstOrDefault(a => a.APIUser.id == Patch_PageUserInfo.SelectedAPI.id);

                if (user == null)
                {
                    return;
                }
                user.VolumeVoice = volume;
            });

            /*volAvatar.Slider.onValueChanged.AddListener(delegate (float volume)
             * {
             *  if (Patch_PageUserInfo.SelectedUser == null)
             *      return;
             *  Patch_PageUserInfo.SelectedUser.VolumeAvatar = volume;
             * });*/
        }
Exemplo n.º 2
0
        void OnLevelWasLoaded(int level) // Level 0 = Loading Screen, Level 1 = Login Screen, Level -1 = Game
        {
            if (level == 0)
            {
                return;
            }

            if (level == 1 && !_initialized)
            {
                // Setup FPS manager
                FrameRate = Application.targetFrameRate;
                ExtendedLogger.Log("Captured default FPS: " + FrameRate);
                if (ModPrefs.GetBool("vrcextended", "unlimitedFPS"))
                {
                    Application.targetFrameRate = 0;
                }

                // Setup systems
                VRCPlayerManager.Setup();
                VRCEPlayer.Setup();

                VRCPlayerManager.OnPlayerJoined += delegate(VRCEPlayer player)
                {
                    ExtendedServer.Users.Add(new ExtendedUser(player));
                    ExtendedLogger.Log("Player joined: " + player.APIUser.displayName);
                };
                VRCPlayerManager.OnPlayerLeft += delegate(VRCEPlayer player)
                {
                    ExtendedServer.Users.Remove(new ExtendedUser(player));
                    ExtendedLogger.Log("Player left: " + player.APIUser.displayName);
                };

                _initialized = true;
                return;
            }
            ExtendedServer.Users.Clear();
        }
Exemplo n.º 3
0
        private IEnumerator VRCToolsSetup()
        {
            initialising = true;
            VRCModLogger.Log("[VRCTools] Initialising VRCTools");
            try
            {
                OculusUtils.ApplyPatches();
            }
            catch (Exception e)
            {
                VRCModLogger.Log("[VRCTools] Error while applying Oculus patches: " + e);
            }
            yield return(VRCUiManagerUtils.WaitForUiManagerInit());

            VRCModLogger.Log("[VRCTools] Overwriting login button event");
            VRCUiPageAuthentication[] authpages = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>();
            VRCUiPageAuthentication   loginPage = authpages.First((page) => page.gameObject.name == "LoginUserPass");

            if (loginPage != null)
            {
                Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>();
                if (loginButton != null)
                {
                    ButtonClickedEvent bce = loginButton.onClick;
                    loginButton.onClick = new ButtonClickedEvent();
                    loginButton.onClick.AddListener(() => {
                        VRCModNetworkManager.SetCredentials(GetTextFromUiInputField(loginPage.loginUserName) + ":" + GetTextFromUiInputField(loginPage.loginPassword));
                        bce?.Invoke();
                    });
                }
                else
                {
                    VRCModLogger.Log("[VRCTools] Unable to find login button in login page");
                }
            }
            else
            {
                VRCModLogger.Log("[VRCTools] Unable to find login page");
            }

            yield return(DependenciesDownloader.CheckDownloadFiles());

            yield return(VRCModLoaderUpdater.CheckVRCModLoaderHash());

            if (ModPrefs.GetBool("vrctools", "enablediscordrichpresence"))
            {
                DiscordManager.Init();
            }

            yield return(AvatarFavUpdater.CheckForAvatarFavUpdate());

            VRCModNetworkStatus.Setup();
            ModConfigPage.Setup();
            ModdedUsersManager.Init();

            /*
             * if (ApiCredentials.Load())
             * {
             *  VRCModLogger.Log("ApiCredentials.GetAuthTokenProviderUserId() => " + ApiCredentials.());
             *  if (!SecurePlayerPrefs.HasKey("vrcmnw_token_" + ApiCredentials.GetAuthTokenProviderUserId()))
             *  {
             *      ApiCredentials.Clear();
             *  }
             * }
             */
            ApiCredentials.Clear();


            VRCModLogger.Log("[VRCTools] Init done !");

            VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();

            VRCFlowManagerUtils.EnableVRCFlowManager();

            initialising = false;
            Initialised  = true;

            VRCModNetworkManager.ConnectAsync();
        }
Exemplo n.º 4
0
        private IEnumerator VRCToolsSetup()
        {
            VRCModLogger.Log("[VRCTools] Waiting for UI Manager...");
            yield return(VRCUiManagerUtils.WaitForUiManagerInit());

            VRCModLogger.Log("[VRCTools] UIManager initialised ! Resuming setup");

            VRCModLogger.Log("[VRCTools] Overwriting login button event");
            VRCUiPageAuthentication[] authpages = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>();
            VRCUiPageAuthentication   loginPage = authpages.First((page) => page.gameObject.name == "LoginUserPass");

            if (loginPage != null)
            {
                Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>();
                if (loginButton != null)
                {
                    ButtonClickedEvent bce = loginButton.onClick;
                    loginButton.onClick = new ButtonClickedEvent();
                    loginButton.onClick.AddListener(() => {
                        VRCModNetworkManager.SetCredentials(GetTextFromUiInputField(loginPage.loginUserName) + ":" + GetTextFromUiInputField(loginPage.loginPassword));
                        bce?.Invoke();
                    });
                }
                else
                {
                    VRCModLogger.Log("[VRCTools] Unable to find login button in login page");
                }
            }
            else
            {
                VRCModLogger.Log("[VRCTools] Unable to find login page");
            }

            VRCModLogger.Log("[VRCTools] CheckDownloadFiles");
            yield return(DependenciesDownloader.CheckDownloadFiles());

            VRCModLogger.Log("[VRCTools] CheckVRCModLoaderHash");
            yield return(VRCModLoaderUpdater.CheckVRCModLoaderHash());

            if (ModPrefs.GetBool("vrctools", "enablediscordrichpresence"))
            {
                VRCModLogger.Log("[VRCTools] DiscordManager Init");
                DiscordManager.Init();
            }
            VRCModLogger.Log("[VRCTools] CheckForPermissions");
            yield return(CheckForPermissions());

            VRCModLogger.Log("[VRCTools] VRCModNetworkStatus Setup");
            VRCModNetworkStatus.Setup();
            VRCModLogger.Log("[VRCTools] ModConfigPage Setup");
            ModConfigPage.Setup();
            VRCModLogger.Log("[VRCTools] ModdedUsersManager Init");
            ModdedUsersManager.Init();

            VRCUiManagerUtils.OnPageShown += (page) => {
                VRCModLogger.Log("[VRCTools] OnPageShown: " + page.screenType + " " + (string.IsNullOrEmpty(page.displayName) ? "" : page.displayName + " ") + "(" + page.GetType() + ")");
            };

            VRCModLogger.Log("[VRCTools] Init done !");

            VRCFlowManagerUtils.EnableVRCFlowManager();

            initialising = false;
            Initialised  = true;

            //DebugUtils.PrintHierarchy(VRCUiManagerUtils.GetVRCUiManager().transform.root, 0);
        }
Exemplo n.º 5
0
        void OnApplicationStart()
        {
            ExtendedLogger.Log("Loading VRCExtended...");

            // Setup config
            ModPrefs.RegisterCategory("vrcextended", "VRCExtended");

            // VRCExtended
            ModPrefs.RegisterPrefBool("vrcextended", "useDTFormat", false, "Use American format");
            ModPrefs.RegisterPrefBool("vrcextended", "fpsManagement", false, "FPS management");
            ModPrefs.RegisterPrefBool("vrcextended", "unlimitedFPS", false, "Unlimited FPS");

            // Exploits
            ModPrefs.RegisterPrefBool("vrcextended", "askUsePortal", true, "Ask to use portal");
            ModPrefs.RegisterPrefBool("vrcextended", "disablePortal", false, "Disable portals");
            ModPrefs.RegisterPrefBool("vrcextended", "antiCrasher", false, "Prevent crashers");
#if DEBUG
            ModPrefs.RegisterPrefBool("vrcextended", "avatarLimiter", false, "Avatar limiter"); // TODO
#else
            ModPrefs.RegisterPrefBool("vrcextended", "avatarLimiter", false, "Avatar limiter", true);
#endif

            // Avatar
            ModPrefs.RegisterPrefBool("vrcextended", "localColliders", false, "Local colliders");
            ModPrefs.RegisterPrefBool("vrcextended", "multiLocalColliders", false, "Others have local colliders");
            ModPrefs.RegisterPrefBool("vrcextended", "selfLocalColliders", true, "Others can touch you");
            ModPrefs.RegisterPrefBool("vrcextended", "targetHandColliders", true, "Target only hand colliders");
            ModPrefs.RegisterPrefBool("vrcextended", "fakeColliders", false, "Add fake colliders to self");
            ModPrefs.RegisterPrefBool("vrcextended", "fakeCollidersOthers", false, "Add fake colliders to others");
            ModPrefs.RegisterPrefBool("vrcextended", "ignoreInsideColliders", true, "Ignore pull colliders");
#if DEBUG
            ModPrefs.RegisterPrefBool("vrcextended", "smartColliders", false, "Use smart colliders"); // TODO
#else
            ModPrefs.RegisterPrefBool("vrcextended", "smartColliders", false, "Use smart colliders", true);
#endif

            // Players
#if DEBUG
            ModPrefs.RegisterPrefBool("vrcextended", "userSpecificVolume", false, "User specific volumes");
#else
            ModPrefs.RegisterPrefBool("vrcextended", "userSpecificVolume", false, "User specific volumes", true); // Can't get this shit to work
#endif

            // Grab the previous data
            p_anticrash             = ModPrefs.GetBool("vrcextended", "antiCrasher");
            p_localcolliders        = ModPrefs.GetBool("vrcextended", "localColliders");
            p_multilocalcolliders   = ModPrefs.GetBool("vrcextended", "multiLocalColliders");
            p_selflocalcolliders    = ModPrefs.GetBool("vrcextended", "selfLocalColliders");
            p_targetHandColliders   = ModPrefs.GetBool("vrcextended", "targetHandColliders");
            p_fakeColliders         = ModPrefs.GetBool("vrcextended", "fakeColliders");
            p_fakeCollidersOthers   = ModPrefs.GetBool("vrcextended", "fakeCollidersOthers");
            p_smartColliders        = ModPrefs.GetBool("vrcextended", "smartColliders");
            p_ignoreInsideColliders = ModPrefs.GetBool("vrcextended", "ignoreInsideColliders");
            p_unlimitedFPS          = ModPrefs.GetBool("vrcextended", "unlimitedFPS");

            // Add scripts
            ScriptObject = new GameObject();
            ScriptObject.AddComponent <PauseDetection>();
            GameObject.DontDestroyOnLoad(ScriptObject);

            // Get AntiCrasher config
            if (File.Exists("antiCrash.json"))
            {
                try
                {
                    if (JsonConvert.DeserializeObject <AntiCrasherConfig>(File.ReadAllText("antiCrash.json")).CheckBackwardsCompatibility())
                    {
                        File.WriteAllText("antiCrash.json", JsonConvert.SerializeObject(AntiCrasherConfig.Instance, Formatting.Indented));
                        ExtendedLogger.Log("Saved AntiCrasher config!");
                    }
                    ExtendedLogger.Log("Loaded AntiCrasher config!");
                }
                catch (Exception ex)
                {
                    ExtendedLogger.LogError("Failed to read/parse AntiCrasher config! Using default values...", ex);

                    AntiCrasherConfig.CreateDefault();
                }
            }
            else
            {
                AntiCrasherConfig.CreateDefault();
                ExtendedLogger.Log("Loaded default AntiCrasher config!");
            }
            if (ModManager.Mods.Any(a => a.Name == "QuitFix" && a.Author == "Herp Derpinstine") && !File.Exists("antiCrash.json"))
            {
                File.WriteAllText("antiCrash.json", JsonConvert.SerializeObject(AntiCrasherConfig.Instance, Formatting.Indented));
                ExtendedLogger.Log("Saved AntiCrasher config!");
            }

            // Get VolumeControl config
            VolumeControl.Setup();

            // Run patches
            Patch_PortalInternal.Setup();
            Patch_PageUserInfo.Setup();

            // Run coroutines
            ModManager.StartCoroutine(WaitForUIManager());
            if (ModPrefs.GetBool("vrcextended", "antiCrasher") && AntiCrasherConfig.Instance.UseOnlineBlacklist == true)
            {
                ModManager.StartCoroutine(LoadShaderBlacklist());
            }

            ExtendedLogger.Log("Loaded VRCExtended!");
        }
Exemplo n.º 6
0
        void OnLateUpdate()
        {
            if (p_anticrash != ModPrefs.GetBool("vrcextended", "antiCrasher"))
            {
                if (ModPrefs.GetBool("vrcextended", "antiCrasher"))
                {
                    foreach (ExtendedUser user in ExtendedServer.Users)
                    {
                        if (user == null || user.Avatar == null)
                        {
                            continue;
                        }

                        try
                        {
                            user.RemoveCrashShaders();
                            user.LimitParticles();
                            user.RemoveCrashMesh();
                        }
                        catch (Exception ex)
                        {
                            ExtendedLogger.LogError("Error enabeling anti-crasher for user " + user.APIUser.displayName, ex);
                        }
                    }
                    ExtendedLogger.Log("Enabled anti crasher!");
                }
                else
                {
                    foreach (ExtendedUser user in ExtendedServer.Users)
                    {
                        if (user == null || user.Avatar == null || user.APIUser == null)
                        {
                            continue;
                        }

                        try
                        {
                            user.RestoreCrashShaders();
                            user.RestoreParticleLimits();
                            user.RestoreCrashMesh();
                        }
                        catch (Exception ex)
                        {
                            ExtendedLogger.LogError("Error disabling anti-crasher for user " + user.APIUser.displayName, ex);
                        }
                    }
                    ExtendedLogger.Log("Disabled anti crasher!");
                }

                p_anticrash = ModPrefs.GetBool("vrcextended", "antiCrasher");
            }
            else if (p_localcolliders != ModPrefs.GetBool("vrcextended", "localColliders") ||
                     p_multilocalcolliders != ModPrefs.GetBool("vrcextended", "multiLocalColliders") ||
                     p_selflocalcolliders != ModPrefs.GetBool("vrcextended", "selfLocalColliders") ||
                     p_fakeColliders != ModPrefs.GetBool("vrcextended", "fakeColliders") ||
                     p_fakeCollidersOthers != ModPrefs.GetBool("vrcextended", "fakeCollidersOthers") ||
                     p_smartColliders != ModPrefs.GetBool("vrcextended", "smartColliders") ||
                     p_targetHandColliders != ModPrefs.GetBool("vrcextended", "targetHandColliders") ||
                     p_ignoreInsideColliders != ModPrefs.GetBool("vrcextended", "ignoreInsideColliders"))
            {
                // Clear colliders
                foreach (ExtendedUser user in ExtendedServer.Users)
                {
                    if (user != null && user.Avatar != null)
                    {
                        user.RemoveLocalColliders();
                    }
                }
                // Add them back settings based
                foreach (ExtendedUser user in ExtendedServer.Users)
                {
                    if (user != null && user.Avatar != null)
                    {
                        user.OnAvatarCreated();
                    }
                }

                p_localcolliders        = ModPrefs.GetBool("vrcextended", "localColliders");
                p_multilocalcolliders   = ModPrefs.GetBool("vrcextended", "multiLocalColliders");
                p_selflocalcolliders    = ModPrefs.GetBool("vrcextended", "selfLocalColliders");
                p_fakeColliders         = ModPrefs.GetBool("vrcextended", "fakeColliders");
                p_fakeCollidersOthers   = ModPrefs.GetBool("vrcextended", "fakeCollidersOthers");
                p_smartColliders        = ModPrefs.GetBool("vrcextended", "smartColliders");
                p_targetHandColliders   = ModPrefs.GetBool("vrcextended", "targetHandColliders");
                p_ignoreInsideColliders = ModPrefs.GetBool("vrcextended", "ignoreInsideColliders");
                ExtendedLogger.Log("Reloaded local colliders!");
            }
            else if (p_unlimitedFPS != ModPrefs.GetBool("vrcextended", "unlimitedFPS"))
            {
                if (ModPrefs.GetBool("vrcextended", "unlimitedFPS"))
                {
                    Application.targetFrameRate = 0;
                }
                else
                {
                    Application.targetFrameRate = FrameRate;
                }
                p_unlimitedFPS = ModPrefs.GetBool("vrcextended", "unlimitedFPS");
            }
        }
Exemplo n.º 7
0
        public static IEnumerator CheckForAvatarFavUpdate()
        {
            string avatarfavPath = Values.ModsPath + "AvatarFav.dll";

            VRCModLogger.Log("AvatarFav.dll path: " + avatarfavPath);
            string fileHash = "";

            if (ModPrefs.GetBool("vrctools", "avatarfavdownloadasked"))
            {
                VRCModLogger.Log("vrctools.avatarfavdownload: " + ModPrefs.GetBool("vrctools", "avatarfavdownload"));
                if (ModPrefs.GetBool("vrctools", "avatarfavdownload"))
                {
                    if (File.Exists(avatarfavPath))
                    {
                        using (var md5 = MD5.Create())
                        {
                            using (var stream = File.OpenRead(avatarfavPath))
                            {
                                var hash = md5.ComputeHash(stream);
                                fileHash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                            }
                        }
                        VRCModLogger.Log("[VRCToolsUpdater] Local AvatarFav file hash: " + fileHash);

                        WWW hashCheckWWW = new WWW(ModValues.avatarfavCheckLink + "?localhash=" + fileHash);
                        yield return(hashCheckWWW);

                        while (!hashCheckWWW.isDone)
                        {
                            yield return(null);
                        }
                        int responseCode = WebRequestsUtils.GetResponseCode(hashCheckWWW);
                        VRCModLogger.Log("[VRCToolsUpdater] hash check webpage returned [" + responseCode + "] \"" + hashCheckWWW.text + "\"");
                        if (responseCode != 200)
                        {
                            popupClosed = false;
                            VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Unable to check AvatarFav file hash", "OK", () =>
                            {
                                VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                                popupClosed = true;
                            });
                            while (!popupClosed)
                            {
                                yield return(null);
                            }
                        }
                        else if (hashCheckWWW.text.Equals("OUTOFDATE"))
                        {
                            popupClosed = false;
                            bool download = false;
                            VRCUiPopupManagerUtils.ShowPopup("VRCTools", "An AvatarFav update is available", "Update", () =>
                            {
                                download    = true;
                                popupClosed = true;
                            }, "Ignore", () =>
                            {
                                VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                                popupClosed = true;
                            });
                            while (!popupClosed)
                            {
                                yield return(null);
                            }

                            if (download)
                            {
                                yield return(DownloadAvatarFav(avatarfavPath));
                            }
                        }
                    }
                    else
                    {
                        yield return(DownloadAvatarFav(avatarfavPath));
                    }
                }
            }
            else
            {
                popupClosed = false;
                bool download = false;
                VRCUiPopupManagerUtils.ShowPopup("VRCTools", "Do you want to install the AvatarFav mod ?", "Accept", () => {
                    ModPrefs.SetBool("vrctools", "avatarfavdownload", true);
                    download    = true;
                    popupClosed = true;
                }, "Deny", () => {
                    ModPrefs.SetBool("vrctools", "avatarfavdownload", false);
                    VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                    popupClosed = true;
                });
                while (!popupClosed)
                {
                    yield return(null);
                }
                ModPrefs.SetBool("vrctools", "avatarfavdownloadasked", true);

                if (download)
                {
                    yield return(DownloadAvatarFav(avatarfavPath));
                }
            }
        }