From d452393fdc957503b0387932f442851265175f08 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 4 Apr 2020 18:42:25 +0200 Subject: Sooo many things - you wouldn't believe it! --- BinaryFun.pro.user | 372 ++++++++++++++++++++++++++++++++++++++++++- qml/Bit.qml | 25 ++- qml/pages/FirstPage.qml | 37 ++++- translations/BinaryFun-de.ts | 4 + translations/BinaryFun.ts | 4 + 5 files changed, 430 insertions(+), 12 deletions(-) diff --git a/BinaryFun.pro.user b/BinaryFun.pro.user index 9c9c20a..d224a80 100644 --- a/BinaryFun.pro.user +++ b/BinaryFun.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {bdaad72d-59f2-4f26-a23b-24e539401131} + {165e634c-1493-4e4a-a669-d4ec7547e75a} ProjectExplorer.Project.ActiveTarget @@ -45,7 +45,7 @@ 0 8 true - 0 + 1 true true true @@ -58,6 +58,370 @@ ProjectExplorer.Project.Target.0 + + SailfishOS-3.2.1.20-armv7hl (in Sailfish OS Build Engine) + SailfishOS-3.2.1.20-armv7hl (in Sailfish OS Build Engine) + SailfishOS-3.2.1.20-armv7hl + 0 + 1 + 0 + + /home/melvin/code/build-BinaryFun-SailfishOS_3_2_1_20_armv7hl_in_Sailfish_OS_Build_Engine-Debug + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/melvin/code/build-BinaryFun-SailfishOS_3_2_1_20_armv7hl_in_Sailfish_OS_Build_Engine-Release + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/melvin/code/build-BinaryFun-SailfishOS_3_2_1_20_armv7hl_in_Sailfish_OS_Build_Engine-Profile + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 3 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Start Build Engine + + Mer.MerSdkStartStep + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 2 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + + true + RPM + + QmakeProjectManager.MerRpmBuildStep + + + true + RPM Validation + + QmakeProjectManager.MerRpmValidationStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Build RPM Package For Manual Deployment + + QmakeProjectManager.MerMb2RpmBuildConfiguration + + + + + true + Prepare Target + + QmakeProjectManager.MerPrepareTargetStep + + + true + Rsync + + QmakeProjectManager.MerRsyncDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Copying Binaries + + QmakeProjectManager.MerRSyncDeployConfiguration + + + + + true + Prepare Target + + QmakeProjectManager.MerPrepareTargetStep + + + true + RPM + + QmakeProjectManager.MerRpmDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy As RPM Package + + QmakeProjectManager.MerRpmDeployConfiguration + + 3 + + + dwarf + + cpu-cycles + + + 250 + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + /home/melvin/code/BinaryFunSFOS + false + -1 + 3 + + 1 + + + BinaryFun (on Sailfish OS Emulator 3.2.1.20) + QmakeProjectManager.MerRunConfiguration:/home/melvin/code/BinaryFunSFOS/BinaryFun.pro + 1 + + false + + 3768 + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.Target.1 SailfishOS-3.2.1.20-i486 (in Sailfish OS Build Engine) SailfishOS-3.2.1.20-i486 (in Sailfish OS Build Engine) @@ -422,7 +786,7 @@ ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/qml/Bit.qml b/qml/Bit.qml index 7bb63ce..c017760 100644 --- a/qml/Bit.qml +++ b/qml/Bit.qml @@ -15,21 +15,40 @@ Loader { } } + function pad(n, width) { + return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n; + } + Component { id: bit_index Label { + id: bit_label text: parent.index.toString() width: Theme.paddingLarge * 2 height: width horizontalAlignment: TextInput.AlignHCenter verticalAlignment: TextInput.AlignVCenter Component.onCompleted: { + // This code could definitely be improved ;) if (index > bits) { - var num = Math.floor(Math.random() * Math.pow(bits - 1, 2)) + 1; + grid.row++; + + var indices = root.matrix.slice(0, bits); + var transformed = []; + indices.forEach(function(elem) { + console.log(elem + " " + pad((parseInt(elem) >>> 0).toString(2), bits)); + transformed.push((pad((parseInt(elem) >>> 0).toString(2), bits))[grid.row - 1]); + }); + + var transformed_num = parseInt(transformed.join(""), 2); + this.text = transformed_num; + root.matrix[index] = transformed_num; + console.log(indices); + console.log(transformed); + } else { + var num = Math.floor(Math.random() * (Math.pow(2, bits) - 1)) + 1; this.text = num; root.matrix[index] = num; - } else { - this.text = "?"; } } } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index d19d1dd..bfc1ba0 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -19,8 +19,7 @@ ApplicationWindow { PullDownMenu { MenuItem { text: qsTr("Leaderboard") - onClicked: pageStack.push(Qt.resolvedUrl( - "LeaderBoard.qml")) + onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml")) } } @@ -35,7 +34,7 @@ ApplicationWindow { spacing: Theme.paddingLarge PageHeader { - title: "Binary Fun" + title: qsTr("Binary Fun") } function nearest(number) { @@ -52,18 +51,22 @@ ApplicationWindow { if (Number(root.matrix.slice(near, near + bits).join("")).toString() === (root.matrix[near + bits] >>> 0).toString(2)) { correct[near / (bits + 1) - 1] = 1; + info_label.text = parseInt(info_label.text.substr(0, info_label.text.indexOf('/'))) + 1 + " / " + root.bits; } else { correct[near / (bits + 1) - 1] = 0; } if (correct.filter(function(i) { return i === 1 }).length === bits) { - console.log("WON!!"); + info_label.text = "Yeeehaa!"; + timer.running = false; } } Grid { + property int row: 0 + id: grid - anchors.verticalCenter: parent.verticalCenter + anchors.bottom: page.bottom columns: root.bits + 1 rows: root.bits + 1 Repeater { @@ -76,6 +79,30 @@ ApplicationWindow { } } } + + Label { + id: info_label + text: "0 / " + root.bits + anchors.horizontalCenter: parent.horizontalCenter + // anchors.top: grid.bottom + anchors.bottom: page.bottom + } + + Label { + id: timer_label + text: "0.0" + anchors.horizontalCenter: parent.horizontalCenter + // anchors.top: won.bottom + anchors.bottom: page.bottom + } + + Timer { + id: timer + interval: 1 + running: true + repeat: true + onTriggered: timer_label.text = (parseFloat(timer_label.text) + 0.01).toFixed(2).toString() + } } } } diff --git a/translations/BinaryFun-de.ts b/translations/BinaryFun-de.ts index 548a5d2..4c92f47 100644 --- a/translations/BinaryFun-de.ts +++ b/translations/BinaryFun-de.ts @@ -14,6 +14,10 @@ Leaderboard + + Binary Fun + Binary Fun + LeaderBoard diff --git a/translations/BinaryFun.ts b/translations/BinaryFun.ts index b322625..cdbdf90 100644 --- a/translations/BinaryFun.ts +++ b/translations/BinaryFun.ts @@ -14,6 +14,10 @@ Leaderboard + + Binary Fun + + LeaderBoard -- cgit v1.2.3