aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2019-04-03 01:26:34 +0900
committerKazuki Yamaguchi <k@rhe.jp>2019-04-03 01:26:34 +0900
commit58e1f7bc0398fb4808aaa8c5d6b91a3d38fa69ad (patch)
treec9e20061ccb59cad52928c52b5234d1752f27636
parentb78592b0cf44a3973ef1cc904a0947710d93b9df (diff)
downloadwf-clock-2019-04-02.tar.gz
fix diff display when actual time is earlier2019-04-02
-rw-r--r--WarframeClock/App.xaml.cs6
-rw-r--r--WarframeClock/EeLogParser.cs3
-rw-r--r--WarframeClock/OverlayWindowViewModel.cs40
3 files changed, 28 insertions, 21 deletions
diff --git a/WarframeClock/App.xaml.cs b/WarframeClock/App.xaml.cs
index 91c86d4..07d86a0 100644
--- a/WarframeClock/App.xaml.cs
+++ b/WarframeClock/App.xaml.cs
@@ -12,7 +12,7 @@ namespace WarframeClock
/// </summary>
public partial class App : Application
{
- public static readonly string VersionString = "Warframe Clock Overlay 2019-04-01";
+ public static readonly string VersionString = "Warframe Clock Overlay 2019-04-02";
public static readonly string WebsiteUriString = "https://poepoe.org/warframe/clock/";
public static readonly Uri WebsiteUri = new Uri(WebsiteUriString);
@@ -43,7 +43,7 @@ namespace WarframeClock
var cetusExpiry = cetusSyndicate.Expiry.Date.NumberLong;
Trace.WriteLine($"WorldState: CetusSyndicate missions expire at {cetusExpiry}");
- OverlayWindowViewModel.CetusExpiry = new DateTime(1970, 1, 1).AddMilliseconds(cetusExpiry);
+ OverlayWindowViewModel.NextBountiesResetByWorldState = new DateTime(1970, 1, 1).AddMilliseconds(cetusExpiry);
}
catch (Exception ex)
{
@@ -82,7 +82,7 @@ namespace WarframeClock
parser.OnLogFileReset += (sender, args) =>
{
- OverlayWindowViewModel.NextBountiesReset = null;
+ OverlayWindowViewModel.NextBountiesReset = new DateTime(1970, 1, 1);
};
_eeLogFetchTimer = new Timer(state =>
diff --git a/WarframeClock/EeLogParser.cs b/WarframeClock/EeLogParser.cs
index 2a05810..ac89db8 100644
--- a/WarframeClock/EeLogParser.cs
+++ b/WarframeClock/EeLogParser.cs
@@ -106,7 +106,8 @@ namespace WarframeClock
lines++;
}
- Trace.WriteLine($"EE.log: Read {lines} lines");
+ if (lines > 0)
+ Trace.WriteLine($"EE.log: Read {lines} lines");
}
}
}
diff --git a/WarframeClock/OverlayWindowViewModel.cs b/WarframeClock/OverlayWindowViewModel.cs
index aacab45..0abeb30 100644
--- a/WarframeClock/OverlayWindowViewModel.cs
+++ b/WarframeClock/OverlayWindowViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Text;
using System.Windows;
using System.Windows.Media;
@@ -6,8 +7,10 @@ namespace WarframeClock
{
public class OverlayWindowViewModel : BindableBase
{
- public DateTime? CetusExpiry { get; set; }
- public DateTime? NextBountiesReset { get; set; }
+ public DateTime NextBountiesResetByWorldState { get; set; } =
+ new DateTime(1970, 1, 1).AddMilliseconds(1548159123053);
+ public DateTime NextBountiesReset { get; set; } =
+ new DateTime(1970, 1, 1);
private string _overlayText = "!!!PLACEHOLDER!!!";
public string OverlayText
@@ -23,17 +26,17 @@ namespace WarframeClock
public void RefreshOverlayText()
{
var currentTime = DateTime.UtcNow;
- const double cetusLen = 8998.8748, cetusNightLen = cetusLen * 1 / 3;
+ const double bountiesLen = 8998.8748, plainsNightLen = bountiesLen * 1 / 3;
string FormatPlainsText(DateTime cetusEnd)
{
- var cetusDayEnd = cetusEnd.AddSeconds(-cetusNightLen);
+ var plainsDayEnd = cetusEnd.AddSeconds(-plainsNightLen);
string sign;
TimeSpan time;
- if (currentTime < cetusDayEnd)
+ if (currentTime < plainsDayEnd)
{
sign = "☀";
- time = cetusDayEnd.Subtract(currentTime);
+ time = plainsDayEnd.Subtract(currentTime);
}
else
{
@@ -43,25 +46,28 @@ namespace WarframeClock
return $"{sign} {Math.Floor(time.TotalMinutes)}m{Math.Floor(time.TotalSeconds % 60)}s";
}
- var cetusEndByWorldState = CetusExpiry ?? new DateTime(1970, 1, 1).AddMilliseconds(1548159123053);
- cetusEndByWorldState = cetusEndByWorldState.AddSeconds(
- (Math.Floor(currentTime.Subtract(cetusEndByWorldState).TotalSeconds / cetusLen) + 1) * cetusLen);
+ var wsReset = NextBountiesResetByWorldState;
+ wsReset = wsReset.AddSeconds(
+ (Math.Floor(currentTime.Subtract(wsReset).TotalSeconds / bountiesLen) + 1) * bountiesLen);
- string ret;
+ var ret = new StringBuilder();
if (NextBountiesReset > currentTime)
{
- var cetusEndByEeLog = NextBountiesReset.Value;
- ret = FormatPlainsText(cetusEndByEeLog);
- var diff = (cetusEndByEeLog.Subtract(cetusEndByWorldState).TotalSeconds + cetusLen) % cetusLen;
- if (Math.Abs(diff) >= 1.0)
- ret += $" [{diff:0.0}s {(diff > 0 ? "late" : "early")}]";
+ var eeReset = NextBountiesReset;
+ ret.Append(FormatPlainsText(eeReset));
+ var diff = eeReset.Subtract(wsReset).TotalSeconds;
+ if (diff > bountiesLen / 2)
+ diff -= bountiesLen;
+ else if (diff < -bountiesLen / 2)
+ diff += bountiesLen;
+ ret.Append($" [{Math.Abs(diff):0.0}s {(diff > 0 ? "late" : "early")}]");
}
else
{
- ret = $"({FormatPlainsText(cetusEndByWorldState)})";
+ ret.Append($"({FormatPlainsText(wsReset)})");
}
- OverlayText = ret;
+ OverlayText = ret.ToString();
}
private bool _settingsMode;