Fix Discord timestamp not reset on pause and resume.
This commit is contained in:
@@ -349,10 +349,12 @@ namespace Cryville.Crtr {
|
||||
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
||||
Game.AudioClient.Start();
|
||||
inputProxy.UnlockTime();
|
||||
DiscordController.Instance.SetResume(cbus.Time);
|
||||
}
|
||||
else {
|
||||
Game.AudioClient.Pause();
|
||||
inputProxy.LockTime();
|
||||
DiscordController.Instance.SetPaused();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@@ -60,16 +60,43 @@ namespace Cryville.Crtr {
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
string _detail;
|
||||
double? _duration;
|
||||
public void SetPlaying(string detail, double? duration) {
|
||||
if (dc == null) return;
|
||||
_detail = detail;
|
||||
_duration = duration;
|
||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart",
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
Timestamps = {
|
||||
Start = now,
|
||||
End = _duration == null ? 0 : now + (long)_duration,
|
||||
},
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
public void SetPaused() {
|
||||
if (dc == null) return;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart (Paused)",
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
public void SetResume(double timestamp) {
|
||||
if (dc == null) return;
|
||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart",
|
||||
Details = detail,
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
Timestamps = {
|
||||
Start = now,
|
||||
End = duration == null ? 0 : now + (long)duration,
|
||||
Start = now - (long)timestamp,
|
||||
End = _duration == null ? 0 : now + (long)_duration - (long)timestamp,
|
||||
},
|
||||
}, Callback);
|
||||
}
|
||||
|
Reference in New Issue
Block a user