private ITextComponent SetValue_INTERNAL(long value, TextValueFormat format, bool animate, bool fromTweener) { if (fromTweener == true && this.tempLastValue == value && this.tempLastFormat == format) { return(this); } this.tempLastValue = value; this.tempLastFormat = format; var tag = this.GetCustomTag("TextComponent"); if (fromTweener == false && TweenerGlobal.instance != null) { TweenerGlobal.instance.removeTweens(tag); } if (animate == true && TweenerGlobal.instance != null) { this.tempLastValue = value - 1L; var duration = this.valueAnimateDuration; if (Mathf.Abs(this.valueAnimateLastValue - value) < 2) { duration = 0.2f; } TweenerGlobal.instance.addTweenCount(this, duration, this.valueAnimateLastValue, value, format, (v) => { this.valueAnimateLastValue = v; this.SetValue_INTERNAL(v, format, animate: false, fromTweener: true); }).tag(tag); } else { this.SetText_INTERNAL(TextComponent.FormatValue(value, format)); } return(this); }
public ITextComponent SetValue(long value, TextValueFormat format) { return(this.SetValue(value, format, this.valueAnimate)); }
public ITextComponent SetValue(int value, TextValueFormat format, bool animate) { return(this.SetValue((long)value, format, animate)); }
public ITextComponent SetValueFormat(TextValueFormat format) { this.valueFormat = format; return(this); }
public static string FormatValue(double value, TextValueFormat format) { var output = string.Empty; switch (format) { case TextValueFormat.None: { output = value.ToString(); break; } case TextValueFormat.WithSpace: { if (value < 0f) { output = string.Format("-{0}", (-value).ToString("# ### ### ##0").Trim()); } else { output = value.ToString("# ### ### ##0").Trim(); } break; } case TextValueFormat.WithComma: { if (value < 0f) { output = string.Format("-{0}", (-value).ToString("#,### ### ##0").Trim(',')); } else { output = value.ToString("#,### ### ##0").Trim(',').Trim(' '); } break; } case TextValueFormat.DateDMHMS: { DateTime date = new DateTime((long)value); output = date.ToString("dd MM hh:mm:ss"); break; } case TextValueFormat.TimeHMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); break; } case TextValueFormat.TimeMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); break; } case TextValueFormat.DateDMHMSFromMilliseconds: { DateTime date = new DateTime((long)(value / 1000d)); output = date.ToString("dd MM hh:mm:ss"); break; } case TextValueFormat.TimeHMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}`{3:D2}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}`{2:D2}", t.Minutes, t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); break; } } return output; }
public static string FormatValue(long value, TextValueFormat format) { return TextComponent.FormatValue((double)value, format); }
public ITextComponent SetValue(int value, TextValueFormat format) { this.SetText(TextComponent.FormatValue(value, format)); return this; }
public static ME.Tweener.Tween <ITextComponent> addTweenCount(this ME.Tweener tweener, ITextComponent textComponent, float duration, long start, long end, TextValueFormat format, System.Action <long> onValue) { return(tweener.addTween(textComponent, duration, 0f, 1f).onUpdate((c, t) => { var value = ME.Math.Lerp(start, end, t); onValue(value); })); }
public static string FormatValue(double value, TextValueFormat format) { var output = string.Empty; switch (format) { case TextValueFormat.None: { output = value.ToString(); break; } case TextValueFormat.WithSpace: { var minus = false; if (value < 0f) { value = -value; minus = true; } output = value.ToString("# ### ### ##0").Trim(); if (minus == true) { output = string.Format("-{0}", value); } break; } case TextValueFormat.WithComma: { var minus = false; if (value < 0f) { value = -value; minus = true; } output = value.ToString("#,### ### ##0").Trim(',').Trim(); if (minus == true) { output = string.Format("-{0}", value); } break; } case TextValueFormat.TimeDHMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0}d {1:D2}:{2:D2}:{3:D2}", Mathf.FloorToInt((float)t.TotalDays), t.Hours, t.Minutes, t.Seconds); break; } case TextValueFormat.DateUniversalFromMilliseconds: { DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: true); output = date.ToString("U", System.Globalization.CultureInfo.CreateSpecificCulture(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetCultureNameByLanguage(UnityEngine.UI.Windows.Plugins.Localization.LocalizationSystem.GetCurrentLanguage()))); break; } case TextValueFormat.DateDMHMS: { DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: false); output = date.ToString("dd MM HH:mm:ss"); break; } case TextValueFormat.DateDMHMSFromMilliseconds: { DateTime date = TextComponent.TimeStampToDateTime(value, milliseconds: true); output = date.ToString("dd MM HH:mm:ss"); break; } case TextValueFormat.TimeHMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds); break; } case TextValueFormat.TimeMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds); break; } case TextValueFormat.TimeHMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}`{3:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}`{2:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}", Mathf.FloorToInt((float)t.TotalMinutes), t.Seconds); break; } case TextValueFormat.TimeHMSFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}", Mathf.FloorToInt((float)t.TotalHours), t.Minutes, t.Seconds); break; } } return(output); }
public static string FormatValue(long value, TextValueFormat format) { return(TextComponent.FormatValue((double)value, format)); }
private ITextComponent SetValue_INTERNAL(long value, TextValueFormat format, bool animate, bool fromTweener) { if (fromTweener == true && this.tempLastValue == value && this.tempLastFormat == format) return this; this.tempLastValue = value; this.tempLastFormat = format; var tag = this.GetCustomTag("TextComponent"); if (fromTweener == false && TweenerGlobal.instance != null) TweenerGlobal.instance.removeTweens(tag); if (animate == true && TweenerGlobal.instance != null) { this.tempLastValue = value - 1L; var duration = this.valueAnimateDuration; if (Mathf.Abs(this.valueAnimateLastValue - value) < 2) duration = 0.2f; TweenerGlobal.instance.addTweenCount(this, duration, this.valueAnimateLastValue, value, format, (v) => { this.valueAnimateLastValue = v; this.SetValue_INTERNAL(v, format, animate: false, fromTweener: true); }).tag(tag); } else { this.SetText_INTERNAL(TextComponent.FormatValue(value, format)); } return this; }
public ITextComponent SetValue(long value, TextValueFormat format, bool animate) { return this.SetValue_INTERNAL(value, format, animate, fromTweener: false); }
public ITextComponent SetValue(long value, TextValueFormat format) { return this.SetValue(value, format, this.valueAnimate); }
public ITextComponent SetValue(int value, TextValueFormat format, bool animate) { return this.SetValue((long)value, format, animate); }
public ITextComponent SetValue(long value, TextValueFormat format, bool animate) { return(this.SetValue_INTERNAL(value, format, animate, fromTweener: false)); }
public ITextComponent SetValueFormat(TextValueFormat format) { this.valueFormat = format; return this; }
public static string FormatValue(double value, TextValueFormat format) { var output = string.Empty; switch (format) { case TextValueFormat.None: { output = value.ToString(); break; } case TextValueFormat.WithSpace: { var minus = false; if (value < 0f) { value = -value; minus = true; } output = value.ToString("# ### ### ##0").Trim(); if (minus == true) { output = string.Format("-{0}", value); } break; } case TextValueFormat.WithComma: { var minus = false; if (value < 0f) { value = -value; minus = true; } output = value.ToString("#,### ### ##0").Trim(',').Trim(); if (minus == true) { output = string.Format("-{0}", value); } break; } case TextValueFormat.DateDMHMS: { DateTime date = new DateTime((long)value); output = date.ToString("dd MM hh:mm:ss"); break; } case TextValueFormat.TimeHMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); break; } case TextValueFormat.TimeMSFromSeconds: { var t = TimeSpan.FromSeconds(value); output = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); break; } case TextValueFormat.DateDMHMSFromMilliseconds: { DateTime date = new DateTime((long)(value / 1000d)); output = date.ToString("dd MM hh:mm:ss"); break; } case TextValueFormat.TimeHMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}`{3:D2}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSmsFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}`{2:D2}", t.Minutes, t.Seconds, t.Milliseconds); break; } case TextValueFormat.TimeMSFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); break; } case TextValueFormat.TimeHMSFromMilliseconds: { var t = TimeSpan.FromMilliseconds(value); output = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds); break; } } return(output); }