diff --git a/src/activities/sudoku/ActivityInfo.qml b/src/activities/sudoku/ActivityInfo.qml --- a/src/activities/sudoku/ActivityInfo.qml +++ b/src/activities/sudoku/ActivityInfo.qml @@ -36,4 +36,5 @@ credit: "" section: "discovery logic" createdInVersion: 0 + levels: "1,2" } diff --git a/src/activities/sudoku/Sudoku.qml b/src/activities/sudoku/Sudoku.qml --- a/src/activities/sudoku/Sudoku.qml +++ b/src/activities/sudoku/Sudoku.qml @@ -44,6 +44,7 @@ signal stop Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) focus = true @@ -62,6 +63,7 @@ property alias columns: sudoColumn.columns property alias rows: sudoColumn.rows property alias sudokuModel: sudokuModel + property var levels: activity.datasetLoader.data } onStart: Activity.start(items) @@ -72,12 +74,34 @@ onClose: home() } + DialogChooseLevel { + id: dialogActivityConfig + currentActivity: activity.activityInfo + onClose: { + home() + } + + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevels + currentActivity.currentLevels = dialogActivityConfig.chosenLevels + ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) + } + + onStartActivity: { + background.stop() + background.start() + } + } + Bar { id: bar - content: BarEnumContent { value: help | home | level | reload } + content: BarEnumContent { value: help | home | level | reload | activityConfig } onHelpClicked: { displayDialog(dialogHelp) } + onActivityConfigClicked: { + displayDialog(dialogActivityConfig) + } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onReloadClicked: Activity.initLevel() diff --git a/src/activities/sudoku/resource/1/Data.qml b/src/activities/sudoku/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/sudoku/resource/1/Data.qml @@ -0,0 +1,77 @@ +/* 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 GCompris 1.0 + +Data { + objective: qsTr("Play with smaller grids using symbols") + difficulty: 3 + data: [ + [ + [ + ['.','C','B'], + ['.','B','A'], + ['.','A','C'] + ], + [ + ['C','A','B'], + ['.','.','.'], + ['B','C','A'] + ], + [ + ['C','A','B'], + ['A','B','C'], + ['.','.','.'] + ], + [ + ['A','.','C'], + ['C','.','B'], + ['B','.','A'] + ], + [ + ['A','.','C'], + ['B','C','.'], + ['.','A','B'] + ], + [ + ['A','B','C'], + ['B','.','A'], + ['.','A','.'] + ], + [ + ['.','B','A'], + ['B','.','C'], + ['A','C','.'] + ], + [ + ['A','B','C'], + ['.','C','A'], + ['.','A','.'] + ] + ], + [ // Level 2 + [ + ['A','.','.'], + ['D','.','.'], + ['C','A','.'] + ] + ] + ] +} diff --git a/src/activities/sudoku/resource/2/Data.qml b/src/activities/sudoku/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/sudoku/resource/2/Data.qml @@ -0,0 +1,70 @@ +/* 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 GCompris 1.0 + +Data { + objective: qsTr("Play with smaller grids using symbols") + difficulty: 4 + data: [ + [ + [ + ['.','C','B'], + ['.','B','A'], + ['.','A','C'] + ], + [ + ['C','A','B'], + ['.','.','.'], + ['B','C','A'] + ], + [ + ['C','A','B'], + ['A','B','C'], + ['.','.','.'] + ], + [ + ['A','.','C'], + ['C','.','B'], + ['B','.','A'] + ], + [ + ['A','.','C'], + ['B','C','.'], + ['.','A','B'] + ], + [ + ['A','B','C'], + ['B','.','A'], + ['.','A','.'] + ], + [ + ['.','B','A'], + ['B','.','C'], + ['A','C','.'] + ], + [ + ['A','B','C'], + ['.','C','A'], + ['.','A','.'] + ] + ] + ] +} diff --git a/src/activities/sudoku/sudoku.js b/src/activities/sudoku/sudoku.js --- a/src/activities/sudoku/sudoku.js +++ b/src/activities/sudoku/sudoku.js @@ -25,47 +25,7 @@ // Hard coded level definitions var levels = [ - [ // Level 1 - [ - ['.','C','B'], - ['.','B','A'], - ['.','A','C'] - ], - [ - ['C','A','B'], - ['.','.','.'], - ['B','C','A'] - ], - [ - ['C','A','B'], - ['A','B','C'], - ['.','.','.'] - ], - [ - ['A','.','C'], - ['C','.','B'], - ['B','.','A'] - ], - [ - ['A','.','C'], - ['B','C','.'], - ['.','A','B'] - ], - [ - ['A','B','C'], - ['B','.','A'], - ['.','A','.'] - ], - [ - ['.','B','A'], - ['B','.','C'], - ['A','C','.'] - ], [ - ['A','B','C'], - ['.','C','A'], - ['.','A','.'] - ], - ], + [ // Level 2 [ ['A','.','.'], @@ -556,7 +516,7 @@ ] var currentLevel = 0 -var numberOfLevel = levels.length +var numberOfLevel var items var symbolizeLevelMax = 7 // Last level in which we set symbols @@ -574,12 +534,11 @@ items = items_ currentLevel = 0 items.score.currentSubLevel = 1 - + numberOfLevel = items.levels.length // Shuffle all levels - for(var nb = 0 ; nb < levels.length ; ++ nb) { - Core.shuffle(levels[nb]); + for(var nb = 0 ; nb < items.levels.length ; ++ nb) { + Core.shuffle(items.levels[nb]); } - // Shuffle the symbols Core.shuffle(symbols); for(var s = 0 ; s < symbols.length ; ++ s) { @@ -595,16 +554,16 @@ function initLevel() { items.bar.level = currentLevel + 1; - items.score.numberOfSubLevels = levels[currentLevel].length + items.score.numberOfSubLevels = items.levels[currentLevel].length for(var i = items.availablePiecesModel.model.count-1 ; i >= 0 ; -- i) { items.availablePiecesModel.model.remove(i); } items.sudokuModel.clear(); // Copy current sudoku in local variable - var initialSudoku = levels[currentLevel][items.score.currentSubLevel-1]; + var initialSudoku =items.levels[currentLevel][items.score.currentSubLevel-1]; items.columns = initialSudoku.length items.rows = items.columns @@ -681,7 +640,7 @@ } function clickOn(caseX, caseY) { - var initialSudoku = levels[currentLevel][items.score.currentSubLevel-1]; + var initialSudoku = items.levels[currentLevel][items.score.currentSubLevel-1]; var currentCase = caseX + caseY * initialSudoku.length;