refract: secondary timer

small fixes on how the timer is calculated
This commit is contained in:
cv
2021-10-29 13:03:47 +02:00
parent 31f1786eae
commit ba3f0372dd
+9 -6
View File
@@ -242,10 +242,6 @@ export class EventTimer extends Timer {
} else { } else {
// look for event if none is loaded // look for event if none is loaded
if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad(); if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad();
// count to next event
// TODO: replace with proper counter
if (this.secondaryTimer != null) this.secondaryTimer -= 1000;
} }
} }
@@ -946,8 +942,12 @@ export class EventTimer extends Timer {
rollLoad() { rollLoad() {
const now = this._getCurrentTime(); const now = this._getCurrentTime();
this._resetTimers(true);
this._resetSelection(); // maybe roll has already been loaded
if (this.secondaryTimer == null) {
this._resetTimers(true);
this._resetSelection();
}
let foundNow = null; let foundNow = null;
let nextIndex = null; let nextIndex = null;
@@ -990,6 +990,7 @@ export class EventTimer extends Timer {
// nothing to play next, unload // nothing to play next, unload
if (foundNow == null && nextIndex == null) { if (foundNow == null && nextIndex == null) {
this.unload(); this.unload();
console.log('Roll: no events found');
return; return;
} }
@@ -998,6 +999,8 @@ export class EventTimer extends Timer {
this._loadThisTitles(nextIndex, 'next'); this._loadThisTitles(nextIndex, 'next');
if (foundNow == null) { if (foundNow == null) {
if (this.secondaryTimer == null)
console.log('Roll: waiting for event start');
// timer counts to nextStart // timer counts to nextStart
this.secondaryTimer = nextStart; this.secondaryTimer = nextStart;
} }