diff --git a/qml/pages/Game.qml b/qml/pages/Game.qml
index fb0f01d..c99c8a3 100644
--- a/qml/pages/Game.qml
+++ b/qml/pages/Game.qml
@@ -1,5 +1,6 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
+import org.nemomobile.configuration 1.0
import ".."
Page {
@@ -14,12 +15,12 @@ Page {
anchors.fill: parent
contentHeight: root.height
- /*PullDownMenu {
+ PullDownMenu {
MenuItem {
text: qsTr("Leaderboard")
onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml"))
}
- }*/
+ }
Column {
property int bits: page.bits
@@ -37,6 +38,18 @@ Page {
title: qsTr("Binary Fun")
}
+ function submit(start_time, end_time, difficulty, level) {
+ var key = "RmMwQ0ptT1FlSkpIeEdzNDB3a1B5OVk1ZE8wYkRjSzI=";
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "https://marvinborner.de/lead/binaryfun1/add", true);
+ 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")
+ + "&name="+ username.value + "&mods=0" + "&time=" + (end_time - start_time);
+ xhr.send(query);
+ }
+
function nearest(number) {
if (number % (bits + 1) === 0) {
return number
@@ -63,10 +76,12 @@ Page {
if (correct.filter(function(i) { return i === 1 }).length === bits) {
if (timer.running) { // aka still playing
+ var end_time = (new Date()).getTime();
info_label.text = "Yeeehaaw!";
- timer_label.text = ((new Date().getTime() - start_time) / 1000) + "s - " + qsTr("Not bad!");
+ timer_label.text = ((end_time - start_time) / 1000) + "s - " + qsTr("Not bad!");
timer.running = false;
new_game.visible = true;
+ submit(start_time, end_time, bits, root.matrix.join(","))
}
}
}
@@ -124,4 +139,10 @@ Page {
}
}
}
+
+ ConfigurationValue {
+ id: username
+ key: "/com/binaryfun/username"
+ defaultValue: "anon"
+ }
}
diff --git a/qml/pages/LeaderBoard.qml b/qml/pages/LeaderBoard.qml
index eae37b0..f80c969 100644
--- a/qml/pages/LeaderBoard.qml
+++ b/qml/pages/LeaderBoard.qml
@@ -1,22 +1,114 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
+import org.nemomobile.configuration 1.0
Page {
id: page
allowedOrientations: Orientation.Portrait
- SilicaFlickable {
+ Column {
anchors.fill: parent
- contentHeight: column.height
+ anchors.margins: Theme.paddingMedium
- Column {
- id: column
+ PageHeader {
+ title: qsTr("Leaderboard")
+ }
+
+ TextField {
+ placeholderText: "Enter username (default: anon)"
+ text: username.value
+ label: "Username"
width: page.width
- spacing: Theme.paddingLarge
+ EnterKey.enabled: text.length > 0 && text.length <= 16
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ EnterKey.onClicked: {
+ focus = false
+ username.value = text
+ }
+ }
+
+ ComboBox {
+ id: selector
+ label: "Difficulty"
- PageHeader {
- title: qsTr("Under Construction!")
+ 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;
+ }
}
+
+ menu: ContextMenu {
+ MenuItem {
+ text: qsTr("Please select")
+ }
+ MenuItem {
+ property int diff: 2
+ text: qsTr("Very easy (2 Bit)")
+ onClicked: selector.select(diff)
+ }
+ MenuItem {
+ property int diff: 4
+ text: qsTr("Easy (4 Bit)")
+ onClicked: selector.select(diff)
+ }
+ MenuItem {
+ property int diff: 6
+ text: qsTr("Medium (6 Bit)")
+ onClicked: selector.select(diff)
+ }
+ MenuItem {
+ property int diff: 8
+ text: qsTr("Hard (8 Bit)")
+ onClicked: selector.select(diff)
+ }
+ MenuItem {
+ property int diff: 10
+ text: qsTr("God-like (10 Bit)")
+ onClicked: selector.select(diff)
+ }
+ }
+ }
+
+ Label {
+ id: internet
+ text: qsTr("No internet connection!")
+ visible: false
}
+
+ ListView {
+ id: list
+ clip: true
+ width: page.width
+ height: page.height - y
+ model: []
+ delegate: ListItem {
+ contentHeight: Theme.itemSizeMedium
+
+ Label {
+ id: name
+ text: index + 1 + ". " + modelData.name
+ }
+
+ Label {
+ anchors.top: name.bottom
+ text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + "s - Help: " + modelData.cheats
+ font.pixelSize: Theme.fontSizeSmall
+ }
+ }
+ }
+ }
+
+ ConfigurationValue {
+ id: username
+ key: "/com/binaryfun/username"
+ defaultValue: "anon"
}
}
diff --git a/qml/pages/Menu.qml b/qml/pages/Menu.qml
index caf2e00..6c1dd08 100644
--- a/qml/pages/Menu.qml
+++ b/qml/pages/Menu.qml
@@ -9,6 +9,13 @@ Page {
anchors.fill: parent
contentHeight: column.height
+ PullDownMenu {
+ MenuItem {
+ text: qsTr("Leaderboard")
+ onClicked: pageStack.push(Qt.resolvedUrl("LeaderBoard.qml"))
+ }
+ }
+
Column {
property bool bar: false
diff --git a/rpm/harbour-binaryfun.spec b/rpm/harbour-binaryfun.spec
index eaff5f8..4ad17dc 100644
--- a/rpm/harbour-binaryfun.spec
+++ b/rpm/harbour-binaryfun.spec
@@ -13,7 +13,7 @@ Name: harbour-binaryfun
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: An awesome binary game
-Version: 0.2
+Version: 1.0
Release: 1
Group: Qt/Qt
License: MIT
@@ -21,6 +21,7 @@ URL: https://openrepos.net/content/melvin/binary-fun
Source0: %{name}-%{version}.tar.bz2
Source100: harbour-binaryfun.yaml
Requires: sailfishsilica-qt5 >= 0.10.9
+Requires: nemo-qml-plugin-configuration-qt5
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
diff --git a/rpm/harbour-binaryfun.yaml b/rpm/harbour-binaryfun.yaml
index 72896d7..1d45899 100644
--- a/rpm/harbour-binaryfun.yaml
+++ b/rpm/harbour-binaryfun.yaml
@@ -1,6 +1,6 @@
Name: harbour-binaryfun
Summary: An awesome binary game
-Version: 0.2
+Version: 1.0
Release: 1
# The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
@@ -32,7 +32,8 @@ PkgConfigBR:
# Runtime dependencies which are not automatically detected
Requires:
- - sailfishsilica-qt5 >= 0.10.9
+ - sailfishsilica-qt5 >= 0.10.9
+ - nemo-qml-plugin-configuration-qt5
# All installed files
Files:
diff --git a/translations/harbour-binaryfun-de.ts b/translations/harbour-binaryfun-de.ts
index 1b660f8..efb8610 100644
--- a/translations/harbour-binaryfun-de.ts
+++ b/translations/harbour-binaryfun-de.ts
@@ -5,7 +5,7 @@
CoverPage
- Binär-Spaß
+ Binär-Spaß
@@ -22,12 +22,44 @@
Nicht schlecht!
+
+
+ Bestenliste
+
LeaderBoard
-
- Im Aufbau!
+
+ Bestenliste
+
+
+
+ Sehr einfach (2 Bit)
+
+
+
+ Einfach (4 Bit)
+
+
+
+ Mittel (6 Bit)
+
+
+
+ Schwer (8 Bit)
+
+
+
+ Krass (10 Bit)
+
+
+
+ Bitte auswählen
+
+
+
+ Keine Internetverbindung!
@@ -58,7 +90,11 @@
- Legende
+ Hilfs-Legende
+
+
+
+ Bestenliste
diff --git a/translations/harbour-binaryfun.ts b/translations/harbour-binaryfun.ts
index 31d14b0..3902a1f 100644
--- a/translations/harbour-binaryfun.ts
+++ b/translations/harbour-binaryfun.ts
@@ -22,11 +22,43 @@
+
+
+
+
LeaderBoard
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -60,5 +92,9 @@
+
+
+
+