diff options
author | Marvin Borner | 2020-04-23 22:13:45 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-23 22:13:45 +0200 |
commit | 7af9769b48321376153b5ceee5c17050eb7d211e (patch) | |
tree | 5a3762c27f1b12bd1881afe1eb00821d39b7cf6b | |
parent | 31867b1a0292267db51f7eb9ba916b572295f4a3 (diff) |
Added new help modes and fixed timing issues
-rw-r--r-- | qml/Bit.qml | 2 | ||||
-rw-r--r-- | qml/pages/Game.qml | 15 | ||||
-rw-r--r-- | qml/pages/LeaderBoard.qml | 11 | ||||
-rw-r--r-- | qml/pages/Menu.qml | 24 | ||||
-rw-r--r-- | translations/harbour-binaryfun-de.ts | 54 | ||||
-rw-r--r-- | translations/harbour-binaryfun.ts | 44 |
6 files changed, 94 insertions, 56 deletions
diff --git a/qml/Bit.qml b/qml/Bit.qml index 1b1e4b1..8332747 100644 --- a/qml/Bit.qml +++ b/qml/Bit.qml @@ -49,7 +49,7 @@ Loader { } } else if (index !== bits){ var num = Math.floor(Math.random() * (Math.pow(2, bits) - 1)) + 1; - this.text = root.help ? (Math.pow(2, bits - index - 1)) : num; + this.text = root.help > 1 ? (Math.pow(2, bits - index - 1)) : num; root.matrix[index] = num; } else { this.text = "0/1"; diff --git a/qml/pages/Game.qml b/qml/pages/Game.qml index 702c4a7..9e89765 100644 --- a/qml/pages/Game.qml +++ b/qml/pages/Game.qml @@ -6,7 +6,8 @@ import ".." Page { // Get passed by previous page property int bits: 0 - property bool help: false + property var help: 0 + property var modes: [] id: page allowedOrientations: Orientation.Portrait @@ -18,13 +19,14 @@ Page { PullDownMenu { MenuItem { text: qsTr("Leaderboard") - onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml")) + onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml"), {modes: root.help_modes}) } } Column { property int bits: page.bits - property bool help: page.help + property var help: page.help + property var help_modes: page.modes property var correct: new Array(bits) property var matrix: new Array(Math.pow(bits + 1, 2)) property var start_time: 0 @@ -45,7 +47,7 @@ Page { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 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") + + "&level=" + level + "&cheats=" + root.help + "&name="+ username.value + "&mods=1" + "&time=" + (end_time - start_time); xhr.send(query); } @@ -107,13 +109,14 @@ Page { Label { id: info_label text: "0 / " + root.bits + visible: root.help === 1 || root.help === 3 anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: page.bottom } Label { id: timer_label - text: "0s" + text: "-1s" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: page.bottom } @@ -127,7 +130,7 @@ Page { 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'))) + "s"; + timer_label.text = parseInt(timer_label.text.substr(0, timer_label.text.indexOf('s'))) + 1 + "s"; } } diff --git a/qml/pages/LeaderBoard.qml b/qml/pages/LeaderBoard.qml index bb45e07..cd76c5d 100644 --- a/qml/pages/LeaderBoard.qml +++ b/qml/pages/LeaderBoard.qml @@ -3,6 +3,8 @@ import Sailfish.Silica 1.0 import Nemo.Configuration 1.0 Page { + property var modes: [] + id: page allowedOrientations: Orientation.Portrait @@ -137,11 +139,12 @@ Page { Label { anchors.top: level.bottom - 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); + text: { + const time = (((modelData.end_time[1] - modelData.start_time[1]) / 1000) + (modelData.mods === "0" ? 1.0 : 0)).toFixed(3); + const help = modelData.cheats === "true" ? 3 : (modelData.cheats === "false" ? 1 : parseInt(modelData.cheats)); + return time + qsTr("s - Help: ") + page.modes[help]; } + font.pixelSize: Theme.fontSizeExtraSmall } } } diff --git a/qml/pages/Menu.qml b/qml/pages/Menu.qml index 6c1dd08..938d95c 100644 --- a/qml/pages/Menu.qml +++ b/qml/pages/Menu.qml @@ -7,19 +7,20 @@ Page { SilicaFlickable { anchors.fill: parent - contentHeight: column.height + contentHeight: menu.height PullDownMenu { MenuItem { text: qsTr("Leaderboard") - onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml")) + onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml"), {modes: menu.help_modes}) } } Column { - property bool bar: false + property var help: 0 + property var help_modes: [qsTr("None"), qsTr("Counter"), qsTr("Bar"), qsTr("Both")] - id: column + id: menu width: page.width height: page.height spacing: Theme.paddingLarge @@ -34,10 +35,9 @@ Page { rowSpacing: Theme.paddingLarge * 2 Button { - text: qsTr("Help bar") + ": 0" + text: qsTr("Help") + ": " + menu.help_modes[menu.help] onClicked: { - column.bar = this.text.slice(-1) === "0"; - this.text = column.bar ? qsTr("Help bar") + ": 1" : qsTr("Help bar") + ": 0" + menu.help = menu.help !== 3 ? ++menu.help : 0; } } @@ -45,35 +45,35 @@ Page { text: qsTr("Very easy (2 Bit)") ButtonLayout.newLine: true onClicked: { - pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 2, help: column.bar}); + pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 2, help: menu.help, modes: menu.help_modes}); } } Button { text: qsTr("Easy (4 Bit)") onClicked: { - pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 4, help: column.bar}); + pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 4, help: menu.help, modes: menu.help_modes}); } } Button { text: qsTr("Medium (6 Bit)") onClicked: { - pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 6, help: column.bar}); + pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 6, help: menu.help, modes: menu.help_modes}); } } Button { text: qsTr("Hard (8 Bit)") onClicked: { - pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 8, help: column.bar}); + pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 8, help: menu.help, modes: menu.help_modes}); } } Button { text: qsTr("God-like (10 Bit)") onClicked: { - pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 10, help: column.bar}); + pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 10, help: menu.help, modes: menu.help_modes}); } } } diff --git a/translations/harbour-binaryfun-de.ts b/translations/harbour-binaryfun-de.ts index 8c0aa0d..df80fc5 100644 --- a/translations/harbour-binaryfun-de.ts +++ b/translations/harbour-binaryfun-de.ts @@ -34,6 +34,18 @@ <translation>Bestenliste</translation> </message> <message> + <source>Enter username (default: anon)</source> + <translation>Nutzername eingeben (standard: anon)</translation> + </message> + <message> + <source>Username</source> + <translation>Nutzername</translation> + </message> + <message> + <source>Difficulty</source> + <translation>Schwierigkeit</translation> + </message> + <message> <source>Please select</source> <translation>Bitte auswählen</translation> </message> @@ -58,16 +70,8 @@ <translation>Krass (10 Bit)</translation> </message> <message> - <source>Enter username (default: anon)</source> - <translation>Nutzername eingeben (Standard: anon)</translation> - </message> - <message> - <source>Username</source> - <translation>Nutzername</translation> - </message> - <message> - <source>Difficulty</source> - <translation>Schwierigkeit</translation> + <source>Please try again later.</source> + <translation>Bitte probiere es später erneut.</translation> </message> <message> <source>Numbers: </source> @@ -75,11 +79,7 @@ </message> <message> <source>s - Help: </source> - <translation>s - Hilfe:</translation> - </message> - <message> - <source>Please try again later.</source> - <translation>Bitte probiere es später nochmal.</translation> + <translation>s- Hilfe:</translation> </message> </context> <context> @@ -109,12 +109,28 @@ <translation>Krass (10 Bit)</translation> </message> <message> - <source>Help bar</source> - <translation>Hilfs-Legende</translation> - </message> - <message> <source>Leaderboard</source> <translation>Bestenliste</translation> </message> + <message> + <source>Help</source> + <translation>Hilfe</translation> + </message> + <message> + <source>None</source> + <translation>Keine</translation> + </message> + <message> + <source>Counter</source> + <translation>Zähler</translation> + </message> + <message> + <source>Bar</source> + <translation>Leiste</translation> + </message> + <message> + <source>Both</source> + <translation>Beides</translation> + </message> </context> </TS> diff --git a/translations/harbour-binaryfun.ts b/translations/harbour-binaryfun.ts index 2d4e464..f70be9e 100644 --- a/translations/harbour-binaryfun.ts +++ b/translations/harbour-binaryfun.ts @@ -34,51 +34,51 @@ <translation type="unfinished"></translation> </message> <message> - <source>Please select</source> + <source>Enter username (default: anon)</source> <translation type="unfinished"></translation> </message> <message> - <source>Very easy (2 Bit)</source> + <source>Username</source> <translation type="unfinished"></translation> </message> <message> - <source>Easy (4 Bit)</source> + <source>Difficulty</source> <translation type="unfinished"></translation> </message> <message> - <source>Medium (6 Bit)</source> + <source>Please select</source> <translation type="unfinished"></translation> </message> <message> - <source>Hard (8 Bit)</source> + <source>Very easy (2 Bit)</source> <translation type="unfinished"></translation> </message> <message> - <source>God-like (10 Bit)</source> + <source>Easy (4 Bit)</source> <translation type="unfinished"></translation> </message> <message> - <source>Enter username (default: anon)</source> + <source>Medium (6 Bit)</source> <translation type="unfinished"></translation> </message> <message> - <source>Username</source> + <source>Hard (8 Bit)</source> <translation type="unfinished"></translation> </message> <message> - <source>Difficulty</source> + <source>God-like (10 Bit)</source> <translation type="unfinished"></translation> </message> <message> - <source>Numbers: </source> + <source>Please try again later.</source> <translation type="unfinished"></translation> </message> <message> - <source>s - Help: </source> + <source>Numbers: </source> <translation type="unfinished"></translation> </message> <message> - <source>Please try again later.</source> + <source>s - Help: </source> <translation type="unfinished"></translation> </message> </context> @@ -109,11 +109,27 @@ <translation type="unfinished"></translation> </message> <message> - <source>Help bar</source> + <source>Leaderboard</source> <translation type="unfinished"></translation> </message> <message> - <source>Leaderboard</source> + <source>Help</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>None</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Counter</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Bar</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Both</source> <translation type="unfinished"></translation> </message> </context> |