Add new samegame and calculator demos
authorAlan Alpert <alan.alpert@nokia.com>
Thu, 5 Jul 2012 01:45:28 +0000 (11:45 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jul 2012 04:33:12 +0000 (06:33 +0200)
Change-Id: I06ac38a1d0f844eba367fc5e163151d1f70a0012
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
109 files changed:
doc/src/images/qml-calculator-example-small.png
doc/src/images/qml-samegame-demo-small.png
examples/demos/calculator/calculator-desktop.qml [deleted file]
examples/demos/calculator/calculator-mobile.qml [deleted file]
examples/demos/calculator/calculator.pro [deleted file]
examples/demos/calculator/content/images/button-.png [deleted file]
examples/demos/calculator/content/images/button-blue.png [deleted file]
examples/demos/calculator/content/images/button-green.png [deleted file]
examples/demos/calculator/content/images/button-purple.png [deleted file]
examples/demos/calculator/content/images/button-red.png [deleted file]
examples/demos/calculator/content/images/display.png [deleted file]
examples/demos/calculator/content/qmldir [deleted file]
examples/demos/calqlatr/calqlatr.pro [new file with mode: 0644]
examples/demos/calqlatr/calqlatr.qdoc [moved from examples/demos/calculator/calculator.qdoc with 70% similarity]
examples/demos/calqlatr/calqlatr.qml [new file with mode: 0644]
examples/demos/calqlatr/calqlatr.qmlproject [new file with mode: 0644]
examples/demos/calqlatr/content/Button.qml [moved from examples/demos/samegame/content/Dialog.qml with 71% similarity]
examples/demos/calqlatr/content/Display.qml [new file with mode: 0644]
examples/demos/calqlatr/content/NumberPad.qml [new file with mode: 0644]
examples/demos/calqlatr/content/StyleLabel.qml [moved from examples/demos/calculator/main.cpp with 73% similarity]
examples/demos/calqlatr/content/audio/touch.wav [new file with mode: 0644]
examples/demos/calqlatr/content/calculator.js [moved from examples/demos/calculator/content/calculator.js with 55% similarity]
examples/demos/calqlatr/content/images/icon-back.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/icon-close.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/icon-settings.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/logo.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/paper-edge-left.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/paper-edge-right.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/paper-grip.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/settings-selected-a.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/settings-selected-b.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/touch-green.png [new file with mode: 0644]
examples/demos/calqlatr/content/images/touch-white.png [new file with mode: 0644]
examples/demos/calqlatr/main.cpp [new file with mode: 0644]
examples/demos/demos.pro
examples/demos/samegame/content/Block.qml [moved from examples/demos/samegame/content/BoomBlock.qml with 83% similarity]
examples/demos/samegame/content/BlockEmitter.qml [moved from examples/demos/samegame/samegame-mobile.qml with 66% similarity]
examples/demos/samegame/content/Button.qml
examples/demos/samegame/content/GameArea.qml
examples/demos/samegame/content/LogoAnimation.qml [new file with mode: 0644]
examples/demos/samegame/content/MenuEmitter.qml [new file with mode: 0644]
examples/demos/samegame/content/PaintEmitter.qml [new file with mode: 0644]
examples/demos/samegame/content/PrimaryPack.qml [new file with mode: 0644]
examples/demos/samegame/content/PuzzleBlock.qml [moved from examples/demos/calculator/content/Button.qml with 54% similarity]
examples/demos/samegame/content/SimpleBlock.qml [moved from examples/demos/samegame/content/NameInputDialog.qml with 57% similarity]
examples/demos/samegame/content/SmokeText.qml [moved from examples/demos/samegame/samegame-desktop.qml with 64% similarity]
examples/demos/samegame/content/gfx/background-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/background.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/bar.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/blue-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/blue.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/bubble-highscore.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/bubble-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-game-1.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-game-2.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-game-3.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-game-4.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-game-new.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-menu.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-puzzle-next.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/but-quit.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/green-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/green.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/icon-fail.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/icon-ok.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/icon-time.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo-a.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo-e.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo-g.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo-m.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo-s.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/logo.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/particle-brick.png [moved from examples/demos/samegame/content/pics/particle.png with 100% similarity]
examples/demos/samegame/content/gfx/particle-paint.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/particle-smoke.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/red-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/red.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-highscore-new.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-highscore.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-no-winner.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p1-go.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p1-won.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p1.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p2-go.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p2-won.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/text-p2.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/yellow-puzzle.png [new file with mode: 0644]
examples/demos/samegame/content/gfx/yellow.png [new file with mode: 0644]
examples/demos/samegame/content/levels/TemplateBase.qml [moved from examples/demos/calculator/content/Display.qml with 70% similarity]
examples/demos/samegame/content/levels/level0.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level1.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level2.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level3.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level4.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level5.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level6.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level7.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level8.qml [new file with mode: 0644]
examples/demos/samegame/content/levels/level9.qml [new file with mode: 0644]
examples/demos/samegame/content/pics/background.png [deleted file]
examples/demos/samegame/content/pics/blueStone.png [deleted file]
examples/demos/samegame/content/pics/greenStone.png [deleted file]
examples/demos/samegame/content/pics/redStone.png [deleted file]
examples/demos/samegame/content/pics/yellowStone.png [deleted file]
examples/demos/samegame/content/samegame.js
examples/demos/samegame/main.cpp
examples/demos/samegame/samegame.pro
examples/demos/samegame/samegame.qml [new file with mode: 0644]
examples/demos/samegame/samegame.qmlproject

index 9e0370f..af67f63 100644 (file)
Binary files a/doc/src/images/qml-calculator-example-small.png and b/doc/src/images/qml-calculator-example-small.png differ
index ec9ad76..174270b 100644 (file)
Binary files a/doc/src/images/qml-samegame-demo-small.png and b/doc/src/images/qml-samegame-demo-small.png differ
diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml
deleted file mode 100644 (file)
index 8718118..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-**     the names of its contributors may be used to endorse or promote
-**     products derived from this software without specific prior written
-**     permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-import "content"
-import "content/calculator.js" as CalcEngine
-
-Rectangle {
-    id: window
-
-    width: 640; height: 480
-    color: "#282828"
-
-    property string rotateLeft: "\u2939"
-    property string rotateRight: "\u2935"
-    property string leftArrow: "\u2190"
-    property string division : "\u00f7"
-    property string multiplication : "\u00d7"
-    property string squareRoot : "\u221a"
-    property string plusminus : "\u00b1"
-
-    function doOp(operation) { CalcEngine.doOperation(operation) }
-    focus: true
-    Keys.onPressed: doOp(event.text);
-
-    Item {
-        id: main
-        width: 640
-        height: 480
-        anchors.centerIn: parent
-
-        Column {
-            id: box; spacing: 8
-
-            anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
-
-            Display {
-                id: display
-                width: box.width-3
-                height: 64
-            }
-
-            Column {
-                id: column; spacing: 6
-
-                property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
-                property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
-
-                Row {
-                    spacing: 6
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
-                }
-
-                Row {
-                    spacing: 6
-                    property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
-
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
-                }
-
-                Grid {
-                    id: grid; rows: 5; columns: 5; spacing: 6
-
-                    property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
-
-                    Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: division }
-                    Button { width: grid.w; height: column.h; operation: squareRoot }
-                    Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: multiplication }
-                    Button { width: grid.w; height: column.h; operation: "x^2" }
-                    Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "-" }
-                    Button { width: grid.w; height: column.h; operation: "1/x" }
-                    Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "." }
-                    Button { width: grid.w; height: column.h; operation: plusminus }
-                    Button { width: grid.w; height: column.h; operation: "+" }
-                    Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
-                }
-            }
-        }
-
-    }
-}
diff --git a/examples/demos/calculator/calculator-mobile.qml b/examples/demos/calculator/calculator-mobile.qml
deleted file mode 100644 (file)
index 18e8b8a..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-**     the names of its contributors may be used to endorse or promote
-**     products derived from this software without specific prior written
-**     permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-import "content"
-import "content/calculator.js" as CalcEngine
-
-Rectangle {
-    id: window
-
-    width: 320; height: 480
-    color: "#282828"
-
-    property string rotateLeft: "\u2939"
-    property string rotateRight: "\u2935"
-    property string leftArrow: "\u2190"
-    property string division : "\u00f7"
-    property string multiplication : "\u00d7"
-    property string squareRoot : "\u221a"
-    property string plusminus : "\u00b1"
-
-    function doOp(operation) { CalcEngine.doOperation(operation) }
-
-    Item {
-        id: main
-        state: "orientation " + Screen.orientation
-
-        //Note: Assumes a primarily portrait device
-        property bool landscapeWindow: window.width > window.height 
-        property real baseWidth: landscapeWindow ? window.height : window.width
-        property real baseHeight: landscapeWindow ? window.width : window.height
-        property real rotationDelta: landscapeWindow ? -90 : 0
-
-        rotation: rotationDelta
-        width: main.baseWidth
-        height: main.baseHeight
-        anchors.centerIn: parent
-
-        Column {
-            id: box; spacing: 8
-
-            anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
-
-            Display {
-                id: display
-                width: box.width-3
-                height: 64
-            }
-
-            Column {
-                id: column; spacing: 6
-
-                property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
-                property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
-
-                Row {
-                    spacing: 6
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: window.leftArrow }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
-                    Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
-                }
-
-                Row {
-                    spacing: 6
-                    property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
-
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
-                    Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
-                }
-
-                Grid {
-                    id: grid; rows: 5; columns: 5; spacing: 6
-
-                    property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
-
-                    Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: window.division }
-                    Button { width: grid.w; height: column.h; operation: window.squareRoot }
-                    Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: window.multiplication }
-                    Button { width: grid.w; height: column.h; operation: "x^2" }
-                    Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "-" }
-                    Button { width: grid.w; height: column.h; operation: "1/x" }
-                    Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
-                    Button { width: grid.w; height: column.h; operation: "." }
-                    Button { width: grid.w; height: column.h; operation: window.plusminus }
-                    Button { width: grid.w; height: column.h; operation: "+" }
-                    Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
-                }
-            }
-        }
-
-        states: [
-            State {
-                name: "orientation " + Qt.LandscapeOrientation
-                PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
-            },
-            State {
-                name: "orientation " + Qt.InvertedPortraitOrientation
-                PropertyChanges { target: main; rotation: 180 + rotationDelta; }
-            },
-            State {
-                name: "orientation " + Qt.InvertedLandscapeOrientation
-                PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
-            }
-        ]
-
-        transitions: Transition {
-            SequentialAnimation {
-                RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint  }
-                NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
-            }
-        }
-    }
-}
diff --git a/examples/demos/calculator/calculator.pro b/examples/demos/calculator/calculator.pro
deleted file mode 100644 (file)
index cf63f7b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-TEMPLATE = app
-
-QT += quick qml
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator
-qml.files = calculator-desktop.qml calculator-mobile.qml content
-qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator
-INSTALLS += target qml
diff --git a/examples/demos/calculator/content/images/button-.png b/examples/demos/calculator/content/images/button-.png
deleted file mode 100644 (file)
index 544e514..0000000
Binary files a/examples/demos/calculator/content/images/button-.png and /dev/null differ
diff --git a/examples/demos/calculator/content/images/button-blue.png b/examples/demos/calculator/content/images/button-blue.png
deleted file mode 100644 (file)
index 5f92de3..0000000
Binary files a/examples/demos/calculator/content/images/button-blue.png and /dev/null differ
diff --git a/examples/demos/calculator/content/images/button-green.png b/examples/demos/calculator/content/images/button-green.png
deleted file mode 100644 (file)
index 36c9391..0000000
Binary files a/examples/demos/calculator/content/images/button-green.png and /dev/null differ
diff --git a/examples/demos/calculator/content/images/button-purple.png b/examples/demos/calculator/content/images/button-purple.png
deleted file mode 100644 (file)
index 347cbbe..0000000
Binary files a/examples/demos/calculator/content/images/button-purple.png and /dev/null differ
diff --git a/examples/demos/calculator/content/images/button-red.png b/examples/demos/calculator/content/images/button-red.png
deleted file mode 100644 (file)
index 3b33589..0000000
Binary files a/examples/demos/calculator/content/images/button-red.png and /dev/null differ
diff --git a/examples/demos/calculator/content/images/display.png b/examples/demos/calculator/content/images/display.png
deleted file mode 100644 (file)
index 9507f43..0000000
Binary files a/examples/demos/calculator/content/images/display.png and /dev/null differ
diff --git a/examples/demos/calculator/content/qmldir b/examples/demos/calculator/content/qmldir
deleted file mode 100644 (file)
index a926b93..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Button Button.qml
-Display Display.qml
diff --git a/examples/demos/calqlatr/calqlatr.pro b/examples/demos/calqlatr/calqlatr.pro
new file mode 100644 (file)
index 0000000..0aa39f9
--- /dev/null
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calqlatr
+qml.files = calqlatr.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calqlatr
+INSTALLS += target qml
similarity index 70%
rename from examples/demos/calculator/calculator.qdoc
rename to examples/demos/calqlatr/calqlatr.qdoc
index 7939487..3e0e1f1 100644 (file)
 ****************************************************************************/
 
 /*!
-    \title QML Demo - Calculator
-    \example demos/calculator
-    \brief This is an example calculator application written in QML.
-    \image qml-calculator-example-small.png
+    \title QML Demo - Calqlatr
+    \example demos/calqlatr
+    \brief This is an example calculator written in QML.
+    \image qml-calqlatr-demo-small.png
 
-    The Calculator demo implements a simple calculator in QML. It is written for desktop and portrait devices,
-    although on device it supports orientation changes.
+    This demo implements a simple calculator app, designed for portrait devices.
+
+    This app has the logic implemented in Javascipt and the appearance implemented in QML.
 */
 
