diff options
author | Marvin Borner | 2020-04-22 01:01:20 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-22 01:01:20 +0200 |
commit | 31867b1a0292267db51f7eb9ba916b572295f4a3 (patch) | |
tree | 6f223d521ad3ea2b2534d6fb7484b3e1a84c75ad /qml | |
parent | a3886dac1392304e1259e4a85f1b9fbcd1598894 (diff) |
Ultimate sub-zero fix ig // SORRY!
Diffstat (limited to 'qml')
-rw-r--r-- | qml/pages/Game.qml | 8 | ||||
-rw-r--r-- | qml/pages/LeaderBoard.qml | 11 |
2 files changed, 13 insertions, 6 deletions
diff --git a/qml/pages/Game.qml b/qml/pages/Game.qml index a45798e..702c4a7 100644 --- a/qml/pages/Game.qml +++ b/qml/pages/Game.qml @@ -46,7 +46,7 @@ Page { var query = "writeKey=" + Qt.atob(key) + "&win=true&board=default&start_time=" + start_time + "&end_time=" + end_time + "&difficulty=" + difficulty + "&level=" + level + "&cheats=" + (root.help ? "true" : "false") - + "&name="+ username.value + "&mods=0" + "&time=" + (end_time - start_time); + + "&name="+ username.value + "&mods=1" + "&time=" + (end_time - start_time); xhr.send(query); } @@ -78,7 +78,7 @@ Page { if (timer.running) { // aka still playing var end_time = (new Date()).getTime(); info_label.text = "Yeeehaaw!"; - timer_label.text = (((end_time - start_time) / 1000) + 1.0).toFixed(3) + "s - " + qsTr("Not bad!"); + timer_label.text = (((end_time - start_time) / 1000)).toFixed(3) + "s - " + qsTr("Not bad!"); timer.running = false; new_game.visible = true; submit(start_time, end_time, bits, root.matrix.join(",")) @@ -123,11 +123,11 @@ Page { interval: 1000 running: true repeat: true - // triggeredOnStart: true // This WOULD fix the timing bug BUT other versions are already used which would cause wrong scores... + triggeredOnStart: true onTriggered: { if (root.start_time === 0) root.start_time = (new Date()).getTime(); - timer_label.text = parseInt(timer_label.text.substr(0, timer_label.text.indexOf('s'))) + 1 + "s"; + timer_label.text = parseInt(timer_label.text.substr(0, timer_label.text.indexOf('s'))) + "s"; } } diff --git a/qml/pages/LeaderBoard.qml b/qml/pages/LeaderBoard.qml index 80b2943..bb45e07 100644 --- a/qml/pages/LeaderBoard.qml +++ b/qml/pages/LeaderBoard.qml @@ -38,7 +38,11 @@ Page { true) xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { - list.model = JSON.parse(xhr.responseText); + list.model = JSON.parse(xhr.responseText).sort(function(a, b){ + const time_a = ((a.end_time[1] - a.start_time[1]) / 1000) + (a.mods === "0" ? 1.0 : 0) + const time_b = ((b.end_time[1] - b.start_time[1]) / 1000) + (b.mods === "0" ? 1.0 : 0) + return time_a - time_b; + });; internet.visible = false; loading.running = false; } else if (xhr.readyState === 4) { @@ -133,8 +137,11 @@ Page { Label { anchors.top: level.bottom - text: (((modelData.end_time[1] - modelData.start_time[1]) / 1000) + 1.0).toFixed(3) + qsTr("s - Help: ") + modelData.cheats + text: (((modelData.end_time[1] - modelData.start_time[1]) / 1000) + (modelData.mods === "0" ? 1.0 : 0)).toFixed(3) + qsTr("s - Help: ") + modelData.cheats font.pixelSize: Theme.fontSizeExtraSmall + Component.onCompleted: { + console.log(modelData.mods); + } } } } |