Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Commit

Permalink
Added simple help legend/bar
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinborner committed Apr 4, 2020
1 parent f6a21a0 commit bfb99fe
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qml/Bit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Loader {
}
} else if (index !== bits){
var num = Math.floor(Math.random() * (Math.pow(2, bits) - 1)) + 1;
this.text = num;
this.text = root.help ? (Math.pow(2, bits - index - 1)) : num;
root.matrix[index] = num;
} else {
this.text = "0/1";
Expand Down
7 changes: 4 additions & 3 deletions qml/pages/Game.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import Sailfish.Silica 1.0
import ".."

Page {
property int bits: 0 // gets passed by previous page
// Get passed by previous page
property int bits: 0
property bool help: false

id: page
allowedOrientations: Orientation.Portrait
Expand All @@ -21,6 +23,7 @@ Page {

Column {
property int bits: page.bits
property bool help: page.help
property var correct: new Array(bits)
property var matrix: new Array(Math.pow(bits + 1, 2))
property var start_time: 0
Expand Down Expand Up @@ -90,15 +93,13 @@ Page {
id: info_label
text: "0 / " + root.bits
anchors.horizontalCenter: parent.horizontalCenter
// anchors.top: grid.bottom
anchors.bottom: page.bottom
}

Label {
id: timer_label
text: "0s"
anchors.horizontalCenter: parent.horizontalCenter
// anchors.top: won.bottom
anchors.bottom: page.bottom
}

Expand Down
21 changes: 16 additions & 5 deletions qml/pages/Menu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Page {
contentHeight: column.height

Column {
property bool bar: false

id: column
width: page.width
height: page.height
Expand All @@ -24,38 +26,47 @@ Page {
anchors.verticalCenter: parent.verticalCenter
rowSpacing: Theme.paddingLarge * 2

Button {
text: qsTr("Help bar") + ": 0"
onClicked: {
column.bar = this.text.slice(-1) === "0";
this.text = column.bar ? qsTr("Help bar") + ": 1" : qsTr("Help bar") + ": 0"
}
}

Button {
text: qsTr("Very easy (2 Bit)")
ButtonLayout.newLine: true
onClicked: {
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 2});
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 2, help: column.bar});
}
}

Button {
text: qsTr("Easy (4 Bit)")
onClicked: {
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 4});
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 4, help: column.bar});
}
}

Button {
text: qsTr("Medium (6 Bit)")
onClicked: {
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 6});
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 6, help: column.bar});
}
}

Button {
text: qsTr("Hard (8 Bit)")
onClicked: {
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 8});
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 8, help: column.bar});
}
}

Button {
text: qsTr("God-like (10 Bit)")
onClicked: {
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 10});
pageStack.push(Qt.resolvedUrl("Game.qml"), {bits: 10, help: column.bar});
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion translations/harbour-binaryfun-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
</message>
<message>
<source>God-like (10 Bit)</source>
<translation type="unfinished"></translation>
<translation>Krass (10 Bit)</translation>
</message>
<message>
<source>Help bar</source>
<translation>Legende</translation>
</message>
</context>
</TS>
4 changes: 4 additions & 0 deletions translations/harbour-binaryfun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@
<source>God-like (10 Bit)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Help bar</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

0 comments on commit bfb99fe

Please sign in to comment.