// ---------[ INITIALIZATION ]--------- protected virtual void Start() { // cache the guest avatar string avatarURL = this.GetInstanceID().ToString() + @":GUEST_AVATAR"; this.m_unauthenticatedUser.profile.avatarLocator = new AvatarImageLocator() { fileName = "_AVATAR_", original = avatarURL, thumbnail_50x50 = avatarURL, thumbnail_100x100 = avatarURL, }; ImageRequestManager.instance.cache[avatarURL] = this.m_unauthenticatedUser.avatar; // set view profile this.view.profile = this.m_unauthenticatedUser.profile; ModManager.GetAuthenticatedUserProfile( (p) => { if(this != null) { this.view.profile = p; } }, (e) => { MessageSystem.QueueMessage(MessageDisplayData.Type.Error, "Unable to fetch your profile from the mod.io servers.\n" + e.displayMessage); }); }
// ---------[ INITIALIZATION ]--------- private void OnEnable() { _instance = this; m_typeDialogMap.Clear(); if (infoDialog != null) { infoDialog.gameObject.SetActive(false); m_typeDialogMap[MessageDisplayData.Type.Info] = infoDialog; infoDialog.onClick -= OnMessageDisplayClicked; infoDialog.onClick += OnMessageDisplayClicked; } else { m_typeDialogMap[MessageDisplayData.Type.Info] = null; } if (successDialog != null) { successDialog.gameObject.SetActive(false); m_typeDialogMap[MessageDisplayData.Type.Success] = successDialog; successDialog.onClick -= OnMessageDisplayClicked; successDialog.onClick += OnMessageDisplayClicked; } else { m_typeDialogMap[MessageDisplayData.Type.Success] = null; } if (warningDialog != null) { warningDialog.gameObject.SetActive(false); m_typeDialogMap[MessageDisplayData.Type.Warning] = warningDialog; warningDialog.onClick -= OnMessageDisplayClicked; warningDialog.onClick += OnMessageDisplayClicked; } else { m_typeDialogMap[MessageDisplayData.Type.Warning] = null; } if (errorDialog != null) { errorDialog.gameObject.SetActive(false); m_typeDialogMap[MessageDisplayData.Type.Error] = errorDialog; errorDialog.onClick -= OnMessageDisplayClicked; errorDialog.onClick += OnMessageDisplayClicked; } else { m_typeDialogMap[MessageDisplayData.Type.Error] = null; } queuedMessages = new List <MessageDisplayData>(); }
public void Refresh() { // create null page this.m_modPage = null; if (this.onModPageChanged != null) { this.onModPageChanged.Invoke(this.m_modPage); } if (this.noSubscriptionsDisplay != null) { this.noSubscriptionsDisplay.gameObject.SetActive(true); } if (this.noResultsDisplay != null) { this.noResultsDisplay.gameObject.SetActive(false); } IList <int> subscribedModIds = LocalUser.SubscribedModIds; ModProfileRequestManager.instance.RequestModProfiles(subscribedModIds, (profiles) => Refresh_OnGetModProfiles(profiles, this.m_nameFieldFilter, this.m_sortDelegate), (requestError) => { MessageSystem.QueueMessage(MessageDisplayData.Type.Warning, "Failed to get subscription data from mod.io servers.\n" + requestError.displayMessage); }); }
public void TrySubmitAuthentication() { string trimmedInput = inputField.text.Trim(); inputField.interactable = false; if (Utility.IsEmail(trimmedInput)) { APIClient.SendSecurityCode(trimmedInput, OnSecurityCodeSent, (e) => ProcessWebRequestError(e, false)); } else if (Utility.IsSecurityCode(trimmedInput)) { APIClient.GetOAuthToken(trimmedInput.ToUpper(), OnUserOAuthTokenReceived, (e) => ProcessWebRequestError(e, true)); } else { StartCoroutine(DisableInteractivity(2f)); MessageSystem.QueueMessage(MessageDisplayData.Type.Error, invalidSubmissionMessage); } }
private void OnSecurityCodeSent(APIMessage apiMessage) { inputField.text = string.Empty; inputField.interactable = true; MessageSystem.QueueMessage(MessageDisplayData.Type.Success, apiMessage.message); }
private IEnumerator FetchUserProfile() { bool isUnresolvable = false; UserProfile profile = null; float nextRetrySeconds = 0; string errorMessage = null; while (!isUnresolvable && profile == null && this != null) { WebRequestError error = null; bool isDone = false; ModManager.GetAuthenticatedUserProfile((p) => { isDone = true; profile = p; }, (e) => { isDone = true; error = e; }); while (!isDone) { yield return(null); } if (error != null) { isUnresolvable = error.isRequestUnresolvable; if (isUnresolvable) { errorMessage = ("Unable to get your profile from the mod.io servers.\n" + error.displayMessage); } else { yield return(new WaitForSecondsRealtime(nextRetrySeconds)); nextRetrySeconds += 5f; } } else if (profile == null) { errorMessage = ("Unable to get your profile from the mod.io servers.\n" + "An unknown error has occurred."); isUnresolvable = true; } } if (isUnresolvable) { MessageSystem.QueueMessage(MessageDisplayData.Type.Error, errorMessage); } else if (this != null) { Debug.Assert(profile != null); view.DisplayUser(profile); } }
private void OnAuthenticated(UserProfile u) { inputField.text = string.Empty; inputField.interactable = true; MessageSystem.QueueMessage(MessageDisplayData.Type.Success, "Login Successful"); ViewManager.instance.CloseWindowedView(this); ModBrowser.instance.OnUserLogin(); }
private void OnUserOAuthTokenReceived(string token) { inputField.text = string.Empty; inputField.interactable = true; MessageSystem.QueueMessage(MessageDisplayData.Type.Success, "Login Successful"); this.gameObject.SetActive(false); ModBrowser.instance.LogUserIn(token); }
private void OnAuthenticated(UserProfile u) { inputField.text = string.Empty; inputField.interactable = true; MessageSystem.QueueMessage(MessageDisplayData.Type.Success, "Login Successful"); this.gameObject.SetActive(false); ModBrowser.instance.OnUserLogin(); }
public void Refresh() { IList <int> subscribedModIds = ModManager.GetSubscribedModIds(); ModProfileRequestManager.instance.RequestModProfiles(subscribedModIds, (profiles) => Refresh_OnGetModProfiles(profiles, this.m_titleFilter, this.m_sortDelegate), (requestError) => { MessageSystem.QueueMessage(MessageDisplayData.Type.Warning, "Failed to get subscription data from mod.io servers.\n" + requestError.displayMessage); }); }
private void OnDisable() { if (m_displayRoutine != null) { this.StopCoroutine(m_displayRoutine); m_displayRoutine = null; } if (_instance == this) { _instance = null; } }
private void ProcessWebRequestError(WebRequestError e, bool isSecurityCode) { if (e.webRequest.responseCode == 401 && isSecurityCode) { MessageSystem.QueueMessage(MessageDisplayData.Type.Error, e.errorMessage); } else if (e.webRequest.responseCode == 422 && !isSecurityCode) { MessageSystem.QueueMessage(MessageDisplayData.Type.Error, emailRefusedMessage); } else { MessageSystem.QueueMessage(MessageDisplayData.Type.Warning, e.displayMessage); } inputField.interactable = true; }