diff options
author | Marvin Borner | 2020-04-06 15:13:13 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-06 15:13:13 +0200 |
commit | d1a16995f263b4985668a26da311fda77d5a92ab (patch) | |
tree | 3788ed4f1fbc0c99bc0546a8d6069d24f9b87ea5 /qml | |
parent | bf800f3b9a78140d6ee5c031389af67f67d52d8f (diff) |
More stats in leaderboard, basic cheat detection1.1
Diffstat (limited to 'qml')
-rw-r--r-- | qml/harbour-binaryfun.qml | 2 | ||||
-rw-r--r-- | qml/pages/Game.qml | 2 | ||||
-rw-r--r-- | qml/pages/LeaderBoard.qml | 49 |
3 files changed, 37 insertions, 16 deletions
diff --git a/qml/harbour-binaryfun.qml b/qml/harbour-binaryfun.qml index 9378223..599a3ea 100644 --- a/qml/harbour-binaryfun.qml +++ b/qml/harbour-binaryfun.qml @@ -6,5 +6,5 @@ ApplicationWindow { initialPage: Component { Menu { } } cover: Qt.resolvedUrl("cover/CoverPage.qml") - allowedOrientations: defaultAllowedOrientations + allowedOrientations: Orientation.Portrait } diff --git a/qml/pages/Game.qml b/qml/pages/Game.qml index c99c8a3..cc13b84 100644 --- a/qml/pages/Game.qml +++ b/qml/pages/Game.qml @@ -132,7 +132,7 @@ Page { Button { id: new_game - text: qsTr("Play again!") + text: qsTr("Play again") visible: false anchors.horizontalCenter: parent.horizontalCenter onClicked: pageStack.replace(Qt.resolvedUrl("Game.qml"), {bits: root.bits}) diff --git a/qml/pages/LeaderBoard.qml b/qml/pages/LeaderBoard.qml index f80c969..75f8c64 100644 --- a/qml/pages/LeaderBoard.qml +++ b/qml/pages/LeaderBoard.qml @@ -15,9 +15,9 @@ Page { } TextField { - placeholderText: "Enter username (default: anon)" + placeholderText: qsTr("Enter username (default: anon)") text: username.value - label: "Username" + label: qsTr("Username") width: page.width EnterKey.enabled: text.length > 0 && text.length <= 16 EnterKey.iconSource: "image://theme/icon-m-enter-close" @@ -29,20 +29,22 @@ Page { ComboBox { id: selector - label: "Difficulty" + label: qsTr("Difficulty") function select(diff) { var xhr = new XMLHttpRequest() xhr.open("GET", "https://marvinborner.de/lead/binaryfun1/list?sort=time&order=asc&count=1000&filter=difficulty,"+diff, - false) - xhr.send() - if (xhr.status !== 0) { - list.model = JSON.parse(xhr.responseText); - internet.visible = false; - } else { - internet.visible = true; + true) + xhr.onreadystatechange = function() { + if (xhr.readyState === 4 && xhr.status === 200) { + list.model = JSON.parse(xhr.responseText); + internet.visible = false; + } else { + internet.visible = true; + } } + xhr.send() } menu: ContextMenu { @@ -79,7 +81,7 @@ Page { Label { id: internet - text: qsTr("No internet connection!") + text: qsTr("Please try again later.") visible: false } @@ -90,7 +92,8 @@ Page { height: page.height - y model: [] delegate: ListItem { - contentHeight: Theme.itemSizeMedium + id: score + contentHeight: Theme.itemSizeLarge Label { id: name @@ -98,9 +101,27 @@ Page { } Label { + id: level anchors.top: name.bottom - text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + "s - Help: " + modelData.cheats - font.pixelSize: Theme.fontSizeSmall + text: { + var numbers = modelData.level.split(",").slice( + modelData.difficulty).filter(function (_, i) { + return i % (modelData.difficulty + 1) === 0. + }).slice(1); + if (numbers.length !== modelData.difficulty && modelData.difficulty !== 10) { + console.log("Tempered: " + numbers.length + " " + modelData.difficulty); + score.visible = false; + } + + return qsTr("Numbers: ") + numbers.join(", "); + } + font.pixelSize: Theme.fontSizeExtraSmall + } + + Label { + anchors.top: level.bottom + text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + qsTr("s - Help: ") + modelData.cheats + font.pixelSize: Theme.fontSizeExtraSmall } } } |