Skip to content

Commit 2d1d810

Browse files
authored
Merge pull request #4 from ILW8/main
add cancel transition button
2 parents d99e78a + 1fa3bb9 commit 2d1d810

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

mappool/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<div id="autoAdvanceTimer" class="control-label">
3131
<span id="autoAdvanceTimerLabel"></span> <span id="autoAdvanceTimerTime"></span>
3232
</div>
33+
<div id="cancelAdvanceButton" class="button control-item" onclick="cancelAdvance()">Cancel transition</div>
3334

3435
<br/><br/>
3536

mappool/index.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ let autoadvance_button = document.getElementById('autoAdvanceButton');
3232
autoadvance_button.style.backgroundColor = '#fc9f9f'; // default to off
3333

3434
let autoadvance_timer_container = document.getElementById('autoAdvanceTimer');
35+
let autoadvance_cancel_transition = document.getElementById('cancelAdvanceButton');
3536
let autoadvance_timer_label = document.getElementById('autoAdvanceTimerLabel');
3637
let autoadvance_timer_time = new CountUp('autoAdvanceTimerTime', 10, 0, 1, 10, {useEasing: false, suffix: 's'});
3738
autoadvance_timer_container.style.opacity = '0';
39+
autoadvance_cancel_transition.style.opacity = '0';
3840

3941
let enableAutoAdvance = false;
4042
let sceneTransitionTimeoutID;
@@ -219,13 +221,16 @@ const pickMap = (bm, teamName, color) => {
219221
if (enableAutoAdvance) {
220222
// idempotent on pick color (none/red/blue). Consider making it idempotent on pick state? (not picked/picked)
221223
if (selectedMapsTransitionTimeout[bm.beatmapID]?.color !== color) {
224+
cancelAdvance();
222225
clearTimeout(selectedMapsTransitionTimeout[bm.beatmapID]?.timeoutId)
223-
selectedMapsTransitionTimeout[bm.beatmapID] = {
224-
color: color,
225-
timeoutId: setTimeout(() => {
226+
const newTimeoutId = setTimeout(() => {
226227
obsSetCurrentScene(gameplay_scene_name);
227228
autoadvance_timer_container.style.opacity = '0';
228-
}, pick_to_transition_delay_ms)
229+
autoadvance_cancel_transition.style.opacity = '0';
230+
}, pick_to_transition_delay_ms);
231+
selectedMapsTransitionTimeout[bm.beatmapID] = {
232+
color: color,
233+
timeoutId: newTimeoutId
229234
};
230235

231236
autoadvance_timer_time = new CountUp('autoAdvanceTimerTime',
@@ -234,6 +239,14 @@ const pickMap = (bm, teamName, color) => {
234239
autoadvance_timer_time.start();
235240
autoadvance_timer_container.style.opacity = '1';
236241
autoadvance_timer_label.textContent = `Switching to ${gameplay_scene_name} in`;
242+
autoadvance_cancel_transition.style.opacity = '1';
243+
244+
245+
cancelAdvance = () => {
246+
clearTimeout(newTimeoutId);
247+
autoadvance_timer_container.style.opacity = '0';
248+
autoadvance_cancel_transition.style.opacity = '0';
249+
}
237250
}
238251
}
239252
}
@@ -287,6 +300,10 @@ const switchAutoAdvance = () => {
287300
}
288301
}
289302

303+
var cancelAdvance = () => {
304+
// do nothing at first, wait to have a cancel action assigned to it
305+
}
306+
290307
const TourneyState = {
291308
'Initialising': 0,
292309
'Idle': 1,

0 commit comments

Comments
 (0)