Skip to content

Commit

Permalink
Add ability for drambar/mariobar timer to countdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
dram55 committed Jun 7, 2020
1 parent 76927dc commit 076aaa1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
21 changes: 18 additions & 3 deletions MarioMaker2OCR/web/drambar/drambar.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,31 @@
return;
}
var currentTime = new Date().getTime();
var totalSeconds = (currentTime - levelStartTime) / 1000;
var secondsInLevel = (currentTime - levelStartTime) / 1000;
var totalSeconds = secondsInLevel;

// Count Down
if (dramBarSettings.timerDirection == 1) {
totalSeconds = (dramBarSettings.playTimerWarningAt * 60) - secondsInLevel;
}

var hours = Math.floor(totalSeconds / 3600);
var minutes = (Math.floor(totalSeconds / 60) % 60);
var seconds = Math.floor(totalSeconds % 60);
state.levelTimer = "";
if (hours > 0) state.levelTimer += hours.toString().padStart(2, '0') + ":";
state.levelTimer += minutes.toString().padStart(2, '0');
state.levelTimer += ":" + seconds.toString().padStart(2, '0');
if (dramBarSettings.playTimerWarning && (dramBarSettings.playTimerWarningAt * 60) == Math.floor(totalSeconds)) {
document.getElementById("timerAudio").play();
if (dramBarSettings.playTimerWarning && (dramBarSettings.playTimerWarningAt * 60) == Math.floor(secondsInLevel)) {
document.getElementById("timerAudio").play();
}

// Stop Time if count down
if (dramBarSettings.timerDirection == 1 && Math.floor(totalSeconds) == 0) {
pauseTimer();
if (dramBarSettings.playTimerWarning) {
document.getElementById("timerAudio").play();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion MarioMaker2OCR/web/drambar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
</div>
<audio id="timerAudio">
<source src="timer.mp3" type="audio/mpeg">
<source src="/drambar/timer.mp3" type="audio/mpeg">
</audio>
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions MarioMaker2OCR/web/drambar/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

backgroundColor: 'rgba(0, 0, 0, 0.77)',


//Other options
playTimerWarning:false,
playTimerWarningAt:15, //minutes
playTimerWarningAt: 15, //minutes
timerDirection: 0 // 0=count up // 1=count down

// SMM Colors
//
Expand Down
2 changes: 1 addition & 1 deletion MarioMaker2OCR/web/mariobar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</div>
</div>
<audio id="timerAudio">
<source src="timer.mp3" type="audio/mpeg">
<source src="/drambar/timer.mp3" type="audio/mpeg">
</audio>
</body>
</html>
Expand Down
3 changes: 2 additions & 1 deletion MarioMaker2OCR/web/mariobar/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

//Other options
playTimerWarning:false,
playTimerWarningAt:15, //minutes
playTimerWarningAt: 15, //minutes
timerDirection: 0 // 0=count up // 1=count down

// SMM Colors
//
Expand Down

0 comments on commit 076aaa1

Please sign in to comment.