diff options
author | Tomaz Noleto <tomaz.noleto@openbossa.org> | 2011-10-25 17:13:31 +0200 |
---|---|---|
committer | Tomaz Noleto <tomaz.noleto@openbossa.org> | 2011-10-25 17:14:32 +0200 |
commit | 5c722451a2bb6702c628a1b7c1468160fc01734a (patch) | |
tree | bf5487fc0f82a0de0d6b7ed38088538acfc1389a /chicken-wranglers/src/qml | |
parent | d7d612ff07253b1cc1ffa4be489a8d90ec750af6 (diff) |
chicken-wranglers: Initial commit
Signed-off-by: Tomaz Noleto <tomaz.noleto@openbossa.org>
Diffstat (limited to 'chicken-wranglers/src/qml')
39 files changed, 5044 insertions, 0 deletions
diff --git a/chicken-wranglers/src/qml/Being.qml b/chicken-wranglers/src/qml/Being.qml new file mode 100644 index 0000000..984ee9b --- /dev/null +++ b/chicken-wranglers/src/qml/Being.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import "match.js" as MatchLogic +import game.types 1.0 + +Image { + id: being + + property string path: "" + property int currentRow: 0 + property int currentColumn: 0 + property int walkingStep: 1 + property string orientation: "side_" + property string movement: "stopped_" + + // Default values + property int moveInterval: 500 + property int changeStepsInterval: 260 + + scale: matchScreen.displayScale + smooth: true + + source: { + if (path == "") + return "" + + path + "/" + orientation + movement + walkingStep + ".png" + } + + state: "stopped" + + Timer { + id: changeSteps; + interval: changeStepsInterval + running: (opacity == 1) && (matchController.status != Match.Paused) + repeat: true + onTriggered: { + if (walkingStep == 1) + walkingStep = 2 + else + walkingStep = 1 + } + } + + states { + State { + name: "Up" + PropertyChanges { + target: being + orientation: "back_" + movement: "walking_" + } + } + + State { + name: "Down" + PropertyChanges { + target: being + orientation: "front_" + movement: "walking_" + } + } + + State { + name: "Left" + PropertyChanges { + target: being + orientation: "side_" + movement: "walking_" + } + } + + State { + name: "Right" + PropertyChanges { + target: being + orientation: "side_" + movement: "walking_" + } + PropertyChanges { + target: rotation + angle: 180 + } + } + + State { + name: "Stop" + PropertyChanges { + target: being + movement: "stopped_" + orientation: orientation + } + PropertyChanges { + target: rotation + angle: angle + } + } + } + + transform { + Rotation { + id: rotation + origin.x: being.width/2; origin.y: being.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 + angle: 0 + } + } +} diff --git a/chicken-wranglers/src/qml/Character.qml b/chicken-wranglers/src/qml/Character.qml new file mode 100644 index 0000000..46ab988 --- /dev/null +++ b/chicken-wranglers/src/qml/Character.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import "match.js" as MatchLogic +import game.types 1.0 + +Being { + id: character + + property int playerNumber: 0 + property PlayerModel model + property PlayerController controller + + path: { + if (model) + return model.characterPath + else + return "" + } + + moveInterval: MatchLogic.characterMoveInterval + changeStepsInterval: MatchLogic.characterChangeStepsInterval + + function onLaserToggleRequested(laserDirection) { + var column = Math.round((x - matchScreen.fieldStartX - (matchScreen.cellSize - width) / 2) / matchScreen.cellSize) + var row = Math.round((y - matchScreen.fieldStartY - (matchScreen.cellSize - height) / 2) / matchScreen.cellSize) + matchController.toggleLaser(column, row, laserDirection) + } + + x: matchScreen.fieldStartX + (currentColumn * matchScreen.cellSize) + (matchScreen.cellSize - width) / 2 + y: matchScreen.fieldStartY + (currentRow * matchScreen.cellSize) + (matchScreen.cellSize - height) / 2 + + Behavior on x { + NumberAnimation { + duration: moveInterval; + easing.type: Easing.Linear + } + } + + Behavior on y { + NumberAnimation { + duration: moveInterval; + easing.type: Easing.Linear + } + } + + Behavior on opacity { + NumberAnimation { duration: 200 } + } + + currentRow: { + if (controller) + return controller.position.y + else + return 4 + } + + currentColumn: { + if (controller) + return controller.position.x + else + return 4 + } + + opacity: 0 + + Timer { + id: moveTimer + + triggeredOnStart: true + interval: moveInterval; + running: model != null && matchController.status != Match.Paused + repeat: true + onTriggered: { + state = model.direction + if (controller) + controller.move() + } + } +} diff --git a/chicken-wranglers/src/qml/CharacterSelectionView.qml b/chicken-wranglers/src/qml/CharacterSelectionView.qml new file mode 100644 index 0000000..e28b6f9 --- /dev/null +++ b/chicken-wranglers/src/qml/CharacterSelectionView.qml @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "common.js" as Common +import "widgets" + +Screen { + id: screen + + signal back + signal characterSelected(int index) + + Image { + id: background + + anchors.fill: parent + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_selectcharacter.png" + else + "qrc:/images/general/bg_selectcharacter.png" + } + } + + Component { + id: characterDelegate + + Item { + width: 191 + height: 220 + + scale: PathView.iconScale + + Image { + id: characterIcon + + y: 0 + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + smooth: true + source: { + if (isAvailable) + Common.getImagePath(path, "select_character.png") + else + Common.getImagePath(path, "unavailable.png") + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + view.currentIndex = index + } + } + } + } + + Item { + id: characterHighlight + + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + bottom: view.bottom + } + + Image { + id: name + + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin: 60 + } + + smooth: true + source: Common.getImagePath(characterListModel.get(view.currentIndex).path, "name.png") + + // XXX: When changing source property, the sourceSize.width + // is not updating accordingly. So we are forcing a hardcoded + // value for now. + onSourceChanged: sourceSize.width = 200 + + Behavior on opacity { + NumberAnimation { duration: 100 } + } + } + + ImageButton { + source: "qrc:/images/general/bt_previous.png" + + anchors.right: parent.horizontalCenter + anchors.rightMargin: 80 + anchors.verticalCenter: name.verticalCenter + + onClicked: view.decrementCurrentIndex() + } + + ImageButton { + source: "qrc:/images/general/bt_next.png" + + anchors.left: parent.horizontalCenter + anchors.leftMargin: 80 + anchors.verticalCenter: name.verticalCenter + + onClicked: view.incrementCurrentIndex() + } + } + + PathView { + id: view + + anchors { + right: parent.right + left: parent.left + verticalCenter: parent.verticalCenter + verticalCenterOffset: 20 + } + + height: 220 + model: characterListModel + delegate: characterDelegate + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + pathItemCount: 5 + highlightMoveDuration: 200 + dragMargin: 500 + + onCurrentIndexChanged: { + name.source = Common.getImagePath(characterListModel.get(currentIndex).path, "name.png") + } + + onMovementStarted: { + name.opacity = 0 + } + + onMovementEnded: { + name.source = Common.getImagePath(characterListModel.get(currentIndex).path, "name.png") + name.opacity = 1 + } + + path: Path { + startX: -40 + startY: 100 + + PathAttribute { name: "iconScale"; value: 0.3 } + + PathLine { + x: screen.width * 0.5 + y: 100 + } + + PathAttribute { name: "iconScale"; value: 1.0 } + + // 4 + PathLine { + x: screen.width + 40 + y: 100 + } + + PathAttribute { name: "iconScale"; value: 0.3 } + } + } + + Button { + id: buttonJoin + + text: "Join" + width: 200 + enabled: characterListModel.get(view.currentIndex).isAvailable + + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + margins: 20 + } + + onClicked: characterSelected(view.currentIndex) + } + + ImageButton { + id: buttonBack + + anchors { + top: parent.top + right: parent.right + margins: 15 + } + + name: "back" + onClicked: back(); + } +} diff --git a/chicken-wranglers/src/qml/Chicken.qml b/chicken-wranglers/src/qml/Chicken.qml new file mode 100644 index 0000000..a09e9c1 --- /dev/null +++ b/chicken-wranglers/src/qml/Chicken.qml @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import "match.js" as MatchLogic +import game.types 1.0 + +Being { + id: chicken + + property ChickenController controller + + path: "qrc:/images/chicken" + + function kill() { + chicken.opacity = 0 + } + + function onPositionChanged() { + currentRow = controller.position.y + currentColumn = controller.position.x + + var newX = matchScreen.fieldStartX + (currentColumn * matchScreen.cellSize) + (matchScreen.cellSize - width) / 2 + var newY = matchScreen.fieldStartY + (currentRow * matchScreen.cellSize) + (matchScreen.cellSize - height) / 2 + + moveInterval = chickenMoveInterval + + if (x != newX && !xAnimation.running) { + xAnimation.to = newX + xAnimation.start() + } + + if (y != newY && !yAnimation.running) { + yAnimation.to = newY + yAnimation.start() + } + } + + function move() { + controller.move() + chicken.state = controller.direction + } + + opacity: 1 + + currentRow: MatchLogic.defaultRows / 2 + currentColumn: MatchLogic.defaultColumns / 2 + + PropertyAnimation { + id: xAnimation + + target: chicken + property: "x" + duration: moveInterval + alwaysRunToEnd: true + + onRunningChanged: { + if (!running) + chicken.move() + } + } + + PropertyAnimation { + id: yAnimation + + target: chicken + property: "y" + duration: moveInterval + alwaysRunToEnd: true + + onRunningChanged: { + if (!running) + chicken.move() + } + } + + property int chickenMoveInterval + + chickenMoveInterval: { + if (!controller) + return MatchLogic.chickenMoveIntervalNormal + + if (controller.isSafe) + return MatchLogic.chickenMoveIntervalNormal + else + return MatchLogic.chickenMoveIntervalRunning + } + + changeStepsInterval: MatchLogic.chickenChangeStepsIntervalNormal + moveInterval: MatchLogic.chickenMoveIntervalNormal + + onOpacityChanged: { + if (opacity == 0) + chicken.destroy() + } + + Behavior on opacity { + NumberAnimation { duration: 500 } + } + + Timer { + id: move; + interval: chickenMoveInterval + running: state == "Stop" && matchController.status != Match.Paused + repeat: true + onTriggered: { + chicken.move() + + if (currentRow < 0 || currentColumn < 0 + || currentRow >= MatchLogic.defaultRows + || currentColumn >= MatchLogic.defaultColumns) { + chicken.kill() + } + } + } + + Component.onCompleted: { + chicken.state = "Stop" + } +} diff --git a/chicken-wranglers/src/qml/ClientView.qml b/chicken-wranglers/src/qml/ClientView.qml new file mode 100644 index 0000000..0bb06af --- /dev/null +++ b/chicken-wranglers/src/qml/ClientView.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +import "widgets" +import "common.js" as Common + +Screen { + id: clientView + + focus: true + + function showControlView() { + var character = characterListModel.get(characterListModel.selectedIndex) + + playerControlView.characterPath = character.path + Common.switchScreens(playerReadyView, playerControlView) + playerControlView.focus = true + } + + function showPlayerReadyView() { + Common.switchScreens(playerControlView, playerReadyView) + } + + + CharacterSelectionView { + id: characterSelectionView + + anchors.fill: parent + + onBack: { + closeRequested() + focus = false + } + + onCharacterSelected: { + characterListModel.selectedIndex = index + var character = characterListModel.get(index) + + if (character.isAvailable) { + playerReadyView.characterPath = character.path + Common.switchScreens(characterSelectionView, playerReadyView) + } else { + console.log("Character is not available."); + } + } + } + + PlayerReadyView { + id: playerReadyView + + anchors.fill: parent + onBack: { + characterListModel.selectedIndex = -1 + Common.switchScreens(playerReadyView, characterSelectionView) + focus = false + } + } + + PlayerControlView { + id: playerControlView + + anchors.fill: parent + onBack: { + characterListModel.selectedIndex = -1 + Common.switchScreens(playerControlView, characterSelectionView) + focus = false + } + } + + onTransitionFinished: { + if (!visible) + closeFinished() + } + + Component.onCompleted: { + characterSelectionView.show() + characterSelectionView.focus = true + } +} diff --git a/chicken-wranglers/src/qml/HenCoop.qml b/chicken-wranglers/src/qml/HenCoop.qml new file mode 100644 index 0000000..ad5db74 --- /dev/null +++ b/chicken-wranglers/src/qml/HenCoop.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +Item { + id: henCoop + + property int playerNumber: 1 + property PlayerModel player: playerListModel.get(playerNumber - 1) + property string side: getSide() + + scale: matchScreen.displayScale + + function getSide () { + if ((playerNumber % 2) == 0) + return "right" + + return "left" + } + + opacity: { + if (henCoop.player == null || henCoop.player.characterPath == "") + return 0 + return 1 + } + + Image { + id: plate + source: { + if (henCoop.player == null || henCoop.player.characterPath == "") + return "" + "qrc:/images/battlefield/hencoop_plate.png" + } + + smooth: true + anchors { + top: parent.top + left: { + if (henCoop.side == "left") + return parent.left + else + return undefined + } + right: { + if (henCoop.side == "right") + return parent.right + else + return undefined + } + } + } + + Image { + id: house + + smooth: true + source: { + if (henCoop.player == null || henCoop.player.characterPath == "") + return "" + return henCoop.player.characterPath + "/hencoop.png" + } + + anchors { + top: parent.top + left: { + if (henCoop.side == "left") + return parent.left + else + return undefined + } + right: { + if (henCoop.side == "right") + return parent.right + else + return undefined + } + leftMargin: 12 + } + + Text { + id: score + + text: { + if (player != null) + return player.score + else + return "0" + } + + color: "white" + style: Text.Outline + styleColor: "black" + smooth: true + + font { + family: "Nokia Sans" + pointSize: 30 + bold: true + } + + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin: 20 + } + } + } +} diff --git a/chicken-wranglers/src/qml/HostView.qml b/chicken-wranglers/src/qml/HostView.qml new file mode 100644 index 0000000..fd37ab2 --- /dev/null +++ b/chicken-wranglers/src/qml/HostView.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import "widgets" +import "common.js" as Common + +Screen { + id: hostView + + anchors.fill: parent + focus: true + + WaitingRoomView { + id: waitingRoomView + + anchors.fill: parent + + onBack: closeRequested() + + onMatchStarted: { + matchViewLoader.source = "MatchView.qml" + } + } + + Loader { + id: matchViewLoader + + signal closeRequested + signal closeFinished + + anchors.fill: parent + + onLoaded: { + Common.switchScreens(waitingRoomView, matchViewLoader.item) + focus = true + } + + onCloseRequested: Common.switchScreens(matchViewLoader.item, waitingRoomView) + onCloseFinished: { + matchViewLoader.source = "" + } + } + + onTransitionFinished: { + if (!visible) + closeFinished() + } + + Component.onCompleted: { + waitingRoomView.show() + waitingRoomView.focus = true + } +} diff --git a/chicken-wranglers/src/qml/Laser.qml b/chicken-wranglers/src/qml/Laser.qml new file mode 100644 index 0000000..2444d0f --- /dev/null +++ b/chicken-wranglers/src/qml/Laser.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 + +Image { + id: laser + + property int step: 1 + property int maxSteps: 5 + property string orientation: "" + property bool turnedOn: false + + property string path: "qrc:/images/laser/laser_" + orientation + "_" + step + ".png" + source: "" + + onSourceChanged: { + // FIXME: Laser image's width and height should not + // be hardcoded. We are forcing this due to a bug in + // Image element after we change source property. + if (orientation == "vertical") { + laser.width = 27 * matchScreen.displayScale + laser.height = 83 * matchScreen.displayScale + } else { + laser.width = 83 * matchScreen.displayScale + laser.height = 27 * matchScreen.displayScale + } + } + + function turnOn(cellX, cellY, cellSize, direction) { + if (direction == Global.LaserLeft || direction == Global.LaserRight) + orientation = "vertical" + else + orientation = "horizontal" + + // FIXME: Same as above. + var diffWidth = ((83 * matchScreen.displayScale) - cellSize) / 2 + var diffHeight = (27 * matchScreen.displayScale) / 2 + + if (direction == Global.LaserUp) { + laser.x = cellX - diffWidth + laser.y = cellY - diffHeight + } else if (direction == Global.LaserDown) { + laser.x = cellX - diffWidth + laser.y = cellY + cellSize - diffHeight + } else if (direction == Global.LaserRight) { + laser.x = cellX + cellSize - diffHeight + laser.y = cellY - diffWidth + } else if (direction == Global.LaserLeft) { + laser.x = cellX - diffHeight + laser.y = cellY - diffWidth + } + + step = 0 + laserOnTimer.start() + } + + function turnOff(cell, direction) { + step = 4 + laserOffTimer.start(); + } + + Timer { + id: laserOnTimer + + repeat: true + interval: 50 + + onTriggered: { + if (step == maxSteps - 1) { + running = false + turnedOn = true + return + } + + step = step + 1 + laser.source = path + } + } + + Timer { + id: laserOffTimer + + repeat: true + interval: 50 + + onTriggered: { + + // FIXME: Check if laser wasn't turned on before + // destroying the previous one + if (step === 0) { + running = false + turnedOn = false + laser.destroy() + return + } + + step = step - 1 + + if (step == 0) + laser.source = "" + else + laser.source = path + } + } +} diff --git a/chicken-wranglers/src/qml/MatchView.qml b/chicken-wranglers/src/qml/MatchView.qml new file mode 100644 index 0000000..9f26cb1 --- /dev/null +++ b/chicken-wranglers/src/qml/MatchView.qml @@ -0,0 +1,345 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "common.js" as Common +import "match.js" as MatchLogic +import "widgets" + +Screen { + id: matchScreen + + anchors.fill: parent + color: "black" + smooth: true + focus: true + + property real displayScale: MatchLogic.getDisplayScale() + property real cellSize: MatchLogic.defaultCellSize * displayScale + property real fieldStartX: (MatchLogic.defaultFieldStartX * displayScale) + MatchLogic.deltaX + property real fieldStartY: (MatchLogic.defaultFieldStartY * displayScale) + MatchLogic.deltaY + + function showQuitDialog() { + quitDialog.show() + } + + function closeQuitDialog() { + quitDialog.hide() + } + + function showScore() { + score.show() + } + + function hideScore() { + score.hide() + } + + Image { + id: fieldBg + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/battlefield/bg_fence_stones_mobile.png" + else + "qrc:/images/battlefield/bg_fence_stones.png" + } + scale : { + if (game.environment() == Global.Symbian) + 1.0 + else + battleField.scale + } + smooth: true + anchors.centerIn: battleField + } + + Item { + id: battleField + anchors.fill: parent + scale: displayScale + + Image { + id: topLeftCorner + + property PlayerModel player: playerListModel.get(0) + + opacity: { + if (player == null || player.characterPath == "") + return 1 + return 0 + } + + source: "qrc:/images/battlefield/fence_corner_top_left.png" + smooth: true + anchors { + left: fenceLayer.left + top: fenceLayer.top + } + } + + Image { + id: bottomRightCorner + + property PlayerModel player: playerListModel.get(1) + + opacity: { + if (player == null || player.characterPath == "") + return 1 + return 0 + } + + source: "qrc:/images/battlefield/fence_corner_bottom_right.png" + smooth: true + anchors { + right: fenceLayer.right + bottom: fenceLayer.bottom + } + } + + Image { + id: bottomLeftCorner + + property PlayerModel player: playerListModel.get(2) + + opacity: { + if (player == null || player.characterPath == "") + return 1 + return 0 + } + + source: "qrc:/images/battlefield/fence_corner_bottom_left.png" + smooth: true + anchors { + left: fenceLayer.left + bottom: fenceLayer.bottom + } + } + + Image { + id: topRightCorner + + property PlayerModel player: playerListModel.get(3) + + opacity: { + if (player == null || player.characterPath == "") + return 1 + return 0 + } + + source: "qrc:/images/battlefield/fence_corner_top_right.png" + smooth: true + anchors { + right: fenceLayer.right + top: fenceLayer.top + } + } + + Image { + id: fenceLayer + source: "qrc:/images/battlefield/fence_layer_over.png" + smooth: true + anchors.centerIn: parent + focus: true + } + + Image { + id: clockContainer + source: "qrc:/images/battlefield/clock.png" + smooth: true + anchors { + top: fenceLayer.top + horizontalCenter: parent.horizontalCenter + } + + Text { + id: clock + + text: matchController.elapsedTime + color: "white" + style: Text.Outline + smooth: true + + font { + bold: true + family: "Nokia Sans" + pointSize: 20 + } + + anchors.centerIn: parent + anchors.verticalCenterOffset: -6 + } + } + + ImageButton { + id: quitButton + name: "quit" + path: "qrc:/images/battlefield" + smooth: true + anchors { + bottom: fenceLayer.bottom + horizontalCenter: parent.horizontalCenter + } + + onClicked: MatchLogic.askQuitMatch() + } + } + + HenCoop { + playerNumber: 1 + + anchors { + top: parent.top + topMargin: 35 + left: parent.left + leftMargin: 29 + } + } + + HenCoop { + playerNumber: 2 + + anchors { + top: parent.verticalCenter + topMargin: 36 + right: parent.right + rightMargin: 29 + } + } + + HenCoop { + playerNumber: 3 + + anchors { + top: parent.verticalCenter + topMargin: 36 + left: parent.left + leftMargin: 29 + } + } + + HenCoop { + playerNumber: 4 + + anchors { + top: parent.top + topMargin: 35 + right: parent.right + rightMargin: 29 + } + } + + ConfirmationDialog { + id: quitDialog + + text: "Do you want to leave this match?" + opacity: 0 + + onRejected: { + closeQuitDialog() + MatchLogic.resumeMatch() + } + + onAccepted: { + closeQuitDialog() + MatchLogic.leaveMatch() + + closeRequested() + } + + z: 10 + } + + Score { + id: score + + opacity: 0 + + onClose: { + MatchLogic.leaveMatch() + hideScore() + + closeRequested() + } + } + + Rectangle { + id: background + + anchors.fill: parent + color: "black" + opacity: 0.7 + z: 49 + + MouseArea { + anchors.fill: parent + } + + Behavior on opacity { + PropertyAnimation { duration: 200 } + } + } + + Countdown { + id: countdown + + z: 50 + + anchors.fill: parent + onTimeout: { + background.opacity = 0 + MatchLogic.startMatch() + } + } + + onTransitionFinished: { + if (visible) + countdown.start() + else + closeFinished() + } + + Component.onCompleted: MatchLogic.newMatch() + + Keys.onEscapePressed: MatchLogic.askQuitMatch() +} diff --git a/chicken-wranglers/src/qml/PlayerControlView.qml b/chicken-wranglers/src/qml/PlayerControlView.qml new file mode 100644 index 0000000..b520587 --- /dev/null +++ b/chicken-wranglers/src/qml/PlayerControlView.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import "widgets" +import "common.js" as Common + +Screen { + id: screen + + property string characterPath: "" + property int margins: -60 + + signal back + + focus: true + + Keys.onUpPressed: gameClient.moveUp() + Keys.onDownPressed: gameClient.moveDown() + Keys.onLeftPressed: gameClient.moveLeft() + Keys.onRightPressed: gameClient.moveRight() + Keys.onSpacePressed: gameClient.moveStop() + + Keys.onPressed: { + switch (event.key) { + + // Quit the game + case Qt.Key_Q: + back() + break + + // Laser shots + case Qt.Key_W: + gameClient.toggleLaserUp() + break + + case Qt.Key_S: + gameClient.toggleLaserDown() + break + + case Qt.Key_A: + gameClient.toggleLaserLeft() + break + + case Qt.Key_D: + gameClient.toggleLaserRight() + break + } + + event.accepted = true + } + + Image { + anchors.fill: parent + + source: Common.getImagePath(characterPath, "control.png") + } + + Row { + anchors.fill: parent + + Item { + width: parent.width / 4 + height: parent.height + + MouseArea { + anchors.fill: parent + onClicked: gameClient.toggleLaserLeft() + } + } + + Column { + width: parent.width / 2 + height: parent.height + + Item { + width: parent.width + height: parent.height / 3 * 2 + + MouseArea { + anchors.fill: parent + onClicked: gameClient.toggleLaserUp() + } + } + + Item { + width: parent.width + height: parent.height / 3 + + MouseArea { + anchors.fill: parent + onClicked: gameClient.toggleLaserDown() + } + } + } + + Item { + width: parent.width / 4 + height: parent.height + + MouseArea { + anchors.fill: parent + onClicked: gameClient.toggleLaserRight() + } + } + } +} diff --git a/chicken-wranglers/src/qml/PlayerReadyView.qml b/chicken-wranglers/src/qml/PlayerReadyView.qml new file mode 100644 index 0000000..41e8c5a --- /dev/null +++ b/chicken-wranglers/src/qml/PlayerReadyView.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "widgets" +import "common.js" as Common + +Screen { + property string characterPath: "" + + signal back + + anchors.fill: parent + + Image { + id: background + + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_selectcharacter.png" + else + "qrc:/images/general/bg_selectcharacter.png" + } + anchors.fill: parent + } + + + Image { + id: title + + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + margins: 40 + } + + source: "qrc:/images/general/you_are_ready.png" + smooth: true + } + + Image { + anchors.centerIn: parent + + smooth: true + source: Common.getImagePath(characterPath, "select_character.png") + } + + Button { + text: "Start" + width: 200 + + // TODO: Enable this button if this client is P1 + opacity: 0 + + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + margins: 20 + } + + onClicked: console.log("Start game via P1 client") + } + + ImageButton { + name: "back" + onClicked: back() + + anchors { + top: parent.top + right: parent.right + margins: 15 + } + } +} diff --git a/chicken-wranglers/src/qml/Score.qml b/chicken-wranglers/src/qml/Score.qml new file mode 100644 index 0000000..1776386 --- /dev/null +++ b/chicken-wranglers/src/qml/Score.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import "widgets" + +import "match.js" as MatchLogic +import "common.js" as Common + +Item { + id: score + + property int numberOfPlayers: playerListModel.count() + property int scoreBoxTick: width / (numberOfPlayers + 1) + + signal close + + anchors.fill: parent + z: 10 + + function sortScore(scoreBox1, scoreBox2) { + return (scoreBox2.score - scoreBox1.score) + } + + function createScore() { + var scoreBoxList = [] + + for (var i = 0; i < numberOfPlayers; i++) { + var scoreBox + scoreBox = MatchLogic.createScoreBox() + if (scoreBox == undefined) + continue + + var player = playerListModel.get(i) + if (player == null) + continue + + scoreBox.source = Common.getImagePath(player.characterPath, "score.png") + scoreBox.score = player.score + scoreBox.z = 15 + scoreBox.y = 0 + + scoreBoxList.push(scoreBox) + } + + scoreBoxList.sort(sortScore) + + for (var i = 0; i < scoreBoxList.length; i++) + scoreBoxList[i].x = (scoreBoxTick * (i + 1)) - (scoreBoxList[i].width / 2) + + closeTimer.start() + } + + function show() { + opacity = 1 + } + + function hide() { + opacity = 0 + } + + Behavior on opacity { + NumberAnimation { duration: 500 } + } + + Rectangle { + anchors.fill: parent + color: "black" + opacity: 0.8 + + MouseArea { + anchors.fill: parent + } + } + + Timer { + id: closeTimer + + interval: 5000 + + onTriggered: close() + } + + onOpacityChanged: { + if (opacity == 1) { + createScore() + } + } +} diff --git a/chicken-wranglers/src/qml/ScoreBox.qml b/chicken-wranglers/src/qml/ScoreBox.qml new file mode 100644 index 0000000..ef2f19d --- /dev/null +++ b/chicken-wranglers/src/qml/ScoreBox.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Image { + id: scoreBox + + property int score: 0 + + y: -593 * matchScreen.displayScale // FIXME: Use image height instead + smooth: true + width: scoreBox.sourceSize.width * matchScreen.displayScale + height: scoreBox.sourceSize.height * matchScreen.displayScale + + Text { + text: score + style: Text.Outline + color: "white" + smooth: true + + font { + family: "Nokia Sans" + pointSize: 60 * matchScreen.displayScale + bold: true + } + + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: 30 * matchScreen.displayScale + } + } + + Behavior on y { + PropertyAnimation { + duration: 1000 + easing.type: Easing.OutBounce + } + } +} + diff --git a/chicken-wranglers/src/qml/Splash.qml b/chicken-wranglers/src/qml/Splash.qml new file mode 100644 index 0000000..5a1aa38 --- /dev/null +++ b/chicken-wranglers/src/qml/Splash.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "widgets" + +Screen { + id: screen + + property int time: 1500 + + Image { + id: background + + smooth: true + + anchors.fill: parent + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_splash.png" + else + "qrc:/images/general/bg_splash.png" + } + } + + Timer { + running: true + interval: time + repeat: false + + onTriggered: timeout() + } + + onTransitionFinished: { + if (!visible) + closeFinished() + } +} diff --git a/chicken-wranglers/src/qml/StartView.qml b/chicken-wranglers/src/qml/StartView.qml new file mode 100644 index 0000000..fd2905d --- /dev/null +++ b/chicken-wranglers/src/qml/StartView.qml @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +import "client.js" as Client +import "host.js" as Host +import "widgets" + +Screen { + id: screen + + signal hostSelected + signal clientSelected + signal clientDiscoveryCanceled + + function showStartServerDialog() { + startServerDialog.show() + } + + function hideStartServerDialog() { + startServerDialog.hide() + } + + function showStartClientDialog() { + if (game.connectivity == "bluetooth") { + connectivityDialog.model = connectivityListModel + connectivityDialog.show() + } else { + startClientDialog.show() + } + } + + function hideStartClientDialog() { + if (game.connectivity == "bluetooth") { + gameClient.scanCanceled() + connectivityDialog.hide() + } else + startClientDialog.hide() + } + + function showErrorDialog(msg) { + errorDialog.text = msg + errorDialog.show() + } + + function hideErrorDialog() { + errorDialog.hide() + } + + onHostSelected: Host.start() + onClientSelected: Client.start() + + Image { + id: background + + smooth: true + anchors.fill: parent + + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_640x360.png" + else if (game.environment() == Global.Maemo) + "qrc:/images/general/bg_800x480.png" + else + "qrc:/images/general/bg_1280x768.png" + } + } + + FeatherFall { + id: featherFall + number: { + if (game.environment() == Global.Symbian) + 2 + else if (game.environment() == Global.Maemo) + 3 + else + 5 + } + fallWidth:{ + if (game.environment() == Global.Symbian) + 640 + else + 800 + } + fallHeight:{ + if (game.environment() == Global.Symbian) + 360 + else + 768 + } + + anchors.fill: parent + } + + Item { + anchors { + centerIn: parent + horizontalCenterOffset: 90 + verticalCenterOffset: 120 + margins: 100 + } + + Button { + id: hostGameButton + + anchors { + right: parent.right + bottom: parent.bottom + } + + text: "Host game" + width: 200 + onClicked: hostSelected() + } + + Button { + id: joinGameButton + + anchors { + left: parent.left + leftMargin: 10 + bottom: parent.bottom + } + + text: "Join game" + width: 200 + onClicked: clientSelected() + } + } + + ImageButton { + anchors { + top: parent.top + left: parent.left + margins: 15 + } + + name: "close" + onClicked: Qt.quit() + } + + ToggleButton { + anchors { + top: parent.top + right: parent.right + margins: 15 + } + } + + MessageDialog { + id: startClientDialog + + text: "Searching for server" + buttonText: "Cancel" + opacity: 0 + + Loading { + anchors.horizontalCenter: startClientDialog.box.horizontalCenter + anchors.bottom: startClientDialog.box.bottom + anchors.bottomMargin: 100 + } + + onButtonClicked: clientDiscoveryCanceled() + } + + ConnectivityDialog { + id: connectivityDialog + + opacity: 0 + onCancel: { + connectivityDialog.hide() + gameClient.scanCanceled() + } + } + + MessageDialog { + id: startServerDialog + + text: "Creating server" + opacity: 0 + + Loading { + anchors.horizontalCenter: startServerDialog.box.horizontalCenter + anchors.bottom: startServerDialog.box.bottom + anchors.bottomMargin: 100 + } + } + + MessageDialog { + id: errorDialog + + text: "error" + buttonText: "Close" + opacity: 0 + + onButtonClicked: hideErrorDialog() + } + + onOpacityChanged: { + if (opacity == 1) + featherFall.start() + else if (opacity == 0) + featherFall.stop() + } +} diff --git a/chicken-wranglers/src/qml/WaitingRoomView.qml b/chicken-wranglers/src/qml/WaitingRoomView.qml new file mode 100644 index 0000000..64b0bea --- /dev/null +++ b/chicken-wranglers/src/qml/WaitingRoomView.qml @@ -0,0 +1,288 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "common.js" as Common +import "widgets" + +Screen { + id: screen + + signal back + signal matchStarted + + Keys.onReturnPressed: { + if (buttonStart.enabled) + matchStarted() + } + + Image { + id: background + smooth: true + anchors.fill: parent + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_640x360.png" + else if (game.environment() == Global.Maemo) + "qrc:/images/general/bg_800x480.png" + else + "qrc:/images/general/bg_1280x768.png" + } + } + + ImageButton { + anchors { + left: screen.left + top: screen.top + margins: 15 + } + + name: "back" + onClicked: back() + } + + + Button { + id: buttonStart + + anchors { + top: screen.top + right: screen.right + margins: 15 + } + + width: 160 + text: "Start" + sourceName: "bt_start" + rightBorder: 35 + horizontalCenterOffset: -6 + italic: true + + enabled: playerListModel.playersReady; + + onClicked: matchStarted() + } + + ListView { + id: playerListView + anchors { + centerIn: parent + horizontalCenterOffset: 30 + verticalCenterOffset: 130 + } + + height: 400 + width: 400 + model: playerListModel + delegate: playerListDelegate + interactive: false + } + + Component { + id: playerListDelegate + + Item { + id: delegatePlayer + + scale: { + if (game.environment() == Global.Symbian) + 0.7 + else + 1 + } + + width: 400 + height: 80 + + property bool isReady: status == PlayerModel.Ready + + states { + State { + name: "playerReady"; when: isReady + PropertyChanges { target: playerInfo; opacity: 1 } + PropertyChanges { target: playerInfoUnknown; opacity: 0 } + } + } + + Image { + id: listItemBg + + anchors { + top: playerInfoUnknown.top + topMargin: 32 + } + + source: "qrc:/images/general/list_name_bg.png" + } + + Item { + id: playerInfoUnknown + + Image { + id: listItemIconUnknown + + smooth: true + + anchors { + top: parent.top + left: parent.left + leftMargin: 25 + } + + source: "qrc:/images/general/list_unknown_character.png" + fillMode: Image.PreserveAspectFit + } + + Loading { + id: listItemLoading + + anchors { + left: listItemIconUnknown.right + leftMargin: 40 + bottom: listItemIconUnknown.bottom + bottomMargin: 20 + } + } + + } + + Item { + id: playerInfo + + opacity: 0 + + Image { + id: listItemIcon + + smooth: true + + anchors { + top: parent.top + left: parent.left + leftMargin: 25 + } + + source: Common.getImagePath(characterPath, "waitinglist.png") + fillMode: Image.PreserveAspectFit + } + + + Item { + id: listItemNameOk + + anchors { + left: listItemIcon.right + leftMargin: 15 + bottom: listItemIcon.bottom + bottomMargin: 12 + } + + Image { + id: listItemName + + smooth: true + + anchors { + left: listItemNameOk.left + bottom: listItemNameOk.bottom + } + + source: Common.getImagePath(characterPath, "name.png") + fillMode: Image.PreserveAspectFit + } + + Image { + id: listItemOk + + smooth: true + + anchors { + left: listItemName.right + leftMargin: 30 + verticalCenter: listItemName.verticalCenter + } + + source: "qrc:/images/general/list_status_ok.png" + fillMode: Image.PreserveAspectFit + } + } + + ParallelAnimation { + id: anim + + SequentialAnimation { + PropertyAnimation { + target: listItemIcon + property: "scale" + duration: 300 + easing.type: Easing.InOutBack + to: 2 + } + PropertyAnimation { + target: listItemIcon + property: "scale" + duration: 200 + to: 1 + } + } + } + + onOpacityChanged: { + anim.running = true + } + } + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: delegatePlayer; property: "scale"; value: 0 } + NumberAnimation { target: delegatePlayer; property: "scale"; to: 1; duration: 250; easing.type: Easing.InOutQuad } + } + + ListView.onRemove: SequentialAnimation { + PropertyAction { target: delegatePlayer; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: delegatePlayer; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { target: delegatePlayer; property: "ListView.delayRemove"; value: false } + } + } + } +} diff --git a/chicken-wranglers/src/qml/client.js b/chicken-wranglers/src/qml/client.js new file mode 100644 index 0000000..16eb9f8 --- /dev/null +++ b/chicken-wranglers/src/qml/client.js @@ -0,0 +1,72 @@ +function start() { + game.mode = Game.ClientMode + + startViewLoader.item.showStartClientDialog("Looking for server") + startViewLoader.item.clientDiscoveryCanceled.connect(cancelDiscovery) + + // gameClient only exists after game.mode is set to Game.ClientMode + gameClient.statusChanged.connect(onStatusChanged) + gameClient.startConnection() +} + +function cancelDiscovery() { + if (gameClient.status == GameClient.Joined) { + gameClient.statusChanged.disconnect(onStatusChanged) + startViewLoader.item.clientDiscoveryCanceled.disconnect(cancelDiscovery) + startViewLoader.item.hideStartClientDialog() + return + } + + quit() +} + +function quit() { + gameClient.statusChanged.disconnect(onStatusChanged) + startViewLoader.item.clientDiscoveryCanceled.disconnect(cancelDiscovery) + startViewLoader.item.hideStartClientDialog() + + gameClient.quit() +} + +function onStatusChanged() { + switch (gameClient.status) { + + case GameClient.Joined: + startViewLoader.item.hideStartClientDialog() + clientViewLoader.source = "ClientView.qml" + break + + case GameClient.LeftMatch: + clientViewLoader.item.showPlayerReadyView() + break + + case GameClient.Ready: + clientViewLoader.item.showControlView() + break + + case GameClient.Error: + startViewLoader.item.hideStartClientDialog() + handleError(gameClient.error) + break + + default: + console.log("Unknown client status") + } +} + +function handleError(error) { + switch (error) { + + case GameClient.ServerDiscoveryTimeoutError: + startViewLoader.item.showErrorDialog("Host not found") + break + + case GameClient.SocketError: + clientViewLoader.closeRequested() + startViewLoader.item.showErrorDialog("Disconnected from host") + break + + default: + console.log("Unknown client error") + } +} diff --git a/chicken-wranglers/src/qml/common.js b/chicken-wranglers/src/qml/common.js new file mode 100644 index 0000000..2ce1585 --- /dev/null +++ b/chicken-wranglers/src/qml/common.js @@ -0,0 +1,26 @@ +var tempFrom +var tempTo + +function switchScreens(from, to) { + if (!from || !to) + return + + tempFrom = from + tempTo = to + + from.hide() + from.opacityChanged.connect(showNextScreen) +} + +function showNextScreen() { + if (tempFrom.opacity == 0) { + tempTo.show() + } +} + +function getImagePath(basePath, fileName) { + if (basePath == "") + return "" + + return basePath + "/" + fileName +} diff --git a/chicken-wranglers/src/qml/host.js b/chicken-wranglers/src/qml/host.js new file mode 100644 index 0000000..d545c31 --- /dev/null +++ b/chicken-wranglers/src/qml/host.js @@ -0,0 +1,46 @@ +function start() { + game.mode = Game.HostMode + + startViewLoader.item.showStartServerDialog("Creating server") + + // gameHosts only exists after game.mode is set to Game.HostMode + gameHost.statusChanged.connect(onStatusChanged) + gameHost.startConnection() +} + +function quit() { + gameHost.statusChanged.disconnect(onStatusChanged) + startViewLoader.item.hideStartServerDialog() + + gameHost.quit(); +} + +function onStatusChanged() { + switch (gameHost.status) { + + case GameHost.Start: + startViewLoader.item.hideStartServerDialog() + hostViewLoader.source = "HostView.qml" + break + + case GameHost.Error: + startViewLoader.item.hideStartServerDialog() + handleError(gameHost.error) + break + + default: + console.log("Unknown server status") + } +} + +function handleError(error) { + switch (error) { + + case GameHost.AnotherServerRunningError: + startViewLoader.item.showErrorDialog("Server is already running") + break + + default: + console.log("Unknown server error") + } +} diff --git a/chicken-wranglers/src/qml/main.qml b/chicken-wranglers/src/qml/main.qml new file mode 100644 index 0000000..32ac3f3 --- /dev/null +++ b/chicken-wranglers/src/qml/main.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +import "common.js" as Common +import "host.js" as Host +import "client.js" as Client +import "widgets" + +Rectangle { + id: main + + width: 800 + height: 480 + + focus: true + + SystemPalette { id: activePalette } + + Loader { + id: splashScreenLoader + + signal closeFinished + signal timeout + + anchors.fill: parent + + onLoaded: splashScreenLoader.item.show() + onTimeout: startViewLoader.source = "StartView.qml" + onCloseFinished: { + splashScreenLoader.source = "" + game.startBackgroundSound() + } + } + + Loader { + id: startViewLoader + + anchors.fill: parent + + onLoaded: Common.switchScreens(splashScreenLoader.item, startViewLoader.item) + } + + Loader { + id: hostViewLoader + + signal closeRequested + signal closeFinished + + anchors.fill: parent + + onLoaded: { + focus = true + Common.switchScreens(startViewLoader.item, hostViewLoader.item) + } + + onCloseRequested: Common.switchScreens(hostViewLoader.item, startViewLoader.item) + onCloseFinished: { + Host.quit() + hostViewLoader.source = "" + } + } + + Loader { + id: clientViewLoader + + signal closeRequested + signal closeFinished + + anchors.fill: parent + + onLoaded: { + focus = true + Common.switchScreens(startViewLoader.item, clientViewLoader.item) + } + + onCloseRequested: Common.switchScreens(clientViewLoader.item, startViewLoader.item) + onCloseFinished: { + Client.quit() + clientViewLoader.source = "" + } + } + + Component.onCompleted: splashScreenLoader.source = "Splash.qml" +} diff --git a/chicken-wranglers/src/qml/match.js b/chicken-wranglers/src/qml/match.js new file mode 100644 index 0000000..be9628e --- /dev/null +++ b/chicken-wranglers/src/qml/match.js @@ -0,0 +1,310 @@ +var defaultRows = settings.battlefieldSize().height +var defaultColumns = settings.battlefieldSize().width +var defaultFieldStartX = settings.battlefieldStartPoint().x +var defaultFieldStartY = settings.battlefieldStartPoint().y +var defaultCellSize = settings.battlefieldCellSize() +var defaultHostWidth = settings.hostDisplaySize().width +var defaultHostHeight = settings.hostDisplaySize().height + +// FIXME: Find better naming and place for these variables +var deltaX = 0 +var deltaY = 0 + +// Chicken values +var chickenMoveIntervalNormal = settings.matchChickenMoveInterval() +var chickenMoveIntervalRunning = chickenMoveIntervalNormal * 0.7 +var chickenChangeStepsIntervalNormal = settings.matchChickenChangeStepsInterval() +var chickenChangeStepsIntervalRunning = chickenChangeStepsIntervalNormal * 0.7 + +// Character values +var characterMoveInterval = settings.matchCharacterMoveInterval() +var characterChangeStepsInterval = settings.matchChickenChangeStepsInterval() + +var chickenComponent = null +var playerComponent = null +var playerScoreComponent = null +var henCoopComponent = null +var laserComponent = null + +var verticalLaserArray = null +var horizontalLaserArray = null +var chickenArray = new Array() +var playerArray = new Array() + +function initLaserArrays() +{ + verticalLaserArray = new Array(defaultRows) + for (var y = 0; y < defaultRows; y++) + verticalLaserArray[y] = new Array(defaultColumns - 1) + + horizontalLaserArray = new Array(defaultRows - 1) + for (var y = 0; y < defaultRows - 1; y++) + horizontalLaserArray[y] = new Array(defaultColumns) + + for (var y = 0; y < defaultRows; y++) + for (var x = 0; x < defaultColumns - 1; x++) + verticalLaserArray[y][x] = null + + for (var y = 0; y < defaultRows - 1; y++) + for (var x = 0; x < defaultColumns; x++) + horizontalLaserArray[y][x] = null +} + +function destroyLasers() +{ + for (var y = 0; y < defaultRows; y++) + for (var x = 0; x < defaultColumns - 1; x++) { + if (verticalLaserArray[y][x] != null && verticalLaserArray[y][x] != undefined) { + verticalLaserArray[y][x].destroy() + verticalLaserArray[y][x] = null + } + } + + for (var y = 0; y < defaultRows - 1; y++) + for (var x = 0; x < defaultColumns; x++) { + if (horizontalLaserArray[y][x] != null && horizontalLaserArray[y][x] != undefined) { + horizontalLaserArray[y][x].destroy() + horizontalLaserArray[y][x] = null + } + } +} + +function getDisplayScale() { + var scaleX = game.displaySize.width / defaultHostWidth + var scaleY = game.displaySize.height / defaultHostHeight + + var max = Math.max(scaleX, scaleY) + deltaX = ((max - scaleY) * defaultHostWidth) / 2 + deltaY = ((max - scaleX) * defaultHostHeight) / 2 + + return Math.min(scaleX, scaleY) +} + +function newMatch() { + gameHost.status = GameHost.Match + + initLaserArrays(); + + matchController.chickenCreated.connect(onChickenCreated); + matchController.playerCreated.connect(onPlayerCreated); + matchController.laserUpdated.connect(onLaserUpdated); + matchController.matchFinished.connect(onMatchFinished); + + matchController.setupMatch() + matchController.status = Match.Paused +} + +function startMatch() { + matchController.status = Match.Started + + for (var i = 0; i < playerArray.length; i++) + playerArray[i].opacity = 1 +} + +function askQuitMatch() { + if (matchController.status == Match.Running) + matchController.status = Match.Paused + + matchScreen.showQuitDialog() +} + +function resumeMatch() { + matchController.status = Match.Running +} + +function leaveMatch() { + destroyChickens() + destroyPlayers() + destroyLasers() + + matchController.status = Match.Over +} + +function onMatchFinished() { + matchController.status = Match.Paused + + matchScreen.showScore() +} + +function destroyChickens() +{ + for (var i = 0; i < chickenArray.length; i++) + if (chickenArray[i] != undefined && chickenArray[i] != null) { + chickenArray[i].destroy() + chickenArray[i] = null + } +} + +function destroyPlayers() +{ + for (var i = 0; i < playerArray.length; i++) + if (playerArray[i] != undefined && playerArray[i] != null) { + playerArray[i].destroy() + playerArray[i] = null + } +} + +function onChickenCreated(id) +{ + if (chickenComponent == null) + chickenComponent = Qt.createComponent("Chicken.qml"); + + if (chickenComponent.status == Component.Ready) { + var dynamicObject = chickenComponent.createObject(matchScreen); + if (dynamicObject == null) { + console.log("error creating chicken"); + console.log(chickenComponent.errorString()); + return false; + } + + chickenArray[id] = dynamicObject + + var chickenController = matchController.getChicken(id) + chickenController.positionChanged.connect(dynamicObject.onPositionChanged) + dynamicObject.controller = chickenController + dynamicObject.x = matchScreen.fieldStartX + (chickenController.position.x * matchScreen.cellSize) + (matchScreen.cellSize - dynamicObject.width) / 2 + dynamicObject.y = matchScreen.fieldStartY + (chickenController.position.y * matchScreen.cellSize) + (matchScreen.cellSize - dynamicObject.height) / 2 + } else { + console.log("error loading block chickenComponent"); + console.log(chickenComponent.errorString()); + return false; + } + + return true; +} + +function onPlayerCreated(id) +{ + if (playerComponent == null) + playerComponent = Qt.createComponent("Character.qml"); + + if (playerComponent.status == Component.Ready) { + // TODO: Only players with status Ready should be added + var dynamicObject = playerComponent.createObject(matchScreen); + if (dynamicObject == null) { + console.log("error creating character"); + console.log(playerComponent.errorString()); + return false; + } + + dynamicObject.playerNumber = id + playerArray[id] = dynamicObject + + var playerController = matchController.getPlayer(id) + dynamicObject.controller = playerController + playerController.laserToggleRequested.connect(dynamicObject.onLaserToggleRequested) + + dynamicObject.model = playerListModel.get(id) + } else { + console.log("error loading block playerComponent"); + console.log(playerComponent.errorString()); + return false; + } + + return true; +} + +function createScoreBox() +{ + if (playerScoreComponent == null) + playerScoreComponent = Qt.createComponent("ScoreBox.qml"); + + var dynamicObject = null; + + if (playerScoreComponent.status == Component.Ready) { + dynamicObject = playerScoreComponent.createObject(score); + if (dynamicObject == null) { + console.log("error creating laser"); + console.log(playerScoreComponent.errorString()); + return null; + } + } else { + console.log("error loading block playerScoreComponent"); + console.log(playerScoreComponent.errorString()); + return null; + } + + return dynamicObject + +} + +function createLaser() +{ + if (laserComponent == null) + laserComponent = Qt.createComponent("Laser.qml"); + + var dynamicObject = null; + + if (laserComponent.status == Component.Ready) { + dynamicObject = laserComponent.createObject(matchScreen); + if (dynamicObject == null) { + console.log("error creating laser"); + console.log(laserComponent.errorString()); + return null; + } + } else { + console.log("error loading block laserComponent"); + console.log(laserComponent.errorString()); + return null; + } + + return dynamicObject +} + +function removeLaser(x, y, direction) +{ + var laserObj = null + + if (direction == Global.LaserRight && x < defaultColumns - 1) { + laserObj = verticalLaserArray[y][x] + verticalLaserArray[y][x] = null + } else if (direction == Global.LaserLeft && x >= 0) { + laserObj = verticalLaserArray[y][x - 1] + verticalLaserArray[y][x - 1] = null + } else if (direction == Global.LaserUp && y > 0) { + laserObj = horizontalLaserArray[y - 1][x] + horizontalLaserArray[y - 1][x] = null + } else if (direction == Global.LaserDown && y < defaultRows - 1) { + laserObj = horizontalLaserArray[y][x] + horizontalLaserArray[y][x] = null + } + + if (laserObj == null) + return + + var cellX = matchScreen.fieldStartX + x * (defaultCellSize * matchScreen.displayScale) + var cellY = matchScreen.fieldStartY + y * (defaultCellSize * matchScreen.displayScale) + + laserObj.turnOff(cellX, cellY, defaultCellSize * matchScreen.displayScale, direction) +} + +function addLaser(x, y, direction) +{ + var laserObj = createLaser(); + + if (direction == Global.LaserRight && verticalLaserArray[y][x] == null) + verticalLaserArray[y][x] = laserObj + else if (direction == Global.LaserLeft && verticalLaserArray[y][x - 1] == null) + verticalLaserArray[y][x - 1] = laserObj + else if (direction == Global.LaserUp && horizontalLaserArray[y - 1][x] == null) + horizontalLaserArray[y - 1][x] = laserObj + else if (direction == Global.LaserDown && horizontalLaserArray[y][x] == null) + horizontalLaserArray[y][x] = laserObj + else { + laserObj.destroy() + return + } + + var cellX = matchScreen.fieldStartX + x * (defaultCellSize * matchScreen.displayScale) + var cellY = matchScreen.fieldStartY + y * (defaultCellSize * matchScreen.displayScale) + + laserObj.turnOn(cellX, cellY, defaultCellSize * matchScreen.displayScale, direction) +} + +function onLaserUpdated(posX, posY, laserDirection, isOn) +{ + if (isOn) + addLaser(posX, posY, laserDirection) + else + removeLaser(posX, posY, laserDirection) +} diff --git a/chicken-wranglers/src/qml/qml.qrc b/chicken-wranglers/src/qml/qml.qrc new file mode 100644 index 0000000..615d922 --- /dev/null +++ b/chicken-wranglers/src/qml/qml.qrc @@ -0,0 +1,43 @@ + <!DOCTYPE RCC><RCC version="1.0"> + <qresource prefix="/"> + <file>main.qml</file> + <file>common.js</file> + <file>client.js</file> + <file>host.js</file> + <file>Splash.qml</file> + <file>StartView.qml</file> + <file>widgets/Screen.qml</file> + <file>widgets/Button.qml</file> + <file>widgets/ImageButton.qml</file> + <file>widgets/Loading.qml</file> + <file>widgets/BaseDialog.qml</file> + <file>widgets/MessageDialog.qml</file> + <file>widgets/ConfirmationDialog.qml</file> + <file>widgets/Feather.qml</file> + <file>widgets/FeatherFall.qml</file> + <file>widgets/featherfall.js</file> + <file>widgets/Countdown.qml</file> + <file>widgets/OptionSlider.qml</file> + <file>widgets/Scrollbar.qml</file> + <file>widgets/ConnectivityDialog.qml</file> + <file>widgets/ConnectivityListView.qml</file> + <file>widgets/ToggleButton.qml</file> + + <file>ClientView.qml</file> + <file>CharacterSelectionView.qml</file> + <file>PlayerReadyView.qml</file> + <file>PlayerControlView.qml</file> + + <file>HostView.qml</file> + <file>WaitingRoomView.qml</file> + <file>MatchView.qml</file> + <file>Laser.qml</file> + <file>Score.qml</file> + <file>ScoreBox.qml</file> + <file>HenCoop.qml</file> + <file>Being.qml</file> + <file>Character.qml</file> + <file>Chicken.qml</file> + <file>match.js</file> + </qresource> + </RCC> diff --git a/chicken-wranglers/src/qml/widgets/BaseDialog.qml b/chicken-wranglers/src/qml/widgets/BaseDialog.qml new file mode 100644 index 0000000..e1cea04 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/BaseDialog.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 + +Item { + id: dialog + + property alias box: box + + signal showFinished + signal hideFinished + + anchors.fill: parent + + function show() { + dialog.opacity = 1 + } + + function hide() { + dialog.opacity = 0 + } + + onOpacityChanged: { + if (dialog.opacity == 1) + showFinished() + else if (dialog.opacity == 0) + hideFinished() + } + + Rectangle { + id: background + + anchors.fill: parent + color: "black" + opacity: 0.7 + + MouseArea { + anchors.fill: parent + } + } + + function backgroundSize() { + var res = {}; + res["height"] = 376 + res["width"] = 622 + + // XXX: if in symbian, make the dialog smaller + if (game.environment() == Global.Symbian) { + res.height = 0.9 * dialog.height + res.width = 0.9 * dialog.width + } + return res; + } + + Image { + id: box + + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/bg_dialog.png" + else + "qrc:/images/general/bg_dialog.png" + } + anchors.centerIn: parent + } + + Behavior on opacity { + NumberAnimation { duration: 200 } + } +} diff --git a/chicken-wranglers/src/qml/widgets/Button.qml b/chicken-wranglers/src/qml/widgets/Button.qml new file mode 100644 index 0000000..6ccd512 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Button.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +BorderImage { + id: button + + property int leftBorder: 18 + property int rightBorder: 18 + property int horizontalCenterOffset: 0 + property string sourceName: "bt" + property string text: "" + property bool blink: false + property bool enabled: true + property bool italic: false + + signal clicked + + source: { + if (!enabled) + return "qrc:/images/general/" + sourceName + "_disabled.png" + + if (mouseArea.pressed) + return "qrc:/images/general/" + sourceName + "_pressed.png" + else + return "qrc:/images/general/" + sourceName + ".png" + } + + smooth: true + + border { + left: leftBorder + right: rightBorder + } + + width: buttonText.width + 40 + + PropertyAnimation { + id: blinkAnimation + + target: button + properties: "opacity" + loops: 2 + from: 0 + to: 1 + duration: 200 + + onRunningChanged: { + if (!running) + button.clicked() + } + } + + Text { + id: buttonText + + text: button.text + smooth: true + + color: { + if (button.enabled) + "#77262d" + else + "#666666" + } + + anchors { + centerIn: parent + verticalCenterOffset: -3 + horizontalCenterOffset: button.horizontalCenterOffset + } + + font { + family: "Nokia Sans" + pixelSize: 26 + bold: true + italic: button.italic + } + } + + MouseArea { + id: mouseArea + + enabled: button.enabled + anchors.fill: parent + onClicked: { + if (blink) + blinkAnimation.running = true + else + button.clicked() + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/ConfirmationDialog.qml b/chicken-wranglers/src/qml/widgets/ConfirmationDialog.qml new file mode 100644 index 0000000..90e922d --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ConfirmationDialog.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +BaseDialog { + id: dialog + + property string text: "Confirmation Dialog" + property string rejectText: "No" + property string acceptText: "Yes" + property int buttonWidth: 160 + + signal rejected() + signal accepted() + + Text { + color: "#4d908f" + text: dialog.text + style: Text.Raised + styleColor: "white" + + anchors.fill: box + anchors.margins: 60 + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + + font { + family: "Nokia Sans" + pixelSize: 34 + } + } + + Button { + id: rejectButton + + width: buttonWidth + text: dialog.rejectText + source: "qrc:/images/general/bt.png" + anchors { + verticalCenter: box.bottom + verticalCenterOffset: -25 + right: box.horizontalCenter + rightMargin: 20 + } + + onClicked: rejected() + } + + Button { + id: acceptButton + + width: buttonWidth + text: dialog.acceptText + source: "qrc:/images/general/bt.png" + anchors { + verticalCenter: box.bottom + verticalCenterOffset: -25 + left: box.horizontalCenter + leftMargin: 20 + } + + onClicked: accepted() + } +} diff --git a/chicken-wranglers/src/qml/widgets/ConnectivityDialog.qml b/chicken-wranglers/src/qml/widgets/ConnectivityDialog.qml new file mode 100644 index 0000000..c7a4f99 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ConnectivityDialog.qml @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +BaseDialog { + id: dialog + + property string buttonText: "Use it" + property string cancelText: "Cancel" + property ConnectivityListModel model: ConnectivityListModel {} + signal cancel() + + Connections { + target: dialog + onHideFinished: { + title.text = "Scanning..." + button.enabled = true + quitButton.enabled = true + } + } + + ConfirmationDialog { + id: quitDialog + + text: "Do you want to cancel scanning?" + opacity: 0 + + onRejected: { + quitDialog.hide() + } + + onAccepted: { + quitDialog.hide() + dialog.cancel() + } + + z: 10 + } + + Text { + id: title + + text: "Scanning..." + style: Text.Raised + styleColor: "white" + color: "#4d908f" + + font { + family: "Nokia Sans" + bold: true + pixelSize: 34 + } + + anchors.top: box.top + anchors.topMargin: 60 + anchors.left: parent.left + anchors.right: parent.right + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + ConnectivityListView { + id: listView + + property real scrollSize: 200 + + width: 400 + height: 200 + model: dialog.model + anchors.top: title.bottom + anchors.topMargin: 15 + anchors.bottom: box.bottom + anchors.bottomMargin: 80 + anchors.horizontalCenter: parent.horizontalCenter + + onContentYChanged: { + scrollbar.setValue((contentY / scrollSize) * 100) + } + + onMovingChanged: { + if (moving) + scrollbar.opacity = 1; + else + scrollbar.opacity = 0; + } + } + + Scrollbar { + id: scrollbar + + opacity: 0 + anchors.top: title.bottom + anchors.bottom: box.bottom + anchors.left: listView.right + anchors.leftMargin: 20 + + Behavior on opacity { + NumberAnimation { + duration: 500 + easing.type: Easing.OutCirc + } + } + } + + Button { + id: button + + text: dialog.buttonText + anchors { + verticalCenter: box.bottom + verticalCenterOffset: -25 + horizontalCenter: box.horizontalCenter + horizontalCenterOffset: 90 + } + + onClicked: { + button.enabled = false + quitButton.enabled = false + title.text = "Connecting..." + + if (listView.currentIndex != -1) + listView.model.selectedIndex = listView.currentIndex + } + } + + Button { + id: quitButton + text: dialog.cancelText + anchors { + verticalCenter: box.bottom + verticalCenterOffset: -25 + horizontalCenter: box.horizontalCenter + horizontalCenterOffset: -90 + } + + onClicked: { + if (quitDialog.opacity == 0) { + quitDialog.show() + } + } + } +} + diff --git a/chicken-wranglers/src/qml/widgets/ConnectivityListModel.qml b/chicken-wranglers/src/qml/widgets/ConnectivityListModel.qml new file mode 100644 index 0000000..df1449f --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ConnectivityListModel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +ListModel { + ListElement { + // N8 cellphone + name: "cw"; address: "18:14:56:44:F4:DB" + category: 2; pairing: 1 + } + + ListElement { + name: "5800gard"; address: "00:25:CF:11:2B:8A" + category: 2; pairing: 1 + } + + ListElement { + name: "FabyAAAAAAAAAAAAAAAAAAAAAAAAAA"; address: "00:24:03:DA:45:00" + category: 1; pairing: 0 + } + + ListElement { + name: "device-0BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"; address: "00:24:03:DA:45:00" + category: 1; pairing: 0 + } + + ListElement { + name: "pc-1"; address: "00:24:03:DA:45:00" + category: 1; pairing: 0 + } + + ListElement { + name: "device-1"; address: "00:24:03:DA:45:00" + category: 1; pairing: 0 + } + + ListElement { + name: "mobile-0"; address: "00:24:03:DA:45:00" + category: 1; pairing: 0 + } +} + diff --git a/chicken-wranglers/src/qml/widgets/ConnectivityListView.qml b/chicken-wranglers/src/qml/widgets/ConnectivityListView.qml new file mode 100644 index 0000000..ca04c5b --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ConnectivityListView.qml @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 +import game.types 1.0 + +ListView { + id: listView + + Component { + id: delegate + + Item { + width: lineDivisor.width + height: 43 + + Image { + id: lineDivisor + + source: "qrc:/images/general/list_line_divisor.png" + + anchors.top: parent.top + } + + Text { + text: name + + width: parent.width - 110 + + style: Text.Raised + styleColor: "white" + + color: "#4d908f" + + font { + family: "Nokia Sans" + bold: true + pixelSize: 21 + } + + elide: Text.ElideRight + + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 23 + + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + MouseArea { + anchors.fill: parent + + onClicked: { + var pos = mapToItem(listView.contentItem, mouseX, mouseY) + var selectedIndex = listView.indexAt(pos.x, pos.y) + + if (selectedIndex == listView.currentIndex) { + listView.currentIndex = -1 + } else { + listView.currentIndex = selectedIndex + } + } + } + } + } + + model: ConnectivityListModel {} + delegate: delegate + + focus: false + clip: true + + Component { + id: highlightIcon + + Item { + width: listView.width + height: 43 + + Image { + source: "qrc:/images/general/list_selected_icon.png" + + anchors.left: parent.right + anchors.leftMargin: -70 + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 1 + } + } + } + + currentIndex: model.selectedIndex + + highlight: highlightIcon + highlightMoveDuration: 100 + + snapMode: ListView.SnapToItem +} + diff --git a/chicken-wranglers/src/qml/widgets/Countdown.qml b/chicken-wranglers/src/qml/widgets/Countdown.qml new file mode 100644 index 0000000..31b5ad9 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Countdown.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Item { + id: countdown + + property int startValue: 3 + property int currentValue: startValue + property int interval: 800 + property string timeoutText: "Go!" + + signal timeout + + function start() { + countdown.opacity = 1 + animation.start() + } + + function decrement() { + if (currentValue - 1 > 0) { + currentValue-- + return + } + + if (currentValue == 1) { + number.text = countdown.timeoutText + currentValue-- + return + } + + countdown.opacity = 0 + countdown.timeout() + } + + Text { + id: number + + text: currentValue + smooth: true + anchors.centerIn: parent + color: "white" + + font { + family: "Nokia Sans" + pointSize: 100 + bold: true + } + + style: Text.Outline + styleColor: "darkgreen" + } + + SequentialAnimation { + id: animation + + loops: startValue + 1 + + ParallelAnimation { + PropertyAnimation { duration: countdown.interval; target: number; property: "scale"; from: 1; to: 2 } + PropertyAnimation { duration: countdown.interval; target: number; property: "opacity"; from: 1; to: 0 } + } + + PropertyAction { target: number; properties: "scale,opacity"; value: 1 } + ScriptAction { script: countdown.decrement() } + } +} diff --git a/chicken-wranglers/src/qml/widgets/Feather.qml b/chicken-wranglers/src/qml/widgets/Feather.qml new file mode 100644 index 0000000..b46585c --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Feather.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "featherfall.js" as Feather + +Image { + id: feather + + property int xMax: 0 + property int xMin: 0 + property int yMax: 768 + + // the delay offset for the initial creation of each feather. + property real delay: 0 + + source: { + if (game.environment() == Global.Symbian) + "qrc:/images/general/symbian/feather1.png" + else + "qrc:/images/general/feather1.png" + } + smooth: true + y: -feather.height + + function startAnimation() { + animY.running = true + animX.running = true + animRotation.running = true + } + + function stopAnimation() { + animY.running = false + animX.running = false + animRotation.running = false + } + + SequentialAnimation on y { + id: animY + + running: false + + PauseAnimation { duration: delay } + NumberAnimation { to: 100; easing.type: Easing.InOutSine; duration: 1050 } + NumberAnimation { to: 300; easing.type: Easing.InOutSine; duration: 950 } + NumberAnimation { to: 500; easing.type: Easing.InOutSine; duration: 1050 } + NumberAnimation { to: 700; easing.type: Easing.InOutSine; duration: 950 } + NumberAnimation { to: 900; easing.type: Easing.InOutSine; duration: 1050 } + NumberAnimation { to: yMax + 2 * feather.height; easing.type: Easing.InOutSine; duration: 950 } + + onRunningChanged: { + if (!running) + feather.destroy() + } + } + + SequentialAnimation on x { + id: animX + + running: false + + PauseAnimation { duration: delay } + NumberAnimation { to: xMax; easing.type: Easing.InOutSine; duration: 950 } + NumberAnimation { to: xMin; easing.type: Easing.InOutSine; duration: 1050 } + NumberAnimation { to: xMax; easing.type: Easing.InOutSine; duration: 950 } + NumberAnimation { to: xMin; easing.type: Easing.InOutSine; duration: 1050 } + NumberAnimation { to: xMax; easing.type: Easing.InOutSine; duration: 950 } + NumberAnimation { to: xMin; easing.type: Easing.InOutSine; duration: 1050 } + } + + SequentialAnimation on rotation { + id: animRotation + + running: false + + PauseAnimation { duration: delay } + NumberAnimation { to: -40; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: 25; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: -40; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: 25; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: -40; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: 25; easing.type: Easing.InOutSine; duration: 1000 } + NumberAnimation { to: -40; easing.type: Easing.InOutSine; duration: 1000 } + } +} diff --git a/chicken-wranglers/src/qml/widgets/FeatherFall.qml b/chicken-wranglers/src/qml/widgets/FeatherFall.qml new file mode 100644 index 0000000..d8b49d7 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/FeatherFall.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +import game.types 1.0 +import "featherfall.js" as FeatherFall + +Item { + id: featherFall + + property real fallWidth: 800 + property real fallHeight: 768 + property int number: 5 + + function start() { + timer.start() + } + + function stop() { + timer.stop() + FeatherFall.destroy() + } + + Timer { + id: timer + + triggeredOnStart: true + repeat: true + interval: 6000 + onTriggered: { + FeatherFall.create(featherFall.width, featherFall.height) + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/ImageButton.qml b/chicken-wranglers/src/qml/widgets/ImageButton.qml new file mode 100644 index 0000000..2ccdbf1 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ImageButton.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Image { + id: button + + property bool blink: false + property string name: "" + property string path: "qrc:/images/general" + property alias buttonPressed: mouseArea.pressed + + signal clicked + + smooth: true + source: { + if (path == "") + return "" + + if (mouseArea.pressed) + path + "/bt_" + name + "_pressed.png" + else + path + "/bt_" + name + ".png" + } + + PropertyAnimation { + id: blinkAnimation + + target: button + properties: "opacity" + loops: 2 + from: 0 + to: 1 + duration: 200 + + onRunningChanged: { + if (!running) + button.clicked() + } + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + onClicked: { + if (blink) + blinkAnimation.running = true + else + button.clicked() + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/Loading.qml b/chicken-wranglers/src/qml/widgets/Loading.qml new file mode 100644 index 0000000..19eeff5 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Loading.qml @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Item { + id: loading + + property int count: 0 + + width: row.width + height: row.height + + Component { + id: dot + + Rectangle { + id: outer + + width: 15 + height: 15 + color: "#e0fce5" + radius: 50 + smooth: true + + Rectangle { + id: inner + + anchors.centerIn: parent + + smooth: true + color: "#9bbaae" + radius: 50 + + anchors.fill: parent + anchors.margins: 3 + } + + states { + State { + name: "off" + PropertyChanges { target: outer; scale: 1 } + PropertyChanges { target: inner; color: "#9bbaae" } + } + State { + name: "on" + PropertyChanges { target: outer; scale: 1.33 } + PropertyChanges { target: inner; color: "#f6c200" } + } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: outer; property: "scale"; easing.type: Easing.InOutQuad } + ColorAnimation { target: inner; property: "color"; easing.type: Easing.InOutQuad } + } + } + } + } + + Row { + id: row + + spacing: 4 + + children: [ + Loader { sourceComponent: dot }, + Loader { sourceComponent: dot }, + Loader { sourceComponent: dot } + ] + } + + Timer { + id: timer + + repeat: true + interval: 200 + running: true + + onTriggered: { + if (count > 0) + row.children[count - 1].item.state = "off" + + if (count < row.children.length) + row.children[count].item.state = "on" + + count = (count + 1) % (row.children.length + 1) + } + } + + onOpacityChanged: { + if (opacity == 1 && !timer.running) { + timer.start() + } + else if (opacity == 0 && timer.running) { + timer.stop() + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/MessageDialog.qml b/chicken-wranglers/src/qml/widgets/MessageDialog.qml new file mode 100644 index 0000000..44cc8d1 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/MessageDialog.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +BaseDialog { + id: dialog + + property string text: "Message Dialog" + property string buttonText: "Ok" + + signal buttonClicked + + Text { + color: "#4d908f" + text: dialog.text + style: Text.Raised + styleColor: "white" + + anchors.fill: box + anchors.margins: 60 + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + + font { + family: "Nokia Sans" + pixelSize: 34 + } + } + + Button { + id: button + + text: dialog.buttonText + anchors { + verticalCenter: box.bottom + verticalCenterOffset: -25 + horizontalCenter: box.horizontalCenter + } + + onClicked: buttonClicked() + } +} + diff --git a/chicken-wranglers/src/qml/widgets/OptionSlider.qml b/chicken-wranglers/src/qml/widgets/OptionSlider.qml new file mode 100644 index 0000000..205f299 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/OptionSlider.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Item { + id: slider + + property string option: "Wifi" + + signal selected(string option) + + width: sliderSelector.width + height: sliderPath.height + + Image { + id: sliderPath + + anchors.centerIn: parent + + source: "qrc:/images/general/slider_path.png" + } + + Image { + anchors { + horizontalCenter: slider.horizontalCenter + bottom: slider.verticalCenter + bottomMargin: 21 + } + + source: "qrc:/images/general/slider_wifi_icon.png" + } + + Image { + anchors { + horizontalCenter: slider.horizontalCenter + horizontalCenterOffset: 3 + top: slider.verticalCenter + topMargin: 16 + } + + source: "qrc:/images/general/slider_bluetooth_icon.png" + } + + Image { + id: sliderSelector + + source: "qrc:/images/general/slider_selector.png" + + x: 0 + y: 10 + + Behavior on y { + NumberAnimation { + id: slideAnimation + + duration: 500 + easing.type: Easing.OutCirc + } + } + } + + MouseArea { + anchors.fill: parent + + enabled: !slideAnimation.running + + onReleased: { + // Wifi selected + if (mouse.y <= ((slider.height / 2) - 1)) { + if (slider.option != "Wifi") { + slider.option = "Wifi" + + selected(slider.option) + + sliderSelector.y = 10 + } + + // Bluetooth selected + } else { + if (slider.option != "Bluetooth") { + slider.option = "Bluetooth" + + selected(slider.option) + + sliderSelector.y = (slider.height / 2) - 10 + } + } + } + } +} + diff --git a/chicken-wranglers/src/qml/widgets/Screen.qml b/chicken-wranglers/src/qml/widgets/Screen.qml new file mode 100644 index 0000000..967f443 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Screen.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Rectangle { + id: screen + + signal transitionFinished(bool visible) + + anchors.fill: parent + opacity: 0 + + function show() { + screen.state = "visible" + } + + function hide() { + screen.state = "hidden" + } + + states { + State { + name: "visible" + PropertyChanges { target: screen; opacity: 1 } + } + State { + name: "hidden" + PropertyChanges { target: screen; opacity: 0 } + } + } + + Behavior on opacity { + NumberAnimation { + duration: 200 + + onRunningChanged: { + if (!running) { + if (opacity == 1) + transitionFinished(true) + else + transitionFinished(false) + } + } + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/Scrollbar.qml b/chicken-wranglers/src/qml/widgets/Scrollbar.qml new file mode 100644 index 0000000..0d59208 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/Scrollbar.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Item { + id: scrollbar + + property real value: 0.0 + property real minimumValue: 0.0 + property real maximumValue: 100.0 + property real offset: 8.0 + property real minimumPos: offset + property real maximumPos: scrollbarPath.height - scrollbarKnob.height - offset + property real scrollSize: maximumPos - minimumPos + 1 + + width: scrollbarKnob.width + height: scrollbarPath.height + + function setValue(newValue) { + if (newValue <= minimumValue) { + value = minimumValue; + } else if (newValue >= maximumValue) { + value = maximumValue; + } else { + value = newValue; + } + } + + Image { + id: scrollbarPath + + anchors.centerIn: parent + + source: "qrc:/images/general/list_scrollbar_path.png" + } + + Image { + id: scrollbarKnob + + anchors.horizontalCenter: parent.horizontalCenter + + y: ((scrollbar.value / scrollbar.maximumValue) * scrollbar.scrollSize) + scrollbar.offset + + source: "qrc:/images/general/list_scrollbar_knob.png" + } +} + diff --git a/chicken-wranglers/src/qml/widgets/ToggleButton.qml b/chicken-wranglers/src/qml/widgets/ToggleButton.qml new file mode 100644 index 0000000..939602f --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/ToggleButton.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** This file is a part of QtChickenWranglers. +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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." +** +****************************************************************************/ + + +import Qt 4.7 + +Image { + id: button + signal clicked + property string mode: "bluetooth" + source: "qrc:/images/general/toggle_bt.png" + + MouseArea { + id: mouseArea + + anchors.fill: parent + onClicked: { + if (button.mode == "bluetooth") { + button.mode = "lan" + button.source = "qrc:/images/general/toggle_lan.png" + } else { + button.mode = "bluetooth" + button.source = "qrc:/images/general/toggle_bt.png" + } + + game.setConnectivity(button.mode) + } + } +} diff --git a/chicken-wranglers/src/qml/widgets/featherfall.js b/chicken-wranglers/src/qml/widgets/featherfall.js new file mode 100644 index 0000000..6ae51a4 --- /dev/null +++ b/chicken-wranglers/src/qml/widgets/featherfall.js @@ -0,0 +1,66 @@ +var component; +var featherObjList = new Array; + +function create(fallWidth, fallHeight) { + var i, range, lowRange, highRange; + + if (component == null) + component = Qt.createComponent("Feather.qml"); + + range = fallWidth / featherFall.number; + lowRange = -range; + highRange = 0; + + var resourcePath = ""; + if (game.environment() == Global.Symbian) + resourcePath = "qrc:/images/general/symbian/feather" + else + resourcePath = "qrc:/images/general/feather" + + for (i = 0; i < featherFall.number; i++) { + if (component.status == Component.Ready) { + + featherObjList[i] = component.createObject(background); + + if (featherObjList[i] == null) { + console.log("error creating featherObj"); + console.log(component.errorString()); + return false; + } + + lowRange = lowRange + range; + highRange = highRange + range; + + var xpos = (highRange - range) * Math.random() + lowRange; + featherObjList[i].x = xpos; + + featherObjList[i].delay = Math.random() * 3000 * i; + + var swing = Math.random() * range; + if (swing < 100) + swing += 100; + + featherObjList[i].xMax = xpos + swing; + featherObjList[i].xMin = xpos - swing; + featherObjList[i].yMax = fallHeight; + featherObjList[i].source = resourcePath + (Math.floor(5 * Math.random()) + 1) + ".png"; + + featherObjList[i].startAnimation(); + } else { + console.log("error loading featherObj component"); + console.log(component.errorString()); + return false; + } + } + + return true; +} + +function destroy() { + for (var i = 0; i < featherFall.number; i++) { + if (featherObjList[i] == null) + continue; + + featherObjList[i].destroy() + } +} |