/**************************************************************************** ** ** Copyright (C) 2011 Nokia Institute of Technology. ** All rights reserved. ** Contact: Manager (renato.chencarek@openbossa.org) ** ** This file is part of the Incredible Circus project. ** ** GNU Lesser General Public License Usage ** ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ import QtQuick 1.1 import Circus 1.0 import "widgets" Item { id: root signal nextClicked() signal menuClicked() signal restartClicked() property int scoreType: 1 property variant nextLevel property bool highscore: false property bool highscoreVisible: false property int recordValue: 0 property int totalScore: 0 property int scoreAnimationDuration: 1300 property double scoreValueWidth: 0 function showScore() { scoreAnimation.start(); } function resetScore() { scoreValue.value = 0; } function showBalloon() { balloonAnimation.start(); } function hideBalloon() { balloonAnimation.stop(); balloon.visible = false; } function showNotification() { notificationLoader.state = "visible"; } Image { anchors.fill: parent fillMode: Image.Tile source: "image://cache/common/bg.png" } Image { anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 41 * scaleFactor sourceSize.width: parent.width - 20 sourceSize.height: 80 * scaleFactor source: "image://title/" + qsTr("YOU WIN") } Loader { id: notificationLoader anchors { bottom: parent.top topMargin: 20 * scaleFactor horizontalCenter: parent.horizontalCenter } states: State { name: "visible" AnchorChanges { target: notificationLoader anchors.bottom: undefined anchors.top: parent.top } } transitions: Transition { AnchorAnimation { duration: 1000 easing.type: Easing.OutQuart } } Component.onCompleted: { notificationLoader.sourceComponent = notificationComponent; } } Component { id: notificationComponent UnlockedNotification { onClicked: menuClicked() } } Frame { id: frame anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter title: qsTr("Congratulations") background: "image://cache/screens/youwin/frame.png" Image { source: { if (scoreType == LevelModel.GoldScore) return "image://cache/screens/youwin/gold_trophy.png" else if (scoreType == LevelModel.SilverScore) return "image://cache/screens/youwin/silver_trophy.png" else return "image://cache/screens/youwin/bronze_trophy.png" } anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 8 * scaleFactor } Image { id: scoreBoard source: "image://cache/screens/youwin/scoreboard.png" anchors { top: parent.top horizontalCenter: parent.horizontalCenter topMargin: 200 * scaleFactor } Label { text: qsTr("Score Board") anchors.fill: parent anchors.topMargin: 5 * scaleFactor fontSize: 18 * scaleFactor color: "#a56d26" } } Item { id: scoreBoardPane anchors { top: scoreBoard.bottom topMargin: 10 * scaleFactor left: parent.left right: parent.right bottom: parent.bottom } Item { width: childrenRect.width height: childrenRect.height anchors { centerIn: parent } Label { id: recordLabel text: qsTr("RECORD") effect: SimpleText.Decal horizontalAlignment: SimpleText.AlignRight fontSize: 22 * scaleFactor color: "#a56d26" visible: root.highscoreVisible anchors { top: parent.top left: parent.left } } Label { id: scoreLabel text: qsTr("SCORE") effect: SimpleText.Decal horizontalAlignment: SimpleText.AlignRight fontSize: 24 * scaleFactor color: "#a56d26" anchors { top: root.highscoreVisible ? recordLabel.bottom : parent.top right: root.highscoreVisible ? recordLabel.right : undefined left: root.highscoreVisible ? undefined : parent.left } } Label { id: recordValue effect: SimpleText.Digit fontSize: 21 * scaleFactor color: "#00b0b2" horizontalAlignment: SimpleText.AlignLeft text: root.recordValue visible: root.highscoreVisible anchors { top: recordLabel.top left: recordLabel.right leftMargin: 3 * scaleFactor } } Label { id: scoreValue property int value: 0 fontSize: 48 * scaleFactor color: "#00b0b2" horizontalAlignment: SimpleText.AlignLeft text: value width: root.scoreValueWidth anchors { left: scoreLabel.right leftMargin: 3 * scaleFactor top: scoreLabel.top topMargin: -2 * scaleFactor } onValueChanged: { if (value == root.totalScore && manager.hasExtraLevels(manager.currentWorld.index) && manager.canUnlockExtraLevels(manager.currentWorld.index)) { manager.unlockExtraLevels(manager.currentWorld.index); root.showNotification(); } } SequentialAnimation { id: scoreAnimation NumberAnimation { target: scoreValue; property: "value"; duration: scoreAnimationDuration; from: 0; to: totalScore; } SequentialAnimation { loops: 3 NumberAnimation { target: scoreValue; property: "opacity"; duration: 500; from: 1.0; to: 0.0; } NumberAnimation { target: scoreValue; property: "opacity"; duration: 500; from: 0.0; to: 1.0; } } } } } } } Item { clip: true anchors.fill: frame anchors.bottomMargin: 40 * scaleFactor Image { id: balloon source: "image://cache/screens/youwin/balloon.png" property int yTarget: parent.height - (246 * scaleFactor) ParallelAnimation { id: balloonAnimation NumberAnimation { target: balloon; property: "x"; easing.type: Easing.OutQuad; duration: 2400; from: parent.width - balloon.width - (84 * scaleFactor); to: parent.width - balloon.width - (6 * scaleFactor) } SequentialAnimation { PropertyAction { target: balloon; property: "visible"; value: true; } NumberAnimation { target: balloon; property: "y"; easing.type: Easing.OutCubic; duration: 1800; from: parent.height; to: balloon.yTarget } NumberAnimation { target: balloon; property: "y"; easing.type: Easing.Linear; duration: 1600; to: balloon.yTarget + (6 * scaleFactor)} NumberAnimation { target: balloon; property: "y"; easing.type: Easing.Linear; duration: 2000; to: balloon.yTarget } } } Item { rotation: -18 anchors { top: parent.top topMargin: 34 * scaleFactor horizontalCenter: parent.horizontalCenter horizontalCenterOffset: -5 } Label { id: newText text: qsTr("NEW") fontSize: 28 * scaleFactor color: "#5c2900" opacity: 0.8 anchors { top: parent.top horizontalCenter: parent.horizontalCenter } } Label { width: newText.width height: newText.height anchors { top: newText.bottom topMargin: -12 horizontalCenter: newText.horizontalCenter } text: qsTr("RECORD") fontSize: 14 * scaleFactor color: "#5c2900" opacity: newText.opacity } } } } BottomBar { Button { text: qsTr("Menu") onClicked: menuClicked() } Button { text: qsTr("Play Again") onClicked: restartClicked() } Button { id: nextButton visible: nextLevel != null text: qsTr("Next") onClicked: nextClicked() } } function updateScoreValueWidth() { root.scoreValueWidth = scoreValue.getTextSize(root.totalScore).width } onMenuClicked: notificationLoader.state = "" onRestartClicked: notificationLoader.state = "" onNextClicked: notificationLoader.state = "" }