diff --git a/src/activities/babymatch/Babymatch.qml b/src/activities/babymatch/Babymatch.qml --- a/src/activities/babymatch/Babymatch.qml +++ b/src/activities/babymatch/Babymatch.qml @@ -32,6 +32,7 @@ // But for imageName for example, we reuse the images of babymatch, so we need to differentiate them property string imagesUrl: boardsUrl property string soundsUrl: boardsUrl + property bool useMultipleDataset: false property string boardsUrl: "qrc:/gcompris/src/activities/babymatch/resource/" property int levelCount: 7 property bool answerGlow: true //For highlighting the answers @@ -51,6 +52,7 @@ property bool vert: background.width >= background.height Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } @@ -70,15 +72,16 @@ property alias instruction: instruction property alias toolTip: toolTip property alias score: score + property var levels: activity.datasetLoader.data.length !== 0 ? activity.datasetLoader.data : null property alias dataset: dataset } Loader { id: dataset asynchronous: false } - onStart: { Activity.start(items, imagesUrl, soundsUrl, boardsUrl, levelCount, answerGlow, displayDropCircle) } + onStart: { Activity.start(items, imagesUrl, soundsUrl, boardsUrl, levelCount, answerGlow, displayDropCircle, useMultipleDataset) } onStop: { Activity.stop() } DialogHelp { @@ -88,13 +91,42 @@ Bar { id: bar - content: BarEnumContent { value: help | home | level } + content: BarEnumContent { value: useMultipleDataset ? (help | home | level | activityConfig) : (help | home | level) } onHelpClicked: {displayDialog(dialogHelp)} onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() - onHomeClicked: activity.home() + onHomeClicked: { + Activity.resetData(); + activity.home() + } + onActivityConfigClicked: { + Activity.initLevel() + displayDialog(dialogActivityConfig) + } } + DialogChooseLevel { + id: dialogActivityConfig + currentActivity: activity.activityInfo + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevels + currentActivity.currentLevels = dialogActivityConfig.chosenLevels + ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) + activity.focus = true + } + onLoadData: { + if(activityData) { + Activity.initLevel() + } + } + onClose: { + home() + } + onStartActivity: { + background.start() + } + } + Score { id: score visible: numberOfSubLevels > 1 diff --git a/src/activities/babymatch/babymatch.js b/src/activities/babymatch/babymatch.js --- a/src/activities/babymatch/babymatch.js +++ b/src/activities/babymatch/babymatch.js @@ -23,6 +23,7 @@ .import QtQuick 2.6 as Quick .import GCompris 1.0 as GCompris //for ApplicationInfo +var useMultipleDataset var currentLevel = 1 var currentSubLevel = 0 var numberOfLevel @@ -37,20 +38,34 @@ var showText = [] var displayDropCircle -function start(items_, imagesUrl_, soundsUrl_, boardsUrl_, levelCount_, answerGlow_, displayDropCircle_) { +function start(items_, imagesUrl_, soundsUrl_, boardsUrl_, levelCount_, answerGlow_, displayDropCircle_, useMultipleDataset_) { items = items_ imagesUrl = imagesUrl_ soundsUrl = soundsUrl_ boardsUrl = boardsUrl_ - numberOfLevel = levelCount_ + useMultipleDataset = useMultipleDataset_ + numberOfLevel = useMultipleDataset ? items.levels.length : levelCount_ glowEnabledDefault = answerGlow_ displayDropCircle = displayDropCircle_ currentLevel = 1 currentSubLevel = 0 numberOfSubLevel = 0 + resetData() + initLevel() +} + +function resetData() { + items.availablePieces.model.clear() + for(var i = 0 ; i < spots.length ; ++ i) + spots[i].destroy() spots = [] + + for(var i = 0 ; i < showText.length ; ++ i) + showText[i].destroy() showText = [] - initLevel() + + items.backgroundPiecesModel.clear() + items.backgroundImage.source = "" } function stop() { @@ -60,22 +75,12 @@ function initLevel() { items.bar.level = currentLevel - var filename = boardsUrl + "board" + "/" + "board" + currentLevel + "_" + currentSubLevel + ".qml" - items.dataset.source = filename + if(useMultipleDataset) + items.dataset.source = items.levels[currentLevel-1][currentSubLevel]; + else + items.dataset.source = boardsUrl + "board" + "/" + "board" + currentLevel + "_" + currentSubLevel + ".qml" var levelData = items.dataset.item - - items.availablePieces.model.clear() - for(var i = 0 ; i < spots.length ; ++ i) - spots[i].destroy() - spots = [] - - for(var i = 0 ; i < showText.length ; ++ i) - showText[i].destroy() - showText = [] - - items.backgroundPiecesModel.clear() - items.backgroundImage.source = "" - + resetData(); items.availablePieces.view.currentDisplayedGroup = 0 items.availablePieces.view.previousNavigation = 1 items.availablePieces.view.nextNavigation = 1 diff --git a/src/activities/chronos/ActivityInfo.qml b/src/activities/chronos/ActivityInfo.qml --- a/src/activities/chronos/ActivityInfo.qml +++ b/src/activities/chronos/ActivityInfo.qml @@ -41,4 +41,5 @@ credit: qsTr("Moon photo is copyright NASA. The space sounds come from Tuxpaint and Vegastrike which are released under the GPL license. The transportation images are copyright Franck Doucet. Dates of Transportation are based on those found in <https://www.wikipedia.org>.") section: "sciences history" createdInVersion: 4000 + levels: "1,2" } diff --git a/src/activities/chronos/CMakeLists.txt b/src/activities/chronos/CMakeLists.txt --- a/src/activities/chronos/CMakeLists.txt +++ b/src/activities/chronos/CMakeLists.txt @@ -1 +1 @@ -GCOMPRIS_ADD_RCC(activities/chronos *.qml *.svg *.js resource/board/* resource/images/* resource/sound/*.${COMPRESSED_AUDIO}) +GCOMPRIS_ADD_RCC(activities/chronos *.qml *.svg *.js resource/*.svg resource/*/*) diff --git a/src/activities/chronos/Chronos.qml b/src/activities/chronos/Chronos.qml --- a/src/activities/chronos/Chronos.qml +++ b/src/activities/chronos/Chronos.qml @@ -25,10 +25,10 @@ Babymatch { id: activity - onStart: focus = true onStop: {} + useMultipleDataset: true boardsUrl: "qrc:/gcompris/src/activities/chronos/resource/" levelCount: 6 } diff --git a/src/activities/chronos/resource/1/Data.qml b/src/activities/chronos/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/chronos/resource/1/Data.qml @@ -0,0 +1,37 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * 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 "../../../../core" + +Dataset { + objective: qsTr("For children who can read numbers") + difficulty: 5 + data: [ + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board1_0.qml" + ], + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board3_0.qml" + ], + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board4_0.qml" + ] + ] +} diff --git a/src/activities/chronos/resource/2/Data.qml b/src/activities/chronos/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/chronos/resource/2/Data.qml @@ -0,0 +1,45 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * 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 "../../../../core" + +Dataset { + objective: qsTr("For children who can read words") + difficulty: 6 + data: [ + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board2_0.qml" + ], + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board5_0.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board5_1.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board5_2.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board5_3.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board5_4.qml", + + ], + [ + "qrc:/gcompris/src/activities/chronos/resource/board/board6_0.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board6_1.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board6_2.qml", + "qrc:/gcompris/src/activities/chronos/resource/board/board6_3.qml", + ] + ] +}