private static void ShowMessage(Texture2D texture, ServerResponseData response) { MessageDisplayLogic.IncreaseTimesShown(response.MessageName); MessageDisplayLogic.SetLastMessageShownDate(response.MessageName); InfoMessage.ShowMessage(texture, response); }
private static void ProcessServerReply(WWW www, object args) { if (www.text.Contains("error")) { // return; throw new InvalidOperationException("Received a error response from the server:\n" + www.text); } var responseData = ServerResponseData.DeserializeFromXML(www.text); if (null == responseData) { return; } // throw new InvalidOperationException("Unable to deserialize XML response:\n" + www.text); // Debug.Log("Response:\n" + // "MessageType: " + responseData.MessageType + "\n" + // "ImageUrl: " + responseData.ImageUrl + "\n" + // "TargetUrl: " + responseData.TargetUrl + "\n" + // "TimesToShow: " + responseData.TimesToShow + "\n" + // "IntervalInMinutes: " + responseData.IntervalInMinutes + "\n"); MessageDisplayLogic.ResetIfShould(responseData); if (!MessageDisplayLogic.CanShowMessage(responseData)) { return; } LoadTexture(responseData); }
private static string GetResetTokenKeyName(ServerResponseData response) { if (response.ResetToken < 0) { return(null); } return(InfoMessageBootstrap.PluginName + "_" + response.MessageName + "_reset_token"); }
public static void ShowMessage(Texture2D texture, ServerResponseData responseData) { var rect = MakeCenteredRect(texture.width + 20, texture.height + 20); var window = EditorWindow.GetWindowWithRect <InfoMessage>(rect, true, InfoMessageBootstrap.PluginName, true); window.position = rect; window._texture = texture; window._responseData = responseData; }
private static void LoadTexture(ServerResponseData response) { if (string.IsNullOrEmpty(response.ImageUrl)) { return; } // throw new Exception("No ImageUrl provided in response"); StartWWWRequest(response.ImageUrl, ProcessWWWTexture, response); }
public static bool ExceededMaxTimesToShow(ServerResponseData response) { var timesMessageWasShownKey = GetTimesMessageWasShownKey(response.MessageName); EditorPrefsHelper.InitIfUndefined(timesMessageWasShownKey, 0); int timesMessageWasShown = GetTimesMessageWasShown(response.MessageName); return(timesMessageWasShown >= response.TimesToShow); }
public static bool CanShowMessage(ServerResponseData response) { if (!HasEnoughTimePassed(response)) { return(false); } if (ExceededMaxTimesToShow(response)) { return(false); } return(true); }
public static void ResetIfShould(ServerResponseData response) { if (response.ResetToken < 0) { return; } var resetTokenKey = GetResetTokenKeyName(response); bool shouldReset = !EditorPrefs.HasKey(resetTokenKey) || (EditorPrefs.GetInt(resetTokenKey) != response.ResetToken); if (shouldReset) { #if DEBUG_INFO_MESSAGE Debug.Log("Reset"); #endif //Reset mesage info MessageDisplayLogic.SetTimesMessageWasShown(response.MessageName, 0); MessageDisplayLogic.SetLastMessageShownDate(response.MessageName); } //Update reset token EditorPrefs.SetInt(resetTokenKey, response.ResetToken); }
public static bool HasEnoughTimePassed(ServerResponseData response) { string messageDateKey = GetMessageDateKey(response.MessageName); string currentDate = System.DateTime.Now.Ticks.ToString(); bool newKey = !EditorPrefs.HasKey(messageDateKey); EditorPrefsHelper.InitIfUndefined(messageDateKey, currentDate); long lastTimeMessageShownTicks = long.Parse(EditorPrefs.GetString(messageDateKey)); double minutesPassedSinceLastMessage = System.TimeSpan.FromTicks(System.DateTime.Now.Ticks - lastTimeMessageShownTicks).TotalMinutes; var timesMessageWasShown = GetTimesMessageWasShown(response.MessageName); var interval = response.IntervalInMinutes * (Mathf.Exp(timesMessageWasShown) - 1); #if DEBUG_INFO_MESSAGE Debug.Log("timesMessageWasShown: " + timesMessageWasShown + "; interval: " + minutesPassedSinceLastMessage + "/" + interval); #endif return(newKey || minutesPassedSinceLastMessage >= interval); }
public static void ShowMessage(Texture2D texture, ServerResponseData responseData) { var rect = MakeCenteredRect(texture.width + 20, texture.height + 20); var window = EditorWindow.GetWindowWithRect<InfoMessage>(rect, true, InfoMessageBootstrap.PluginName, true); window.position = rect; window._texture = texture; window._responseData = responseData; }
public static bool ExceededMaxTimesToShow(ServerResponseData response) { var timesMessageWasShownKey = GetTimesMessageWasShownKey(response.MessageName); EditorPrefsHelper.InitIfUndefined( timesMessageWasShownKey, 0 ); int timesMessageWasShown = GetTimesMessageWasShown( response.MessageName ); return timesMessageWasShown >= response.TimesToShow; }
public static bool HasEnoughTimePassed( ServerResponseData response ) { string messageDateKey = GetMessageDateKey( response.MessageName ); string currentDate = System.DateTime.Now.Ticks.ToString(); bool newKey = !EditorPrefs.HasKey( messageDateKey ); EditorPrefsHelper.InitIfUndefined( messageDateKey, currentDate ); long lastTimeMessageShownTicks = long.Parse( EditorPrefs.GetString( messageDateKey ) ); double minutesPassedSinceLastMessage = System.TimeSpan.FromTicks(System.DateTime.Now.Ticks - lastTimeMessageShownTicks).TotalMinutes; var timesMessageWasShown = GetTimesMessageWasShown( response.MessageName ); var interval = response.IntervalInMinutes * ( Mathf.Exp(timesMessageWasShown) - 1 ); #if DEBUG_INFO_MESSAGE Debug.Log("timesMessageWasShown: " + timesMessageWasShown + "; interval: " + minutesPassedSinceLastMessage + "/" + interval); #endif return newKey || minutesPassedSinceLastMessage >= interval; }
public static bool CanShowMessage(ServerResponseData response) { if ( !HasEnoughTimePassed( response ) ) return false; if ( ExceededMaxTimesToShow( response ) ) return false; return true; }
private static void ShowMessage( Texture2D texture, ServerResponseData response) { MessageDisplayLogic.IncreaseTimesShown( response.MessageName ); MessageDisplayLogic.SetLastMessageShownDate( response.MessageName ); InfoMessage.ShowMessage( texture, response ); }
private static void LoadTexture(ServerResponseData response) { if ( string.IsNullOrEmpty( response.ImageUrl ) ) return; // throw new Exception("No ImageUrl provided in response"); StartWWWRequest( response.ImageUrl, ProcessWWWTexture, response ); }
private static string GetResetTokenKeyName( ServerResponseData response ) { if (response.ResetToken < 0) return null; return InfoMessageBootstrap.PluginName + "_" + response.MessageName + "_reset_token"; }
public static void ResetIfShould( ServerResponseData response ) { if (response.ResetToken < 0 ) return; var resetTokenKey = GetResetTokenKeyName( response ); bool shouldReset = !EditorPrefs.HasKey( resetTokenKey ) || (EditorPrefs.GetInt( resetTokenKey ) != response.ResetToken); if ( shouldReset ) { #if DEBUG_INFO_MESSAGE Debug.Log("Reset"); #endif //Reset mesage info MessageDisplayLogic.SetTimesMessageWasShown( response.MessageName, 0 ); MessageDisplayLogic.SetLastMessageShownDate( response.MessageName ); } //Update reset token EditorPrefs.SetInt( resetTokenKey, response.ResetToken ); }