Warning, /education/gcompris/src/activities/reversecount/Reversecount.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ReverseCount.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Emmanuel Charruau <echarruau@gmail.com> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Emmanuel Charruau <echarruau@gmail.com> (Qt Quick port) 0008 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Major rework) 0009 * Timothée Giet <animtim@gcompris.net> (Layout and graphics rework) 0010 * 0011 * SPDX-License-Identifier: GPL-3.0-or-later 0012 */ 0013 import QtQuick 2.12 0014 import GCompris 1.0 0015 0016 import "../../core" 0017 import "reversecount.js" as Activity 0018 0019 0020 ActivityBase { 0021 id: activity 0022 0023 onStart: focus = true 0024 onStop: {} 0025 0026 pageComponent: Rectangle { 0027 id: background 0028 anchors.fill: parent 0029 color: "#ff1dade4" 0030 0031 signal start 0032 signal stop 0033 0034 Component.onCompleted: { 0035 dialogActivityConfig.initialize() 0036 activity.start.connect(start) 0037 activity.stop.connect(stop) 0038 } 0039 0040 // Add here the QML items you need to access in javascript 0041 QtObject { 0042 id: items 0043 property Item main: activity.main 0044 property GCSfx audioEffects: activity.audioEffects 0045 readonly property string resourceUrl: activity.resourceUrl 0046 readonly property var levels: activity.datasetLoader.data 0047 property alias background: background 0048 property int currentLevel: activity.currentLevel 0049 property alias bonus: bonus 0050 property alias chooseDiceBar: chooseDiceBar 0051 property alias tux: tux 0052 property alias fishToReach: fishToReach 0053 property int clockPosition: 4 0054 property string mode: "dot" 0055 property var heightBase: (background.height - bar.height * 1.5) / 5 0056 property var widthBase: background.width / 5 0057 property bool tuxIsMoving: false 0058 property bool tuxCanMove: true 0059 } 0060 0061 onStart: { Activity.start(items) } 0062 onStop: { 0063 sizeChangedTimer.stop() 0064 Activity.stop() 0065 } 0066 0067 Keys.onEnterPressed: chooseDiceBar.moveTux() 0068 Keys.onReturnPressed: chooseDiceBar.moveTux() 0069 0070 onWidthChanged: { 0071 sizeChangedTimer.restart() 0072 } 0073 0074 onHeightChanged: { 0075 sizeChangedTimer.restart() 0076 } 0077 0078 function replaceItems() { 0079 if(Activity.fishIndex > 0) { 0080 // set x 0081 fishToReach.x = Activity.iceBlocksLayout[Activity.fishIndex % Activity.iceBlocksLayout.length][0] * 0082 items.widthBase + (items.widthBase - fishToReach.width) / 2 0083 // set y 0084 fishToReach.y = Activity.iceBlocksLayout[Activity.fishIndex % Activity.iceBlocksLayout.length][1] * 0085 items.heightBase + (items.heightBase - fishToReach.height) / 2 0086 // Move Tux 0087 Activity.moveTuxToIceBlock() 0088 } 0089 } 0090 0091 Timer { 0092 id: sizeChangedTimer 0093 interval: 100 0094 onTriggered: replaceItems() 0095 } 0096 0097 // === The ice blocks === 0098 Repeater { 0099 model: Activity.iceBlocksLayout 0100 0101 Image { 0102 x: modelData[0] * items.widthBase 0103 y: modelData[1] * items.heightBase 0104 width: items.widthBase 0105 height: items.heightBase 0106 source: items.resourceUrl + "ice-block.svg" 0107 } 0108 } 0109 0110 Tux { 0111 id: tux 0112 sourceSize.width: Math.min(items.widthBase, items.heightBase) 0113 z: 11 0114 } 0115 0116 0117 Image { 0118 id: fishToReach 0119 source: items.resourceUrl + "fish-blue.svg" 0120 sourceSize.width: Math.min(items.widthBase, items.heightBase) 0121 z: 10 0122 property int nextX 0123 property int nextY 0124 0125 function showParticles() { 0126 particles.burst(40) 0127 } 0128 0129 ParticleSystemStarLoader { 0130 id: particles 0131 clip: false 0132 } 0133 0134 onOpacityChanged: { 0135 if(opacity == 0) { 0136 x = nextX 0137 y = nextY 0138 opacity = 1 0139 items.tuxCanMove = true 0140 } 0141 } 0142 0143 Behavior on opacity { NumberAnimation { duration: 500 } } 0144 } 0145 0146 0147 DialogHelp { 0148 id: dialogHelp 0149 onClose: home() 0150 } 0151 0152 Bar { 0153 id: bar 0154 level: items.currentLevel + 1 0155 content: BarEnumContent { value: help | home | level | activityConfig } 0156 onHelpClicked: { 0157 displayDialog(dialogHelp) 0158 } 0159 onPreviousLevelClicked: Activity.previousLevel() 0160 onNextLevelClicked: Activity.nextLevel() 0161 onHomeClicked: activity.home() 0162 onActivityConfigClicked: { 0163 displayDialog(dialogActivityConfig) 0164 } 0165 } 0166 0167 Image { 0168 id: clock 0169 anchors { 0170 right: parent.right 0171 bottom: parent.bottom 0172 margins: 10 0173 } 0174 sourceSize.width: 66 * bar.barZoom 0175 property int remainingLife: items.clockPosition 0176 onRemainingLifeChanged: if(remainingLife >= 0) clockAnim.restart() 0177 0178 SequentialAnimation { 0179 id: clockAnim 0180 alwaysRunToEnd: true 0181 ParallelAnimation { 0182 NumberAnimation { 0183 target: clock; properties: "opacity"; 0184 to: 0; duration: 800; easing.type: Easing.OutCubic 0185 } 0186 NumberAnimation { 0187 target: clock; properties: "rotation"; from: 0; to: 180; 0188 duration: 800; easing.type: Easing.OutCubic 0189 } 0190 } 0191 PropertyAction { 0192 target: clock; property: 'source'; 0193 value: items.resourceUrl + "flower" + items.clockPosition + ".svg" 0194 } 0195 ParallelAnimation { 0196 NumberAnimation { 0197 target: clock; properties: "opacity"; 0198 to: 1; duration: 800; easing.type: Easing.OutCubic 0199 } 0200 NumberAnimation { 0201 target: clock; properties: "rotation"; from: 180; to: 0; 0202 duration: 800; easing.type: Easing.OutCubic 0203 } 0204 } 0205 } 0206 } 0207 0208 DialogChooseLevel { 0209 id: dialogActivityConfig 0210 currentActivity: activity.activityInfo 0211 0212 onClose: { 0213 home() 0214 } 0215 onSaveData: { 0216 levelFolder = dialogActivityConfig.chosenLevels 0217 currentActivity.currentLevels = dialogActivityConfig.chosenLevels 0218 ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) 0219 } 0220 onLoadData: { 0221 if(activityData && activityData["mode"]) { 0222 items.mode = activityData["mode"]; 0223 } 0224 } 0225 onStartActivity: { 0226 background.stop() 0227 background.start() 0228 } 0229 } 0230 0231 ChooseDiceBar { 0232 id: chooseDiceBar 0233 mode: items.mode 0234 anchors.horizontalCenter: items.background.horizontalCenter 0235 y: items.heightBase * 2 0236 audioEffects: activity.audioEffects 0237 } 0238 0239 Bonus { 0240 id: bonus 0241 winSound: "qrc:/gcompris/src/activities/ballcatch/resource/tuxok.wav" 0242 looseSound: "qrc:/gcompris/src/activities/ballcatch/resource/youcannot.wav" 0243 onWin: Activity.nextLevel() 0244 onLoose: Activity.initLevel() 0245 } 0246 } 0247 }