From 942b5fa9cc3924d5f022091c015ab0717bc79512 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 5 Jul 2012 11:45:28 +1000 Subject: Add new samegame and calculator demos Change-Id: I06ac38a1d0f844eba367fc5e163151d1f70a0012 Reviewed-by: Alan Alpert --- examples/demos/calculator/calculator-desktop.qml | 135 ------ examples/demos/calculator/calculator-mobile.qml | 163 ------- examples/demos/calculator/calculator.pro | 9 - examples/demos/calculator/calculator.qdoc | 37 -- examples/demos/calculator/content/Button.qml | 83 ---- examples/demos/calculator/content/Display.qml | 67 --- examples/demos/calculator/content/calculator.js | 134 ------ .../demos/calculator/content/images/button-.png | Bin 1288 -> 0 bytes .../calculator/content/images/button-blue.png | Bin 1565 -> 0 bytes .../calculator/content/images/button-green.png | Bin 1543 -> 0 bytes .../calculator/content/images/button-purple.png | Bin 1566 -> 0 bytes .../demos/calculator/content/images/button-red.png | Bin 1586 -> 0 bytes .../demos/calculator/content/images/display.png | Bin 998 -> 0 bytes examples/demos/calculator/content/qmldir | 2 - examples/demos/calculator/main.cpp | 66 --- examples/demos/calqlatr/calqlatr.pro | 9 + examples/demos/calqlatr/calqlatr.qdoc | 38 ++ examples/demos/calqlatr/calqlatr.qml | 110 +++++ examples/demos/calqlatr/calqlatr.qmlproject | 16 + examples/demos/calqlatr/content/Button.qml | 80 ++++ examples/demos/calqlatr/content/Display.qml | 124 ++++++ examples/demos/calqlatr/content/NumberPad.qml | 69 +++ examples/demos/calqlatr/content/StyleLabel.qml | 50 +++ examples/demos/calqlatr/content/audio/touch.wav | Bin 0 -> 950 bytes examples/demos/calqlatr/content/calculator.js | 143 +++++++ .../demos/calqlatr/content/images/icon-back.png | Bin 0 -> 328 bytes .../demos/calqlatr/content/images/icon-close.png | Bin 0 -> 488 bytes .../calqlatr/content/images/icon-settings.png | Bin 0 -> 503 bytes examples/demos/calqlatr/content/images/logo.png | Bin 0 -> 5950 bytes .../calqlatr/content/images/paper-edge-left.png | Bin 0 -> 12401 bytes .../calqlatr/content/images/paper-edge-right.png | Bin 0 -> 12967 bytes .../demos/calqlatr/content/images/paper-grip.png | Bin 0 -> 298 bytes .../content/images/settings-selected-a.png | Bin 0 -> 2326 bytes .../content/images/settings-selected-b.png | Bin 0 -> 2334 bytes .../demos/calqlatr/content/images/touch-green.png | Bin 0 -> 4808 bytes .../demos/calqlatr/content/images/touch-white.png | Bin 0 -> 4601 bytes examples/demos/calqlatr/main.cpp | 41 ++ examples/demos/demos.pro | 2 +- examples/demos/samegame/content/Block.qml | 114 +++++ examples/demos/samegame/content/BlockEmitter.qml | 55 +++ examples/demos/samegame/content/BoomBlock.qml | 111 ----- examples/demos/samegame/content/Button.qml | 48 +-- examples/demos/samegame/content/Dialog.qml | 80 ---- examples/demos/samegame/content/GameArea.qml | 193 +++++++-- examples/demos/samegame/content/LogoAnimation.qml | 102 +++++ examples/demos/samegame/content/MenuEmitter.qml | 53 +++ .../demos/samegame/content/NameInputDialog.qml | 92 ---- examples/demos/samegame/content/PaintEmitter.qml | 97 +++++ examples/demos/samegame/content/PrimaryPack.qml | 122 ++++++ examples/demos/samegame/content/PuzzleBlock.qml | 111 +++++ examples/demos/samegame/content/SimpleBlock.qml | 108 +++++ examples/demos/samegame/content/SmokeText.qml | 83 ++++ .../samegame/content/gfx/background-puzzle.png | Bin 0 -> 86666 bytes examples/demos/samegame/content/gfx/background.png | Bin 0 -> 101018 bytes examples/demos/samegame/content/gfx/bar.png | Bin 0 -> 10970 bytes .../demos/samegame/content/gfx/blue-puzzle.png | Bin 0 -> 2219 bytes examples/demos/samegame/content/gfx/blue.png | Bin 0 -> 1018 bytes .../samegame/content/gfx/bubble-highscore.png | Bin 0 -> 2276 bytes .../demos/samegame/content/gfx/bubble-puzzle.png | Bin 0 -> 2811 bytes examples/demos/samegame/content/gfx/but-game-1.png | Bin 0 -> 2728 bytes examples/demos/samegame/content/gfx/but-game-2.png | Bin 0 -> 3378 bytes examples/demos/samegame/content/gfx/but-game-3.png | Bin 0 -> 1423 bytes examples/demos/samegame/content/gfx/but-game-4.png | Bin 0 -> 2096 bytes .../demos/samegame/content/gfx/but-game-new.png | Bin 0 -> 3662 bytes examples/demos/samegame/content/gfx/but-menu.png | Bin 0 -> 2391 bytes .../demos/samegame/content/gfx/but-puzzle-next.png | Bin 0 -> 3658 bytes examples/demos/samegame/content/gfx/but-quit.png | Bin 0 -> 2100 bytes .../demos/samegame/content/gfx/green-puzzle.png | Bin 0 -> 2271 bytes examples/demos/samegame/content/gfx/green.png | Bin 0 -> 1024 bytes examples/demos/samegame/content/gfx/icon-fail.png | Bin 0 -> 6549 bytes examples/demos/samegame/content/gfx/icon-ok.png | Bin 0 -> 7190 bytes examples/demos/samegame/content/gfx/icon-time.png | Bin 0 -> 1159 bytes examples/demos/samegame/content/gfx/logo-a.png | Bin 0 -> 1814 bytes examples/demos/samegame/content/gfx/logo-e.png | Bin 0 -> 1725 bytes examples/demos/samegame/content/gfx/logo-g.png | Bin 0 -> 1765 bytes examples/demos/samegame/content/gfx/logo-m.png | Bin 0 -> 1743 bytes examples/demos/samegame/content/gfx/logo-s.png | Bin 0 -> 1791 bytes examples/demos/samegame/content/gfx/logo.png | Bin 0 -> 3608 bytes .../demos/samegame/content/gfx/particle-brick.png | Bin 0 -> 861 bytes .../demos/samegame/content/gfx/particle-paint.png | Bin 0 -> 714 bytes .../demos/samegame/content/gfx/particle-smoke.png | Bin 0 -> 5409 bytes examples/demos/samegame/content/gfx/red-puzzle.png | Bin 0 -> 2218 bytes examples/demos/samegame/content/gfx/red.png | Bin 0 -> 1018 bytes .../samegame/content/gfx/text-highscore-new.png | Bin 0 -> 6767 bytes .../demos/samegame/content/gfx/text-highscore.png | Bin 0 -> 3179 bytes .../demos/samegame/content/gfx/text-no-winner.png | Bin 0 -> 6321 bytes examples/demos/samegame/content/gfx/text-p1-go.png | Bin 0 -> 5395 bytes .../demos/samegame/content/gfx/text-p1-won.png | Bin 0 -> 5618 bytes examples/demos/samegame/content/gfx/text-p1.png | Bin 0 -> 1751 bytes examples/demos/samegame/content/gfx/text-p2-go.png | Bin 0 -> 5874 bytes .../demos/samegame/content/gfx/text-p2-won.png | Bin 0 -> 6177 bytes examples/demos/samegame/content/gfx/text-p2.png | Bin 0 -> 2381 bytes .../demos/samegame/content/gfx/yellow-puzzle.png | Bin 0 -> 2239 bytes examples/demos/samegame/content/gfx/yellow.png | Bin 0 -> 1008 bytes .../demos/samegame/content/levels/TemplateBase.qml | 70 +++ examples/demos/samegame/content/levels/level0.qml | 59 +++ examples/demos/samegame/content/levels/level1.qml | 59 +++ examples/demos/samegame/content/levels/level2.qml | 61 +++ examples/demos/samegame/content/levels/level3.qml | 60 +++ examples/demos/samegame/content/levels/level4.qml | 58 +++ examples/demos/samegame/content/levels/level5.qml | 59 +++ examples/demos/samegame/content/levels/level6.qml | 60 +++ examples/demos/samegame/content/levels/level7.qml | 58 +++ examples/demos/samegame/content/levels/level8.qml | 59 +++ examples/demos/samegame/content/levels/level9.qml | 62 +++ .../demos/samegame/content/pics/background.png | Bin 313930 -> 0 bytes examples/demos/samegame/content/pics/blueStone.png | Bin 3054 -> 0 bytes .../demos/samegame/content/pics/greenStone.png | Bin 2932 -> 0 bytes examples/demos/samegame/content/pics/particle.png | Bin 861 -> 0 bytes examples/demos/samegame/content/pics/redStone.png | Bin 2902 -> 0 bytes .../demos/samegame/content/pics/yellowStone.png | Bin 3056 -> 0 bytes examples/demos/samegame/content/samegame.js | 474 ++++++++++++++++----- examples/demos/samegame/main.cpp | 28 +- examples/demos/samegame/samegame-desktop.qml | 86 ---- examples/demos/samegame/samegame-mobile.qml | 82 ---- examples/demos/samegame/samegame.pro | 2 +- examples/demos/samegame/samegame.qml | 398 +++++++++++++++++ examples/demos/samegame/samegame.qmlproject | 2 +- 118 files changed, 3140 insertions(+), 1344 deletions(-) delete mode 100644 examples/demos/calculator/calculator-desktop.qml delete mode 100644 examples/demos/calculator/calculator-mobile.qml delete mode 100644 examples/demos/calculator/calculator.pro delete mode 100644 examples/demos/calculator/calculator.qdoc delete mode 100644 examples/demos/calculator/content/Button.qml delete mode 100644 examples/demos/calculator/content/Display.qml delete mode 100644 examples/demos/calculator/content/calculator.js delete mode 100644 examples/demos/calculator/content/images/button-.png delete mode 100644 examples/demos/calculator/content/images/button-blue.png delete mode 100644 examples/demos/calculator/content/images/button-green.png delete mode 100644 examples/demos/calculator/content/images/button-purple.png delete mode 100644 examples/demos/calculator/content/images/button-red.png delete mode 100644 examples/demos/calculator/content/images/display.png delete mode 100644 examples/demos/calculator/content/qmldir delete mode 100644 examples/demos/calculator/main.cpp create mode 100644 examples/demos/calqlatr/calqlatr.pro create mode 100644 examples/demos/calqlatr/calqlatr.qdoc create mode 100644 examples/demos/calqlatr/calqlatr.qml create mode 100644 examples/demos/calqlatr/calqlatr.qmlproject create mode 100644 examples/demos/calqlatr/content/Button.qml create mode 100644 examples/demos/calqlatr/content/Display.qml create mode 100644 examples/demos/calqlatr/content/NumberPad.qml create mode 100644 examples/demos/calqlatr/content/StyleLabel.qml create mode 100644 examples/demos/calqlatr/content/audio/touch.wav create mode 100644 examples/demos/calqlatr/content/calculator.js create mode 100644 examples/demos/calqlatr/content/images/icon-back.png create mode 100644 examples/demos/calqlatr/content/images/icon-close.png create mode 100644 examples/demos/calqlatr/content/images/icon-settings.png create mode 100644 examples/demos/calqlatr/content/images/logo.png create mode 100644 examples/demos/calqlatr/content/images/paper-edge-left.png create mode 100644 examples/demos/calqlatr/content/images/paper-edge-right.png create mode 100644 examples/demos/calqlatr/content/images/paper-grip.png create mode 100644 examples/demos/calqlatr/content/images/settings-selected-a.png create mode 100644 examples/demos/calqlatr/content/images/settings-selected-b.png create mode 100644 examples/demos/calqlatr/content/images/touch-green.png create mode 100644 examples/demos/calqlatr/content/images/touch-white.png create mode 100644 examples/demos/calqlatr/main.cpp create mode 100644 examples/demos/samegame/content/Block.qml create mode 100644 examples/demos/samegame/content/BlockEmitter.qml delete mode 100644 examples/demos/samegame/content/BoomBlock.qml delete mode 100644 examples/demos/samegame/content/Dialog.qml create mode 100644 examples/demos/samegame/content/LogoAnimation.qml create mode 100644 examples/demos/samegame/content/MenuEmitter.qml delete mode 100644 examples/demos/samegame/content/NameInputDialog.qml create mode 100644 examples/demos/samegame/content/PaintEmitter.qml create mode 100644 examples/demos/samegame/content/PrimaryPack.qml create mode 100644 examples/demos/samegame/content/PuzzleBlock.qml create mode 100644 examples/demos/samegame/content/SimpleBlock.qml create mode 100644 examples/demos/samegame/content/SmokeText.qml create mode 100644 examples/demos/samegame/content/gfx/background-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/background.png create mode 100644 examples/demos/samegame/content/gfx/bar.png create mode 100644 examples/demos/samegame/content/gfx/blue-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/blue.png create mode 100644 examples/demos/samegame/content/gfx/bubble-highscore.png create mode 100644 examples/demos/samegame/content/gfx/bubble-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/but-game-1.png create mode 100644 examples/demos/samegame/content/gfx/but-game-2.png create mode 100644 examples/demos/samegame/content/gfx/but-game-3.png create mode 100644 examples/demos/samegame/content/gfx/but-game-4.png create mode 100644 examples/demos/samegame/content/gfx/but-game-new.png create mode 100644 examples/demos/samegame/content/gfx/but-menu.png create mode 100644 examples/demos/samegame/content/gfx/but-puzzle-next.png create mode 100644 examples/demos/samegame/content/gfx/but-quit.png create mode 100644 examples/demos/samegame/content/gfx/green-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/green.png create mode 100644 examples/demos/samegame/content/gfx/icon-fail.png create mode 100644 examples/demos/samegame/content/gfx/icon-ok.png create mode 100644 examples/demos/samegame/content/gfx/icon-time.png create mode 100644 examples/demos/samegame/content/gfx/logo-a.png create mode 100644 examples/demos/samegame/content/gfx/logo-e.png create mode 100644 examples/demos/samegame/content/gfx/logo-g.png create mode 100644 examples/demos/samegame/content/gfx/logo-m.png create mode 100644 examples/demos/samegame/content/gfx/logo-s.png create mode 100644 examples/demos/samegame/content/gfx/logo.png create mode 100644 examples/demos/samegame/content/gfx/particle-brick.png create mode 100644 examples/demos/samegame/content/gfx/particle-paint.png create mode 100644 examples/demos/samegame/content/gfx/particle-smoke.png create mode 100644 examples/demos/samegame/content/gfx/red-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/red.png create mode 100644 examples/demos/samegame/content/gfx/text-highscore-new.png create mode 100644 examples/demos/samegame/content/gfx/text-highscore.png create mode 100644 examples/demos/samegame/content/gfx/text-no-winner.png create mode 100644 examples/demos/samegame/content/gfx/text-p1-go.png create mode 100644 examples/demos/samegame/content/gfx/text-p1-won.png create mode 100644 examples/demos/samegame/content/gfx/text-p1.png create mode 100644 examples/demos/samegame/content/gfx/text-p2-go.png create mode 100644 examples/demos/samegame/content/gfx/text-p2-won.png create mode 100644 examples/demos/samegame/content/gfx/text-p2.png create mode 100644 examples/demos/samegame/content/gfx/yellow-puzzle.png create mode 100644 examples/demos/samegame/content/gfx/yellow.png create mode 100644 examples/demos/samegame/content/levels/TemplateBase.qml create mode 100644 examples/demos/samegame/content/levels/level0.qml create mode 100644 examples/demos/samegame/content/levels/level1.qml create mode 100644 examples/demos/samegame/content/levels/level2.qml create mode 100644 examples/demos/samegame/content/levels/level3.qml create mode 100644 examples/demos/samegame/content/levels/level4.qml create mode 100644 examples/demos/samegame/content/levels/level5.qml create mode 100644 examples/demos/samegame/content/levels/level6.qml create mode 100644 examples/demos/samegame/content/levels/level7.qml create mode 100644 examples/demos/samegame/content/levels/level8.qml create mode 100644 examples/demos/samegame/content/levels/level9.qml delete mode 100644 examples/demos/samegame/content/pics/background.png delete mode 100644 examples/demos/samegame/content/pics/blueStone.png delete mode 100644 examples/demos/samegame/content/pics/greenStone.png delete mode 100644 examples/demos/samegame/content/pics/particle.png delete mode 100644 examples/demos/samegame/content/pics/redStone.png delete mode 100644 examples/demos/samegame/content/pics/yellowStone.png delete mode 100644 examples/demos/samegame/samegame-desktop.qml delete mode 100644 examples/demos/samegame/samegame-mobile.qml create mode 100644 examples/demos/samegame/samegame.qml (limited to 'examples') diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml deleted file mode 100644 index 87181181eb..0000000000 --- a/examples/demos/calculator/calculator-desktop.qml +++ /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 index 18e8b8aabc..0000000000 --- a/examples/demos/calculator/calculator-mobile.qml +++ /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 index cf63f7ba6c..0000000000 --- a/examples/demos/calculator/calculator.pro +++ /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/calculator.qdoc b/examples/demos/calculator/calculator.qdoc deleted file mode 100644 index 793948703e..0000000000 --- a/examples/demos/calculator/calculator.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \title QML Demo - Calculator - \example demos/calculator - \brief This is an example calculator application written in QML. - \image qml-calculator-example-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. -*/ - diff --git a/examples/demos/calculator/content/Button.qml b/examples/demos/calculator/content/Button.qml deleted file mode 100644 index 48deeb89b7..0000000000 --- a/examples/demos/calculator/content/Button.qml +++ /dev/null @@ -1,83 +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 - -BorderImage { - id: button - - 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 - } - - 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 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - window.doOp(operation) - button.clicked() - } - } - - states: State { - name: "pressed"; when: mouseArea.pressed == true - PropertyChanges { target: shade; opacity: .4 } - } -} diff --git a/examples/demos/calculator/content/Display.qml b/examples/demos/calculator/content/Display.qml deleted file mode 100644 index baa68bfd4c..0000000000 --- a/examples/demos/calculator/content/Display.qml +++ /dev/null @@ -1,67 +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 - -BorderImage { - id: image - - property alias text : displayText.text - property alias currentOperation : operationText - - 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 } - } -} diff --git a/examples/demos/calculator/content/calculator.js b/examples/demos/calculator/content/calculator.js deleted file mode 100644 index 121d670fb2..0000000000 --- a/examples/demos/calculator/content/calculator.js +++ /dev/null @@ -1,134 +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$ -** -****************************************************************************/ - -var curVal = 0 -var memory = 0 -var lastOp = "" -var timer = 0 - -function disabled(op) { - if (op == "." && display.text.toString().search(/\./) != -1) { - return true - } else if (op == window.squareRoot && display.text.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)) { - return - } - - 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 - 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 (op == "+" || op == "-" || op == window.multiplication || op == window.division) { - display.currentOperation.text = op - curVal = display.text.valueOf() - return - } - - curVal = 0 - display.currentOperation.text = "" - - if (op == "1/x") { - display.text = (1 / display.text.valueOf()).toString() - } else if (op == "x^2") { - display.text = (display.text.valueOf() * display.text.valueOf()).toString() - } else if (op == "Abs") { - display.text = (Math.abs(display.text.valueOf())).toString() - } else if (op == "Int") { - display.text = (Math.floor(display.text.valueOf())).toString() - } else if (op == window.plusminus) { - display.text = (display.text.valueOf() * -1).toString() - } else if (op == window.squareRoot) { - display.text = (Math.sqrt(display.text.valueOf())).toString() - } else if (op == "mc") { - memory = 0; - } else if (op == "m+") { - memory += display.text.valueOf() - } else if (op == "mr") { - display.text = memory.toString() - } else if (op == "m-") { - memory = display.text.valueOf() - } else if (op == window.leftArrow) { - display.text = display.text.toString().slice(0, -1) - if (display.text.length == 0) { - display.text = "0" - } - } else if (op == "Off") { - Qt.quit(); - } else if (op == "C") { - display.text = "0" - } else if (op == "AC") { - curVal = 0 - memory = 0 - lastOp = "" - display.text ="0" - } -} - diff --git a/examples/demos/calculator/content/images/button-.png b/examples/demos/calculator/content/images/button-.png deleted file mode 100644 index 544e514536..0000000000 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 index 5f92de32d0..0000000000 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 index 36c93914c7..0000000000 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 index 347cbbea9d..0000000000 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 index 3b335891ae..0000000000 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 index 9507f4382e..0000000000 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 index a926b93fac..0000000000 --- a/examples/demos/calculator/content/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Button Button.qml -Display Display.qml diff --git a/examples/demos/calculator/main.cpp b/examples/demos/calculator/main.cpp deleted file mode 100644 index fafe14fe46..0000000000 --- a/examples/demos/calculator/main.cpp +++ /dev/null @@ -1,66 +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$ -** -****************************************************************************/ - -#include -#include -#include -#include - -void usage() -{ - printf("Pass -desktop to use the Desktop UI"); - exit(0); -} - -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/calqlatr.pro b/examples/demos/calqlatr/calqlatr.pro new file mode 100644 index 0000000000..0aa39f9278 --- /dev/null +++ b/examples/demos/calqlatr/calqlatr.pro @@ -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 diff --git a/examples/demos/calqlatr/calqlatr.qdoc b/examples/demos/calqlatr/calqlatr.qdoc new file mode 100644 index 0000000000..3e0e1f1eb0 --- /dev/null +++ b/examples/demos/calqlatr/calqlatr.qdoc @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title QML Demo - Calqlatr + \example demos/calqlatr + \brief This is an example calculator written in QML. + \image qml-calqlatr-demo-small.png + + 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 index 0000000000..33833619ec --- /dev/null +++ b/examples/demos/calqlatr/calqlatr.qml @@ -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 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/demos/calqlatr/calqlatr.qmlproject @@ -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: "." + } +} diff --git a/examples/demos/calqlatr/content/Button.qml b/examples/demos/calqlatr/content/Button.qml new file mode 100644 index 0000000000..ecd7bc9bd1 --- /dev/null +++ b/examples/demos/calqlatr/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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 { + property alias text: textItem.text + property alias color: textItem.color + + property bool operator: false + + signal clicked + + width: 30 + height: 50 + + Text { + id: textItem + font.pixelSize: 48 + wrapMode: Text.WordWrap + lineHeight: 0.75 + color: "white" + } + +// Rectangle { +// color: "red" +// opacity: 0.2 +// anchors.fill: mouse +// } + + 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 index 0000000000..37c7592c61 --- /dev/null +++ b/examples/demos/calqlatr/content/Display.qml @@ -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 index 0000000000..377cd57354 --- /dev/null +++ b/examples/demos/calqlatr/content/NumberPad.qml @@ -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 } +} diff --git a/examples/demos/calqlatr/content/StyleLabel.qml b/examples/demos/calqlatr/content/StyleLabel.qml new file mode 100644 index 0000000000..ccc09bb4a9 --- /dev/null +++ b/examples/demos/calqlatr/content/StyleLabel.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** 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 + +Text { + width: 64 + font.pixelSize: 14 + font.bold: false + wrapMode: Text.WordWrap + lineHeight: 0.75 + color: "#676764" +} diff --git a/examples/demos/calqlatr/content/audio/touch.wav b/examples/demos/calqlatr/content/audio/touch.wav new file mode 100644 index 0000000000..94cccb7546 Binary files /dev/null and b/examples/demos/calqlatr/content/audio/touch.wav differ diff --git a/examples/demos/calqlatr/content/calculator.js b/examples/demos/calqlatr/content/calculator.js new file mode 100644 index 0000000000..a08d419c42 --- /dev/null +++ b/examples/demos/calqlatr/content/calculator.js @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + + +var curVal = 0 +var memory = 0 +var lastOp = "" +var previousOperator = "" +var digits = "" + +function disabled(op) { + if (op == "." && digits.toString().search(/\./) != -1) { + return true + } else if (op == window.squareRoot && digits.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +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 +} + +function operatorPressed(op) +{ + if (disabled(op)) + return + lastOp = op + + 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 == "×" || op == "÷") { + previousOperator = op + curVal = digits.valueOf() + display.displayOperator(previousOperator) + return + } + + if (op == "=") { + display.newLine("=", digits.toString()) + } + + curVal = 0 + previousOperator = "" + + if (op == "1/x") { + digits = (1 / digits.valueOf()).toString() + } else if (op == "x^2") { + digits = (digits.valueOf() * digits.valueOf()).toString() + } else if (op == "Abs") { + digits = (Math.abs(digits.valueOf())).toString() + } else if (op == "Int") { + digits = (Math.floor(digits.valueOf())).toString() + } else if (op == window.plusminus) { + digits = (digits.valueOf() * -1).toString() + } else if (op == window.squareRoot) { + digits = (Math.sqrt(digits.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += digits.valueOf() + } else if (op == "mr") { + digits = memory.toString() + } else if (op == "m-") { + memory = digits.valueOf() + } else if (op == window.leftArrow) { + digits = digits.toString().slice(0, -1) + if (digits.length == 0) { + digits = "0" + } + } else if (op == "Off") { + Qt.quit(); + } else if (op == "C") { + digits = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + 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 index 0000000000..2989ee2e35 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 index 0000000000..3e21248232 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 index 0000000000..98e662f53f 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 index 0000000000..6bc65610bc 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 index 0000000000..ca29a3ae10 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 index 0000000000..7c2da7b930 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 index 0000000000..953c408bca 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 index 0000000000..e08ddface8 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 index 0000000000..d9aa7e3431 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 index 0000000000..64dbde66b1 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 index 0000000000..bb02b000cf 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 index 0000000000..345713443e --- /dev/null +++ b/examples/demos/calqlatr/main.cpp @@ -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) diff --git a/examples/demos/demos.pro b/examples/demos/demos.pro index af7d769c7d..d5505c8650 100644 --- a/examples/demos/demos.pro +++ b/examples/demos/demos.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = calculator \ +SUBDIRS = calqlatr \ samegame \ tweetsearch diff --git a/examples/demos/samegame/content/Block.qml b/examples/demos/samegame/content/Block.qml new file mode 100644 index 0000000000..041ee05f76 --- /dev/null +++ b/examples/demos/samegame/content/Block.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + 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 + } + + //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 + } + + //Paint particles on the background + PaintEmitter { + id: particles2 + system: particleSystem + } + + 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); particles2.pulse(100);} } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/examples/demos/samegame/content/BlockEmitter.qml b/examples/demos/samegame/content/BlockEmitter.qml new file mode 100644 index 0000000000..5f45753825 --- /dev/null +++ b/examples/demos/samegame/content/BlockEmitter.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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 + 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 +} diff --git a/examples/demos/samegame/content/BoomBlock.qml b/examples/demos/samegame/content/BoomBlock.qml deleted file mode 100644 index b853341658..0000000000 --- a/examples/demos/samegame/content/BoomBlock.qml +++ /dev/null @@ -1,111 +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.Particles 2.0 - -Item { - id: block - property bool dying: false - property bool spawned: false - property int type: 0 - property ParticleSystem particleSystem - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - - Image { - id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - anchors.fill: parent - } - Emitter { - id: particles - system: particleSystem - group: { - if(type == 0){ - "red"; - } else if (type == 1) { - "blue"; - } else { - "green"; - } - } - 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 - } - - 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); } - } - ] -} diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml index 7fdb1fc75e..e8a67a540c 100644 --- a/examples/demos/samegame/content/Button.qml +++ b/examples/demos/samegame/content/Button.qml @@ -39,37 +39,29 @@ ****************************************************************************/ 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);} } } diff --git a/examples/demos/samegame/content/Dialog.qml b/examples/demos/samegame/content/Dialog.qml deleted file mode 100644 index 5c0da99eaf..0000000000 --- a/examples/demos/samegame/content/Dialog.qml +++ /dev/null @@ -1,80 +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 - -Rectangle { - id: page - anchors.centerIn: parent - - property Item text: dialogText - property bool open: false - - signal closed - signal opened - function forceClose() { - if(!open) - return; //already closed - page.open = false; - page.closed(); - page.opacity = 0; - } - - function show(txt) { - page.open = true; - page.opened(); - dialogText.text = txt; - page.opacity = 1; - } - - 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: dialogText; anchors.centerIn: parent; text: "Hello World!" } - - MouseArea { anchors.fill: parent; onClicked: forceClose(); } -} - diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml index 8f7a415a34..8f025fb2ae 100644 --- a/examples/demos/samegame/content/GameArea.qml +++ b/examples/demos/samegame/content/GameArea.qml @@ -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 index 0000000000..622438b84a --- /dev/null +++ b/examples/demos/samegame/content/LogoAnimation.qml @@ -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 index 0000000000..a0e9bf2e5e --- /dev/null +++ b/examples/demos/samegame/content/MenuEmitter.qml @@ -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/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml deleted file mode 100644 index f14a4038ad..0000000000 --- a/examples/demos/samegame/content/NameInputDialog.qml +++ /dev/null @@ -1,92 +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 - -Dialog { - id: nameInputDialog - - property int initialWidth: 0 - property alias name: nameInputText.text - - anchors.centerIn: parent - z: 22; - - Behavior on width { - NumberAnimation {} - enabled: nameInputDialog.initialWidth != 0 - } - - signal accepted(string name) - onClosed: { - if (nameInputText.text != "") - accepted(name); - } - 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(); - } - } - - 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(); - } - } -} diff --git a/examples/demos/samegame/content/PaintEmitter.qml b/examples/demos/samegame/content/PaintEmitter.qml new file mode 100644 index 0000000000..1c69f138fb --- /dev/null +++ b/examples/demos/samegame/content/PaintEmitter.qml @@ -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
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 index 0000000000..8b0a6e915a --- /dev/null +++ b/examples/demos/samegame/content/levels/level1.qml @@ -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

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 index 0000000000..ce3813e23f --- /dev/null +++ b/examples/demos/samegame/content/levels/level2.qml @@ -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

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 index 0000000000..6fe723a25f --- /dev/null +++ b/examples/demos/samegame/content/levels/level3.qml @@ -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
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 index 0000000000..ae45f3e837 --- /dev/null +++ b/examples/demos/samegame/content/levels/level4.qml @@ -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

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 index 0000000000..47f6f32dbc --- /dev/null +++ b/examples/demos/samegame/content/levels/level5.qml @@ -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

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 index 0000000000..c0ef89396e --- /dev/null +++ b/examples/demos/samegame/content/levels/level6.qml @@ -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

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 index 0000000000..f725f0c4ba --- /dev/null +++ b/examples/demos/samegame/content/levels/level7.qml @@ -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

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 index 0000000000..4999d727f8 --- /dev/null +++ b/examples/demos/samegame/content/levels/level8.qml @@ -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

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 index 0000000000..eed25c4c04 --- /dev/null +++ b/examples/demos/samegame/content/levels/level9.qml @@ -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

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 index 3734a27744..0000000000 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 index 20e43c75b6..0000000000 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 index b568a1900c..0000000000 Binary files a/examples/demos/samegame/content/pics/greenStone.png and /dev/null differ diff --git a/examples/demos/samegame/content/pics/particle.png b/examples/demos/samegame/content/pics/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/demos/samegame/content/pics/particle.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 index 36b09a2686..0000000000 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 index b1ce76212c..0000000000 Binary files a/examples/demos/samegame/content/pics/yellowStone.png and /dev/null differ diff --git a/examples/demos/samegame/content/samegame.js b/examples/demos/samegame/content/samegame.js index d859bf11bc..456007c2d0 100755 --- a/examples/demos/samegame/content/samegame.js +++ b/examples/demos/samegame/content/samegame.js @@ -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(); +} diff --git a/examples/demos/samegame/main.cpp b/examples/demos/samegame/main.cpp index 4a0f88ae70..1456f3ef2a 100644 --- a/examples/demos/samegame/main.cpp +++ b/examples/demos/samegame/main.cpp @@ -37,29 +37,5 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#include -#include -#include -#include - -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) diff --git a/examples/demos/samegame/samegame-desktop.qml b/examples/demos/samegame/samegame-desktop.qml deleted file mode 100644 index 51b7a6d452..0000000000 --- a/examples/demos/samegame/samegame-desktop.qml +++ /dev/null @@ -1,86 +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.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 } - } - - 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) - } - - 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 - } - } -} diff --git a/examples/demos/samegame/samegame-mobile.qml b/examples/demos/samegame/samegame-mobile.qml deleted file mode 100644 index 61c7edac6c..0000000000 --- a/examples/demos/samegame/samegame-mobile.qml +++ /dev/null @@ -1,82 +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.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 - } - } -} diff --git a/examples/demos/samegame/samegame.pro b/examples/demos/samegame/samegame.pro index 96a8c34ab0..e9b9f4bf16 100644 --- a/examples/demos/samegame/samegame.pro +++ b/examples/demos/samegame/samegame.pro @@ -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 index 0000000000..24c15c1122 --- /dev/null +++ b/examples/demos/samegame/samegame.qml @@ -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: 'P1: ' + 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: 'Highscore: ' + 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: 'P1: ' + 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: 'P2: ' + 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: 'Moves: ' + 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: 'Score: ' + 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; +} diff --git a/examples/demos/samegame/samegame.qmlproject b/examples/demos/samegame/samegame.qmlproject index e0f1074913..42ffacf4f8 100644 --- a/examples/demos/samegame/samegame.qmlproject +++ b/examples/demos/samegame/samegame.qmlproject @@ -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 { -- cgit v1.2.3