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); } }
private static IEnumerator CheckForPermissions() { if (!ModPrefs.GetBool("vrctools", "remoteauthcheckasked")) { VRCModLogger.Log("[VRCTools] Asking for auth"); yield return(ShowAuthAgreePopup()); ModPrefs.SetBool("vrctools", "remoteauthcheckasked", true); } if (ModPrefs.GetBool("vrctools", "remoteauthcheck")) { VRCModNetworkManager.ConnectAsync(); VRCModLogger.Log("[VRCTools] Key remoteauthcheck found (true)"); yield return(AvatarFavUpdater.CheckForAvatarFavUpdate()); } else { VRCModLogger.Log("[VRCTools] Key remoteauthcheck found (false)"); } }
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)); } } }