Ejemplo n.º 1
0
        public static IEnumerator CheckVRCModLoaderHash()
        {
            string vrcmodloaderPath = Values.VRCModLoaderAssemblyPath;

            if (File.Exists(vrcmodloaderPath))
            {
                string fileHash = "";
                using (var md5 = MD5.Create())
                {
                    using (var stream = File.OpenRead(vrcmodloaderPath))
                    {
                        var hash = md5.ComputeHash(stream);
                        fileHash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                    }
                }
                VRCModLogger.Log("[VRCModLoaderUpdater] Local VRCModLoader file hash: " + fileHash);

                WWW hashCheckWWW = new WWW("https://download2.survival-machines.fr/vrcmodloader/VRCModLoaderHashCheck.php?localhash=" + fileHash);
                yield return(hashCheckWWW);

                while (!hashCheckWWW.isDone)
                {
                    yield return(null);
                }
                int responseCode = WebRequestsUtils.GetResponseCode(hashCheckWWW);
                VRCModLogger.Log("[VRCModLoaderUpdater] hash check webpage returned [" + responseCode + "] \"" + hashCheckWWW.text + "\"");
                if (responseCode == 200 && hashCheckWWW.text.Equals("OUTOFDATE"))
                {
                    yield return(ShowVRCModLoaderUpdatePopup());
                }
            }
        }
Ejemplo n.º 2
0
        private static IEnumerator CheckAvatarOriginalReleaseStatus(string blueprintId, string id, string authorId)
        {
            VRCModLogger.Log("[AvatarStealerChecker] Checking avatar " + blueprintId);
            using (WWW avtrRequest = new WWW(API.GetApiUrl() + "avatars/" + blueprintId + "?apiKey=" + API.ApiKey))
            {
                yield return(avtrRequest);

                int rc = WebRequestsUtils.GetResponseCode(avtrRequest);
                if (rc == 200)
                {
                    try
                    {
                        VRCModLogger.Log("[AvatarStealerChecker] " + avtrRequest.text);
                        SerializableApiAvatar aa = JsonConvert.DeserializeObject <SerializableApiAvatar>(avtrRequest.text);
                        if (!aa.releaseStatus.Equals("public") && !aa.authorId.Equals(authorId))
                        {
                            VRCModLogger.Log("[AvatarStealerChecker] Avatar " + id + " is a private stealed avatar ! (" + blueprintId + ")");
                            checkedAvatars[id] = true;
                        }
                    }
                    catch (Exception e)
                    {
                        VRCModLogger.LogError("[AvatarStealerChecker] " + e.ToString());
                    }
                }
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
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));
                }
            }
        }
Ejemplo n.º 7
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());
            }
        }