コード例 #1
0
ファイル: VRCTools.cs プロジェクト: jb1361/VRCTools
 private static void ShowAuthChangePopup()
 {
     VRCUiPopupManagerUtils.ShowPopup("VRCTools", "You can change this in the Mods Config page at any time", "OK", () => {
         VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
         popupClosed = true;
     });
 }
コード例 #2
0
 private static void ShowAuthChangePopup()
 {
     VRCUiPopupManagerUtils.ShowPopup("VRCTools", "You can change this in the setting panel of VRCTools at any time (Upcoming feature)", "OK", () => {
         VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
         popupClosed = true;
     });
 }
コード例 #3
0
        internal static IEnumerator ShowVRCModLoaderUpdatePopup()
        {
            VRCUiPopupManagerUtils.ShowPopup("VRCTools", "A VRCModLoader update is available. You can install it using the installer (more info on the VRCTools website)", "OK", () =>
            {
                VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                updatePopupClose = true;
            });

            while (!updatePopupClose)
            {
                yield return(null);
            }
        }
コード例 #4
0
        internal static IEnumerator ShowVRCModLoaderUpdatePopup()
        {
            VRCUiPopupManagerUtils.ShowPopup("VRCTools", "A VRCModLoader update is available. You can install it using the mod manager (see the #how-to discord channel for more infos)", "OK", () =>
            {
                VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                updatePopupClose = true;
            });

            while (!updatePopupClose)
            {
                yield return(null);
            }
        }
コード例 #5
0
 private static IEnumerator ShowAuthAgreePopup(IEnumerator onDone = null)
 {
     popupClosed = false;
     VRCUiPopupManagerUtils.ShowPopup("VRCTools", "To use the VRCTools networking features, you will need to send your auth token to the server (Required for the AvatarFav mod)", "Accept", () => {
         ModPrefs.SetBool("vrctools", "remoteauthcheck", true);
         ShowAuthChangePopup();
     }, "Deny", () => {
         ModPrefs.SetBool("vrctools", "remoteauthcheck", false);
         ShowAuthChangePopup();
     });
     while (!popupClosed)
     {
         yield return(false);
     }
 }
コード例 #6
0
        private static IEnumerator DownloadDependency(string downloadUrl, string dllName)
        {
            VRCModLogger.Log("[DependenciesDownloader] Checking dependency " + dllName);
            String dependenciesDownloadFile = Values.VRCToolsDependenciesPath + dllName;

            if (!File.Exists(dependenciesDownloadFile))
            {
                VRCUiPopupManagerUtils.ShowPopup("VRCTools", "Downloading VRCTools dependency:\n" + dllName, "Quit", () => Application.Quit(), (popup) =>
                {
                    if (popup.popupProgressFillImage != null)
                    {
                        popup.popupProgressFillImage.enabled    = true;
                        popup.popupProgressFillImage.fillAmount = 0f;
                        downloadProgressFillImage = popup.popupProgressFillImage;
                    }
                });


                WWW dependencyDownload = new WWW(downloadUrl);
                yield return(dependencyDownload);

                while (!dependencyDownload.isDone)
                {
                    VRCModLogger.Log("[DependenciesDownloader] Download progress: " + dependencyDownload.progress);
                    downloadProgressFillImage.fillAmount = dependencyDownload.progress;
                    yield return(null);
                }

                int responseCode = WebRequestsUtils.GetResponseCode(dependencyDownload);
                VRCModLogger.Log("[DependenciesDownloader] Download done ! response code: " + responseCode);
                VRCModLogger.Log("[DependenciesDownloader] File size: " + dependencyDownload.bytes.Length);

                if (responseCode == 200)
                {
                    VRCUiPopupManagerUtils.ShowPopup("VRCTools", "Saving dependency " + dllName);
                    VRCModLogger.Log("[DependenciesDownloader] Saving file " + dllName);
                    VRCModLogger.Log(Path.GetDirectoryName(dependenciesDownloadFile));
                    Directory.CreateDirectory(Path.GetDirectoryName(dependenciesDownloadFile));
                    File.WriteAllBytes(dependenciesDownloadFile, dependencyDownload.bytes);
                    VRCModLogger.Log("[DependenciesDownloader] File saved");
                }
                else
                {
                    VRCUiPopupManagerUtils.ShowPopup("VRCTools", "Unable to download VRCTools dependencies " + dllName + ": Server returned code " + responseCode, "Quit", () => Application.Quit());
                    throw new Exception("Unable to download VRCTools dependencies 0Harmony.dll: Server returned code " + responseCode);
                }
            }
        }
