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;
|
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
||||||
Game.AudioClient.Start();
|
Game.AudioClient.Start();
|
||||||
inputProxy.UnlockTime();
|
inputProxy.UnlockTime();
|
||||||
|
DiscordController.Instance.SetResume(cbus.Time);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Game.AudioClient.Pause();
|
Game.AudioClient.Pause();
|
||||||
inputProxy.LockTime();
|
inputProxy.LockTime();
|
||||||
|
DiscordController.Instance.SetPaused();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -60,16 +60,43 @@ namespace Cryville.Crtr {
|
|||||||
}, Callback);
|
}, Callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string _detail;
|
||||||
|
double? _duration;
|
||||||
public void SetPlaying(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;
|
if (dc == null) return;
|
||||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||||
am.UpdateActivity(new Activity {
|
am.UpdateActivity(new Activity {
|
||||||
State = "Playing a chart",
|
State = "Playing a chart",
|
||||||
Details = detail,
|
Details = _detail,
|
||||||
Instance = true,
|
Instance = true,
|
||||||
Timestamps = {
|
Timestamps = {
|
||||||
Start = now,
|
Start = now - (long)timestamp,
|
||||||
End = duration == null ? 0 : now + (long)duration,
|
End = _duration == null ? 0 : now + (long)_duration - (long)timestamp,
|
||||||
},
|
},
|
||||||
}, Callback);
|
}, Callback);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user