summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2014-08-25 22:24:47 +0200
committerSébastien Dailly <sebastien@chimrod.com>2014-08-25 22:24:47 +0200
commitcecbf060661a3cf47e876f8dec0207e0f082c3d4 (patch)
treeb925908f4dd96a3cd6d861f0c3e0d406d05ff6cc
parent5a8c5c5bbdafc08a3e42e12ca81789c8a96126e4 (diff)
Added icons :
- restart level Added transitions
-rw-r--r--qml/pages/Board.qml39
-rw-r--r--qml/pages/Goban.qml80
-rw-r--r--qml/pages/Point.qml44
-rw-r--r--qml/python/tests/test2.sgf6
4 files changed, 122 insertions, 47 deletions
diff --git a/qml/pages/Board.qml b/qml/pages/Board.qml
index 37a0e89..27b1974 100644
--- a/qml/pages/Board.qml
+++ b/qml/pages/Board.qml
@@ -2,7 +2,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
-
import io.thp.pyotherside 1.2
@@ -16,25 +15,25 @@ Page {
Column {
- width:parent.width
- height: parent.height
+ anchors.fill: parent;
+ spacing: 25
- spacing: 2
-// Row {
+ Row {
-// height: 60
+ width: parent.width;
-// //anchors.horizontalCenter: parent.horizontalCenter
-// Repeater {
-// model: 3
-// Rectangle {
-// width: 100; height: 40
-// border.width: 1
-// color: "yellow"
-// }
-// }
-// }
+ IconButton {
+ width: parent.width / 2;
+ icon.source: "image://theme/icon-m-back"
+ onClicked: console.log("Previous!")
+ }
+ IconButton {
+ width: parent.width / 2;
+ icon.source: "image://theme/icon-m-refresh"
+ onClicked: goban.start()
+ }
+ }
Goban {
id:goban
@@ -54,10 +53,14 @@ Page {
delegate: Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
+
+ color: Theme.primaryColor
+ font.family: Theme.fontFamily
+ font.pixelSize: Theme.fontSizeMedium
+
width: view.itemWidth
height: view.height
- text: "Level " + index
- color: "white"
+ text: "Problem " + index
}
}
diff --git a/qml/pages/Goban.qml b/qml/pages/Goban.qml
index 64475ec..baffa39 100644
--- a/qml/pages/Goban.qml
+++ b/qml/pages/Goban.qml
@@ -25,6 +25,47 @@ Item {
*/
property bool currentPlayer: true;
+ property variant tree;
+
+ /*
+ * Start the game.
+ *
+ * Initialize the board with the stones, and set player color.
+ */
+ function start() {
+
+ currentPlayer = true;
+
+ for (var i = 0; i < goban.rows * goban.columns; i++) {
+ repeater.itemAt(i).clear();
+ }
+
+ var initial
+
+ i = 0;
+
+ while (tree[i].AW === undefined && tree[i].AB === undefined) {
+ i++;
+ }
+
+ initial = tree[i]
+
+ var aw = initial.AW;
+ if (aw !== undefined) {
+ aw.forEach(function (pos) {
+ goban.getItemAt(pos[0], pos[1]).setColor(currentPlayer);
+ });
+ }
+
+ var ab = initial.AB;
+ if (ab !== undefined) {
+ ab.forEach(function (pos) {
+ goban.getItemAt(pos[0], pos[1]).setColor(!currentPlayer);
+
+ });
+ }
+ }
+
function setGoban(ret) {
limitTop = ret.side.TOP;
@@ -35,7 +76,6 @@ Item {
goban.columns = ret.size[0]
goban.rows = ret.size[1]
- currentPlayer = true;
var maxWidth = width / ret.size[0]
var maxHeight = height / ret.size[1]
@@ -49,22 +89,8 @@ Item {
/*
* Put the initials stones
*/
- var initial = ret.tree[0]
-
- var aw = initial.AW;
- if (aw !== undefined) {
- aw.forEach(function (pos) {
- goban.getItemAt(pos[0], pos[1]).setColor(currentPlayer);
- });
- }
-
- var ab = initial.AB;
- if (ab !== undefined) {
- ab.forEach(function (pos) {
- goban.getItemAt(pos[0], pos[1]).setColor(!currentPlayer);
-
- });
- }
+ tree = ret.tree;
+ start();
}
/**
@@ -113,7 +139,7 @@ Item {
// return;
// }
- point.setColor(currentPlayer);
+ point.put(currentPlayer);
if (neighbors.length !== 0) {
@@ -235,16 +261,30 @@ Item {
Item {
+ function put(isWhite) {
+ piece.type = isWhite ? "white" : "black";
+ piece.state = "shown";
+ }
+
function setColor(isWhite) {
- piece.type = isWhite ? "white" : "black"
+ piece.init(isWhite ? "white" : "black");
}
function remove() {
+ piece.state = "remove"
+ }
+
+ function clear() {
piece.type = "";
+ piece.state = "";
}
function getType() {
- return piece.type;
+ if (piece.state == "remove") {
+ return "";
+ } else {
+ return piece.type;
+ }
}
width: caseSize; height: caseSize
diff --git a/qml/pages/Point.qml b/qml/pages/Point.qml
index f610461..e889336 100644
--- a/qml/pages/Point.qml
+++ b/qml/pages/Point.qml
@@ -1,19 +1,57 @@
import QtQuick 2.0
-import "../actions.js" as Actions
-
Item {
property string type: "";
+ property alias piece_scale: piece.scale;
function getImageForType() {
if ("" === type) {
return ""
}
-
return "../content/gfx/" + type + ".png"
}
+ function init(initType) {
+ type = initType;
+ piece.opacity = 1;
+ piece.scale = 1;
+
+ }
+
+ states: [
+ State {
+ name: "shown"
+ PropertyChanges { target: piece; opacity:1 }
+ }, State {
+ name: "remove"
+ onCompleted: type = "";
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "remove"
+ NumberAnimation {
+ targets: piece;
+ property: "opacity";
+ from: 1;
+ to: 0
+ duration: 500;
+ }
+ },
+ Transition {
+ to: "shown"
+ PropertyAnimation {
+ target: piece;
+ property: "scale";
+ from: 0;
+ to: 1
+ easing.type: Easing.OutBack
+ }
+ }
+ ]
+
MouseArea {
id: interactiveArea
diff --git a/qml/python/tests/test2.sgf b/qml/python/tests/test2.sgf
deleted file mode 100644
index a11356c..0000000
--- a/qml/python/tests/test2.sgf
+++ /dev/null
@@ -1,6 +0,0 @@
-(;GM[1]FF[3]
-;AW[qn][mp][qp][rp][kq][mq][oq][pq][nr][pr][rs]
-AB[nn][mo][np][op][pp][nq][qq][rq][qr][sr][qs]
-(;B[or];W[os];B[ps];W[or];B[mr])
-(;B[ps]WV[ps];W[or];B[mr];W[lr])
-)