diff --git a/src/activities/hydroelectric/Hydro.qml b/src/activities/hydroelectric/Hydro.qml index 481b7bd04..d0a602017 100644 --- a/src/activities/hydroelectric/Hydro.qml +++ b/src/activities/hydroelectric/Hydro.qml @@ -1,574 +1,599 @@ /* 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 state: "down" IntroMessage { id: message opacity: Activity.currentLevel == 0 ? true : start() 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. ") ] } function start() { message.opacity = 0 anim.running= true sun_area.visible= true } 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 Activity.tuxreached= true Activity.showtuxmeter() } } } } 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: { hydro.state= "up" sun_area.visible= false Activity.panel( true ) + cloudarea.start() } } } 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: 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 { + id: cloud_area + visible: false anchors.fill: cloud onClicked: { rain.visible= true river.visible= true anim2.running= true } } Image { id: rain source: activity.url + "rain.svg" height:cloud.height*2 width: cloud.width anchors { top: cloud.bottom } visible: false } } 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: 1000 } PropertyAnimation{ target: reservoir2 property: "opacity" to: 1 } PauseAnimation { duration: 1000 } PropertyAnimation{ target: reservoir3 property: "opacity" to: 1 } onRunningChanged: { if(!anim2.running) { hydro.state= "down" rain.visible= false cloud.opacity= 0 dam_area.visible= true if( Activity.currentLevel == 2) { panel_timer.start() } } } } Image{ - source: activity.url + "hydroelectric/hydro.svg" - width: dam.width + source: activity.url + "left.svg" + width: dam.width/2 height: dam.height*0.5 anchors { - left:dam.right - bottom: dam.bottom - } - Text { - id:dam_voltage - anchors.centerIn: parent - text: qsTr("0 W") + left:dam.left + leftMargin: parent.width*0.05 + top: dam.top + } + Rectangle{ + width: dam_voltage.width*1.5 + height: dam_voltage.height*1.1 + border.color: "black" + radius :5 + color:"yellow" + anchors { + left: parent.right + } + Text { + id: dam_voltage + anchors.centerIn: parent + text: qsTr("0 W") + } } } 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 dam_voltage.text= qsTr("900 W") } } } SequentialAnimation { id: anim3 running: false PropertyAnimation{ target: reservoir3 property: "opacity" to: 0 } PauseAnimation { duration: 1000 } PropertyAnimation{ target: reservoir2 property: "opacity" to: 0 } PauseAnimation { 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: { if(stepupwire1.visible == true){ stepupwire1.visible= false Activity.add(-900) Activity.volt(-900) Activity.update() Activity.verify() } else { stepupwire1.visible= true Activity.add(900) Activity.volt(900) Activity.update() } } } } 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: hydro.width*0.05 topMargin: hydro.height*0.05 } } AnchorChanges { target:vapor anchors { left: parent.left top: parent.top } } PropertyChanges { target: vapor opacity: 1 anchors { leftMargin: hydro.width*0.05 topMargin: hydro.height*0.15 } } AnchorChanges { target: cloud anchors { top: parent.top left: parent.left } } PropertyChanges { target: cloud opacity: 1 anchors { leftMargin: hydro.width*0.35 } } } , State { name: "down" AnchorChanges { target: sun anchors { left: parent.left top: parent.top } } PropertyChanges { target: sun anchors { leftMargin: hydro.width*0.05 topMargin: hydro.height*0.30 } } AnchorChanges { target: vapor anchors { top: mask.bottom left: parent.left } } PropertyChanges { target: vapor opacity: 0 anchors { leftMargin: hydro.width*0.05 } } } ] transitions: [ Transition { to: "up" SequentialAnimation { - + id: rainform 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 { id: down NumberAnimation { target: vapor property: "opacity" duration: 100 } AnchorAnimation { targets: vapor duration: 100 } AnchorAnimation { id: check targets: sun duration: Activity.currentLevel != 2 ? 3000 : 5000 } } } ] Timer { id: panel_timer interval: 5200 running: false repeat: false onTriggered: { Activity.paneloff() panel_timer.stop() } } + + Timer { + id: cloudarea + interval: 11150 + running: false + repeat: false + onTriggered: { + cloud_area.visible= true + cloudarea.stop() + } + } } diff --git a/src/activities/hydroelectric/Hydroelectric.qml b/src/activities/hydroelectric/Hydroelectric.qml index 448dd55c5..f8068399c 100755 --- a/src/activities/hydroelectric/Hydroelectric.qml +++ b/src/activities/hydroelectric/Hydroelectric.qml @@ -1,750 +1,786 @@ /* 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 property bool transformer: false 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" } Rectangle { id: check visible: false - width: 500 * ApplicationInfo.ratio - height: 350 * ApplicationInfo.ratio + width: 400 * ApplicationInfo.ratio + height: 200 * ApplicationInfo.ratio anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter z: 3 border.width: 2 radius: 5 color: "#00d635" - GCText { + Text { id: warning anchors.fill: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: qsTr( "It is not possible to consume more electricity "+ "than what is produced. This is a key limitation in the "+ "distribution of electricity, with minor exceptions, "+ "electrical energy cannot be stored, and therefore it "+ "must be generated as it is needed. A sophisticated "+ "system of control is therefore required to ensure electric "+ "generation very closely matches the demand. If supply and demand "+ "are not in balance, generation plants and transmission equipment "+ "can shut down which, in the worst cases, can lead to a major "+ "regional blackout.") fontSizeMode: Text.Fit minimumPointSize: 10 - fontSize: 20 wrapMode: Text.WordWrap } Behavior on opacity { NumberAnimation { duration: 200 } } MouseArea { anchors.fill: parent onClicked: check.visible= false } } 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 { anchors.fill: stepdown onClicked: { power() if( Activity.power > 0 ) { stepdownwire.visible= true } else { stepdownwire.visible= false } } } } Image{ - source: activity.url + "power.svg" - sourceSize.width: stepdown.width - sourceSize.height: stepdown.height + source: activity.url + "right.svg" + sourceSize.width: stepdown.width/2 + sourceSize.height: stepdown.height/2 anchors { right:stepdown.left bottom:stepdown.bottom - bottomMargin: parent.height*0.05 + bottomMargin: parent.height*0.03 } - Text { - id: pow - anchors.centerIn: parent + + + Rectangle{ + width: pow.width*1.5 + height: pow.height*1.1 + border.color: "black" + radius :5 + color:"yellow" + anchors { + top: parent.top + right: parent.left + + } + Text { + id: pow + anchors.centerIn: parent + } } } Image{ - source: activity.url + "consume.svg" - sourceSize.width: stepdown.width - sourceSize.height: stepdown.height + source: activity.url + "down.svg" + sourceSize.width: stepdown.width/2 + sourceSize.height: stepdown.height/2 anchors { left: stepdown.left top: stepdown.top - leftMargin: parent.width*0.05 + leftMargin: parent.width*0.04 } - Text { - id: stepdown_info - anchors.centerIn: parent + + + Rectangle{ + width: stepdown_info.width*1.5 + height: stepdown_info.height*1.1 + border.color: "black" + radius :5 + color:"red" + anchors { + bottom: parent.top + } + Text { + id: stepdown_info + anchors.centerIn: parent + } } } + Image { id: stepdownwire source: activity.url + "hydroelectric/stepdown.svg" sourceSize.width: parent.width anchors.fill: parent visible: false } Image { id: residentsmalloff visible: false source: activity.url + "off.svg" sourceSize.height: parent.height*0.03 sourceSize.width: parent.height*0.03 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.55 topMargin: parent.height*0.65 } MouseArea { id: small_area visible: false anchors.fill: residentsmalloff onClicked: { if( Activity.power >= 300 && stepdownwire.visible == true) { Activity.add(-300) resident_smalllights.visible= true residentsmalloff.visible= false residentsmallon.visible= true Activity.consume(300) - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") small_consume.text= qsTr("300 W") checkbonus() } else { if(stepdownwire.visible == true) { check.visible= true } } } } } Image { id: residentsmallon visible: false source: activity.url + "on.svg" sourceSize.height: parent.height*0.03 sourceSize.width: parent.height*0.03 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.55 topMargin: parent.height*0.65 } MouseArea { anchors.fill: residentsmallon onClicked: { Activity.add(300) Activity.consume(-300) resident_smalllights.visible= false residentsmallon.visible= false residentsmalloff.visible= true small_consume.text= qsTr("0 W") - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") } } } Image { id: residentbigoff visible: false source: activity.url + "off.svg" sourceSize.height: parent.height*0.03 sourceSize.width: parent.height*0.03 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.60 topMargin: parent.height*0.65 } MouseArea { id: big_area visible: false anchors.fill: residentbigoff onClicked: { if( Activity.power >= 600 && stepdownwire.visible == true) { Activity.add(-600) resident_biglights.visible= true residentbigoff.visible= false residentbigon.visible= true Activity.consume(600) - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") big_consume.text= qsTr("600 W") checkbonus() } else { if(stepdownwire.visible == true) { check.visible= true } } } } } Image { id: residentbigon visible: false source: activity.url + "on.svg" sourceSize.height: parent.height*0.03 sourceSize.width: parent.height*0.03 anchors { left: parent.left top: parent.top leftMargin: parent.width*0.60 topMargin: parent.height*0.65 } MouseArea { anchors.fill: residentbigon onClicked: { Activity.add(600) Activity.consume(-600) residentbigon.visible= false residentbigoff.visible= true resident_biglights.visible= false - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") big_consume.text= qsTr("0 W") } } } Image { id: resident_smalllights source: activity.url+ "resident_smallon.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent visible: false } Rectangle{ id: small_consume_rect width: small_consume.width*1.5 height: small_consume.height*1.1 border.color: "black" radius :5 color:"yellow" anchors { top: residentsmallon.bottom left:residentsmallon.left } Text { id: small_consume anchors.centerIn: parent text: qsTr("0 W") } visible: false } Image { id: resident_biglights source: activity.url+ "resident_bigon.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent visible: false } Rectangle{ id: big_consume_rect width: big_consume.width*1.5 height: big_consume.height*1.1 border.color: "black" radius :5 color:"yellow" anchors { top: residentbigon.bottom left: small_consume_rect.right leftMargin: parent.width*0.05 } Text { id: big_consume anchors.centerIn: parent text: qsTr("0 W") } 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: { if( Activity.power >= 100 && stepdownwire.visible == true) { Activity.add(-100) tuxon.visible= true tuxoff.visible= false Activity.consume(100) - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") checkbonus() tux_consume.text= qsTr("100 W") } } } } } 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: { Activity.add(100) Activity.consume(-100) tuxon.visible= false tuxoff.visible= true - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") tux_consume.text= qsTr("0 W") } } } visible: false } Rectangle{ id: tux_meter width: tux_consume.width*1.5 height: tux_consume.height*1.1 border.color: "black" radius :5 color:"yellow" anchors { top: tuxon.bottom left: tuxon.left } Text { id: tux_consume anchors.centerIn: parent text: qsTr("0 W") } + visible: false } function initiate() { unload() reload() power() } Loader { id: hydro anchors.fill: parent } Loader { id: wind anchors.fill: parent } Loader { id: solar anchors.fill: parent } function unload( ) { pow.text = qsTr("0 W") stepdown_info.text= qsTr("0 W") stepdownwire.visible= false off_area.visible= false small_area.visible= false big_area.visible= false tuxon.visible= false tuxoff.visible= false residentsmalloff.visible= false residentsmallon.visible= false residentbigoff.visible= false residentbigon.visible= false resident_smalllights.visible= false resident_biglights.visible= false small_consume_rect.visible= false big_consume_rect.visible= false + tux_meter.visible= false small_consume.text= qsTr("0 W") big_consume.text= qsTr("0 W") tux_consume.text= qsTr("0 W") 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" residentsmalloff.visible= true small_consume_rect.visible= true } if(Activity.currentLevel == 2) { solar.source = "Solar.qml" wind.source = "Wind.qml" hydro.source = "Hydro.qml" residentsmalloff.visible= true residentbigoff.visible= true small_consume_rect.visible= true big_consume_rect.visible= true } } function power() { if(Activity.currentLevel == 0 && Activity.power >= 0 ) { off_area.visible = true } if(Activity.currentLevel == 1 && Activity.power >= 0) { off_area.visible= true small_area.visible= true } if(Activity.currentLevel == 2 && Activity.count >= 0 ) { off_area.visible= true small_area.visible= true big_area.visible= true } } function tux() { Activity.add(100) Activity.consume(-100) tuxon.visible= false tuxoff.visible= true Activity.update() tux_consume.text= qsTr("0 W") - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") } function small() { resident_smalllights.visible= false residentsmalloff.visible= true residentsmallon.visible=false Activity.add(300) Activity.consume(-300) Activity.update() small_consume.text= qsTr("0 W") - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") } function big() { resident_biglights.visible= false residentbigoff.visible= true residentbigon.visible= false Activity.add(600) Activity.consume(-600) Activity.update() big_consume.text= qsTr("0 W") - stepdown_info.text = (Activity.count.toString()).concat("W") + stepdown_info.text = (Activity.count.toString()).concat(" W") } function reset() { - if(Activity.currentLevel == 0 && Activity.voltage == 0) { - stepdownwire.visible= false - tux() + if(Activity.currentLevel == 0) { + if(Activity.voltage == 0 && tuxon.visible != true) { + stepdownwire.visible= false + } + } if(Activity.currentLevel == 1) { + if(Activity.voltage == 0 && residentsmallon.visible != true && tuxon.visible != true) { stepdownwire.visible= false } + if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible == true) { tux() small() stepdownwire.visible= false } + if(Activity.voltage == 0 && residentsmallon.visible != true && tuxon.visible == true) { tux() stepdownwire.visible= false } + if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible != true) { small() stepdownwire.visible= false } + if(Activity.voltage == 100 && residentsmallon.visible == true && tuxon.visible == true) { small() } + if(Activity.voltage == 100 && residentsmallon.visible == true && tuxon.visible != true) { small() stepdownwire.visible= false } } if(Activity.currentLevel == 2) { if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible == true && residentbigon.visible == true) { tux() small() big() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible == true && residentbigon.visible != true) { tux() small() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible != true && tuxon.visible == true && residentbigon.visible == true) { tux() big() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible != true && residentbigon.visible == true) { big() small() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible == true && tuxon.visible != true && residentbigon.visible != true) { small() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible != true && tuxon.visible == true && residentbigon.visible != true) { tux() stepdownwire.visible= false } if(Activity.voltage == 0 && residentsmallon.visible != true && tuxon.visible != true && residentbigon.visible == true) { big() stepdownwire.visible= false } if (Activity.voltage == 100 && tuxon.visible == true && residentsmallon.visible == true && residentbigon.visible == true) { small() big() } if (Activity.voltage == 100 && tuxon.visible == true &&residentsmallon.visible == true && residentbigon.visible != true) { small() } - if (Activity.voltage ==400 && residentbigon.visible == true) + if (Activity.voltage == 400 && residentbigon.visible == true) { big() } } } function checkbonus() { if(Activity.currentLevel == 0 && tuxon.visible == true) { Activity.win() } if(Activity.currentLevel == 1 && tuxon.visible == true && residentsmallon.visible == true) { Activity.win() } if(Activity.currentLevel == 2 && tuxon.visible == true && residentbigon.visible == true && residentsmallon.visible == true) { Activity.win() } } onStart: { Activity.start(items,pow,solar,tux_meter) } 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) } } } diff --git a/src/activities/hydroelectric/Solar.qml b/src/activities/hydroelectric/Solar.qml index 0e355c14a..42a19bb3b 100644 --- a/src/activities/hydroelectric/Solar.qml +++ b/src/activities/hydroelectric/Solar.qml @@ -1,175 +1,186 @@ /* 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 property int clicks: 0 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: { if(clicks == 0 ) { solarpoweron.visible= true solarpoweroff.visible= false - solar_info.text= qsTr("400") + solar_info.text= qsTr("400 W") Activity.add(400) Activity.volt(400) clicks= 1 Activity.solargrid(clicks) Activity.update() } else { solarpoweron.visible= false solarpoweroff.visible= true - solar_info.text= qsTr("0") + solar_info.text= qsTr("0 W") Activity.add(-400) clicks= 0 Activity.volt(-400) Activity.solargrid(clicks) Activity.update() Activity.verify() } } } } Image{ - source: activity.url + "solar/solar.svg" - sourceSize.width: solar_transformer.width - sourceSize.height: solar_transformer.height + source: activity.url + "left.svg" + sourceSize.width: solar_transformer.width/2 + sourceSize.height: solar_transformer.height/2 anchors { top: solarpaneloff.top left:solar_transformer.left leftMargin: solar_transformer.width topMargin: solar_transformer.height } - Text { - id: solar_info - anchors.centerIn: parent - text: qsTr("0W") + Rectangle{ + width: solar_info.width*1.5 + height: solar_info.height*1.1 + border.color: "black" + radius :5 + color:"yellow" + anchors { + left: parent.right + } + Text { + id: solar_info + anchors.centerIn: parent + text: qsTr("0 W") + } } + } Image { id: solarpoweroff source: activity.url + "solar/solarpoweroff.svg" sourceSize.width: parent.width anchors.fill: parent visible: true } Image { id: solarpoweron source: activity.url + "solar/solarpoweron.svg" sourceSize.width: parent.width anchors.fill: parent visible: false } 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 { id: solarpanelarea anchors.fill: solarpaneloff onClicked: { if( Activity.panel_activate == true && Activity.flag == 0) { solar_area.visible= true solarpaneloff.source= activity.url + "solar/solarpanelon.svg" // solarpaneloff.visible= false //solarpanelon.visible= true panelpoweron.visible= true panelpoweroff.visible= false solarpanelarea.visible= false } } } } Image { id: panelpoweroff source: activity.url + "solar/panelpoweroff.svg" sourceSize.width: parent.width anchors.fill: parent 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 // } // visible: false // MouseArea { // anchors.fill: solarpanelon // onClicked: { // solar_area.visible= false // solarpanelon.visible= false // solarpaneloff.visible= true // panelpoweron.visible= false // panelpoweroff.visible= true // } // } // } Image { id: panelpoweron source: activity.url + "solar/panelpoweron.svg" sourceSize.width: parent.width anchors.fill: parent visible: false } } diff --git a/src/activities/hydroelectric/Wind.qml b/src/activities/hydroelectric/Wind.qml index 1df322be7..3b77acd29 100644 --- a/src/activities/hydroelectric/Wind.qml +++ b/src/activities/hydroelectric/Wind.qml @@ -1,237 +1,248 @@ /* 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 property int click: 0 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_quiet.source= activity.url+ "wind/cloud_fury.svg" turbine_area.visible= true wind.state= "move" wind_timer.restart() } } } 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: { if(click == 0) { wind_power.source= activity.url + "wind/windpoweron.svg" click = 1 Activity.add(100) Activity.volt(100) - windvoltage.text= qsTr("100W") + windvoltage.text= qsTr("100 W") Activity.update() } else { click = 0 wind_power.source= activity.url + "wind/windpoweroff.svg" Activity.add(-100) Activity.volt(-100) - windvoltage.text= qsTr("0W") + windvoltage.text= qsTr("0 W") Activity.update() Activity.verify() } } } } Image{ - sourceSize.width: wind_transformer.width - sourceSize.height: wind_transformer.height - source: activity.url + "wind/wind.svg" + sourceSize.width: wind_transformer.width/2 + sourceSize.height: wind_transformer.height/2 + source: activity.url + "up.svg" anchors { top: wind_transformer.top topMargin: wind_transformer.height*0.9 right: parent.right - rightMargin: parent.width*0.15 + rightMargin: parent.width*0.18 } - Text { - id: windvoltage - anchors.centerIn: parent - text: qsTr("0W") + + Rectangle{ + width: windvoltage.width*1.5 + height: windvoltage.height*1.1 + border.color: "black" + radius :5 + color:"yellow" + anchors { + top: parent.bottom + } + Text { + id: windvoltage + anchors.centerIn: parent + text: qsTr("0 W") + } } } Image { id: wind_power source: activity.url + "wind/windpoweroff.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent opacity: 1 } Image { id: wind_turbine source: activity.url + "wind/windturbineoff.svg" sourceSize.width: parent.width sourceSize.height: parent.height anchors.fill: parent opacity: 1 } //wind turbines animations Image { id:turbine1 source: activity.url + "wind/turbine1.svg" visible: true 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 } } MouseArea { anchors.fill: turbine1 id: turbine_area visible: false onClicked: { wind_turbine.source= activity.url + "wind/windturbineon.svg" wind_transformer_area.visible= true } } Image { id:turbine2 visible: false source: activity.url + "wind/turbine2.svg" 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 } } states: [ State { name: "move" PropertyChanges { target: turbine1 visible: false } PropertyChanges { target: turbine2 visible: true } }, State { name: "off" PropertyChanges { target: turbine2 visible: false } PropertyChanges { target: turbine1 visible: true } } ] transitions: Transition { SequentialAnimation { loops: Animation.Infinite NumberAnimation { easing.type: Easing.InQuad properties: "visible" duration: 2000 } } } Timer { id: wind_timer interval: 10000 running: false repeat: false onTriggered: click == 0 ? wind_reset() : wind_power_reset() } function wind_reset() { cloud_quiet.source = activity.url+ "wind/cloud_quiet.svg" wind_power.source= activity.url + "wind/windpoweroff.svg" wind_turbine.source= activity.url + "wind/windturbineoff.svg" turbine_area.visible= false state= "off" - windvoltage.text= qsTr("0") + windvoltage.text= qsTr("0 W") wind_transformer_area.visible= false wind_timer.stop() } function wind_power_reset() { cloud_quiet.source = activity.url+ "wind/cloud_quiet.svg" wind_turbine.source= activity.url + "wind/windturbineoff.svg" state= "off" wind_power.source= activity.url + "wind/windpoweroff.svg" wind_transformer_area.visible= false turbine_area.visible= false click= 0 Activity.add(-100) Activity.volt(-100) - windvoltage.text= qsTr("0") + windvoltage.text= qsTr("0 W") Activity.update() Activity.verify() wind_timer.stop() } } diff --git a/src/activities/hydroelectric/resource/consume.svg b/src/activities/hydroelectric/resource/consume.svg deleted file mode 100644 index 964ff1f02..000000000 --- a/src/activities/hydroelectric/resource/consume.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - 2010-04-06T21:01:40 - Speech bubble - https://openclipart.org/detail/38605/speech-bubble-by-pascallapalme-38605 - - - pascallapalme - - - - - cartoon - speech bubble - - - - - - - - - - - diff --git a/src/activities/hydroelectric/resource/down.svg b/src/activities/hydroelectric/resource/down.svg new file mode 100644 index 000000000..c858a6d10 --- /dev/null +++ b/src/activities/hydroelectric/resource/down.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/activities/hydroelectric/resource/hydroelectric/hydro.svg b/src/activities/hydroelectric/resource/hydroelectric/hydro.svg deleted file mode 100644 index 022643f50..000000000 --- a/src/activities/hydroelectric/resource/hydroelectric/hydro.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - 2010-04-06T21:01:40 - Speech bubble - https://openclipart.org/detail/38605/speech-bubble-by-pascallapalme-38605 - - - pascallapalme - - - - - cartoon - speech bubble - - - - - - - - - - - diff --git a/src/activities/hydroelectric/resource/left.svg b/src/activities/hydroelectric/resource/left.svg new file mode 100644 index 000000000..1ae2d5998 --- /dev/null +++ b/src/activities/hydroelectric/resource/left.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/activities/hydroelectric/resource/power.svg b/src/activities/hydroelectric/resource/power.svg deleted file mode 100644 index 3688130d2..000000000 --- a/src/activities/hydroelectric/resource/power.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - 2010-04-06T21:01:40 - Speech bubble - https://openclipart.org/detail/38605/speech-bubble-by-pascallapalme-38605 - - - pascallapalme - - - - - cartoon - speech bubble - - - - - - - - - - - diff --git a/src/activities/hydroelectric/resource/right.svg b/src/activities/hydroelectric/resource/right.svg new file mode 100644 index 000000000..970860f74 --- /dev/null +++ b/src/activities/hydroelectric/resource/right.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/activities/hydroelectric/resource/solar/solar.svg b/src/activities/hydroelectric/resource/solar/solar.svg deleted file mode 100644 index cbbe8aaaa..000000000 --- a/src/activities/hydroelectric/resource/solar/solar.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - 2010-04-06T21:01:40 - Speech bubble - https://openclipart.org/detail/38605/speech-bubble-by-pascallapalme-38605 - - - pascallapalme - - - - - cartoon - speech bubble - - - - - - - - - - - diff --git a/src/activities/hydroelectric/resource/up.svg b/src/activities/hydroelectric/resource/up.svg new file mode 100644 index 000000000..67b045f16 --- /dev/null +++ b/src/activities/hydroelectric/resource/up.svg @@ -0,0 +1,70 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/activities/hydroelectric/resource/wind/wind.svg b/src/activities/hydroelectric/resource/wind/wind.svg deleted file mode 100644 index 70ab281d2..000000000 --- a/src/activities/hydroelectric/resource/wind/wind.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - 2010-04-06T21:01:40 - Speech bubble - https://openclipart.org/detail/38605/speech-bubble-by-pascallapalme-38605 - - - pascallapalme - - - - - cartoon - speech bubble - - - - - - - - - - -