diff --git a/src/activities/intro_gravity/IntroGravity.qml b/src/activities/intro_gravity/IntroGravity.qml index 06609bfed..b68bb448d 100644 --- a/src/activities/intro_gravity/IntroGravity.qml +++ b/src/activities/intro_gravity/IntroGravity.qml @@ -1,214 +1,243 @@ /* GCompris - intro_gravity.qml * * Copyright (C) 2015 Siddhesh suthar * * Authors: * Bruno Coudoin and Matilda Bernard (GTK+ version) * Siddhesh suthar (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.2 import GCompris 1.0 import "../../core" import "intro_gravity.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} property int oldWidth: width onWidthChanged: { // Reposition planets and asteroids, same for height Activity.repositionObjectsOnWidthChanged(width / oldWidth) oldWidth = width } property int oldHeight: height onHeightChanged: { // Reposition planets and asteroids, same for height Activity.repositionObjectsOnHeightChanged(height / oldHeight) oldHeight = height } pageComponent: Image { id: background anchors.fill: parent source: Activity.url+"background.svg" sourceSize.width: parent.width fillMode: Image.PreserveAspectCrop signal start signal stop Component.onCompleted: { activity.start.connect(start) activity.stop.connect(stop) } // Add here the QML items you need to access in javascript QtObject { id: items property Item main: activity.main property alias background: background property alias bar: bar property alias bonus: bonus property alias planetLeft: planetLeft property alias planetRight: planetRight property alias scaleLeft: planetLeft.value property alias scaleRight: planetRight.value property alias spaceship: spaceship property alias shuttle: shuttle property alias shuttleMotion: shuttleMotion property alias timer: timer property alias arrow: arrow property alias asteroidCreation: asteroidCreation property GCAudio audioEffects: activity.audioEffects property double distLeft: Math.abs(spaceshipX) property double distRight: Math.abs(background.width - spaceshipX) property double forceLeft: (Math.pow(scaleLeft, 2) / Math.pow(distLeft, 2)) * Math.pow(10, 6) property double forceRight: (Math.pow(scaleRight, 2) / Math.pow(distRight, 2)) * Math.pow(10, 6) // the center value for the spaceship property double spaceshipX property double spaceshipY: parent.height / 2 + property alias trigger: trigger } onStart: Activity.start(items,message) onStop: Activity.stop() DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level | reload } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: Activity.initLevel() - } + } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } + Timer { + id: trigger + onTriggered: { + items.timer.start() + items.asteroidCreation.start() + items.shuttleMotion.restart() + } + } - Message { + IntroMessage { id: message + intro: [ + "", + qsTr("Gravity is universal and Newton's law of universal gravitation extends gravity" + +" beyond earth. This force of gravitational attraction is directly dependent" + +" upon the masses of both objects and inversely proportional to" + +" the square of the distance that separates their centers."), + qsTr("Since the gravitational force is directly proportional to the mass of both interacting " + +"objects, more massive objects will attract each other with a greater gravitational " + +"force. So as the mass of either object increases, the force of gravitational " + +"attraction between them also increases"), + qsTr("But this force is inversely proportional to the square of the separation distance " + +"between the two interacting objects, more separation distance will " + +"result in weaker gravitational forces."), + qsTr("Your goal is to let Tux's spaceship move by changing the mass " + +"of its surrounding planets. Don't get too close to the planets " + +"or you will crash on them. " + +"The arrow indicates the direction of the force on your ship."), + qsTr("Avoid the asteroid and join the space " + +"shuttle to win.") + ] z: 20 anchors { top: parent.top topMargin: 10 right: parent.right rightMargin: 5 left: parent.left leftMargin: 5 } } Planet { id: planetLeft x: 0 width: parent.width * 0.5 height: parent.height planetSource: Activity.url + "saturn.svg" planetWidth: 240 * ApplicationInfo.ratio isLeft: true } Planet { id: planetRight x: parent.width / 2 width: parent.width * 0.5 height: parent.height planetSource: Activity.url + "neptune.svg" planetWidth: 184 * ApplicationInfo.ratio isLeft: false } Image { id: spaceship source: Activity.url + "tux_spaceship.svg" sourceSize.width: 120 * ApplicationInfo.ratio x: items.spaceshipX - width / 2 y: items.spaceshipY - height / 2 } // line to show force magnitude and direction Image { id: arrow visible: !message.displayed && width > 6 && timer.running x: items.forceLeft < items.forceRight ? items.spaceshipX : items.spaceshipX - width y: spaceship.y - 80 z: 11 sourceSize.width: 120 * 10 * ApplicationInfo.ratio width: Math.min(background.width / 4, Math.abs(items.forceLeft - items.forceRight) * 6) height: 40 * ApplicationInfo.ratio source: Activity.url +"arrow.svg" rotation: items.forceLeft > items.forceRight ? 0 : 180 Behavior on rotation { NumberAnimation{ duration: 100 } } Behavior on width { NumberAnimation{ duration: 100 } } } Image { id: shuttle source: Activity.url + "space_shuttle.svg" sourceSize.width: 80 * ApplicationInfo.ratio z: 10 NumberAnimation { id: shuttleMotion target: shuttle property: "y" to: 0 - shuttle.height duration: 40000 / (Activity.currentLevel+1) } } Timer { id: timer interval: 16 running: false repeat: true onTriggered: { Activity.movespaceship() Activity.handleCollisionWithAsteroid() } } Timer { id: asteroidCreation running: false repeat: true interval: 10200 - (bar.level * 200) onTriggered: Activity.createAsteroid() } } } diff --git a/src/activities/intro_gravity/Message.qml b/src/activities/intro_gravity/Message.qml deleted file mode 100644 index 0bc777bfc..000000000 --- a/src/activities/intro_gravity/Message.qml +++ /dev/null @@ -1,154 +0,0 @@ -/*GCompris-Qt Message.qml -* -* Copyright (C) 2015 Siddhesh suthar -* -* Authors: -* Bruno Coudoin and Matilda Bernard (GTK+ version) -* Siddhesh suthar (Qt Quick port) -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, see . -*/ - -import QtQuick 2.1 -import "../../core" -import GCompris 1.0 -import "intro_gravity.js" as Activity - -Item{ - id: message - opacity: displayed ? 1 : 0 - - property bool displayed: index == 0 ? false : true - - // The message in the intro array, set to 0 to disable - property int index: 1 - - property variant intro: [ - "", - qsTr("Gravity is universal and Newton's law of universal gravitation extends gravity" - +" beyond earth. This force of gravitational attraction is directly dependent" - +" upon the masses of both objects and inversely proportional to" - +" the square of the distance that separates their centers."), - qsTr("Since the gravitational force is directly proportional to the mass of both interacting " - +"objects, more massive objects will attract each other with a greater gravitational " - +"force. So as the mass of either object increases, the force of gravitational " - +"attraction between them also increases"), - qsTr("But this force is inversely proportional to the square of the separation distance " - +"between the two interacting objects, more separation distance will " - +"result in weaker gravitational forces."), - qsTr("Your goal is to let Tux's spaceship move by changing the mass " - +"of its surrounding planets. Don't get too close to the planets " - +"or you will crash on them. " - +"The arrow indicates the direction of the force on your ship."), - qsTr("Avoid the asteroid and join the space " - +"shuttle to win.") - ] - - Behavior on opacity { NumberAnimation {duration: 100 } } - - Rectangle { - id: intro_textbg - x: intro_text.x -4 - y: intro_text.y -4 - width: intro_text.width +4 - height: intro_text.height +4 - color: "#d8ffffff" - border.color: "#2a2a2a" - border.width: 2 - radius: 8 - } - - GCText { - id: intro_text - fontSize: regularSize - font.weight: Font.DemiBold - horizontalAlignment: Text.AlignHCenter - anchors { - top: parent.top - topMargin: 10 *ApplicationInfo.ratio - right: parent.right - rightMargin: 5 * ApplicationInfo.ratio - left: parent.left - leftMargin: 5 * ApplicationInfo.ratio - } - width: parent.width - wrapMode: Text.WordWrap - text: parent.intro[parent.index] - } - - Rectangle { // our inlined button ui - id: button - width: Math.max(skipText.width, nextText.width) * 1.2 - height: Math.max(skipText.height, nextText.height) * 1.4 - x: intro_textbg.x + (intro_textbg.width/2) + 20 - y: intro_textbg.y + intro_textbg.height - button.height - 5 - color: "#d8ffffff" - border.color: "#2a2a2a" - border.width: 3 - radius: 8 - z: 5 - - anchors.top : intro_textbg.bottom - anchors.topMargin: 10 - - GCText { - id: nextText - anchors.centerIn: parent - text: index != 4 ? qsTr("Next") : qsTr("Let's Go") - } - - MouseArea { - anchors.fill: parent - onClicked: { - if(index++ == 4) { - index = 0 - items.timer.start() - items.asteroidCreation.start() - items.shuttleMotion.restart() - } - } - } - } - - Rectangle { // our inlined button ui - id: skipButton - width: button.width - height: button.height - x: intro_textbg.x + (intro_textbg.width/2) -20- skipButton.width - y: intro_textbg.y + intro_textbg.height - skipButton.height - 5 - color: "#d8ffffff" - border.color: "#2a2a2a" - border.width: 3 - radius: 8 - z: 5 - - anchors.top : intro_textbg.bottom - anchors.topMargin: 10 - GCText { - id: skipText - anchors.centerIn: parent - text: qsTr("Skip Instruction") - } - - MouseArea { - anchors.fill: parent - onClicked: { - message.index = 0 - items.timer.start() - items.asteroidCreation.start() - items.shuttleMotion.restart() - } - } - } -} diff --git a/src/core/IntroMessage.qml b/src/core/IntroMessage.qml index 126ed4696..013b89aa2 100644 --- a/src/core/IntroMessage.qml +++ b/src/core/IntroMessage.qml @@ -1,135 +1,134 @@ /*GCompris-Qt IntroMessage.qml * Copyright (C) 2015 Siddhesh suthar * * Authors: * * Siddhesh suthar * Sagar Chand Agarwal * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.1 import GCompris 1.0 Item { id: message opacity: displayed ? 1 : 0 visible: true property bool displayed: index == 0 ? false : true // The message in the intro array, set to 0 to disable property int index: 1 property variant intro; Behavior on opacity { NumberAnimation {duration: 100 } } Rectangle { id: intro_textbg x: intro_text.x -4 y: intro_text.y -4 width: intro_text.width +4 height: intro_text.height +4 color: "#d8ffffff" border.color: "#2a2a2a" border.width: 2 radius: 8 } GCText { id: intro_text fontSize: regularSize font.weight: Font.DemiBold horizontalAlignment: Text.AlignHCenter anchors { top: parent.top topMargin: 10 *ApplicationInfo.ratio right: parent.right rightMargin: 5 * ApplicationInfo.ratio left: parent.left leftMargin: 5 * ApplicationInfo.ratio } width: parent.width wrapMode: Text.WordWrap text: parent.intro[parent.index] } Rectangle { // our inlined button ui id: button width: Math.max(skipText.width, nextText.width) * 1.2 height: Math.max(skipText.height, nextText.height) * 1.4 x: intro_textbg.x + (intro_textbg.width/2) + 20 y: intro_textbg.y + intro_textbg.height - button.height - 5 color: "#d8ffffff" border.color: "#2a2a2a" border.width: 3 radius: 8 z: 5 anchors.top : intro_textbg.bottom anchors.topMargin: 10 GCText { id: nextText anchors.centerIn: parent - text: index != (intro.length - 1)? qsTr("Next") : qsTr("Let's Go") + text: index != (intro.length - 2)? qsTr("Next") : qsTr("Let's Go") } MouseArea { id: button_area anchors.fill: button onClicked: { - if(index++ == (intro.length - 1)) { + if(index++ == (intro.length - 2)) { index = 0 items.trigger.start() message.visible= false } } } } Rectangle { // our inlined button ui id: skipButton width: button.width height: button.height x: intro_textbg.x + (intro_textbg.width/2) -20- skipButton.width y: intro_textbg.y + intro_textbg.height - skipButton.height - 5 color: "#d8ffffff" border.color: "#2a2a2a" border.width: 3 radius: 8 z: 5 anchors.top : intro_textbg.bottom anchors.topMargin: 10 GCText { id: skipText anchors.centerIn: parent text: qsTr("Skip Instruction") } MouseArea { id: skipButton_area anchors.fill: parent onClicked: { message.index = 0 message.visible= false items.trigger.start() } } } - }