コード例 #7
0
        public static IEnumerator CheckAndUpdate()
        {
            VRCUiPopupManagerUtils.ShowPopup("VRCTools Updater", "Checking VRCTools version");

            WWW versionWWW = new WWW("https://download2.survival-machines.fr/vrcmodloader/VRCToolsVersion");

            yield return(versionWWW);

            while (!versionWWW.isDone)
            {
                yield return(null);
            }
            int responseCode = WebRequestsUtils.GetResponseCode(versionWWW);

            VRCModLogger.Log("[VRCModLoaderUpdater] version webpage returned [" + responseCode + "] \"" + versionWWW.text + "\"");
            if (responseCode == 200 && versionWWW.text.Trim() != ModManager.Mods.FirstOrDefault(m => m.Name == "VRCTools").Version)
            {
                yield return(ShowVRCToolsUpdatePopup(versionWWW.text.Trim()));
            }
            else
            {
                VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
            }
        }
コード例 #8
0
        internal static IEnumerator ShowVRCToolsUpdatePopup(string version)
        {
            string vrctoolsPath = "";

            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                DirectoryInfo baseDir = Directory.GetParent(Values.ModsPath);
                FileInfo      oldFile = baseDir.GetFiles().FirstOrDefault(f => f.Name.ToLower().StartsWith("vrctools.") && f.Name.ToLower().EndsWith(".dll"));
                if (oldFile != null)
                {
                    oldFile.Delete();
                }
                vrctoolsPath = Path.Combine(Directory.GetParent(Values.ModsPath).FullName, "VRCTools." + version + ".dll");
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                vrctoolsPath = "/sdcard/VRCTools/Mods/VRCTools.dll";
            }

            Image downloadProgressFillImage = null;

            VRCUiPopupManagerUtils.ShowPopup("VRCTools Updater", "Updating VRCTools to " + version + "...", "Quit", () => Application.Quit(), (popup) =>
            {
                if (popup.popupProgressFillImage != null)
                {
                    popup.popupProgressFillImage.enabled    = true;
                    popup.popupProgressFillImage.fillAmount = 0f;
                    downloadProgressFillImage = popup.popupProgressFillImage;
                }
            });


            WWW vrctoolsDownload = new WWW(string.Format(ModValues.vrctoolsDownloadLink, version));

            yield return(vrctoolsDownload);

            while (!vrctoolsDownload.isDone)
            {
                VRCModLogger.Log("[AvatarFavUpdater] Download progress: " + vrctoolsDownload.progress);
                downloadProgressFillImage.fillAmount = vrctoolsDownload.progress;
                yield return(null);
            }

            int responseCode = WebRequestsUtils.GetResponseCode(vrctoolsDownload);

            VRCModLogger.Log("[AvatarFavUpdater] Download done ! response code: " + responseCode);
            VRCModLogger.Log("[AvatarFavUpdater] File size: " + vrctoolsDownload.bytes.Length);

            if (responseCode == 200)
            {
                VRCUiPopupManagerUtils.ShowPopup("VRCTools Updater", "Saving VRCTools");
                VRCModLogger.Log("[AvatarFavUpdater] Saving file");
                File.WriteAllBytes(vrctoolsPath, vrctoolsDownload.bytes);
                updatePopupClose = false;
                VRCUiPopupManagerUtils.ShowPopup("VRCTools Updater", "A VRCTools updated has been downloaded. Please restart your game for it to take effect", "OK", () =>
                {
                    VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                    updatePopupClose = true;
                });
                while (!updatePopupClose)
                {
                    yield return(null);
                }
            }
            else
            {
                updatePopupClose = false;
                VRCUiPopupManagerUtils.ShowPopup("VRCTools Updater", "Failed to download the VRCTools update (E" + responseCode + "): " + vrctoolsDownload.text, "OK", () =>
                {
                    VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();
                    updatePopupClose = true;
                });
                while (!updatePopupClose)
                {
                    yield return(null);
                }
            }
        }
コード例 #9
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
                {
                    VRCFlowManagerUtils.EnableVRCFlowManager();
                }
            }
            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));
                }
            }
        }
