@@ -32,9 +32,11 @@ let autoadvance_button = document.getElementById('autoAdvanceButton');
3232autoadvance_button . style . backgroundColor = '#fc9f9f' ; // default to off
3333
3434let autoadvance_timer_container = document . getElementById ( 'autoAdvanceTimer' ) ;
35+ let autoadvance_cancel_transition = document . getElementById ( 'cancelAdvanceButton' ) ;
3536let autoadvance_timer_label = document . getElementById ( 'autoAdvanceTimerLabel' ) ;
3637let autoadvance_timer_time = new CountUp ( 'autoAdvanceTimerTime' , 10 , 0 , 1 , 10 , { useEasing : false , suffix : 's' } ) ;
3738autoadvance_timer_container . style . opacity = '0' ;
39+ autoadvance_cancel_transition . style . opacity = '0' ;
3840
3941let enableAutoAdvance = false ;
4042let 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+
290307const TourneyState = {
291308 'Initialising' : 0 ,
292309 'Idle' : 1 ,
0 commit comments