Skip to content

Commit

Permalink
Optimize time remaining calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kokernutz committed Sep 9, 2018
1 parent 0d150c5 commit c678a45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Screens/Views/Deck/TrackDeck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Item {
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
color: colors.textColors[deckId]
text: utils.computeRemainingTimeString(trackLength.value, elapsedTime.value)
text: "-" + utils.computeRemainingTimeString(trackLength.value, elapsedTime.value)
}
}

Expand Down
31 changes: 2 additions & 29 deletions Screens/Views/Definitions/Utils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@ QtObject {

function convertToTimeString(inSeconds)
{
var neg = (inSeconds < 0);
var roundedSec = Math.floor(inSeconds);

if (neg)
{
roundedSec = -roundedSec;
}

var sec = roundedSec % 60;
var min = (roundedSec - sec) / 60;

var secStr = sec.toString();
if (sec < 10) secStr = "0" + secStr;

var minStr = min.toString();
// if (min < 10) minStr = "0" + minStr;

return (neg ? "-" : "") + minStr + ":" + secStr;
return Math.floor(inSeconds / 60).toString() + ":" + ("0" + Math.abs(Math.floor(inSeconds % 60)).toString()).slice(-2);
}

function computeRemainingTimeString(length, elapsed)
{
return ((elapsed > length) ? convertToTimeString(0) : convertToTimeString( Math.floor(elapsed) - Math.floor(length)));
return elapsed > length ? convertToTimeString(0) : convertToTimeString( Math.floor(length) - Math.floor(elapsed));
}

function getKeyOffset(offset)
Expand Down Expand Up @@ -67,16 +50,6 @@ QtObject {
return "";
}

function getKeyMatchText(masterKey, trackKey)
{
var keyOffset = getMasterKeyOffset(masterKey, trackKey);

if (keyOffset == 0) return ">";
else if (keyOffset > 0) return "U";
else if (keyOffset < 0) return "D";
else return "-";
}

function convertToCamelot(keyToConvert)
{
if (keyToConvert == "") return "-";
Expand Down

0 comments on commit c678a45

Please sign in to comment.