diff --git a/examples/demos/calqlatr/calqlatr.qml b/examples/demos/calqlatr/calqlatr.qml
new file mode 100644 (file)
index 0000000..3383361
--- /dev/null
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/calculator.js" as CalcEngine
+
+
+Rectangle {
+    id: window
+    width: 320
+    height: 480
+    focus: true
+    color: "#272822"
+
+    onWidthChanged: controller.reload()
+
+    function operatorPressed(operator) { CalcEngine.operatorPressed(operator) }
+    function digitPressed(digit) { CalcEngine.digitPressed(digit) }
+
+    Item {
+        id: pad
+        width: window.width * 0.58
+        NumberPad { y: 10; anchors.horizontalCenter: parent.horizontalCenter }
+    }
+
+    AnimationController {
+        id: controller
+        animation: ParallelAnimation {
+            id: anim
+            NumberAnimation { target: display; property: "x"; duration: 400; from: -16; to: window.width - display.width; easing.type: Easing.InOutQuad }
+            NumberAnimation { target: pad; property: "x"; duration: 400; from: window.width - pad.width; to: 0; easing.type: Easing.InOutQuad }
+            SequentialAnimation {
+                NumberAnimation { target: pad; property: "scale"; duration: 200; from: 1; to: 0.97; easing.type: Easing.InOutQuad }
+                NumberAnimation { target: pad; property: "scale"; duration: 200; from: 0.97; to: 1; easing.type: Easing.InOutQuad }
+            }
+        }
+    }
+
+    Display {
+        id: display
+        x: -16
+        width: window.width * 0.42
+        height: parent.height
+
+        MouseArea {
+            property real startX: 0
+            property real oldP: 0
+            property bool rewind: false
+
+            anchors.fill: parent
+            onPositionChanged: {
+                var reverse = startX > window.width / 2
+                var mx = mapToItem(window, mouse.x).x
+                var p = Math.abs((mx - startX) / (window.width - display.width))
+                if (p < oldP)
+                    rewind = reverse ? false : true
+                else
+                    rewind = reverse ? true : false
+                controller.progress = reverse ? 1 - p : p
+                oldP = p
+            }
+            onPressed: startX = mapToItem(window, mouse.x).x
+            onReleased: {
+                if (rewind)
+                    controller.completeToBeginning()
+                else
+                    controller.completeToEnd()
+            }
+        }
+    }
+
+}
diff --git a/examples/demos/calqlatr/calqlatr.qmlproject b/examples/demos/calqlatr/calqlatr.qmlproject
new file mode 100644 (file)
index 0000000..42ffacf
--- /dev/null
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+    mainFile: "samegame.qml"
+
+    /* Include .qml, .js, and image files from current directory and subdirectories */
+    QmlFiles {
+        directory: "."
+    }
+    JavaScriptFiles {
+        directory: "."
+    }
+    ImageFiles {
+        directory: "."
+    }
+}
similarity index 71%
rename from examples/demos/samegame/content/Dialog.qml
rename to examples/demos/calqlatr/content/Button.qml
index 5c0da99..ecd7bc9 100644 (file)
 
 import QtQuick 2.0
 
