diff --git a/src/activities/hydroelectric/Hydro.qml b/src/activities/hydroelectric/Hydro.qml index 052d825eb..f36db7877 100644 --- a/src/activities/hydroelectric/Hydro.qml +++ b/src/activities/hydroelectric/Hydro.qml @@ -1,525 +1,520 @@ /* GCompris - hydro.qml * * Copyright (C) 2015 Sagar Chand Agarwal * * Authors: * Bruno Coudoin (GTK+ version) * Sagar Chand Agarwal (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 GCompris 1.0 import "../../core" - +import "hydroelectric.js" as Activity Item { id: hydro signal hydro IntroMessage { z: 20 anchors { top: parent.top topMargin: 10 right: parent.right rightMargin: 5 left: parent.left leftMargin: 5 } onIntroDone: { anim.running= true sun_area.visible= true } intro:[ qsTr("Tux has come back from a long fishing party on his boat. Bring the electrical system back up so he can have light in his home. "), qsTr("Click on different active elements : sun, cloud, dam, solar array, wind farm and transformers, in order to reactivate the entire electrical system."), qsTr("When the system is back up and Tux is in his home, push the light button for him. To win you must switch on all the consumers while all the producers are up. "), qsTr("Learn about an electrical system based on renewable energy. Enjoy. ") ] } Image { id: tuxboat opacity: 1 source: activity.url + "boat.svg" sourceSize.width: root.width*0.15 sourceSize.height: root.height*0.15 anchors{ bottom: parent.bottom bottomMargin: 15 } x: 0 z: 20 NumberAnimation on x { id: anim running: false to: root.width - tuxboat.width duration: 15000 onRunningChanged: { if(!anim.running) { tuxboat.opacity = 0 tuxparked.opacity = 1 tuxoff.visible= true } } } } Image { id: tuxparked source: activity.url + "boat_parked.svg" sourceSize.width: parent.width*0.15 sourceSize.height: parent.height*0.15 opacity: 0 anchors { right: parent.right bottom: parent.bottom bottomMargin: 20 } z: 20 } Image { id: sun source: activity.url + "sun.svg" sourceSize.width: parent.width*0.05 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.05 topMargin: parent.height*0.30 } MouseArea { id: sun_area anchors.fill: sun visible: false onClicked: { - if(sun_area.visible == true) - {console.log("visible")} hydro.state= "up" sun_area.visible= false } } } Image { id: mask source: activity.url + "mask.svg" sourceSize.width: parent.width*0.05 anchors{ left: parent.left top: parent.top leftMargin: parent.width*0.05 topMargin: parent.height*0.32 } } Image { id: vapor opacity: 0 state: "vapor" source: activity.url + "vapor.svg" sourceSize.width: parent.width*0.05 anchors { top: mask.bottom left: parent.left leftMargin: parent.width*0.05 } } Image { id: cloud2 visible: false source: activity.url + "cloud.svg" sourceSize.width: parent.width * 0.20 sourceSize.height: parent.height*0.10 anchors { left: parent.left top: parent.top leftMargin: 0.35*parent.width } Image { id: rain source: activity.url + "rain.svg" height:cloud2.height*2 width: cloud2.width anchors { top: cloud2.bottom } visible: true } } Image { id: cloud opacity: 0 source: activity.url + "cloud.svg" sourceSize.width: parent.width * 0.20 sourceSize.height: parent.height*0.10 anchors { left: parent.left top: parent.top leftMargin: 0.05*parent.width } MouseArea { anchors.fill: cloud onClicked: { hydro.state= "down" cloud2.visible= true river.visible= true anim2.running= true } } } Image { id: river source: activity.url + "river.svg" width: parent.width*0.415 height: parent.height*0.74 anchors { top: parent.top left: parent.left topMargin: parent.height*0.1775 leftMargin: parent.width*0.293 } visible: false } Image { id: reservoir1 source: activity.url + "hydroelectric/reservoir1.svg" width: parent.width*0.06 height: parent.height*0.15 anchors { top: parent.top left: parent.left topMargin: parent.height*0.2925 leftMargin: parent.width*0.3225 } opacity: 0 } Image { id: reservoir2 source: activity.url + "hydroelectric/reservoir2.svg" width: parent.width*0.12 height: parent.height*0.155 anchors { top: parent.top left: parent.left topMargin: parent.height*0.2925 leftMargin: parent.width*0.285 } opacity: 0 } Image { id: reservoir3 source: activity.url + "hydroelectric/reservoir3.svg" width: parent.width*0.2 height: parent.height*0.17 anchors { top: parent.top left: parent.left topMargin: parent.height*0.29 leftMargin: parent.width*0.25 } opacity: 0 } SequentialAnimation { id: anim2 running: false PropertyAnimation{ target: reservoir1 property: "opacity" to: 1 } PauseAnimation { - duration: 200 + duration: 1000 } PropertyAnimation{ target: reservoir2 property: "opacity" to: 1 } PauseAnimation { - duration: 200 + duration: 1000 } PropertyAnimation{ target: reservoir3 property: "opacity" to: 1 } onRunningChanged: { if(!anim2.running) { rain.visible= false cloud2.opacity= 0 dam_area.visible= true } } } Image { id: dam source: activity.url + "hydroelectric/dam.svg" width: river.width*0.12 sourceSize.height: parent.height*0.08 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.33 topMargin: parent.height*0.42 } MouseArea{ id: dam_area visible: false anchors.fill: dam onClicked:{ anim3.running= true damwire.visible= true } } } SequentialAnimation { id: anim3 running: false PropertyAnimation{ target: reservoir3 property: "opacity" to: 0 } PauseAnimation { - duration: 100 + duration: 1000 } PropertyAnimation{ target: reservoir2 property: "opacity" to: 0 } PauseAnimation { - duration: 100 + duration: 1000 } PropertyAnimation{ target: reservoir1 property: "opacity" to: 0 } onRunningChanged: { if(!anim3.running) { stepup1_area.visible= true dam_area.visible= false } } } Image { id: damwire source: activity.url+ "hydroelectric/damwire.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent visible: false } Image { id: stepup1 source: activity.url + "transformer.svg" sourceSize.width: parent.width*0.06 height: parent.height*0.09 anchors { top: parent.top left: parent.left topMargin: parent.height*0.435 leftMargin: parent.width*0.44 } MouseArea { id: stepup1_area visible: false anchors.fill: stepup1 onClicked: { stepupwire1.visible= true + stepup1_area.visible= false + Activity.activate_power() } } } Image { id: stepupwire1 source: activity.url + "hydroelectric/stepupwire.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent visible: false } //transitions,animations and state changes. states: [ State { name:"up" AnchorChanges { target: sun anchors { left: parent.left top: parent.top } } PropertyChanges { target: sun anchors { leftMargin: parent.width*0.05 topMargin: parent.height*0.05 } } AnchorChanges { target:vapor anchors { left: parent.left top: parent.top } } PropertyChanges { target: vapor opacity: 1 anchors { leftMargin: parent.width*0.05 topMargin: parent.height*0.15 } } AnchorChanges { target: cloud anchors { top: parent.top left: parent.left } } PropertyChanges { target: cloud opacity: 1 anchors { leftMargin: parent.width*0.35 } } } , State { name: "down" AnchorChanges { target: sun anchors { left:parent.left top:parent.top } } PropertyChanges{ target: cloud opacity:0 } PropertyChanges { target: vapor opacity: 0 } } ] transitions: [ Transition { to: "up" SequentialAnimation { AnchorAnimation { targets: sun duration: 3000 - } - NumberAnimation { target: vapor property: "opacity" duration:100 } AnchorAnimation { targets: vapor loops: 5 duration: 1000 } NumberAnimation { target: cloud property: "opacity" duration: 50 } AnchorAnimation { targets: cloud duration: 3000 } } } , Transition { from: "up" to: "down" SequentialAnimation { - PauseAnimation { - duration: 1000 - } + NumberAnimation { target: cloud property: "opacity" duration: 100 } NumberAnimation { target: vapor property: "opacity" duration: 100 } AnchorAnimation { targets: sun - duration: 1000 + duration: 3000 } } } ] - } diff --git a/src/activities/hydroelectric/Hydroelectric.qml b/src/activities/hydroelectric/Hydroelectric.qml index 1b909d557..2124efbb4 100755 --- a/src/activities/hydroelectric/Hydroelectric.qml +++ b/src/activities/hydroelectric/Hydroelectric.qml @@ -1,322 +1,343 @@ /* GCompris - hydroelectric.qml * * Copyright (C) 2015 Sagar Chand Agarwal * * Authors: * Bruno Coudoin (GTK+ version) * Sagar Chand Agarwal (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 GCompris 1.0 import "../../core" import "hydroelectric.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} property string url: "qrc:/gcompris/src/activities/hydroelectric/resource/" property int oldWidth: width onWidthChanged: { oldWidth: width } property int oldHeight: height onHeightChanged: { oldHeight: height } pageComponent: Item { id: background anchors.fill: parent 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 } Image { id: sky anchors.top: parent.top sourceSize.width: parent.width source: activity.url + "sky.svg" height: (background.height - landscape.paintedHeight) / 2 + landscape.paintedHeight * 0.3 } Image { id: sea anchors { left: parent.left bottom: parent.bottom } sourceSize.width: parent.width source: activity.url + "sea.svg" height : (background.height - landscape.paintedHeight) / 2 + landscape.paintedHeight * 0.7 } Image { id: landscape anchors.fill: parent sourceSize.width: parent.width sourceSize.height: parent.height source: activity.url + "landscape.svg" } Image { id: stepdown source: activity.url + "transformer.svg" sourceSize.width: parent.width*0.06 height: parent.height*0.09 anchors { top: parent.top left: parent.left topMargin: parent.height*0.41 leftMargin: parent.width*0.72 } MouseArea { - id: stepdown_area - visible: false anchors.fill: stepdown onClicked: { - stepdownwire.visible= true - resident_area.visible= true - off_area.visible= true + // console.log(Activity.count) + power() } } } Image { id: stepdownwire source: activity.url + "hydroelectric/stepdown.svg" sourceSize.width: parent.width anchors.fill: parent visible: false } // residents on and off section activated after step-down click Image { id: residentoff source: activity.url + "off.svg" sourceSize.height: parent.height*0.05 sourceSize.width: parent.height*0.05 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.60 topMargin: parent.height*0.65 } MouseArea { id: resident_area visible: false anchors.fill: residentoff onClicked: { residentlights.visible= true residentoff.visible= false residenton.visible= true } } } Image { id: residenton visible: false source: activity.url + "on.svg" sourceSize.height: parent.height*0.05 sourceSize.width: parent.height*0.05 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.60 topMargin: parent.height*0.65 } MouseArea { anchors.fill: residenton onClicked: { residentlights.visible= false residenton.visible= false residentoff.visible= true } } } Image { id: residentlights source: activity.url+ "residenton.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent visible: false } //tuxoff is visible when tuxboat animation stops and on is activated after stepdown is activated. Image { id: tuxoff source: activity.url + "lightsoff.svg" height: parent.height*0.2 width: parent.width*0.15 anchors { bottom: parent.bottom right: parent.right bottomMargin: parent.height* 0.3 rightMargin: parent.width*0.02 } visible: false Image { id: off source: activity.url + "off.svg" sourceSize.height: parent.height*0.20 sourceSize.width: parent.height*0.20 anchors { right: tuxoff.right top: tuxoff.top rightMargin: tuxoff.width*0.20 topMargin: tuxoff.height*0.30 } MouseArea { id: off_area visible: false anchors.fill: off onClicked: { tuxoff.visible= false tuxon.visible= true } } } } Image { id: tuxon source: activity.url + "lightson.svg" height: parent.height*0.2 width: parent.width*0.15 anchors { bottom: parent.bottom right: parent.right bottomMargin: parent.height* 0.3 rightMargin: parent.width*0.02 } Image { id: on source: activity.url + "on.svg" sourceSize.height: parent.height*0.20 sourceSize.width: parent.height*0.20 anchors { right: tuxon.right top: tuxon.top rightMargin: tuxon.width*0.20 topMargin: tuxon.height*0.30 } MouseArea { anchors.fill: on onClicked: { tuxoff.visible= true tuxon.visible= false } } } visible: false } function initiate() { unload() reload() } Loader { id: hydro anchors.fill: parent } Loader { id: wind anchors.fill: parent } Loader { id: solar anchors.fill: parent } function unload( ) { + stepdownwire.visible= false + resident_area.visible= false + off_area.visible= false + residenton.visible= false + tuxon.visible= false + residentoff.visible= true + residentlights.visible= false wind.source = "" hydro.source ="" solar.source= "" } function reload() { + if(Activity.currentLevel == 0) { + hydro.source = "Hydro.qml" + } if(Activity.currentLevel == 1) { wind.source = "Wind.qml" hydro.source = "Hydro.qml" } if(Activity.currentLevel == 2) { - solar.source = "Solar.qml" wind.source = "Wind.qml" hydro.source = "Hydro.qml" } - if(Activity.currentLevel == 0) { - hydro.source = "Hydro.qml" + } + + function power() { + if(Activity.currentLevel == 0 && Activity.count == 1) { + stepdownwire.visible= true + resident_area.visible= true + off_area.visible= true + } + if(Activity.currentLevel == 1 && Activity.count == 2) { + stepdownwire.visible= true + resident_area.visible= true + off_area.visible= true + } + if(Activity.currentLevel == 2 && Activity.count == 3) { + stepdownwire.visible= true + resident_area.visible= true + off_area.visible= true } } onStart: { Activity.start(items) } onStop: { Activity.stop() } DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } } } diff --git a/src/activities/hydroelectric/Solar.qml b/src/activities/hydroelectric/Solar.qml index 985c58f88..82510829d 100644 --- a/src/activities/hydroelectric/Solar.qml +++ b/src/activities/hydroelectric/Solar.qml @@ -1,108 +1,111 @@ /* GCompris - solar.qml * * Copyright (C) 2015 Sagar Chand Agarwal * * Authors: * Bruno Coudoin (GTK+ version) * Sagar Chand Agarwal (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 GCompris 1.0 +import "hydroelectric.js" as Activity Item { id: solar Image { id: solar_transformer source: activity.url + "transformer.svg" sourceSize.width: parent.width*0.05 height: parent.height*0.08 anchors { top: parent.top right: parent.right topMargin: parent.height*0.38 rightMargin: parent.width*0.11 } MouseArea { id: solar_area visible: false anchors.fill: solar_transformer onClicked: { solarpoweron.visible= true solarpoweroff.visible= false + solar_area.visible= false + Activity.activate_power() } } } Image { id: solarpoweron source: activity.url + "solar/solarpoweron.svg" sourceSize.width: parent.width anchors.fill: parent visible: false } Image { id: solarpoweroff source: activity.url + "solar/solarpoweroff.svg" sourceSize.width: parent.width anchors.fill: parent visible: true } Image { id: solarpaneloff source: activity.url + "solar/solarpaneloff.svg" sourceSize.width: parent.width*0.07 height: parent.height*0.09 anchors { top: parent.top right: parent.right topMargin: parent.height*0.31 rightMargin: parent.width*0.14 } visible: true MouseArea { anchors.fill: solarpaneloff onClicked: { solarpanelon.visible= true solar_area.visible= true } } } Image { id: solarpanelon source: activity.url + "solar/solarpanelon.svg" sourceSize.width: parent.width*0.07 height: parent.height*0.09 anchors { top: parent.top right: parent.right topMargin: parent.height*0.31 rightMargin: parent.width*0.14 } MouseArea { anchors.fill: solarpanelon onClicked: { solarpaneloff.visible= true solarpanelon.visible= false } } visible: false } visible: true } diff --git a/src/activities/hydroelectric/Wind.qml b/src/activities/hydroelectric/Wind.qml index 00472461d..1079bf45e 100644 --- a/src/activities/hydroelectric/Wind.qml +++ b/src/activities/hydroelectric/Wind.qml @@ -1,152 +1,154 @@ /* GCompris - wind.qml * * Copyright (C) 2015 Sagar Chand Agarwal * * Authors: * Bruno Coudoin (GTK+ version) * Sagar Chand Agarwal (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 GCompris 1.0 - +import "hydroelectric.js" as Activity Item { id: wind Image { id: cloud_quiet opacity: 1 source: activity.url + "wind/cloud_quiet.svg" sourceSize.width: parent.width * 0.20 sourceSize.height: parent.height*0.10 anchors { right: parent.right top: parent.top rightMargin: 0.05*parent.width } MouseArea { anchors.fill: cloud_quiet onClicked: { cloud_fury.opacity= 1 cloud_quiet.visible= false wind_anim.running= true wind_transformer_area.visible= true } } } Image { id: cloud_fury opacity: 0 source: activity.url + "wind/cloud_fury.svg" sourceSize.width: parent.width * 0.20 sourceSize.height: parent.height*0.10 anchors { right: parent.right top: parent.top rightMargin: 0.05*parent.width } } Image { id: wind_transformer source: activity.url + "transformer.svg" sourceSize.width: parent.width*0.035 height: parent.height*0.06 anchors { top: parent.top right: parent.right topMargin: parent.height*0.2 rightMargin: parent.width*0.18 } MouseArea { id: wind_transformer_area anchors.fill: wind_transformer visible: false onClicked: { wind_poweroff.opacity= 0 wind_poweron.opacity= 1 + wind_transformer_area.visible= false + Activity.activate_power() } } } Image { id: wind_poweroff source: activity.url + "wind/windpoweroff.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent opacity: 1 } Image { id: wind_poweron source: activity.url + "wind/windpoweron.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent opacity: 0 } Image { id:turbine1 source: activity.url + "wind/turbine1.svg" opacity: 1 sourceSize.width: parent.width*0.15 height: parent.height*0.15 anchors { top: parent.top right: parent.right topMargin: parent.height*0.13 rightMargin: parent.width*0.03 } } Image { id:turbine2 source: activity.url + "wind/turbine2.svg" opacity: 0 sourceSize.width: parent.width*0.15 height: parent.height*0.15 anchors { top: parent.top right: parent.right topMargin: parent.height*0.13 rightMargin: parent.width*0.03 } } SequentialAnimation { id: wind_anim running: false loops: Animation.Infinite PropertyAnimation { target:turbine1 property: "opacity" to: 1 } PropertyAnimation { target:turbine2 property: "opacity" to: 1 } } } diff --git a/src/activities/hydroelectric/hydroelectric.js b/src/activities/hydroelectric/hydroelectric.js index eaf387a83..d89833b45 100755 --- a/src/activities/hydroelectric/hydroelectric.js +++ b/src/activities/hydroelectric/hydroelectric.js @@ -1,57 +1,63 @@ /* GCompris - hydroelectric.js * * Copyright (C) 2015 Sagar Chand Agarwal * * Authors: * Bruno Coudoin (GTK+ version) * Sagar Chand Agarwal (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 . */ .pragma library .import QtQuick 2.0 as Quick var currentLevel = 0 var numberOfLevel = 3 var items - +var count = 0 function start(items_) { items = items_ currentLevel = 0 - initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 items.background.initiate() + count = 0 } function nextLevel() { if(numberOfLevel <= ++currentLevel ) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0 ) { currentLevel = numberOfLevel - 1 } initLevel(); } + +function activate_power() +{ + count = count + 1 +} +