コード例 #10
0
        private static IEnumerator DownloadAvatarFav(string avatarfavPath)
        {
            VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Updating AvatarFav", "Quit", () => Application.Quit(), (popup) => {
                if (popup.popupProgressFillImage != null)
                {
                    popup.popupProgressFillImage.enabled    = true;
                    popup.popupProgressFillImage.fillAmount = 0f;
                    downloadProgressFillImage = popup.popupProgressFillImage;
                }
            });


            WWW vrctoolsDownload = new WWW(ModValues.avatarfavDownloadLink);

            yield return(vrctoolsDownload);

            while (!vrctoolsDownload.isDone)
            {
                VRCModLogger.Log("[AvatarFavUpdater] Download progress: " + vrctoolsDownload.progress);
                downloadProgressFillImage.fillAmount = vrctoolsDownload.progress;
                yield return(null);
            }

            int responseCode = WebRequestsUtils.GetResponseCode(vrctoolsDownload);

            VRCModLogger.Log("[AvatarFavUpdater] Download done ! response code: " + responseCode);
            VRCModLogger.Log("[AvatarFavUpdater] File size: " + vrctoolsDownload.bytes.Length);

            if (responseCode == 200)
            {
                VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Saving AvatarFav");
                VRCModLogger.Log("[AvatarFavUpdater] Saving file");
                File.WriteAllBytes(avatarfavPath, vrctoolsDownload.bytes);

                VRCModLogger.Log("[AvatarFavUpdater] Showing restart dialog");
                bool choiceDone = false;
                VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Update downloaded", "Restart", () => {
                    choiceDone = true;
                });
                yield return(new WaitUntil(() => choiceDone));

                VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Restarting game");
                string args = "";
                foreach (string arg in Environment.GetCommandLineArgs())
                {
                    args = args + arg + " ";
                }
                VRCModLogger.Log("[AvatarFavUpdater] Rebooting game with args " + args);

                Thread t = new Thread(() =>
                {
                    Thread.Sleep(1000);
                    System.Diagnostics.Process.Start(Path.GetDirectoryName(Path.GetDirectoryName(avatarfavPath)) + "\\VRChat.exe", args);
                    Thread.Sleep(100);
                });
                t.Start();

                Application.Quit();
            }
            else
            {
                VRCUiPopupManagerUtils.ShowPopup("AvatarFav Updater", "Unable to update VRCTools: Server returned code " + responseCode, "Quit", () => Application.Quit());
            }
        }
コード例 #11
0
ファイル: VRCTools.cs プロジェクト: VRCMG/VRCTools
        private IEnumerator VRCToolsSetup()
        {
            VRCModLogger.Log("[VRCTools] Initialising VRCTools");
            VRCModLogger.Log("[VRCTools] Current scene: " + SceneManager.GetActiveScene().name + "(index: " + SceneManager.GetActiveScene().buildIndex + ", path: " + SceneManager.GetActiveScene().path + ")");
            VRCModLogger.Log("[VRCTools] ModComponent Sibling index: " + ModComponent.Instance.transform.GetSiblingIndex());
            VRCModLogger.Log("[VRCTools] Root gameobjects:");
            foreach (GameObject g in SceneManager.GetActiveScene().GetRootGameObjects())
            {
                VRCModLogger.Log(" - " + g);
            }
            VRCModLogger.Log("[VRCTools] Call trace - THIS IS NOT AN ERROR:");
            VRCModLogger.Log(new System.Diagnostics.StackTrace().ToString());
            initializing = true;

            yield return(VRCUiManagerUtils.WaitForUiManagerInit());

            if (!HarmonyLoaded())
            {
                bool waitforpopup = true;
                VRCUiPopupManagerUtils.ShowPopup("VRCTools", "Missing library: Harmony. Please install it using the VRChat Mod Manager (see #how-to on discord.gg/rCqKSvR)", "Close game", () => Application.Quit(), "Ignore", () => waitforpopup = false);
                while (waitforpopup)
                {
                    yield return(null);
                }

                Initialized = true;
                if (!usingVRCMenuUtils)
                {
                    VRCFlowManagerUtils.EnableVRCFlowManager();
                }

                yield break;
            }

            VRCModLogger.Log("[VRCTools] Overwriting login button event");
            VRCUiPageAuthentication loginPage = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>().FirstOrDefault((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(Uri.EscapeDataString(GetTextFromUiInputField(loginPage.loginUserName)) + ":" + Uri.EscapeDataString(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(VRCModLoaderUpdater.CheckVRCModLoaderHash());

            yield return(VRCToolsAutoUpdater.CheckAndUpdate());

            try
            {
                VRCModNetworkStatus.Setup();
                VRCModNetworkLogin.SetupVRCModNetworkLoginPage();
                ModConfigPage.Setup();
                ModdedUsersManager.Init();
            } catch (Exception ex)
            {
                VRCModLogger.Log("[VRCTools]" + ex.ToString());
            }

            VRCModLogger.Log("[VRCTools] Injecting VRCModNetwork login page");
            VRCModNetworkLogin.InjectVRCModNetworkLoginPage();

            yield return(VRCModNetworkManager.ConnectInit());

            VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();

            Initialized  = true;
            initializing = false;

            if (!usingVRCMenuUtils)
            {
                VRCFlowManagerUtils.EnableVRCFlowManager();
            }
        }