-Rectangle {
-    id: page
-    anchors.centerIn: parent
+Item {
+    property alias text: textItem.text
+    property alias color: textItem.color
 
-    property Item text: dialogText
-    property bool open: false
+    property bool operator: false
 
-    signal closed
-    signal opened
-    function forceClose() {
-        if(!open)
-            return; //already closed
-        page.open = false;
-        page.closed();
-        page.opacity = 0;
-    }
+    signal clicked
 
-    function show(txt) {
-        page.open = true;
-        page.opened();
-        dialogText.text = txt;
-        page.opacity = 1;
-    }
+    width: 30
+    height: 50
 
-    width: dialogText.width + 20; height: dialogText.height + 20
-    color: "white"
-    border.width: 1
-    opacity: 0
-    visible: opacity > 0
-    Behavior on opacity {
-        NumberAnimation { duration: 1000 }
+    Text {
+        id: textItem
+        font.pixelSize: 48
+        wrapMode: Text.WordWrap
+        lineHeight: 0.75
+        color: "white"
     }
 
-    Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+//    Rectangle {
+//        color: "red"
+//        opacity: 0.2
+//        anchors.fill: mouse
+//    }
 
-    MouseArea { anchors.fill: parent; onClicked: forceClose(); }
+    MouseArea {
+        id: mouse
+        anchors.fill: parent
+        anchors.margins: -5
+        onClicked: {
+            //parent.clicked()
+            if (operator)
+                window.operatorPressed(parent.text)
+            else
+                window.digitPressed(parent.text)
+        }
+    }
 }
-
diff --git a/examples/demos/calqlatr/content/Display.qml b/examples/demos/calqlatr/content/Display.qml
new file mode 100644 (file)
index 0000000..37c7592
--- /dev/null
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+    id: display
+
+    function displayOperator(operator)
+    {
+        listView.model.append({ "operator": operator, "operand": "" })
+    }
+
+    function newLine(operator, operand)
+    {
+        listView.model.append({ "operator": operator, "operand": operand })
+    }
+
+    function appendDigit(digit)
+    {
+        if (!listView.model.count)
+            listView.model.append({ "operator": "", "operand": "" })
+        var i = listView.model.count - 1;
+        listView.model.get(i).operand = listView.model.get(i).operand + digit;
+    }
+
+    Item {
+        id: theItem
+        width: parent.width + 32
+        height: parent.height
+
+        Rectangle {
+            id: rect
+            x: 16
+            color: "white"
+            height: parent.height
+            width: display.width - 16
+        }
+        Image {
+            anchors.right: rect.left
+            source: "images/paper-edge-left.png"
+            height: parent.height
+            fillMode: Image.TileVertically
+        }
+        Image {
+            anchors.left: rect.right
+            source: "images/paper-edge-right.png"
+            height: parent.height
+            fillMode: Image.TileVertically
+        }
+
+        Image {
+            source: "images/paper-grip.png"
+            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.bottom: parent.bottom
+            anchors.bottomMargin: 20
+        }
+
+        ListView {
+            id: listView
+            x: 16; y: 30
+            width: display.width
+            height: display.height
+            delegate: Item {
+                height: 20
+                width: parent.width
+                Text {
+                    id: operator
+                    x: 8
+                    font.pixelSize: 18
+                    color: "#6da43d"
+                    text: model.operator
+                }
+                Text {
+                    id: operand
+                    font.pixelSize: 18
+                    anchors.right: parent.right
+                    anchors.rightMargin: 26
+                    text: model.operand
+                }
+            }
+            model: ListModel { }
+        }
+
+    }
+
+}
diff --git a/examples/demos/calqlatr/content/NumberPad.qml b/examples/demos/calqlatr/content/NumberPad.qml
new file mode 100644 (file)
index 0000000..377cd57
--- /dev/null
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Grid {
+    columns: 3
+    columnSpacing: 32
+    rowSpacing: 16
+
+    Button { text: "7" }
+    Button { text: "8" }
+    Button { text: "9" }
+    Button { text: "4" }
+    Button { text: "5" }
+    Button { text: "6" }
+    Button { text: "1" }
+    Button { text: "2" }
+    Button { text: "3" }
+    Button { text: "0" }
+    Button { text: "." }
+    Button { text: " " }
+    Button { text: "±"; color: "#6da43d"; operator: true }
+    Button { text: "−"; color: "#6da43d"; operator: true }
+    Button { text: "+"; color: "#6da43d"; operator: true }
+    Button { text: " "; color: "#6da43d"; operator: true }
+    Button { text: "÷"; color: "#6da43d"; operator: true }
+    Button { text: "×"; color: "#6da43d"; operator: true }
+    Button { text: "C"; color: "#6da43d"; operator: true }
+    Button { text: " "; color: "#6da43d"; operator: true }
+    Button { text: "="; color: "#6da43d"; operator: true }
+}
similarity index 73%
rename from examples/demos/calculator/main.cpp
rename to examples/demos/calqlatr/content/StyleLabel.qml
index fafe14f..ccc09bb 100644 (file)
 **
 ****************************************************************************/
 
-#include <QGuiApplication>
-#include <QStringList>
-#include <QQuickView>
-#include <QQmlEngine>
+import QtQuick 2.0
 
-void usage()
-{
-    printf("Pass -desktop to use the Desktop UI");
-    exit(0);
+Text {
+    width: 64
+    font.pixelSize: 14
+    font.bold: false
+    wrapMode: Text.WordWrap
+    lineHeight: 0.75
+    color: "#676764"
 }
-
-int main(int argc, char* argv[])
-{
-    QGuiApplication app(argc,argv);
-    QQuickView view;
-    QUrl launchFile = QUrl::fromLocalFile(QLatin1String("calculator-mobile.qml"));
-    if (app.arguments().contains(QLatin1String("-help")))
-        usage();
-    if (app.arguments().contains(QLatin1String("-desktop")))
-        launchFile =  QUrl::fromLocalFile(QLatin1String("calculator-desktop.qml"));
-    view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
-    view.setSource(launchFile);
-    view.show();
-    return app.exec();
-}
-
diff --git a/examples/demos/calqlatr/content/audio/touch.wav b/examples/demos/calqlatr/content/audio/touch.wav
new file mode 100644 (file)
index 0000000..94cccb7
Binary files /dev/null and b/examples/demos/calqlatr/content/audio/touch.wav differ
 **
 ****************************************************************************/
 
+
 var curVal = 0
 var memory = 0
 var lastOp = ""
-var timer = 0
+var previousOperator = ""
+var digits = ""
 
 function disabled(op) {
-    if (op == "." && display.text.toString().search(/\./) != -1) {
+    if (op == "." && digits.toString().search(/\./) != -1) {
         return true
-    } else if (op == window.squareRoot &&  display.text.toString().search(/-/) != -1) {
+    } else if (op == window.squareRoot &&  digits.toString().search(/-/) != -1) {
         return true
     } else {
         return false
     }
 }
 
-function doOperation(op) {
-    if (op == '*')//Keyboard Aliases
-        op = window.multiplication;
-    if (op == '/')
-        op = window.division;
-    if (disabled(op)) {
+function digitPressed(op)
+{
+    if (disabled(op))
+        return
+    if (digits.toString().length >= 14)
         return
+    if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
+        digits = digits + op.toString()
+        display.appendDigit(op.toString())
+    } else {
+        digits = op
+        display.appendDigit(op.toString())
     }
+    lastOp = op
+}
 
-    if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) {
-        if (display.text.toString().length >= 14)
-            return; // No arbitrary length numbers
-        if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
-            display.text = display.text + op.toString()
-        } else {
-            display.text = op
-        }
-        lastOp = op
+function operatorPressed(op)
+{
+    if (disabled(op))
         return
-    }
     lastOp = op
 
-    if (display.currentOperation.text == "+") {
-        display.text = Number(display.text.valueOf()) + Number(curVal.valueOf())
-    } else if (display.currentOperation.text == "-") {
-        display.text = Number(curVal) - Number(display.text.valueOf())
-    } else if (display.currentOperation.text == window.multiplication) {
-        display.text = Number(curVal) * Number(display.text.valueOf())
-    } else if (display.currentOperation.text == window.division) {
-        display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString()
-    } else if (display.currentOperation.text == "=") {
+    if (previousOperator == "+") {
+        digits = Number(digits.valueOf()) + Number(curVal.valueOf())
+    } else if (previousOperator == "−") {
+        digits = Number(curVal) - Number(digits.valueOf())
+    } else if (previousOperator == "×") {
+        digits = Number(curVal) * Number(digits.valueOf())
+    } else if (previousOperator == "÷") {
+        digits = Number(Number(curVal) / Number(digits.valueOf())).toString()
+    } else if (previousOperator == "=") {
     }
 
-    if (op == "+" || op == "-" || op == window.multiplication || op == window.division) {
-        display.currentOperation.text = op
-        curVal = display.text.valueOf()
+    if (op == "+" || op == "−" || op == "×" || op == "÷") {
+        previousOperator = op
+        curVal = digits.valueOf()
+        display.displayOperator(previousOperator)
         return
     }
 
+    if (op == "=") {
+        display.newLine("=", digits.toString())
+    }
+
     curVal = 0
-    display.currentOperation.text = ""
+    previousOperator = ""
 
     if (op == "1/x") {
-        display.text = (1 / display.text.valueOf()).toString()
+        digits = (1 / digits.valueOf()).toString()
     } else if (op == "x^2") {
-        display.text = (display.text.valueOf() * display.text.valueOf()).toString()
+        digits = (digits.valueOf() * digits.valueOf()).toString()
     } else if (op == "Abs") {
-        display.text = (Math.abs(display.text.valueOf())).toString()
+        digits = (Math.abs(digits.valueOf())).toString()
     } else if (op == "Int") {
-        display.text = (Math.floor(display.text.valueOf())).toString()
+        digits = (Math.floor(digits.valueOf())).toString()
     } else if (op == window.plusminus) {
-        display.text = (display.text.valueOf() * -1).toString()
+        digits = (digits.valueOf() * -1).toString()
     } else if (op == window.squareRoot) {
-        display.text = (Math.sqrt(display.text.valueOf())).toString()
+        digits = (Math.sqrt(digits.valueOf())).toString()
     } else if (op == "mc") {
         memory = 0;
     } else if (op == "m+") {
-        memory += display.text.valueOf()
+        memory += digits.valueOf()
     } else if (op == "mr") {
-        display.text = memory.toString()
+        digits = memory.toString()
     } else if (op == "m-") {
-        memory = display.text.valueOf()
+        memory = digits.valueOf()
     } else if (op == window.leftArrow) {
-        display.text = display.text.toString().slice(0, -1)
-        if (display.text.length == 0) {
-            display.text = "0"
+        digits = digits.toString().slice(0, -1)
+        if (digits.length == 0) {
+            digits = "0"
         }
     } else if (op == "Off") {
         Qt.quit();
     } else if (op == "C") {
-        display.text = "0"
+        digits = "0"
     } else if (op == "AC") {
         curVal = 0
         memory = 0
         lastOp = ""
-        display.text ="0"
+        digits ="0"
     }
+
+
 }
 
diff --git a/examples/demos/calqlatr/content/images/icon-back.png b/examples/demos/calqlatr/content/images/icon-back.png
new file mode 100644 (file)
index 0000000..2989ee2
Binary files /dev/null and b/examples/demos/calqlatr/content/images/icon-back.png differ
diff --git a/examples/demos/calqlatr/content/images/icon-close.png b/examples/demos/calqlatr/content/images/icon-close.png
new file mode 100644 (file)
index 0000000..3e21248
Binary files /dev/null and b/examples/demos/calqlatr/content/images/icon-close.png differ
diff --git a/examples/demos/calqlatr/content/images/icon-settings.png b/examples/demos/calqlatr/content/images/icon-settings.png
new file mode 100644 (file)
index 0000000..98e662f
Binary files /dev/null and b/examples/demos/calqlatr/content/images/icon-settings.png differ
diff --git a/examples/demos/calqlatr/content/images/logo.png b/examples/demos/calqlatr/content/images/logo.png
new file mode 100644 (file)
index 0000000..6bc6561
Binary files /dev/null and b/examples/demos/calqlatr/content/images/logo.png differ
diff --git a/examples/demos/calqlatr/content/images/paper-edge-left.png b/examples/demos/calqlatr/content/images/paper-edge-left.png
new file mode 100644 (file)
index 0000000..ca29a3a
Binary files /dev/null and b/examples/demos/calqlatr/content/images/paper-edge-left.png differ
diff --git a/examples/demos/calqlatr/content/images/paper-edge-right.png b/examples/demos/calqlatr/content/images/paper-edge-right.png
new file mode 100644 (file)
index 0000000..7c2da7b
Binary files /dev/null and b/examples/demos/calqlatr/content/images/paper-edge-right.png differ
diff --git a/examples/demos/calqlatr/content/images/paper-grip.png b/examples/demos/calqlatr/content/images/paper-grip.png
new file mode 100644 (file)
index 0000000..953c408
Binary files /dev/null and b/examples/demos/calqlatr/content/images/paper-grip.png differ
diff --git a/examples/demos/calqlatr/content/images/settings-selected-a.png b/examples/demos/calqlatr/content/images/settings-selected-a.png
new file mode 100644 (file)
index 0000000..e08ddfa
Binary files /dev/null and b/examples/demos/calqlatr/content/images/settings-selected-a.png differ
diff --git a/examples/demos/calqlatr/content/images/settings-selected-b.png b/examples/demos/calqlatr/content/images/settings-selected-b.png
new file mode 100644 (file)
index 0000000..d9aa7e3
Binary files /dev/null and b/examples/demos/calqlatr/content/images/settings-selected-b.png differ
diff --git a/examples/demos/calqlatr/content/images/touch-green.png b/examples/demos/calqlatr/content/images/touch-green.png
new file mode 100644 (file)
index 0000000..64dbde6
Binary files /dev/null and b/examples/demos/calqlatr/content/images/touch-green.png differ
diff --git a/examples/demos/calqlatr/content/images/touch-white.png b/examples/demos/calqlatr/content/images/touch-white.png
new file mode 100644 (file)
index 0000000..bb02b00
Binary files /dev/null and b/examples/demos/calqlatr/content/images/touch-white.png differ
diff --git a/examples/demos/calqlatr/main.cpp b/examples/demos/calqlatr/main.cpp
new file mode 100644 (file)
index 0000000..3457134
--- /dev/null
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(calqlatr)
index af7d769..d5505c8 100644 (file)
@@ -1,4 +1,4 @@
 TEMPLATE = subdirs
-SUBDIRS =   calculator \
+SUBDIRS =   calqlatr \
             samegame \
             tweetsearch
similarity index 83%
rename from examples/demos/samegame/content/BoomBlock.qml
rename to examples/demos/samegame/content/Block.qml
index b853341..041ee05 100644 (file)
@@ -59,40 +59,43 @@ Item {
     Image {
         id: img
         source: {
-            if(type == 0){
-                "pics/redStone.png";
-            } else if(type == 1) {
-                "pics/blueStone.png";
+            if (type == 0){
+                "gfx/red.png";
+            } else if (type == 1) {
+                "gfx/blue.png";
+            } else if (type == 2) {
+                "gfx/green.png";
             } else {
-                "pics/greenStone.png";
+                "gfx/yellow.png";
             }
         }
         opacity: 0
         Behavior on opacity { NumberAnimation { duration: 200 } }
         anchors.fill: parent
     }
-    Emitter {
+
+    //Foreground particles
+    BlockEmitter {
         id: particles
         system: particleSystem
-        group: { 
-            if(type == 0){
+        group: {
+            if (type == 0){
                 "red";
             } else if (type == 1) {
                 "blue";
-            } else {
+            } else if (type == 2) {
                 "green";
+            } else {
+                "yellow";
             }
         }
         anchors.fill: parent
+    }
 
-        velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
-        shape: EllipseShape{fill:true}
-        enabled: false;
-        lifeSpan: 700; lifeSpanVariation: 100
-        emitRate: 1000
-        maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
-        size: 28
-        endSize: 14
+    //Paint particles on the background
+    PaintEmitter {
+        id: particles2
+        system: particleSystem
     }
 
     states: [
@@ -103,7 +106,7 @@ Item {
 
         State {
             name: "DeathState"; when: dying == true
-            StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} }
+            StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
             PropertyChanges { target: img; opacity: 0 }
             StateChangeScript { script: block.destroy(1000); }
         }
 
 import QtQuick 2.0
 import QtQuick.Particles 2.0
-import "content"
-import "content/samegame.js" as Logic
 
-Rectangle {
-    id: screen
-    width: 320; height: 480
-
-    SystemPalette { id: activePalette }
-
-    GameArea {
-        id: gameCanvas
-        width: parent.width
-        blockSize: 40
-        anchors { top: parent.top; bottom: toolBar.top }
-    }
-
-    Rectangle {
-        id: toolBar
-        width: parent.width; height: 40
-        color: activePalette.window
-        anchors.bottom: screen.bottom
-
-        Button {
-            id: newGameButton
-            anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter }
-            fontSize: 12
-            text: "New Game" 
-            onClicked: Logic.startNewGame(gameCanvas)
-        }
-
-        Text {
-            id: score
-            anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter }
-            text: "Score: " + gameCanvas.score
-            font.bold: true
-            font.pixelSize: 12
-            color: activePalette.windowText
-        }
-    }
+Emitter {
+    property Item block: parent
+    velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40}
+    acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;}
+    shape: EllipseShape{fill:true}
+    enabled: false;
+    lifeSpan: 700; lifeSpanVariation: 100
+    emitRate: 1000
+    maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+    size: 28
+    endSize: 14
 }
index 7fdb1fc..e8a67a5 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
+import QtQuick.Particles 2.0
 
-Rectangle {
-    id: container
-
-    property string text: "Button"
-    property int fontSize: 24
-
+Item {
+    property alias imgSrc: image.source
+    property alias system: emitter.system
+    property alias group: emitter.group
     signal clicked
-
-    width: buttonLabel.width + 20; height: buttonLabel.height + 20
-    smooth: true
-    border { width: 1; color: Qt.darker(activePalette.button) }
-    radius: 8
-    color: activePalette.button
-
-    gradient: Gradient {
-        GradientStop {
-            position: 0.0
-            color: {
-                if (mouseArea.pressed)
-                    return activePalette.dark
-                else
-                    return activePalette.light
-            }
+    property bool rotatedButton: false
+    //Defaults, feel free to override
+    width: image.width
+    height: image.height
+    Image {
+        id: image
+        anchors.centerIn: parent
+        rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
+        MenuEmitter {
+            id: emitter
+            anchors.fill: parent
+            //shape: MaskShape {source: image.source}
         }
-        GradientStop { position: 1.0; color: activePalette.button }
     }
-
-    MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
-
-    Text {
-        id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: container.fontSize
+    MouseArea {
+        anchors.fill: parent
+        onClicked: {parent.clicked(); emitter.burst(400);}
     }
 }
index 8f7a415..8f025fb 100644 (file)
@@ -44,48 +44,185 @@ import "samegame.js" as Logic
 
 Item {
     id: gameCanvas
+    property bool gameOver: true
     property int score: 0
-    property int blockSize: 40
+    property int highScore: 0
+    property int moves: 0
+    property int blockSize: 32
+    property string mode: ""
     property ParticleSystem ps: particleSystem
+    //For easy theming
+    property alias backgroundVisible: bg.visible
+    property string background: "gfx/background.png"
+    property string blockFile: "Block.qml"
+    onBlockFileChanged: Logic.changeBlock(blockFile);
+    property alias particlePack: auxLoader.source
+    //For multiplayer
+    property int score2: 0
+    property int curTurn: 1
+    property bool autoTurnChange: false
+    signal swapPlayers
+    property bool swapping: false
+    //onSwapPlayers: if (autoTurnChange) Logic.turnChange();//Now implemented below
+    //For puzzle
+    property url level
+    property bool puzzleWon: false
+    signal puzzleLost //Since root is tracking the puzzle progress
+    function showPuzzleEnd (won) {
+        if (won) {
+            smokeParticle.color = Qt.rgba(0,1,0,0);
+            puzzleWin.play();
+        } else {
+            smokeParticle.color = Qt.rgba(1,0,0,0);
+            puzzleFail.play();
+            puzzleLost();
+        }
+    }
+    function showPuzzleGoal (str) {
+        puzzleTextBubble.opacity = 1;
+        puzzleTextLabel.text = str;
+    }
     Image {
-        id: background
-        anchors.fill: parent
+        id: bg
         z: -1
-        source: "pics/background.png"
+        source: background;
         fillMode: Image.PreserveAspectCrop
     }
 
-    width: 480
-    height: 800
+    width: 320
+    height: 480
     MouseArea {
-        anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
+        anchors.fill: parent; onClicked: {
+            if (puzzleTextBubble.opacity == 1) {
+                puzzleTextBubble.opacity = 0;
+                Logic.finishLoadingMap();
+            } else if (!swapping) {
+                Logic.handleClick(mouse.x,mouse.y);
+            }
+        }
     }
-    ParticleSystem{ 
-        id: particleSystem;
-        onEmptyChanged: if (empty) paused = true;
-        z:2
-        ImageParticle {
-            groups: ["red"]
-            color: Qt.darker("red");//Actually want desaturated...
-            source: "pics/particle.png"
-            colorVariation: 0.4
-            alpha: 0.1
+
+    Image {
+        id: highScoreTextBubble
+        opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
+        Behavior on opacity { NumberAnimation {} }
+        anchors.centerIn: parent
+        z: 10
+        source: "gfx/bubble-highscore.png"
+        Image {
+            anchors.centerIn: parent
+            source: "gfx/text-highscore-new.png"
+            rotation: -10
         }
-        ImageParticle {
-            groups: ["green"]
-            color: Qt.darker("green");//Actually want desaturated...
-            source: "pics/particle.png"
-            colorVariation: 0.4
-            alpha: 0.1
+    }
+
+    Image {
+        id: puzzleTextBubble
+        anchors.centerIn: parent
+        opacity: 0
+        Behavior on opacity { NumberAnimation {} }
+        z: 10
+        source: "gfx/bubble-puzzle.png"
+        Connections {
+            target: gameCanvas
+            onModeChanged: if (mode != "puzzle" && puzzleTextBubble.opacity > 0) puzzleTextBubble.opacity = 0;
+        }
+        Text {
+            id: puzzleTextLabel
+            width: parent.width - 24
+            anchors.centerIn: parent
+            horizontalAlignment: Text.AlignHCenter
+            color: "white"
+            font.pixelSize: 24
+            font.bold: true
+            wrapMode: Text.WordWrap
+        }
+    }
+    onModeChanged: {
+        p1WonImg.opacity = 0;
+        p2WonImg.opacity = 0;
+    }
+    SmokeText { id: puzzleWin; source: "gfx/icon-ok.png"; system: particleSystem }
+    SmokeText { id: puzzleFail; source: "gfx/icon-fail.png"; system: particleSystem }
+
+    onSwapPlayers: {
+        smokeParticle.color = "yellow"
+        Logic.turnChange();
+        if (curTurn == 1) {
+            p1Text.play();
+        } else {
+            p2Text.play();
+        }
+        clickDelay.running = true;
+    }
+    SequentialAnimation {
+        id: clickDelay
+        ScriptAction { script: gameCanvas.swapping = true; }
+        PauseAnimation { duration: 750 }
+        ScriptAction { script: gameCanvas.swapping = false; }
+    }
+
+    SmokeText {
+        id: p1Text; source: "gfx/text-p1-go.png";
+        system: particleSystem; playerNum: 1
+        opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+    }
+
+    SmokeText {
+        id: p2Text; source: "gfx/text-p2-go.png";
+        system: particleSystem; playerNum: 2
+        opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+    }
+
+    onGameOverChanged: {
+        if (gameCanvas.mode == "multiplayer") {
+            if (gameCanvas.score >= gameCanvas.score2) {
+                p1WonImg.opacity = 1;
+            } else {
+                p2WonImg.opacity = 1;
+            }
         }
+    }
+    Image {
+        id: p1WonImg
+        source: "gfx/text-p1-won.png"
+        anchors.centerIn: parent
+        opacity: 0
+        Behavior on opacity { NumberAnimation {} }
+        z: 10
+    }
+    Image {
+        id: p2WonImg
+        source: "gfx/text-p2-won.png"
+        anchors.centerIn: parent
+        opacity: 0
+        Behavior on opacity { NumberAnimation {} }
+        z: 10
+    }
+
+    ParticleSystem{
+        id: particleSystem;
+        anchors.fill: parent
+        z: 5
         ImageParticle {
-            groups: ["blue"]
-            color: Qt.darker("blue");//Actually want desaturated...
-            source: "pics/particle.png"
-            colorVariation: 0.4
+            id: smokeParticle
+            groups: ["smoke"]
+            source: "gfx/particle-smoke.png"
             alpha: 0.1
+            alphaVariation: 0.1
+            color: "yellow"
+        }
+        Loader {
+            id: auxLoader
+            anchors.fill: parent
+            source: "PrimaryPack.qml"
+            onItemChanged: {
+                if (item && "particleSystem" in item)
+                    item.particleSystem = particleSystem
+                if (item && "gameArea" in item)
+                    item.gameArea = gameCanvas
+            }
         }
-        anchors.fill: parent
     }
 }
 
diff --git a/examples/demos/samegame/content/LogoAnimation.qml b/examples/demos/samegame/content/LogoAnimation.qml
new file mode 100644 (file)
index 0000000..622438b
--- /dev/null
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+    id: container //Positioned where the 48x48 S/G should be
+    property alias running: mainAnim.running
+    property ParticleSystem particleSystem
+    property int dur: 500
+    signal boomTime
+    Image {
+        id: s1
+        source: "gfx/logo-s.png"
+        y: 0
+    }
+    Image {
+        id: g1
+        source: "gfx/logo-g.png"
+        y: -128
+    }
+    Column {
+        Repeater {
+            model: 2
+            Item {
+                width: 48
+                height: 48
+                BlockEmitter {
+                    id: emitter
+                    anchors.fill: parent
+                    group: "red"
+                    system: particleSystem
+                    Connections {
+                        target: container
+                        onBoomTime: emitter.pulse(100);
+                    }
+                }
+            }
+        }
+    }
+    SequentialAnimation {
+        id: mainAnim
+        running: true
+        loops: -1
+        PropertyAction { target: g1; property: "y"; value: -128}
+        PropertyAction { target: g1; property: "opacity"; value: 1}
+        PropertyAction { target: s1; property: "y"; value: 0}
+        PropertyAction { target: s1; property: "opacity"; value: 1}
+        NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur}
+        ParallelAnimation {
+            NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur}
+            NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur }
+        }
+        PauseAnimation { duration: dur }
+        ScriptAction { script: container.boomTime(); }
+        ParallelAnimation {
+            NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur }
+            NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur }
+        }
+        PropertyAction { target: s1; property: "y"; value: -128}
+        PropertyAction { target: s1; property: "opacity"; value: 1}
+        NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2}
+    }
+}
diff --git a/examples/demos/samegame/content/MenuEmitter.qml b/examples/demos/samegame/content/MenuEmitter.qml
new file mode 100644 (file)
index 0000000..a0e9bf2
--- /dev/null
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Emitter {
+    anchors.fill: parent
+    velocity: AngleDirection{angleVariation: 360; magnitude: 140; magnitudeVariation: 40}
+    enabled: false;
+    lifeSpan: 500;
+    emitRate: 1
+    size: 28
+    endSize: 14
+    group: "yellow"
+}
diff --git a/examples/demos/samegame/content/PaintEmitter.qml b/examples/demos/samegame/content/PaintEmitter.qml
new file mode 100644 (file)
index 0000000..1c69f13
--- /dev/null
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Emitter {
+    property Item block: parent
+    anchors.fill: parent
+    shape: EllipseShape { fill: true }
+    group: {
+        if (block.type == 0){
+            "redspots";
+        } else if (block.type == 1) {
+            "bluespots";
+        } else if (block.type == 2) {
+            "greenspots";
+        } else {
+            "yellowspots";
+        }
+    }
+    size: 64
+    endSize: 16
+    lifeSpan: 30000
+    enabled: false
+    emitRate: 60
+    maximumEmitted: 60
+    velocity: PointDirection{ y: 4; yVariation: 4 }
+    /* Possibly better, but dependent on gerrit change,28212
+    property real mainIntensity: 0.8
+    property real subIntensity: 0.1
+    property real colorVariation: 0.005
+    onEmitParticles: {//One group, many colors, for better stacking
+        for (var i=0; i<particles.length; i++) {
+            var particle = particles[i];
+            if (block.type == 0) {
+                particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+            } else if (block.type == 1) {
+                particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+            } else if (block.type == 2) {
+                particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+            } else if (block.type == 3) {
+                particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+            } else {
+                particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+                particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+            }
+        }
+    }
+    */
+}
diff --git a/examples/demos/samegame/content/PrimaryPack.qml b/examples/demos/samegame/content/PrimaryPack.qml
new file mode 100644 (file)
index 0000000..3f6b556
--- /dev/null
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+    id: container
+    property ParticleSystem particleSystem
+    property GameArea gameArea
+    onGameAreaChanged: bgstacker.parent = gameArea;//Move to direct child of game canvas
+    Item {
+        id: bgstacker
+        z: 0
+        ImageParticle {
+            groups: ["yellowspots"]
+            color: Qt.darker("yellow");//Actually want desaturated...
+            system: particleSystem
+            source: "gfx/particle-paint.png"
+            colorVariation: 0.2
+            alpha: 0.2
+            entryEffect: ImageParticle.None
+        }
+        ImageParticle {
+            groups: ["redspots"]
+            system: particleSystem
+            color: Qt.darker("red");//Actually want desaturated...
+            source: "gfx/particle-paint.png"
+            colorVariation: 0.2
+            alpha: 0.2
+            entryEffect: ImageParticle.None
+        }
+        ImageParticle {
+            groups: ["greenspots"]
+            system: particleSystem
+            color: Qt.darker("green");//Actually want desaturated...
+            source: "gfx/particle-paint.png"
+            colorVariation: 0.2
+            alpha: 0.2
+            entryEffect: ImageParticle.None
+        }
+        ImageParticle {
+            groups: ["bluespots"]
+            system: particleSystem
+            color: Qt.darker("blue");//Actually want desaturated...
+            source: "gfx/particle-paint.png"
+            colorVariation: 0.2
+            alpha: 0.2
+            entryEffect: ImageParticle.None
+        }
+    }
+    ImageParticle {
+        groups: ["yellow"]
+        system: particleSystem
+        color: Qt.darker("yellow");//Actually want desaturated...
+        source: "gfx/particle-brick.png"
+        colorVariation: 0.4
+        alpha: 0.1
+    }
+    ImageParticle {
+        groups: ["red"]
+        system: particleSystem
+        color: Qt.darker("red");//Actually want desaturated...
+        source: "gfx/particle-brick.png"
+        colorVariation: 0.4
+        alpha: 0.1
+    }
+    ImageParticle {
+        groups: ["green"]
+        system: particleSystem
+        color: Qt.darker("green");//Actually want desaturated...
+        source: "gfx/particle-brick.png"
+        colorVariation: 0.4
+        alpha: 0.1
+    }
+    ImageParticle {
+        groups: ["blue"]
+        system: particleSystem
+        color: Qt.darker("blue");//Actually want desaturated...
+        source: "gfx/particle-brick.png"
+        colorVariation: 0.4
+        alpha: 0.1
+    }
+}
 ****************************************************************************/
 
 import QtQuick 2.0
+import QtQuick.Particles 2.0
 
-BorderImage {
-    id: button
+Item {
+    id: block
+    property bool dying: false
+    property bool spawned: false
+    property int type: 0
+    property ParticleSystem particleSystem
 
-    property alias operation: buttonText.text
-    property string color: ""
-
-    Accessible.name: operation
-    Accessible.description: "This button does " + operation
-    Accessible.role: Accessible.Button
-
-    signal clicked
-
-    source: "images/button-" + color + ".png"; clip: true
-    border { left: 10; top: 10; right: 10; bottom: 10 }
-
-    Rectangle {
-        id: shade
-        anchors.fill: button; radius: 10; color: "black"; opacity: 0
+    Behavior on x {
+        enabled: spawned;
+        NumberAnimation{ easing.type: Easing.OutBounce }
     }
-
-    Text {
-        id: buttonText
-        anchors.centerIn: parent; anchors.verticalCenterOffset: -1
-        font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
-        style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+    Behavior on y {
+        NumberAnimation{ easing.type: Easing.InQuad }
     }
 
-    MouseArea {
-        id: mouseArea
-        anchors.fill: parent
-        onClicked: {
-            window.doOp(operation)
-            button.clicked()
+    Image {
+        id: img
+        source: {
+            if (type == 0){
+                "gfx/red-puzzle.png";
+            } else if (type == 1) {
+                "gfx/blue-puzzle.png";
+            } else if (type == 2) {
+                "gfx/green-puzzle.png";
+            } else {
+                "gfx/yellow-puzzle.png";
+            }
         }
+        opacity: 0
+        Behavior on opacity { NumberAnimation { duration: 200 } }
+        anchors.centerIn: parent
+        anchors.verticalCenterOffset: -4
+        anchors.horizontalCenterOffset: 4
     }
 
-    states: State {
-        name: "pressed"; when: mouseArea.pressed == true
-        PropertyChanges { target: shade; opacity: .4 }
+    //Foreground particles
+    BlockEmitter {
+        id: particles
+        system: particleSystem
+        group: {
+            if (type == 0){
+                "red";
+            } else if (type == 1) {
+                "blue";
+            } else if (type == 2) {
+                "green";
+            } else {
+                "yellow";
+            }
+        }
+        anchors.fill: parent
     }
+
+    states: [
+        State {
+            name: "AliveState"; when: spawned == true && dying == false
+            PropertyChanges { target: img; opacity: 1 }
+        },
+
+        State {
+            name: "DeathState"; when: dying == true
+            PropertyChanges { target: img; scale: 2 }
+            StateChangeScript { script: particles.pulse(200); }
+            PropertyChanges { target: img; opacity: 0 }
+            StateChangeScript { script: block.destroy(1000); }
+        }
+    ]
 }
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
-import QtQuick 2.0
-
-Dialog {
-    id: nameInputDialog
 
-    property int initialWidth: 0
-    property alias name: nameInputText.text
+import QtQuick 2.0
+import QtQuick.Particles 2.0
 
-    anchors.centerIn: parent
-    z: 22;
+Item {
+    id: block
+    property bool dying: false
+    property bool spawned: false
+    property int type: 0
+    property ParticleSystem particleSystem
 
-    Behavior on width {
-        NumberAnimation {} 
-        enabled: nameInputDialog.initialWidth != 0
+    Behavior on x {
+        enabled: spawned;
+        SpringAnimation{ spring: 2; damping: 0.2 }
     }
-
-    signal accepted(string name)
-    onClosed: {
-        if (nameInputText.text != "")
-            accepted(name);
+    Behavior on y {
+        SpringAnimation{ spring: 2; damping: 0.2 }
     }
-    Text {
-        id: dialogText
-        anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
-        text: "You won! Your name: "
-    }
-    MouseArea {
-        anchors.fill: parent
-        onClicked: {
-            if (nameInputText.text == "")
-                nameInputText.openSoftwareInputPanel();
-            else
-                nameInputDialog.forceClose();
+
+    Image {
+        id: img
+        source: {
+            if (type == 0){
+                "gfx/red.png";
+            } else if (type == 1) {
+                "gfx/blue.png";
+            } else if (type == 2) {
+                "gfx/green.png";
+            } else {
+                "gfx/yellow.png";
+            }
         }
+        opacity: 0
+        Behavior on opacity { NumberAnimation { duration: 200 } }
+        anchors.fill: parent
     }
 
-    TextInput {
-        id: nameInputText
-        anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
-        focus: visible
-        autoScroll: false
-        maximumLength: 24
-        onTextChanged: {
-            var newWidth = nameInputText.width + dialogText.width + 40;
-            if ( (newWidth > nameInputDialog.width && newWidth < screen.width) 
-                    || (nameInputDialog.width > nameInputDialog.initialWidth) )
-                nameInputDialog.width = newWidth;
-        }
-        onAccepted: {
-            nameInputDialog.forceClose();
+    //Foreground particles
+    BlockEmitter {
+        id: particles
+        system: particleSystem
+        group: {
+            if (type == 0){
+                "red";
+            } else if (type == 1) {
+                "blue";
+            } else if (type == 2) {
+                "green";
+            } else {
+                "yellow";
+            }
         }
+        anchors.fill: parent
     }
+
+    states: [
+        State {
+            name: "AliveState"; when: spawned == true && dying == false
+            PropertyChanges { target: img; opacity: 1 }
+        },
+
+        State {
+            name: "DeathState"; when: dying == true
+            StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); } }
+            PropertyChanges { target: img; opacity: 0 }
+            StateChangeScript { script: block.destroy(1000); }
+        }
+    ]
 }
similarity index 64%
rename from examples/demos/samegame/samegame-desktop.qml
rename to examples/demos/samegame/content/SmokeText.qml
index 51b7a6d..58507e8 100644 (file)
 
 import QtQuick 2.0
 import QtQuick.Particles 2.0
-import "content"
-import "content/samegame.js" as Logic
 
-Rectangle {
-    id: screen
-    width: 480; height: 640
-
-    SystemPalette { id: activePalette }
-
-    GameArea {
-        id: gameCanvas
-        width: parent.width
-        anchors { top: parent.top; bottom: toolBar.top }
+Item {
+    z: 10
+    property alias source: img.source
+    property alias system: emitter.system
+    property int playerNum: 1
+    function play() {
+        anim.running = true;
     }
-
-    Rectangle {
-        id: toolBar
-        width: parent.width; height: 80
-        color: activePalette.window
-        anchors.bottom: screen.bottom
-
-        Button {
-            id: newGameButton
-            anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter }
-            text: "New Game" 
-            onClicked: Logic.startNewGame(gameCanvas)
+    anchors.centerIn: parent
+    Image {
+        opacity: 0
+        id: img
+        anchors.centerIn: parent
+        rotation: playerNum == 1 ? -8 : -5
+        Emitter {
+            id: emitter
+            group: "smoke"
+            anchors.fill: parent
+            shape: MaskShape { source: img.source }
+            enabled: false
+            emitRate: 1000
+            lifeSpan: 600
+            size: 64
+            endSize: 32
+            velocity: AngleDirection { angleVariation: 360; magnitudeVariation: 160 }
         }
-
-        Button {
-            text: "Quit"
-            anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter }
-            onClicked: Qt.quit();
-        }
-
-        Text {
-            id: score
-            anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter }
-            text: "Score: " + gameCanvas.score
-            font.bold: true
-            font.pixelSize: 24
-            color: activePalette.windowText
+    }
+    SequentialAnimation {
+        id: anim
+        running: false
+        PauseAnimation { duration: 500}
+        ParallelAnimation {
+            NumberAnimation { target: img; property: "opacity"; from: 0.1; to: 1.0 }
+            NumberAnimation { target: img; property: "scale"; from: 0.1; to: 1.0 }
         }
+        PauseAnimation { duration: 250}
+        ScriptAction { script: emitter.pulse(100); }
+        NumberAnimation { target: img; property: "opacity"; from: 1.0; to: 0.0 }
     }
 }
diff --git a/examples/demos/samegame/content/gfx/background-puzzle.png b/examples/demos/samegame/content/gfx/background-puzzle.png
new file mode 100644 (file)
index 0000000..c2eca5f
Binary files /dev/null and b/examples/demos/samegame/content/gfx/background-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/background.png b/examples/demos/samegame/content/gfx/background.png
new file mode 100644 (file)
index 0000000..60f57b6
Binary files /dev/null and b/examples/demos/samegame/content/gfx/background.png differ
diff --git a/examples/demos/samegame/content/gfx/bar.png b/examples/demos/samegame/content/gfx/bar.png
new file mode 100644 (file)
index 0000000..4953cd6
Binary files /dev/null and b/examples/demos/samegame/content/gfx/bar.png differ
diff --git a/examples/demos/samegame/content/gfx/blue-puzzle.png b/examples/demos/samegame/content/gfx/blue-puzzle.png
new file mode 100644 (file)
index 0000000..e550d59
Binary files /dev/null and b/examples/demos/samegame/content/gfx/blue-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/blue.png b/examples/demos/samegame/content/gfx/blue.png
new file mode 100644 (file)
index 0000000..b8161c0
Binary files /dev/null and b/examples/demos/samegame/content/gfx/blue.png differ
diff --git a/examples/demos/samegame/content/gfx/bubble-highscore.png b/examples/demos/samegame/content/gfx/bubble-highscore.png
new file mode 100644 (file)
index 0000000..c4e38df
Binary files /dev/null and b/examples/demos/samegame/content/gfx/bubble-highscore.png differ
diff --git a/examples/demos/samegame/content/gfx/bubble-puzzle.png b/examples/demos/samegame/content/gfx/bubble-puzzle.png
new file mode 100644 (file)
index 0000000..278556b
Binary files /dev/null and b/examples/demos/samegame/content/gfx/bubble-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/but-game-1.png b/examples/demos/samegame/content/gfx/but-game-1.png
new file mode 100644 (file)
index 0000000..3343b7f
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-game-1.png differ
diff --git a/examples/demos/samegame/content/gfx/but-game-2.png b/examples/demos/samegame/content/gfx/but-game-2.png
new file mode 100644 (file)
index 0000000..afba106
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-game-2.png differ
diff --git a/examples/demos/samegame/content/gfx/but-game-3.png b/examples/demos/samegame/content/gfx/but-game-3.png
new file mode 100644 (file)
index 0000000..adea77a
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-game-3.png differ
diff --git a/examples/demos/samegame/content/gfx/but-game-4.png b/examples/demos/samegame/content/gfx/but-game-4.png
new file mode 100644 (file)
index 0000000..18c922b
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-game-4.png differ
diff --git a/examples/demos/samegame/content/gfx/but-game-new.png b/examples/demos/samegame/content/gfx/but-game-new.png
new file mode 100644 (file)
index 0000000..257e182
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-game-new.png differ
diff --git a/examples/demos/samegame/content/gfx/but-menu.png b/examples/demos/samegame/content/gfx/but-menu.png
new file mode 100644 (file)
index 0000000..8440e87
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-menu.png differ
diff --git a/examples/demos/samegame/content/gfx/but-puzzle-next.png b/examples/demos/samegame/content/gfx/but-puzzle-next.png
new file mode 100644 (file)
index 0000000..7e3ed41
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-puzzle-next.png differ
diff --git a/examples/demos/samegame/content/gfx/but-quit.png b/examples/demos/samegame/content/gfx/but-quit.png
new file mode 100644 (file)
index 0000000..95c77ce
Binary files /dev/null and b/examples/demos/samegame/content/gfx/but-quit.png differ
diff --git a/examples/demos/samegame/content/gfx/green-puzzle.png b/examples/demos/samegame/content/gfx/green-puzzle.png
new file mode 100644 (file)
index 0000000..581f76f
Binary files /dev/null and b/examples/demos/samegame/content/gfx/green-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/green.png b/examples/demos/samegame/content/gfx/green.png
new file mode 100644 (file)
index 0000000..da4cca5
Binary files /dev/null and b/examples/demos/samegame/content/gfx/green.png differ
diff --git a/examples/demos/samegame/content/gfx/icon-fail.png b/examples/demos/samegame/content/gfx/icon-fail.png
new file mode 100644 (file)
index 0000000..4072611
Binary files /dev/null and b/examples/demos/samegame/content/gfx/icon-fail.png differ
diff --git a/examples/demos/samegame/content/gfx/icon-ok.png b/examples/demos/samegame/content/gfx/icon-ok.png
new file mode 100644 (file)
index 0000000..15a8442
Binary files /dev/null and b/examples/demos/samegame/content/gfx/icon-ok.png differ
diff --git a/examples/demos/samegame/content/gfx/icon-time.png b/examples/demos/samegame/content/gfx/icon-time.png
new file mode 100644 (file)
index 0000000..9490e49
Binary files /dev/null and b/examples/demos/samegame/content/gfx/icon-time.png differ
diff --git a/examples/demos/samegame/content/gfx/logo-a.png b/examples/demos/samegame/content/gfx/logo-a.png
new file mode 100644 (file)
index 0000000..20c20ba
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo-a.png differ
diff --git a/examples/demos/samegame/content/gfx/logo-e.png b/examples/demos/samegame/content/gfx/logo-e.png
new file mode 100644 (file)
index 0000000..dd663f1
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo-e.png differ
diff --git a/examples/demos/samegame/content/gfx/logo-g.png b/examples/demos/samegame/content/gfx/logo-g.png
new file mode 100644 (file)
index 0000000..a319bf9
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo-g.png differ
diff --git a/examples/demos/samegame/content/gfx/logo-m.png b/examples/demos/samegame/content/gfx/logo-m.png
new file mode 100644 (file)
index 0000000..6a029b3
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo-m.png differ
diff --git a/examples/demos/samegame/content/gfx/logo-s.png b/examples/demos/samegame/content/gfx/logo-s.png
new file mode 100644 (file)
index 0000000..963b175
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo-s.png differ
diff --git a/examples/demos/samegame/content/gfx/logo.png b/examples/demos/samegame/content/gfx/logo.png
new file mode 100644 (file)
index 0000000..e900edd
Binary files /dev/null and b/examples/demos/samegame/content/gfx/logo.png differ
diff --git a/examples/demos/samegame/content/gfx/particle-paint.png b/examples/demos/samegame/content/gfx/particle-paint.png
new file mode 100644 (file)
index 0000000..9bd0a2a
Binary files /dev/null and b/examples/demos/samegame/content/gfx/particle-paint.png differ
diff --git a/examples/demos/samegame/content/gfx/particle-smoke.png b/examples/demos/samegame/content/gfx/particle-smoke.png
new file mode 100644 (file)
index 0000000..b27f954
Binary files /dev/null and b/examples/demos/samegame/content/gfx/particle-smoke.png differ
diff --git a/examples/demos/samegame/content/gfx/red-puzzle.png b/examples/demos/samegame/content/gfx/red-puzzle.png
new file mode 100644 (file)
index 0000000..9ceb17e
Binary files /dev/null and b/examples/demos/samegame/content/gfx/red-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/red.png b/examples/demos/samegame/content/gfx/red.png
new file mode 100644 (file)
index 0000000..681810f
Binary files /dev/null and b/examples/demos/samegame/content/gfx/red.png differ
diff --git a/examples/demos/samegame/content/gfx/text-highscore-new.png b/examples/demos/samegame/content/gfx/text-highscore-new.png
new file mode 100644 (file)
index 0000000..50f7fcd
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-highscore-new.png differ
diff --git a/examples/demos/samegame/content/gfx/text-highscore.png b/examples/demos/samegame/content/gfx/text-highscore.png
new file mode 100644 (file)
index 0000000..7198c27
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-highscore.png differ
diff --git a/examples/demos/samegame/content/gfx/text-no-winner.png b/examples/demos/samegame/content/gfx/text-no-winner.png
new file mode 100644 (file)
index 0000000..b4a6685
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-no-winner.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p1-go.png b/examples/demos/samegame/content/gfx/text-p1-go.png
new file mode 100644 (file)
index 0000000..c7bd2a5
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p1-go.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p1-won.png b/examples/demos/samegame/content/gfx/text-p1-won.png
new file mode 100644 (file)
index 0000000..41c2eb7
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p1-won.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p1.png b/examples/demos/samegame/content/gfx/text-p1.png
new file mode 100644 (file)
index 0000000..b59c87b
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p1.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p2-go.png b/examples/demos/samegame/content/gfx/text-p2-go.png
new file mode 100644 (file)
index 0000000..f03cd93
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p2-go.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p2-won.png b/examples/demos/samegame/content/gfx/text-p2-won.png
new file mode 100644 (file)
index 0000000..116b7f2
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p2-won.png differ
diff --git a/examples/demos/samegame/content/gfx/text-p2.png b/examples/demos/samegame/content/gfx/text-p2.png
new file mode 100644 (file)
index 0000000..d4f2bc7
Binary files /dev/null and b/examples/demos/samegame/content/gfx/text-p2.png differ
diff --git a/examples/demos/samegame/content/gfx/yellow-puzzle.png b/examples/demos/samegame/content/gfx/yellow-puzzle.png
new file mode 100644 (file)
index 0000000..66044c8
Binary files /dev/null and b/examples/demos/samegame/content/gfx/yellow-puzzle.png differ
diff --git a/examples/demos/samegame/content/gfx/yellow.png b/examples/demos/samegame/content/gfx/yellow.png
new file mode 100644 (file)
index 0000000..6bc5d38
Binary files /dev/null and b/examples/demos/samegame/content/gfx/yellow.png differ
 
 import QtQuick 2.0
 
-BorderImage {
-    id: image
+Rectangle{
+    id: control
+    property int scoreTarget: -1
+    property int timeTarget: -1
+    property int moveTarget: -1
+    property bool mustClear: true
+    property string goalText: "Clear the level..."
 
-    property alias text : displayText.text
-    property alias currentOperation : operationText
+    property var startingGrid //If this isn't an array of ints, we will refuse to load the level.
+    /*  Ints are 0-4. If not enough ints are there it will be prepadded with 0s to fill the grid
+        (which ruins everything if you have the wrong number of rows).
+        0 - No block
+        1 - Red
+        2 - Blue
+        3 - Green
+        4 - Yellow
+        Ideas for future colors, but not supported in this version:
+        5 - Purple
+        6 - Cyan
+        7 - Gray
+        8 - Black
+        9 - White
+    */
 
-    source: "images/display.png"
-    border { left: 10; top: 10; right: 10; bottom: 10 }
-
-    Text {
-        id: displayText
-        anchors {
-            right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1
-            rightMargin: 6; left: operationText.right
-        }
-        font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight
-        color: "#343434"; smooth: true; font.bold: true
-    }
-    Text {
-        id: operationText
-        font.bold: true; font.pixelSize: parent.height * .7
-        color: "#343434"; smooth: true
-        anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter }
-    }
+    width: 320
+    height: 416
+    color: "white" //TODO: Theme support for both setting themes per level, and seeing it in the control!
 }
diff --git a/examples/demos/samegame/content/levels/level0.qml b/examples/demos/samegame/content/levels/level0.qml
new file mode 100644 (file)
index 0000000..40ca1f4
--- /dev/null
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    moveTarget: 3
+    goalText: "1 of 10<br><br>Clear in three moves..."
+    startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ,
+                    0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 1 ,
+                    0 , 0 , 0 , 1 , 1 , 3 , 3 , 3 , 3 , 3 ,
+                    0 , 1 , 1 , 3 , 3 , 3 , 1 , 3 , 1 , 1 ,
+                    1 , 2 , 3 , 3 , 1 , 1 , 3 , 3 , 3 , 3 ,
+                    1 , 3 , 3 , 2 , 3 , 3 , 3 , 3 , 1 , 1 ,
+                    1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
+}
diff --git a/examples/demos/samegame/content/levels/level1.qml b/examples/demos/samegame/content/levels/level1.qml
new file mode 100644 (file)
index 0000000..8b0a6e9
--- /dev/null
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    timeTarget: 10
+    goalText: "2 of 10<br><br>Clear in 10 seconds..."
+    startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    1 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 2 ,
+                    1 , 2 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 ,
+                    2 , 2 , 1 , 3 , 3 , 3 , 1 , 1 , 1 , 2 ,
+                    2 , 1 , 1 , 1 , 3 , 3 , 3 , 1 , 2 , 2 ,
+                    1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 2 , 1 ]
+}
diff --git a/examples/demos/samegame/content/levels/level2.qml b/examples/demos/samegame/content/levels/level2.qml
new file mode 100644 (file)
index 0000000..ce3813e
--- /dev/null
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    scoreTarget: 1200
+    timeTarget: 60
+    goalText: "3 of 10<br><br>Score over 1200 points in one minute..."
+    mustClear: false
+    startingGrid: [ 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 3 , 3 ,
+                    1 , 3 , 3 , 2 , 3 , 3 , 1 , 1 , 3 , 1 ,
+                    3 , 1 , 3 , 3 , 2 , 3 , 3 , 3 , 1 , 2 ,
+                    3 , 2 , 2 , 1 , 3 , 3 , 2 , 1 , 1 , 2 ,
+                    3 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 3 , 1 ,
+                    2 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , 3 , 2 ,
+                    3 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 2 , 1 ,
+                    1 , 2 , 2 , 3 , 2 , 3 , 3 , 3 , 1 , 1 ,
+                    1 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 1 ,
+                    3 , 3 , 2 , 1 , 2 , 2 , 1 , 1 , 1 , 3 ,
+                    2 , 1 , 3 , 2 , 3 , 2 , 3 , 2 , 2 , 1 ,
+                    1 , 3 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 2 ,
+                    1 , 2 , 2 , 2 , 1 , 1 , 2 , 3 , 1 , 2 ]
+}
diff --git a/examples/demos/samegame/content/levels/level3.qml b/examples/demos/samegame/content/levels/level3.qml
new file mode 100644 (file)
index 0000000..6fe723a
--- /dev/null
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    scoreTarget: 3000
+    timeTarget: 60
+    goalText: "4 of 10<br>Clear the board with over 3000 points in under a minute..."
+    startingGrid: [ 3 , 3 , 1 , 1 , 1 , 2 , 2 , 4 , 3 , 3 ,
+                    4 , 3 , 1 , 4 , 2 , 2 , 2 , 4 , 3 , 4 ,
+                    4 , 3 , 3 , 4 , 1 , 1 , 3 , 3 , 4 , 4 ,
+                    3 , 3 , 3 , 3 , 3 , 1 , 3 , 2 , 2 , 4 ,
+                    4 , 4 , 3 , 4 , 3 , 1 , 4 , 4 , 4 , 4 ,
+                    4 , 4 , 3 , 4 , 1 , 1 , 4 , 4 , 3 , 3 ,
+                    4 , 2 , 2 , 2 , 2 , 2 , 4 , 4 , 4 , 1 ,
+                    4 , 4 , 2 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ,
+                    4 , 4 , 2 , 4 , 2 , 2 , 1 , 4 , 4 , 1 ,
+                    4 , 1 , 1 , 4 , 3 , 3 , 4 , 2 , 4 , 1 ,
+                    4 , 1 , 1 , 2 , 3 , 3 , 4 , 2 , 2 , 1 ,
+                    1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 2 , 1 ,
+                    4 , 1 , 1 , 2 , 2 , 3 , 4 , 3 , 4 , 4 ]
+}
diff --git a/examples/demos/samegame/content/levels/level4.qml b/examples/demos/samegame/content/levels/level4.qml
new file mode 100644 (file)
index 0000000..ae45f3e
--- /dev/null
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    goalText: "5 of 10<br><br>Clear the level..."
+    startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+                    1 , 3 , 2 , 1 , 1 , 1 , 1 , 3 , 2 , 3 ,
+                    1 , 2 , 3 , 1 , 3 , 2 , 2 , 1 , 1 , 2 ,
+                    3 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 ,
+                    2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 3 ,
+                    1 , 3 , 3 , 1 , 2 , 1 , 2 , 1 , 3 , 3 ,
+                    1 , 3 , 2 , 2 , 2 , 1 , 1 , 3 , 2 , 3 ,
+                    1 , 1 , 3 , 2 , 3 , 3 , 2 , 1 , 1 , 1 ,
+                    1 , 2 , 2 , 3 , 2 , 2 , 1 , 3 , 1 , 3 ]
+}
diff --git a/examples/demos/samegame/content/levels/level5.qml b/examples/demos/samegame/content/levels/level5.qml
new file mode 100644 (file)
index 0000000..47f6f32
--- /dev/null
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    moveTarget: 4
+    goalText: "6 of 10<br><br>Clear in four or less moves..."
+    startingGrid: [ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+                    4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+                    4 , 2 , 4 , 4 , 4 , 3 , 2 , 3 , 4 , 4 ,
+                    4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+                    4 , 4 , 4 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+                    4 , 2 , 2 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+                    4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+                    4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+                    4 , 3 , 3 , 3 , 4 , 2 , 4 , 4 , 4 , 3 ,
+                    4 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+                    4 , 3 , 4 , 3 , 4 , 2 , 4 , 4 , 4 , 4 ,
+                    4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+                    4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ]
+}
diff --git a/examples/demos/samegame/content/levels/level6.qml b/examples/demos/samegame/content/levels/level6.qml
new file mode 100644 (file)
index 0000000..c0ef893
--- /dev/null
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    moveTarget: 20
+    timeTarget: 40
+    goalText: "7 of 10<br><br>Clear with 20 moves in 40 seconds (or better)."
+    startingGrid: [ 1 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 ,
+                    2 , 1 , 2 , 3 , 3 , 1 , 3 , 1 , 1 , 3 ,
+                    3 , 1 , 1 , 1 , 2 , 2 , 3 , 2 , 3 , 1 ,
+                    1 , 3 , 1 , 1 , 3 , 1 , 1 , 1 , 2 , 3 ,
+                    2 , 1 , 1 , 1 , 3 , 2 , 3 , 3 , 2 , 3 ,
+                    3 , 3 , 3 , 3 , 2 , 2 , 3 , 1 , 3 , 2 ,
+                    2 , 2 , 3 , 2 , 2 , 3 , 2 , 2 , 2 , 2 ,
+                    1 , 2 , 1 , 2 , 1 , 3 , 2 , 3 , 2 , 3 ,
+                    1 , 1 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 2 ,
+                    3 , 3 , 2 , 2 , 2 , 2 , 3 , 1 , 3 , 1 ,
+                    1 , 2 , 3 , 3 , 3 , 1 , 3 , 2 , 1 , 2 ,
+                    1 , 2 , 1 , 1 , 2 , 3 , 1 , 2 , 1 , 3 ,
+                    3 , 1 , 2 , 2 , 1 , 3 , 3 , 1 , 3 , 2 ]
+}
diff --git a/examples/demos/samegame/content/levels/level7.qml b/examples/demos/samegame/content/levels/level7.qml
new file mode 100644 (file)
index 0000000..f725f0c
--- /dev/null
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    goalText: "8 of 10<br><br>Clear the grid."
+    startingGrid: [ 2 , 4 , 3 , 2 , 3 , 2 , 3 , 3 , 4 , 3 ,
+                    2 , 2 , 3 , 3 , 1 , 4 , 3 , 3 , 3 , 2 ,
+                    1 , 4 , 2 , 3 , 4 , 3 , 3 , 1 , 1 , 1 ,
+                    2 , 1 , 2 , 4 , 4 , 2 , 2 , 3 , 2 , 1 ,
+                    3 , 4 , 4 , 1 , 3 , 2 , 4 , 2 , 1 , 1 ,
+                    2 , 2 , 3 , 1 , 2 , 4 , 1 , 2 , 1 , 2 ,
+                    1 , 2 , 3 , 2 , 4 , 4 , 3 , 1 , 1 , 2 ,
+                    4 , 4 , 2 , 1 , 2 , 4 , 2 , 2 , 4 , 3 ,
+                    4 , 2 , 4 , 1 , 3 , 4 , 1 , 4 , 2 , 4 ,
+                    4 , 3 , 4 , 1 , 4 , 3 , 1 , 3 , 1 , 1 ,
+                    3 , 3 , 2 , 3 , 2 , 4 , 1 , 2 , 4 , 4 ,
+                    3 , 4 , 2 , 2 , 4 , 3 , 4 , 1 , 3 , 2 ,
+                    4 , 3 , 3 , 4 , 2 , 4 , 1 , 2 , 3 , 2 ]
+}
diff --git a/examples/demos/samegame/content/levels/level8.qml b/examples/demos/samegame/content/levels/level8.qml
new file mode 100644 (file)
index 0000000..4999d72
--- /dev/null
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    scoreTarget: 1000
+    goalText: "9 of 10<br><br>Score over 1000 points"
+    startingGrid: [ 1 , 4 , 4 , 3 , 2 , 1 , 4 , 2 , 4 , 2 ,
+                    2 , 3 , 4 , 4 , 1 , 1 , 1 , 4 , 4 , 4 ,
+                    1 , 3 , 1 , 2 , 2 , 1 , 2 , 1 , 4 , 2 ,
+                    4 , 3 , 4 , 2 , 1 , 4 , 1 , 2 , 2 , 3 ,
+                    3 , 4 , 2 , 4 , 4 , 3 , 2 , 2 , 2 , 1 ,
+                    4 , 4 , 3 , 2 , 4 , 4 , 2 , 1 , 1 , 1 ,
+                    1 , 2 , 1 , 3 , 4 , 1 , 1 , 3 , 2 , 3 ,
+                    3 , 4 , 2 , 2 , 1 , 3 , 2 , 2 , 4 , 2 ,
+                    2 , 4 , 1 , 2 , 2 , 4 , 3 , 3 , 3 , 1 ,
+                    1 , 2 , 2 , 4 , 1 , 2 , 2 , 3 , 3 , 3 ,
+                    4 , 4 , 1 , 4 , 3 , 1 , 3 , 3 , 3 , 4 ,
+                    1 , 2 , 4 , 1 , 2 , 1 , 1 , 4 , 2 , 1 ,
+                    1 , 2 , 3 , 4 , 2 , 4 , 4 , 2 , 1 , 3 ]
+}
diff --git a/examples/demos/samegame/content/levels/level9.qml b/examples/demos/samegame/content/levels/level9.qml
new file mode 100644 (file)
index 0000000..eed25c4
--- /dev/null
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+    scoreTarget: 2000
+    timeTarget: 60
+    moveTarget: 20
+    mustClear: false
+    goalText: "10 of 10<br><br>Score 2000 in one minute with less than 20 moves!"
+    startingGrid: [ 3 , 2 , 3 , 1 , 3 , 3 , 4 , 1 , 3 , 3 ,
+                    2 , 3 , 2 , 1 , 1 , 2 , 2 , 2 , 4 , 1 ,
+                    2 , 4 , 4 , 4 , 3 , 1 , 4 , 4 , 4 , 1 ,
+                    3 , 1 , 3 , 4 , 4 , 2 , 2 , 2 , 2 , 3 ,
+                    2 , 1 , 4 , 4 , 3 , 3 , 1 , 1 , 3 , 2 ,
+                    3 , 2 , 1 , 4 , 3 , 4 , 1 , 3 , 4 , 2 ,
+                    3 , 3 , 1 , 4 , 4 , 4 , 2 , 1 , 2 , 3 ,
+                    2 , 3 , 4 , 3 , 4 , 1 , 1 , 3 , 2 , 4 ,
+                    4 , 4 , 1 , 2 , 4 , 3 , 2 , 2 , 2 , 4 ,
+                    1 , 4 , 2 , 2 , 1 , 1 , 2 , 1 , 1 , 4 ,
+                    1 , 4 , 3 , 3 , 3 , 1 , 3 , 4 , 4 , 2 ,
+                    3 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 2 , 1 ,
+                    3 , 3 , 4 , 3 , 1 , 1 , 1 , 4 , 4 , 3 ]
+}
diff --git a/examples/demos/samegame/content/pics/background.png b/examples/demos/samegame/content/pics/background.png
deleted file mode 100644 (file)
index 3734a27..0000000
Binary files a/examples/demos/samegame/content/pics/background.png and /dev/null differ
diff --git a/examples/demos/samegame/content/pics/blueStone.png b/examples/demos/samegame/content/pics/blueStone.png
deleted file mode 100644 (file)
index 20e43c7..0000000
Binary files a/examples/demos/samegame/content/pics/blueStone.png and /dev/null differ
diff --git a/examples/demos/samegame/content/pics/greenStone.png b/examples/demos/samegame/content/pics/greenStone.png
deleted file mode 100644 (file)
index b568a19..0000000
Binary files a/examples/demos/samegame/content/pics/greenStone.png and /dev/null differ
diff --git a/examples/demos/samegame/content/pics/redStone.png b/examples/demos/samegame/content/pics/redStone.png
deleted file mode 100644 (file)
index 36b09a2..0000000
Binary files a/examples/demos/samegame/content/pics/redStone.png and /dev/null differ
diff --git a/examples/demos/samegame/content/pics/yellowStone.png b/examples/demos/samegame/content/pics/yellowStone.png
deleted file mode 100644 (file)
index b1ce762..0000000
Binary files a/examples/demos/samegame/content/pics/yellowStone.png and /dev/null differ
index d859bf1..456007c 100755 (executable)
@@ -3,57 +3,67 @@
 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 ** Contact: http://www.qt-project.org/
 **
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
+** This file is part of the examples of the Qt Toolkit.
 **
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
 **
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
 **
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 **
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+
 /* This script file handles the game logic */
 .pragma library
 .import QtQuick.LocalStorage 2.0 as Sql
 
 var maxColumn = 10;
-var maxRow = 15;
+var maxRow = 13;
+var types = 3;
 var maxIndex = maxColumn*maxRow;
 var board = new Array(maxIndex);
-var blockSrc = "BoomBlock.qml";
-var scoresURL = "";
+var blockSrc = "Block.qml";
 var gameDuration;
 var component = Qt.createComponent(blockSrc);
-var highScoreBar = -1;
 var gameCanvas;
-var nameInputDialog = null;
-var dialog = null;
+var betweenTurns = false;
+
+var puzzleLevel = null;
+var puzzlePath = "";
+
+var gameMode = "arcade"; //Set in new game, then tweaks behaviour of other functions
+var gameOver = false;
+
+function changeBlock(src)
+{
+    blockSrc = src;
+    component = Qt.createComponent(blockSrc);
+}
 
 // Index function used instead of a 2D array
 function index(column, row)
@@ -69,35 +79,58 @@ function timeStr(msecs)
     return ret;
 }
 
-function startNewGame(gc)
+function cleanUp()
 {
-    gameCanvas = gc;
+    if (gameCanvas == undefined)
+        return;
     // Delete blocks from previous game
     for (var i = 0; i < maxIndex; i++) {
         if (board[i] != null)
             board[i].destroy();
+        board[i] = null;
     }
+    if (puzzleLevel != null){
+        puzzleLevel.destroy();
+        puzzleLevel = null;
+    }
+    gameCanvas.mode = ""
+}
 
+function startNewGame(gc, mode, map)
+{
+    gameCanvas = gc;
+    if (mode == undefined)
+        gameMode = "arcade";
+    else
+        gameMode = mode;
+    gameOver = false;
+
+    cleanUp();
+
+    gc.gameOver = false;
+    gc.mode = gameMode;
     // Calculate board size
     maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
     maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
     maxIndex = maxRow * maxColumn;
+    if (gameMode == "arcade") //Needs to be after board sizing
+        getHighScore();
 
-    // Close dialogs
-    if(nameInputDialog != null)
-        nameInputDialog.forceClose();
-    if(dialog != null)
-        dialog.forceClose();
 
     // Initialize Board
     board = new Array(maxIndex);
     gameCanvas.score = 0;
-    for (var column = 0; column < maxColumn; column++) {
-        for (var row = 0; row < maxRow; row++) {
-            board[index(column, row)] = null;
-            createBlock(column, row);
-        }
-    }
+    gameCanvas.score2 = 0;
+    gameCanvas.moves = 0;
+    gameCanvas.curTurn = 1;
+    if (gameMode == "puzzle")
+        loadMap(map);
+    else//Note that we load them in reverse order for correct visual stacking
+        for (var column = maxColumn - 1; column >= 0; column--)
+            for (var row = maxRow - 1; row >= 0; row--)
+                createBlock(column, row);
+    if (gameMode == "puzzle")
+        getLevelHistory();//Needs to be after map load
     gameDuration = new Date();
 }
 
@@ -107,10 +140,8 @@ var floodBoard; // Set to 1 if the floodFill reaches off that node
 // NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
 function handleClick(x,y)
 {
-    if(gameCanvas == undefined){
-        console.log("But the game hasn't started yet!");
+    if (betweenTurns || gameOver || gameCanvas == undefined)
         return;
-    }
     var column = Math.floor(x/gameCanvas.blockSize);
     var row = Math.floor(y/gameCanvas.blockSize);
     if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
@@ -121,9 +152,23 @@ function handleClick(x,y)
     floodFill(column,row, -1);
     if (fillFound <= 0)
         return;
-    gameCanvas.score += (fillFound - 1) * (fillFound - 1);
-    shuffleDown();
-    victoryCheck();
+    if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+        gameCanvas.score2 += (fillFound - 1) * (fillFound - 1);
+    else
+        gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+    if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+        shuffleUp();
+    else
+        shuffleDown();
+    gameCanvas.moves += 1;
+    if (gameMode == "endless")
+        refill();
+    else if (gameMode != "multiplayer")
+        victoryCheck();
+    if (gameMode == "multiplayer" && !gc.gameOver){
+        betweenTurns = true;
+        gameCanvas.swapPlayers();//signal, animate and call turnChange() when ready
+    }
 }
 
 function floodFill(column,row,type)
@@ -193,39 +238,108 @@ function shuffleDown()
     }
 }
 
+
+function shuffleUp()
+{
+    // Fall up
+    for (var column = 0; column < maxColumn; column++) {
+        var fallDist = 0;
+        for (var row = 0; row < maxRow; row++) {
+            if (board[index(column,row)] == null) {
+                fallDist += 1;
+            } else {
+                if (fallDist > 0) {
+                    var obj = board[index(column, row)];
+                    obj.y = (row - fallDist) * gameCanvas.blockSize;
+                    board[index(column, row - fallDist)] = obj;
+                    board[index(column, row)] = null;
+                }
+            }
+        }
+    }
+    // Fall to the left (or should it be right, so as to be left for P2?)
+    fallDist = 0;
+    for (column = 0; column < maxColumn; column++) {
+        if (board[index(column, 0)] == null) {
+            fallDist += 1;
+        } else {
+            if (fallDist > 0) {
+                for (row = 0; row < maxRow; row++) {
+                    obj = board[index(column, row)];
+                    if (obj == null)
+                        continue;
+                    obj.x = (column - fallDist) * gameCanvas.blockSize;
+                    board[index(column - fallDist,row)] = obj;
+                    board[index(column, row)] = null;
+                }
+            }
+        }
+    }
+}
+
+function turnChange()//called by ui outside
+{
+    betweenTurns = false;
+    if (gameCanvas.curTurn == 1){
+        shuffleUp();
+        gameCanvas.curTurn = 2;
+        victoryCheck();
+    }else{
+        shuffleDown();
+        gameCanvas.curTurn = 1;
+        victoryCheck();
+    }
+}
+
+function refill()
+{
+    for (var column = 0; column < maxColumn; column++) {
+        for (var row = 0; row < maxRow; row++) {
+            if (board[index(column, row)] == null)
+                createBlock(column, row);
+        }
+    }
+}
+
 function victoryCheck()
 {
     // Awards bonuses for no blocks left
     var deservesBonus = true;
-    for (var column = maxColumn - 1; column >= 0; column--)
-        if (board[index(column, maxRow - 1)] != null)
-            deservesBonus = false;
-    if (deservesBonus)
-        gameCanvas.score += 500;
+    if (board[index(0,maxRow - 1)] != null || board[index(0,0)] != null)
+        deservesBonus = false;
     // Checks for game over
-    if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
-        gameDuration = new Date() - gameDuration;
-        if(nameInputDialog == null){
-            nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml");
-        }
-        if(dialog == null){
-            dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas);
-        }
-        initHighScoreBar();
-        if(gameCanvas.score > highScoreBar){
-            nameInputDialog.show("You won! Your name:                 ");
-            nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
-            if (nameInputDialog.name == "")
-               nameInputDialog.width = nameInputDialog.initialWidth;
-            nameInputDialog.text.opacity = 0; // Just a spacer
-        }else{
-            dialog.show("You won!");
+    if (deservesBonus){
+        if (gameCanvas.curTurn = 1)
+            gameCanvas.score += 1000;
+        else
+            gameCanvas.score2 += 1000;
+    }
+    gameOver = deservesBonus;
+    if (gameCanvas.curTurn == 1){
+        if (!(floodMoveCheck(0, maxRow - 1, -1)))
+            gameOver = true;
+    }else{
+        if (!(floodMoveCheck(0, 0, -1, true)))
+            gameOver = true;
+    }
+    if (gameMode == "puzzle"){
+        puzzleVictoryCheck(deservesBonus);//Takes it from here
+        return;
+    }
+    if (gameOver) {
+        var winnerScore = Math.max(gameCanvas.score, gameCanvas.score2);
+        if (gameMode == "multiplayer"){
+            gameCanvas.score = winnerScore;
+            saveHighScore(gameCanvas.score2);
         }
+        saveHighScore(gameCanvas.score);
+        gameDuration = new Date() - gameDuration;
+        gameCanvas.gameOver = true;
     }
 }
 
 // Only floods up and right, to see if it can find adjacent same-typed blocks
-function floodMoveCheck(column, row, type)
+function floodMoveCheck(column, row, type, goDownInstead)
 {
     if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
         return false;
@@ -234,24 +348,35 @@ function floodMoveCheck(column, row, type)
     var myType = board[index(column, row)].type;
     if (type == myType)
         return true;
-    return floodMoveCheck(column + 1, row, myType) ||
-           floodMoveCheck(column, row - 1, board[index(column, row)].type);
+    if (goDownInstead)
+        return floodMoveCheck(column + 1, row, myType, goDownInstead) ||
+               floodMoveCheck(column, row + 1, myType, goDownInstead);
+    else
+        return floodMoveCheck(column + 1, row, myType) ||
+               floodMoveCheck(column, row - 1, myType);
 }
 
-function createBlock(column,row)
+function createBlock(column,row,type)
 {
     // Note that we don't wait for the component to become ready. This will
     // only work if the block QML is a local file. Otherwise the component will
     // not be ready immediately. There is a statusChanged signal on the
     // component you could use if you want to wait to load remote files.
-    if(component.status == 1){
+    if (component.status == 1){
+        if (type == undefined)
+            type = Math.floor(Math.random() * types);
+        if (type < 0 || type > 4) {
+            console.log("Invalid type requested");//TODO: Is this triggered by custom levels much?
+            return;
+        }
         var dynamicObject = component.createObject(gameCanvas,
-                {"type": Math.floor(Math.random() * 3),
+                {"type": type,
                 "x": column*gameCanvas.blockSize,
+                "y": -1*gameCanvas.blockSize,
                 "width": gameCanvas.blockSize,
                 "height": gameCanvas.blockSize,
                 "particleSystem": gameCanvas.ps});
-        if(dynamicObject == null){
+        if (dynamicObject == null){
             console.log("error creating block");
             console.log(component.errorString());
             return false;
@@ -268,63 +393,188 @@ function createBlock(column,row)
     return true;
 }
 
-function initHighScoreBar()
+function showPuzzleError(str)
+{
+    //TODO: Nice user visible UI?
+    console.log(str);
+}
+
+function loadMap(map)
+{
+    puzzlePath = map;
+    var levelComp = Qt.createComponent(puzzlePath);
+    if (levelComp.status != 1){
+        console.log("Error loading level");
+        showPuzzleError(levelComp.errorString());
+        return;
+    }
+    puzzleLevel = levelComp.createObject();
+    if (puzzleLevel == null || !puzzleLevel.startingGrid instanceof Array) {
+        showPuzzleError("Bugger!");
+        return;
+    }
+    gameCanvas.showPuzzleGoal(puzzleLevel.goalText);
+    //showPuzzleGoal should call finishLoadingMap as the next thing it does, before handling more events
+}
+
+function finishLoadingMap()
+{
+    for (var i in puzzleLevel.startingGrid)
+        if (! (puzzleLevel.startingGrid[i] >= 0 && puzzleLevel.startingGrid[i] <= 9) )
+            puzzleLevel.startingGrid[i] = 0;
+    //TODO: Don't allow loading larger levels, leads to cheating
+    while (puzzleLevel.startingGrid.length > maxIndex) puzzleLevel.startingGrid.shift();
+    while (puzzleLevel.startingGrid.length < maxIndex) puzzleLevel.startingGrid.unshift(0);
+    for (var i in puzzleLevel.startingGrid)
+        if (puzzleLevel.startingGrid[i] > 0)
+            createBlock(i % maxColumn, Math.floor(i / maxColumn), puzzleLevel.startingGrid[i] - 1);
+
+    //### Experimental feature - allow levels to contain arbitrary QML scenes as well!
+    //while (puzzleLevel.children.length)
+    //    puzzleLevel.children[0].parent = gameCanvas;
+    gameDuration = new Date(); //Don't start until we finish loading
+}
+
+function puzzleVictoryCheck(clearedAll)//gameOver has also been set if no more moves
+{
+    var won = true;
+    var soFar = new Date() - gameDuration;
+    if (puzzleLevel.scoreTarget != -1 && gameCanvas.score < puzzleLevel.scoreTarget){
+        won = false;
+    } if (puzzleLevel.scoreTarget != -1 && gameCanvas.score >= puzzleLevel.scoreTarget && !puzzleLevel.mustClear){
+        gameOver = true;
+    } if (puzzleLevel.timeTarget != -1 && soFar/1000.0 > puzzleLevel.timeTarget){
+        gameOver = true;
+    } if (puzzleLevel.moveTarget != -1 && gameCanvas.moves >= puzzleLevel.moveTarget){
+        gameOver = true;
+    } if (puzzleLevel.mustClear && gameOver && !clearedAll) {
+        won = false;
+    }
+
+    if (gameOver) {
+        gameCanvas.gameOver = true;
+        gameCanvas.showPuzzleEnd(won);
+
+        if (won) {
+            // Store progress
+            saveLevelHistory();
+        }
+    }
+}
+
+function getHighScore()
 {
     var db = Sql.openDatabaseSync(
-        "SameGameScores",
-        "1.0",
-        "Local SameGame High Scores",
+        "SameGame",
+        "2.0",
+        "SameGame Local Data",
         100
     );
     db.transaction(
         function(tx) {
-            tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+            tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
             // Only show results for the current grid size
             var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
-                + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
-            if(rs.rows.length < 10)
-                highScoreBar = 0;
-            else 
-                highScoreBar = rs.rows.item(rs.rows.length - 1).score;
+                + maxColumn + "x" + maxRow + '" AND game = "' + gameMode + '" ORDER BY score desc');
+            if (rs.rows.length > 0)
+                gameCanvas.highScore = rs.rows.item(0).score;
+            else
+                gameCanvas.highScore = 0;
         }
     );
 }
 
-function saveHighScore(name)
+function saveHighScore(score)
 {
-    if (scoresURL != "")
-        sendHighScore(name);
     // Offline storage
     var db = Sql.openDatabaseSync(
-        "SameGameScores",
-        "1.0",
-        "Local SameGame High Scores",
+        "SameGame",
+        "2.0",
+        "SameGame Local Data",
         100
     );
     var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
     var data = [
-        name,
-        gameCanvas.score,
+        gameMode,
+        score,
         maxColumn + "x" + maxRow,
         Math.floor(gameDuration / 1000)
     ];
+    if (score >= gameCanvas.highScore)//Update UI field
+        gameCanvas.highScore = score;
+
     db.transaction(
         function(tx) {
-            tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+            tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
             tx.executeSql(dataStr, data);
+        }
+    );
+}
 
-            // Only show results for the current grid size
-            var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
-                + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
-            var r = "\nHIGH SCORES for this grid size\n\n"
-            for (var i = 0; i < rs.rows.length; i++) {
-                r += (i+1) + ". " + rs.rows.item(i).name + ' got '
-                    + rs.rows.item(i).score + ' points in '
-                    + rs.rows.item(i).time + ' seconds.\n';
+function getLevelHistory()
+{
+    var db = Sql.openDatabaseSync(
+        "SameGame",
+        "2.0",
+        "SameGame Local Data",
+        100
+    );
+    db.transaction(
+        function(tx) {
+            tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+            var rs = tx.executeSql('SELECT * FROM Puzzle WHERE level = "' + puzzlePath + '" ORDER BY score desc');
+            if (rs.rows.length > 0) {
+                gameCanvas.puzzleWon = true;
+                gameCanvas.highScore = rs.rows.item(0).score;
+            } else {
+                gameCanvas.puzzleWon = false;
+                gameCanvas.highScore = 0;
             }
-            if(rs.rows.length == 10)
-                highScoreBar = rs.rows.item(9).score;
-            dialog.show(r);
         }
     );
 }
+
+function saveLevelHistory()
+{
+    var db = Sql.openDatabaseSync(
+        "SameGame",
+        "2.0",
+        "SameGame Local Data",
+        100
+    );
+    var dataStr = "INSERT INTO Puzzle VALUES(?, ?, ?, ?)";
+    var data = [
+        puzzlePath,
+        gameCanvas.score,
+        gameCanvas.moves,
+        Math.floor(gameDuration / 1000)
+    ];
+    gameCanvas.puzzleWon = true;
+
+    db.transaction(
+        function(tx) {
+            tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+            tx.executeSql(dataStr, data);
+        }
+    );
+}
+
+function nuke() //For "Debug mode"
+{
+    for (var row = 1; row <= 5; row++) {
+        for (var col = 0; col < 5; col++) {
+            if (board[index(col, maxRow - row)] != null) {
+                board[index(col, maxRow - row)].dying = true;
+                board[index(col, maxRow - row)] = null;
+            }
+        }
+    }
+    if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+        shuffleUp();
+    else
+        shuffleDown();
+    if (gameMode == "endless")
+        refill();
+    else
+        victoryCheck();
+}
index 4a0f88a..1456f3e 100644 (file)
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
-
-#include <QGuiApplication>
-#include <QStringList>
-#include <QQuickView>
-#include <QQmlEngine>
-
-void usage()
-{
-    printf("Pass -desktop to use the Desktop UI. Default is the mobile UI.");
-    exit(0);
-}
-
-int main(int argc, char* argv[])
-{
-    QGuiApplication app(argc,argv);
-    QQuickView view;
-    QUrl launchFile = QUrl::fromLocalFile(QLatin1String("samegame-mobile.qml"));
-    if (app.arguments().contains(QLatin1String("-help")))
-        usage();
-    if (app.arguments().contains(QLatin1String("-desktop")))
-        launchFile =  QUrl::fromLocalFile(QLatin1String("samegame-desktop.qml"));
-    view.setSource(launchFile);
-    view.show();
-    return app.exec();
-}
-
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(samegame)
index 96a8c34..e9b9f4b 100644 (file)
@@ -4,6 +4,6 @@ QT += qml quick
 SOURCES += main.cpp
 
 target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/samegame
-qml.files = samegame-desktop.qml samegame-mobile.qml content
+qml.files = samegame.qml content
 qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/samegame
 INSTALLS += target qml
diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame.qml
new file mode 100644 (file)
index 0000000..24c15c1
--- /dev/null
@@ -0,0 +1,398 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/samegame.js" as Logic
+import "content"
+
+Rectangle {
+    id: root
+    width: 320; height: 480
+    property int acc: 0
+    property int menuDelay: 500
+
+    function loadPuzzle() {
+        if (gameCanvas.mode != "")
+            Logic.cleanUp();
+        Logic.startNewGame(gameCanvas,"puzzle","levels/level"+acc+".qml")
+    }
+    function nextPuzzle() {
+        acc = (acc + 1) % 10;
+        loadPuzzle();
+    }
+    Timer {
+        id: gameOverTimer
+        interval: 1500
+        running : gameCanvas.gameOver && gameCanvas.mode == "puzzle" //mode will be reset by cleanUp();
+        repeat  : false
+        onTriggered: {
+            Logic.cleanUp();
+            nextPuzzle();
+        }
+    }
+
+    Image {
+        source: "content/gfx/background.png"
+        anchors.fill: parent
+    }
+
+    GameArea {
+        id: gameCanvas
+        z: 1
+        width: parent.width
+
+        y: 20
+        height: parent.height - 64
+        backgroundVisible: root.state == "in-game"
+        onModeChanged: if (gameCanvas.mode != "puzzle") puzzleWon = false; //UI has stricter constraints on this variable than the game does
+        Age {
+            groups: ["redspots", "greenspots", "bluespots", "yellowspots"]
+            enabled: root.state == ""
+            system: gameCanvas.ps
+        }
+
+        onPuzzleLost: acc--;//So that nextPuzzle() reloads the current one
+
+    }
+
+    Item {
+        id: menu
+        z: 2
+        width: parent.width;
+        anchors.top: parent.top
+        anchors.bottom: bottomBar.top
+
+        LogoAnimation {
+            x: 64
+            y: 20
+            particleSystem: gameCanvas.ps
+            running: root.state == ""
+        }
+        Row {
+            x: 112
+            y: 20
+            Image { source: "content/gfx/logo-a.png" }
+            Image { source: "content/gfx/logo-m.png" }
+            Image { source: "content/gfx/logo-e.png" }
+        }
+
+        Column {
+            y: 100 + 40
+            spacing: 0
+
+            Button {
+                height: 64
+                width: root.width
+                rotatedButton: true
+                imgSrc: "content/gfx/but-game-1.png"
+                onClicked: {
+                    if (root.state == "in-game")
+                        return //Prevent double clicking
+                    root.state = "in-game"
+                    gameCanvas.blockFile = "Block.qml"
+                    gameCanvas.background = "gfx/background.png"
+                    arcadeTimer.start();
+                }
+                //Emitted particles don't fade out, because ImageParticle is on the GameArea
+                system: gameCanvas.ps
+                group: "green"
+                Timer {
+                    id: arcadeTimer
+                    interval: menuDelay
+                    running : false
+                    repeat  : false
+                    onTriggered: Logic.startNewGame(gameCanvas)
+                }
+            }
+
+            Button {
+                height: 64
+                width: root.width
+                rotatedButton: true
+                imgSrc: "content/gfx/but-game-2.png"
+                onClicked: {
+                    if (root.state == "in-game")
+                        return
+                    root.state = "in-game"
+                    gameCanvas.blockFile = "Block.qml"
+                    gameCanvas.background = "gfx/background.png"
+                    twopTimer.start();
+                }
+                system: gameCanvas.ps
+                group: "green"
+                Timer {
+                    id: twopTimer
+                    interval: menuDelay
+                    running : false
+                    repeat  : false
+                    onTriggered: Logic.startNewGame(gameCanvas, "multiplayer")
+                }
+            }
+
+            Button {
+                height: 64
+                width: root.width
+                rotatedButton: true
+                imgSrc: "content/gfx/but-game-3.png"
+                onClicked: {
+                    if (root.state == "in-game")
+                        return
+                    root.state = "in-game"
+                    gameCanvas.blockFile = "SimpleBlock.qml"
+                    gameCanvas.background = "gfx/background.png"
+                    endlessTimer.start();
+                }
+                system: gameCanvas.ps
+                group: "blue"
+                Timer {
+                    id: endlessTimer
+                    interval: menuDelay
+                    running : false
+                    repeat  : false
+                    onTriggered: Logic.startNewGame(gameCanvas, "endless")
+                }
+            }
+
+            Button {
+                height: 64
+                width: root.width
+                rotatedButton: true
+                imgSrc: "content/gfx/but-game-4.png"
+                group: "yellow"
+                onClicked: {
+                    if (root.state == "in-game")
+                        return
+                    root.state = "in-game"
+                    gameCanvas.blockFile = "PuzzleBlock.qml"
+                    gameCanvas.background = "gfx/background.png"
+                    puzzleTimer.start();
+                }
+                Timer {
+                    id: puzzleTimer
+                    interval: menuDelay
+                    running : false
+                    repeat  : false
+                    onTriggered: loadPuzzle();
+                }
+                system: gameCanvas.ps
+            }
+        }
+    }
+
+    Image {
+        id: scoreBar
+        source: "content/gfx/bar.png"
+        width: parent.width
+        z: 6
+        y: -24
+        height: 24
+        Behavior on opacity { NumberAnimation {} }
+        Text {
+            id: arcadeScore
+            anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+            font.pixelSize: 14
+            textFormat: Text.StyledText
+            color: "white"
+            opacity: gameCanvas.mode == "arcade" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+        }
+        Text {
+            id: arcadeHighScore
+            anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">Highscore:</font> ' + gameCanvas.highScore
+            font.pixelSize: 14
+            color: "white"
+            textFormat: Text.StyledText
+            opacity: gameCanvas.mode == "arcade" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+        }
+        Text {
+            id: p1Score
+            anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+            textFormat: Text.StyledText
+            font.pixelSize: 14
+            color: "white"
+            opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+        }
+        Text {
+            id: p2Score
+            anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">P2:</font> ' + gameCanvas.score2
+            textFormat: Text.StyledText
+            font.pixelSize: 14
+            color: "white"
+            opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+            rotation: 180
+        }
+        Text {
+            id: puzzleMoves
+            anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">Moves:</font> ' + gameCanvas.moves
+            textFormat: Text.StyledText
+            font.pixelSize: 14
+            color: "white"
+            opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+        }
+        Text {
+            Image {
+                source: "content/gfx/icon-time.png"
+                x: -20
+            }
+            id: puzzleTime
+            anchors { topMargin: 3; top: parent.top; horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 20}
+            text: "00:00"
+            font.pixelSize: 14
+            color: "white"
+            opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+            Timer {
+                interval: 1000
+                repeat: true
+                running: gameCanvas.mode == "puzzle" && !gameCanvas.gameOver
+                onTriggered: {
+                    var elapsed = Math.floor((new Date() - Logic.gameDuration)/ 1000.0);
+                    var mins = Math.floor(elapsed/60.0);
+                    var secs = (elapsed % 60);
+                    puzzleTime.text =  (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
+                }
+            }
+        }
+        Text {
+            id: puzzleScore
+            anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+            text: '<font color="#f7d303">Score:</font> ' + gameCanvas.score
+            textFormat: Text.StyledText
+            font.pixelSize: 14
+            color: "white"
+            opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+            Behavior on opacity { NumberAnimation {} }
+        }
+    }
+
+    Image {
+        id: bottomBar
+        width: parent.width
+        height: 44
+        source: "content/gfx/bar.png"
+        y: parent.height - 44
+        z: 2
+        function selectButtons() {
+            menuButton.visible = (root.state == "in-game");
+            nextButton.visible = (root.state == "in-game");
+            againButton.visible = (root.state == "in-game");
+        }
+        Button {
+            id: quitButton
+            imgSrc: "content/gfx/but-quit.png"
+            onClicked: {Qt.quit(); }
+            anchors { left: parent.left; verticalCenter: parent.verticalCenter; leftMargin: 11 }
+        }
+        Button {
+            id: menuButton
+            imgSrc: "content/gfx/but-menu.png"
+            visible: false
+            onClicked: {root.state = ""; Logic.cleanUp(); gameCanvas.mode = ""}
+            anchors { left: quitButton.right; verticalCenter: parent.verticalCenter; leftMargin: 0 }
+        }
+        Button {
+            id: againButton
+            imgSrc: "content/gfx/but-game-new.png"
+            visible: false
+            opacity: gameCanvas.gameOver && (gameCanvas.mode == "arcade" || gameCanvas.mode == "multiplayer") ? 1 : 0
+            Behavior on opacity{ NumberAnimation {} }
+            onClicked: {if (gameCanvas.gameOver) Logic.startNewGame(gameCanvas, gameCanvas.mode);}
+            anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+        }
+        Button {
+            id: nextButton
+            imgSrc: "content/gfx/but-puzzle-next.png"
+            visible: false
+            opacity: gameCanvas.puzzleWon ? 1 : 0
+            Behavior on opacity{ NumberAnimation {} }
+            onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();}
+            anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+        }
+    }
+
+    Connections {
+        target: root
+        onStateChanged: stateChangeAnim.running = true
+    }
+    SequentialAnimation {
+        id: stateChangeAnim
+        ParallelAnimation {
+            NumberAnimation { target: bottomBar; property: "y"; to: root.height; duration: menuDelay/2; easing.type: Easing.OutQuad }
+            NumberAnimation { target: scoreBar; property: "y"; to: -24; duration: menuDelay/2; easing.type: Easing.OutQuad }
+        }
+        ScriptAction { script: bottomBar.selectButtons(); }
+        ParallelAnimation {
+            NumberAnimation { target: bottomBar; property: "y"; to: root.height - 44; duration: menuDelay/2; easing.type: Easing.OutBounce}
+            NumberAnimation { target: scoreBar; property: "y"; to: root.state == "" ? -24 : 0; duration: menuDelay/2; easing.type: Easing.OutBounce}
+        }
+    }
+
+    states: [
+        State {
+            name: "in-game"
+            PropertyChanges {
+                target: menu
+                opacity: 0
+                visible: false
+            }
+        }
+    ]
+
+    transitions: [
+        Transition {
+            NumberAnimation {properties: "x,y,opacity"}
+        }
+    ]
+
+    //"Debug mode"
+    focus: true
+    Keys.onAsteriskPressed: Logic.nuke();
+    Keys.onSpacePressed: gameCanvas.puzzleWon = true;
+}
index e0f1074..42ffacf 100644 (file)
@@ -1,7 +1,7 @@
 import QmlProject 1.1
 
 Project {
-    mainFile: "samegame-desktop.qml"
+    mainFile: "samegame.qml"
 
     /* Include .qml, .js, and image files from current directory and subdirectories */
     QmlFiles {