diff --git a/src/activities/share/ActivityInfo.qml b/src/activities/share/ActivityInfo.qml index 1b232fd20..71b3fca2d 100644 --- a/src/activities/share/ActivityInfo.qml +++ b/src/activities/share/ActivityInfo.qml @@ -1,40 +1,40 @@ /* GCompris - ActivityInfo.qml * * Copyright (C) 2016 Stefan Toncu * * 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 ActivityInfo { name: "share/Share.qml" difficulty: 2 icon: "share/share.svg" author: "Stefan Toncu <stefan.toncu29@gmail.com>" demo: true //: Activity title - title: qsTr("Share the candies") + title: qsTr("Share pieces of candy") //: Help title - description: qsTr("Try to split the candies to a given number of children") + description: qsTr("Try to split the pieces of candy to a given number of children") //intro: "Share the candies equally among the specified number of children and notice that there may be a rest left" //: Help goal goal: qsTr("Learn the division of numbers") //: Help prerequisite prerequisite: qsTr("Know how to count") //: Help manual - manual: qsTr("Follow the instructions shown on the screen: first, drag the given number of boys/girls to the middle, then drag candies to each child's rectangle.") + manual: qsTr("Follow the instructions shown on the screen: first, drag the given number of boys/girls to the middle, then drag pieces of candy to each child's rectangle.") credit: "" section: "math" createdInVersion: 7000 } diff --git a/src/activities/share/Share.qml b/src/activities/share/Share.qml index 9453a5d73..692b58a67 100644 --- a/src/activities/share/Share.qml +++ b/src/activities/share/Share.qml @@ -1,432 +1,432 @@ /* GCompris - Share.qml * * Copyright (C) 2016 Stefan Toncu * * 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.6 import GCompris 1.0 import "../../core" import "share.js" as Activity ActivityBase { id: activity onStart: focus = true onStop: {} pageComponent: Rectangle { id: background anchors.fill: parent color: "#ffffb3" signal start signal stop Component.onCompleted: { dialogActivityConfig.getInitialConfiguration() 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 property alias instruction: instruction property int currentSubLevel: 0 property int nbSubLevel property alias listModel: listModel property bool acceptCandy: false property alias dataset: dataset property alias girlWidget: girlWidget property alias boyWidget: boyWidget property alias candyWidget: candyWidget property alias basketWidget: basketWidget property alias leftWidget: leftWidget property int totalBoys property int totalGirls property int totalCandies property int totalChildren: totalBoys + totalGirls property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3 property int cellSize: Math.min(background.width / 11, background.height / (9 + barHeightAddon)) property alias repeaterDropAreas: repeaterDropAreas property int maxNumberOfCandiesPerWidget: 8 } Loader { id: dataset asynchronous: false } onStart: { Activity.start(items) } onStop: { Activity.stop() } property bool vert: background.width > background.height property int currentBoys: 0 property int currentGirls: 0 property int currentCandies: 0 property int rest property int placedInGirls property int placedInBoys property bool showCount: true property bool easyMode: true property alias wrongMove: wrongMove property bool finished: false //returns true if the x and y is in the "dest" area function contains(x, y, dest) { return (x > dest.x && x < dest.x + dest.width && y > dest.y && y < dest.y + dest.height) } //stop the candy rotation function resetCandy() { items.acceptCandy = false; candyWidget.element.rotation = 0 } //check if the answer is correct function check() { background.resetCandy() background.finished = true var ok = 0 var okRest = 0 if (listModel.count >= items.totalChildren) { for (var i = 0 ; i < listModel.count ; i++) { if (listModel.get(i).nameS === "basket") okRest = listModel.get(i).countS else if (listModel.get(i).countS === Math.floor(items.totalCandies/items.totalChildren)) ok ++ } //condition without rest if (rest == 0 && ok == items.totalChildren) { bonus.good("flower") return } //condition with rest else if (rest == okRest && ok == items.totalChildren) { bonus.good("tux") return } } //else => bad bonus.bad("flower") } //center zone Rectangle { id: grid z: 4 //map the coordinates from widgets to grid property var boy: leftWidget.mapFromItem(boyWidget, boyWidget.element.x, boyWidget.element.y) property var girl: leftWidget.mapFromItem(girlWidget, girlWidget.element.x, girlWidget.element.y) property var basket: leftWidget.mapFromItem(basketWidget, basketWidget.element.x, basketWidget.element.y) //show that the widget can be dropped here color: background.contains(boy.x, boy.y, grid) || background.contains(girl.x, girl.y, grid) || background.contains(basket.x, basket.y, grid) ? "pink" : "transparent" anchors { top: background.vert ? parent.top : leftWidget.bottom left: background.vert ? leftWidget.right : parent.left topMargin: 20 leftMargin: 20 } width: background.vert ? background.width - leftWidget.width - 40 : background.width - 40 height: ApplicationSettings.isBarHidden ? background.height : background.vert ? background.height - (bar.height * 1.1) : background.height - (bar.height * 1.1) - leftWidget.height //shows/hides the Instruction MouseArea { anchors.fill: parent // first hide the wrong move if visible, then show/hide instruction onClicked: wrongMove.visible ? wrongMove.visible = false : (instruction.opacity === 0) ? instruction.show() : instruction.hide() } ListModel { id: listModel } Flow { id: dropAreas spacing: 10 width: parent.width height: parent.height Repeater { id: repeaterDropAreas model: listModel DropChild { id: rect2 //"nameS" from listModel name: nameS } } } } //instruction rectangle Rectangle { id: instruction anchors.fill: instructionTxt opacity: 0.8 radius: 10 border.width: 2 z: 10 border.color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#000" } GradientStop { position: 0.9; color: "#666" } GradientStop { position: 1.0; color: "#AAA" } } property alias text: instructionTxt.text Behavior on opacity { PropertyAnimation { duration: 200 } } //shows/hides the Instruction MouseArea { anchors.fill: parent onClicked: instruction.hide() enabled: instruction.opacity !== 0 } function show() { if(text) opacity = 1 } function hide() { opacity = 0 } } //instruction for playing the game GCText { id: instructionTxt anchors { top: background.vert ? parent.top : leftWidget.bottom topMargin: -10 horizontalCenter: grid.horizontalCenter } opacity: instruction.opacity z: instruction.z fontSize: background.vert ? regularSize : smallSize color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter width: Math.max(Math.min(parent.width * 0.8, text.length * 8), parent.width * 0.3) wrapMode: TextEdit.WordWrap } //left widget, with girl/boy/candy/basket widgets in a grid Rectangle { id: leftWidget width: background.vert ? items.cellSize * 1.74 : background.width height: background.vert ? background.height : items.cellSize * 1.74 color: "#FFFF42" border.color: "#FFD85F" border.width: 4 z: 4 //grid with ok button and images of a boy, a girl, a candy and a basket Grid { id: view x: 10 y: 10 width: background.vert ? leftWidget.width : 3 * bar.height height: background.vert ? background.height - 2 * bar.height : bar.height spacing: 10 columns: background.vert ? 1 : 5 //ok button Image { id: okButton source:"qrc:/gcompris/src/core/resource/bar_ok.svg" sourceSize.width: items.cellSize * 1.5 fillMode: Image.PreserveAspectFit MouseArea { id: mouseArea anchors.fill: parent enabled: background.finished ? false : true onPressed: okButton.opacity = 0.6 onReleased: okButton.opacity = 1 onClicked: background.check() } } ChildWidget { id: girlWidget name: "girl" total: items.totalGirls current: background.currentGirls placedInChild: background.placedInGirls } ChildWidget { id: boyWidget name: "boy" total: items.totalBoys current: background.currentBoys placedInChild: background.placedInBoys } CandyWidget { id: candyWidget total: background.easyMode ? items.totalCandies : 8 * items.totalChildren + 1 current: background.currentCandies element.opacity: background.easyMode ? 1 : 0 } BasketWidget { id: basketWidget } } } // show message warning for placing too many candies in one area Rectangle { id: wrongMove z: 5 color: "orange" radius: width / height * 10 visible: false width: grid.width height: grid.height / 3 anchors.centerIn: grid MouseArea { anchors.fill: parent onClicked: parent.visible = false } GCText { id: wrongMoveText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width - 2 // -2 for margin height: parent.height fontSizeMode: Text.Fit wrapMode: Text.WordWrap color: "#404040" - text: qsTr("You can't put more than %1 candies in the same widget").arg(items.maxNumberOfCandiesPerWidget) + text: qsTr("You can't put more than %1 pieces of candy in the same rectangle").arg(items.maxNumberOfCandiesPerWidget) } } DialogActivityConfig { id: dialogActivityConfig currentActivity: activity content: Component { Item { height: column.height Column { id: column spacing: 10 width: parent.width GCDialogCheckBox { id: easyModeBox width: dialogActivityConfig.width text: qsTr("Display candy counter") checked: background.easyMode onCheckedChanged: { background.easyMode = checked Activity.reloadRandom() } } } } } onLoadData: { if(dataToSave && dataToSave["mode"]) { background.easyMode = (dataToSave["mode"] === "true"); } } onSaveData: { dataToSave = { "mode": "" + background.easyMode } } onClose: home() } //bar buttons DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level | reload | config} onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: Activity.reloadRandom() onConfigClicked: { dialogActivityConfig.active = true displayDialog(dialogActivityConfig) } } Bonus { id: bonus Component.onCompleted: { win.connect(Activity.nextSubLevel) } onStop: background.finished = false } Score { anchors { bottom: parent.bottom bottomMargin: 10 * ApplicationInfo.ratio right: parent.right rightMargin: 10 * ApplicationInfo.ratio top: undefined left: undefined } numberOfSubLevels: items.nbSubLevel currentSubLevel: items.currentSubLevel + 1 } } } diff --git a/src/activities/share/resource/board/board0.qml b/src/activities/share/resource/board/board0.qml index 38d399fc1..ccbe76565 100644 --- a/src/activities/share/resource/board/board0.qml +++ b/src/activities/share/resource/board/board0.qml @@ -1,69 +1,69 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are given in the left widget which eases kid work. No rest (basket). */ QtObject { property var levels : [ { - "instruction": qsTr("Paul wants to equally share 2 candies between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the candies to each of them."), + "instruction": qsTr("Paul wants to equally share 2 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them."), "totalBoys": 1, "totalGirls": 1, "totalCandies": 2, "showCount": true, "forceShowBasket": "false", "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Now he wants to give 4 candies to his friends."), + "instruction": qsTr("Now he wants to give 4 pieces of candy to his friends."), "totalBoys": 1, "totalGirls": 1, "totalCandies": 4, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Can you now give 6 of Paul's candies to his friends?"), + "instruction": qsTr("Can you now give 6 of Paul's pieces of candy to his friends?"), "totalBoys": 1, "totalGirls": 1, "totalCandies": 6, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Paul has only 10 candies left. He eats 2 candies and he gives the rest to his friends. Can you help him equally split the 8 remaining candies?"), + "instruction": qsTr("Paul has only 10 pieces of candy left. He eats 2 pieces of candy and he gives the rest to his friends. Can you help him equally split the 8 remaining pieces of candy?"), "totalBoys": 1, "totalGirls": 1, "totalCandies": 8, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 } ] } diff --git a/src/activities/share/resource/board/board1.qml b/src/activities/share/resource/board/board1.qml index eb087c596..f09a2eee9 100644 --- a/src/activities/share/resource/board/board1.qml +++ b/src/activities/share/resource/board/board1.qml @@ -1,58 +1,58 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are given in the left widget which eases kid work. There is a rest (basket) */ QtObject { property var levels : [ { - "instruction": qsTr("George wants to equally share 3 candies between 2 of his friends: one girl and one boy. Can he equally split the candies between his friends? First, place the children in center, then drag the candies to each of them. Be careful, a rest will remain!"), + "instruction": qsTr("George wants to equally share 3 pieces of candy between 2 of his friends: one girl and one boy. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"), "totalBoys": 1, "totalGirls": 1, "totalCandies": 3, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Maria wants to equally share 5 candies between 3 of her friends: one girl and two boys. Can she equally split the candies between her friends? First, place the children in center, then drag the candies to each of them. Be careful, a rest will remain!"), + "instruction": qsTr("Maria wants to equally share 5 pieces of candy between 3 of her friends: one girl and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"), "totalBoys": 2, "totalGirls": 1, "totalCandies": 5, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("John wants to equally share 10 candies between 3 of his friends: one boy and two girls. Can he equally split the candies between his friends? First, place the children in center, then drag the candies to each of them."), + "instruction": qsTr("John wants to equally share 10 pieces of candy between 3 of his friends: one boy and two girls. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), "totalBoys": 1, "totalGirls": 2, "totalCandies": 10, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 } ] } diff --git a/src/activities/share/resource/board/board2.qml b/src/activities/share/resource/board/board2.qml index aa773c988..39c2d76c2 100644 --- a/src/activities/share/resource/board/board2.qml +++ b/src/activities/share/resource/board/board2.qml @@ -1,68 +1,68 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are not given anymore in the left widget which forces kids to understand this part. No rest (basket). */ QtObject { property var levels : [ { - "instruction": qsTr("Alice wants to equally share 3 candies between 3 of her friends: one girl and two boys. Can you help her? First, place the children in the center, then drag the candies to each of them."), + "instruction": qsTr("Alice wants to equally share 3 pieces of candy between 3 of her friends: one girl and two boys. Can you help her? First, place the children in the center, then drag the pieces of candy to each of them."), "totalBoys": 2, "totalGirls": 1, "totalCandies": 3, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Now, Alice wants to give 6 candies to her friends"), + "instruction": qsTr("Now, Alice wants to give 6 pieces of candy to her friends"), "totalBoys": 2, "totalGirls": 1, "totalCandies": 6, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Can you help Alice give 9 candies to her friends: one girl and two boys?"), + "instruction": qsTr("Can you help Alice give 9 pieces of candy to her friends: one girl and two boys?"), "totalBoys": 2, "totalGirls": 1, "totalCandies": 9, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Alice has 12 candies left. She wants to give them all to her friends. Can you help her split the candies equally?"), + "instruction": qsTr("Alice has 12 pieces of candy left. She wants to give them all to her friends. Can you help her split the pieces of candy equally?"), "totalBoys": 2, "totalGirls": 1, "totalCandies": 12, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 } ] } diff --git a/src/activities/share/resource/board/board3.qml b/src/activities/share/resource/board/board3.qml index 4b55f1cf6..3f8c6939c 100644 --- a/src/activities/share/resource/board/board3.qml +++ b/src/activities/share/resource/board/board3.qml @@ -1,68 +1,68 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are not given anymore in the left widget. There is a rest (basket). */ QtObject { property var levels : [ { - "instruction": qsTr("Michael wants to equally share 5 candies between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the candies to each of them!"), + "instruction": qsTr("Michael wants to equally share 5 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them!"), "totalBoys": 1, "totalGirls": 1, "totalCandies": 5, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Helen has 3 friends: one boy and two girls. She wants to give them 7 candies. Help her split the candies between her friends!"), + "instruction": qsTr("Helen has 3 friends: one boy and two girls. She wants to give them 7 pieces of candy. Help her split the pieces of candy between her friends!"), "totalBoys": 1, "totalGirls": 2, "totalCandies": 7, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Michelle has 9 candies and wants to split them with two brothers and two sisters. Help her share the candies!"), + "instruction": qsTr("Michelle has 9 pieces of candy and wants to split them with two brothers and two sisters. Help her share the pieces of candy!"), "totalBoys": 2, "totalGirls": 2, "totalCandies": 9, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Thomas wants to share his 11 candies with his friends: three boys and one girl. Can you help him?"), + "instruction": qsTr("Thomas wants to share his 11 pieces of candy with his friends: three boys and one girl. Can you help him?"), "totalBoys": 3, "totalGirls": 1, "totalCandies": 11, "showCount": false, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 0 } ] } diff --git a/src/activities/share/resource/board/board4.qml b/src/activities/share/resource/board/board4.qml index 4a27c3fb8..71a19b678 100644 --- a/src/activities/share/resource/board/board4.qml +++ b/src/activities/share/resource/board/board4.qml @@ -1,58 +1,58 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are not given anymore in the left widget. There is always a basket even if the rest can be equal to 0 */ QtObject { property var levels : [ { - "instruction": qsTr("Charles wants to share his 8 candies with 3 of his friends: one boy and two girls. Can he split the candies equally?"), + "instruction": qsTr("Charles wants to share his 8 pieces of candy with 3 of his friends: one boy and two girls. Can he split the pieces of candy equally?"), "totalBoys": 1, "totalGirls": 2, "totalCandies": 8, "showCount": true, "forceShowBasket": true, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("For her birthday, Elizabeth has 12 candies to share with 4 of her friends: two girls and two boys. How should she split the candies to her friends?"), + "instruction": qsTr("For her birthday, Elizabeth has 12 pieces of candy to share with 4 of her friends: two girls and two boys. How should she split the pieces of candy to her friends?"), "totalBoys": 2, "totalGirls": 2, "totalCandies": 12, "showCount": true, "forceShowBasket": true, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Jason's father gave him 14 candies to share with his friends: two boys and three girls. Help him give the candies to his friends!"), + "instruction": qsTr("Jason's father gave him 14 pieces of candy to share with his friends: two boys and three girls. Help him give the pieces of candy to his friends!"), "totalBoys": 2, "totalGirls": 3, "totalCandies": 14, "showCount": true, "forceShowBasket": true, "placedInGirls": 0, "placedInBoys": 0 } ] } diff --git a/src/activities/share/resource/board/board5.qml b/src/activities/share/resource/board/board5.qml index 2874e70f7..5950461cc 100644 --- a/src/activities/share/resource/board/board5.qml +++ b/src/activities/share/resource/board/board5.qml @@ -1,59 +1,59 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are not given anymore in the left widget. No rest (basket). - Boy or Girl rectangles already contain a given number of candies. + Boy or Girl rectangles already contain a given number of pieces of candy. */ QtObject { property var levels : [ { - "instruction": qsTr("Bob wants to give 5 candies to his friends: two boys and one girl, his girlfriend already has one candy. Can you help him equally split the candies so that each friend will have the same amount of candies?"), + "instruction": qsTr("Bob wants to give 5 pieces of candy to his friends: two boys and one girl, his girlfriend already has one candy. Can you help him equally split the pieces of candy so that each friend will have the same amount of pieces of candy?"), "totalBoys": 2, "totalGirls": 1, "totalCandies": 6, "showCount": true, "forceShowBasket": false, "placedInGirls": 1, "placedInBoys": 0 }, { - "instruction": qsTr("Harry wants to equally share 8 candies between his friends: one boy and two girls. Place the children in center, then drag the candies to each of them so that each of them has an equal number of candies."), + "instruction": qsTr("Harry wants to equally share 8 pieces of candy between his friends: one boy and two girls. Place the children in center, then drag the pieces of candy to each of them so that each of them has an equal number of pieces of candy."), "totalBoys": 1, "totalGirls": 2, "totalCandies": 9, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 1 }, { - "instruction": qsTr("Can you now give 6 of Harry's candies to his friends?"), + "instruction": qsTr("Can you now give 6 of Harry's pieces of candy to his friends?"), "totalBoys": 1, "totalGirls": 2, "totalCandies": 8, "showCount": true, "forceShowBasket": false, "placedInGirls": 0, "placedInBoys": 2 } ] } diff --git a/src/activities/share/resource/board/board6.qml b/src/activities/share/resource/board/board6.qml index 84970a25a..a793a6684 100644 --- a/src/activities/share/resource/board/board6.qml +++ b/src/activities/share/resource/board/board6.qml @@ -1,59 +1,59 @@ /* GCompris * * Copyright (C) 2016 Stefan Toncu * * 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.6 /* Numbers of kids are not given anymore in the left widget. No rest (basket). - Boy or Girl rectangles already contain a given number of candies. + Boy or Girl rectangles already contain a given number of pieces of candies. */ QtObject { property var levels : [ { - "instruction": qsTr("Help Jon split 9 candies between three boys and two girls. The rest will remain to Jon."), + "instruction": qsTr("Help Jon split 9 pieces of candies between three boys and two girls. The rest will remain to Jon."), "totalBoys": 3, "totalGirls": 2, "totalCandies": 9, "showCount": false, "forceShowBasket": true, "placedInGirls": 0, "placedInBoys": 0 }, { - "instruction": qsTr("Jon wants to share the rest of his candies with his brother and his sister. Can you split them equally, knowing that his brother already has two candies?"), + "instruction": qsTr("Jon wants to share the rest of his pieces of candies with his brother and his sister. Can you split them equally, knowing that his brother already has two pieces of candies?"), "totalBoys": 1, "totalGirls": 1, "totalCandies": 6, "showCount": false, "forceShowBasket": true, "placedInGirls": 0, "placedInBoys": 2 }, { - "instruction": qsTr("Help Tux split some candies to his friends: 9 candies to one boy and two girls."), + "instruction": qsTr("Help Tux split some pieces of candies to his friends: 9 pieces of candies to one boy and two girls."), "totalBoys": 1, "totalGirls": 2, "totalCandies": 13, "showCount": false, "forceShowBasket": true, "placedInGirls": 2, "placedInBoys": 0 } ] } diff --git a/src/activities/share/share.js b/src/activities/share/share.js index b8346474e..e45e47440 100644 --- a/src/activities/share/share.js +++ b/src/activities/share/share.js @@ -1,220 +1,220 @@ /* GCompris - share.js * * Copyright (C) 2016 Stefan Toncu * * 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.6 as Quick var currentLevel = 0 var numberOfLevel = 10 var items var savedTotalBoys var savedTotalGirls var savedTotalCandies var savedPlacedInGirls var savedPlacedInBoys var savedCurrentCandies function start(items_) { items = items_ currentLevel = 0 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 var filename = "resource/board/"+ "board" + currentLevel + ".qml" items.dataset.source = filename setUp() } function setUp() { var levelData = items.dataset.item // use board levels if (currentLevel < 7) { var subLevelData = levelData.levels[items.currentSubLevel]; items.totalBoys = subLevelData.totalBoys items.totalGirls = subLevelData.totalGirls items.totalCandies = subLevelData.totalCandies items.instruction.text = subLevelData.instruction items.nbSubLevel = levelData.levels.length items.background.currentCandies = items.totalGirls * subLevelData.placedInGirls + items.totalBoys * subLevelData.placedInBoys items.background.placedInGirls = subLevelData.placedInGirls items.background.placedInBoys = subLevelData.placedInBoys items.background.showCount = subLevelData.showCount items.background.rest = items.totalCandies - Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) items.basketWidget.element.opacity = (subLevelData.forceShowBasket === true || items.background.rest !== 0) ? 1 : 0 items.background.wrongMove.visible = false } else { // create random (guided) levels // get a random number between 1 and max for boys, girls and candies var maxBoys = levelData.levels[0].maxBoys var maxGirls = levelData.levels[0].maxGirls var maxCandies = levelData.levels[0].maxCandies items.totalBoys = Math.floor(Math.random() * maxBoys) + 1 items.totalGirls = Math.floor(Math.random() * maxGirls) + 1 var sum = items.totalBoys + items.totalGirls // use sum * 4 as top margin (max 4 candies per rectangle) items.totalCandies = Math.floor(Math.random() * (4 * sum - sum + 1)) + sum // stay within the max margin if (items.totalCandies > maxCandies) items.totalCandies = maxCandies //~ singular Place %n boy //~ plural Place %n boys - items.instruction.text = qsTr("Place %n boy(s) ", "First part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n candies between them.", items.totalBoys); + items.instruction.text = qsTr("Place %n boy(s) ", "First part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalBoys); //~ singular and %n girl in the center. //~ plural and %n girls in the center. - items.instruction.text += qsTr("and %n girl(s) in the center. ", "Second part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n candies between them.", items.totalGirls); + items.instruction.text += qsTr("and %n girl(s) in the center. ", "Second part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalGirls); //~ singular Then equally split %n candy between them. //~ plural Then equally split %n candies between them. - items.instruction.text += qsTr("Then equally split %n candies between them.", "Third part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n candies between them.", items.totalCandies); + items.instruction.text += qsTr("Then equally split %n pieces of candy between them.", "Third part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalCandies); items.background.showCount = false items.nbSubLevel = 5 // depending on the levels configuration, add candies from start in a child rectangle if (levelData.levels[0].alreadyPlaced == false) { items.background.placedInGirls = 0 items.background.placedInBoys = 0 items.background.currentCandies = 0 } else { items.background.currentCandies = items.totalCandies * 2 // Place randomly between 0 and 3 candies for each child while (items.background.currentCandies > items.totalCandies / 3) { items.background.placedInGirls = Math.floor(Math.random() * 3) items.background.placedInBoys = Math.floor(Math.random() * 3) items.background.currentCandies = items.totalGirls * items.background.placedInGirls + items.totalBoys * items.background.placedInBoys } } items.background.rest = items.totalCandies - Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) items.basketWidget.element.opacity = 1 items.background.wrongMove.visible = false; saveVariables() } resetBoard() } function resetBoard() { items.background.currentGirls = 0 items.background.currentBoys = 0 items.background.resetCandy() items.background.finished = false items.acceptCandy = false items.instruction.opacity = 1 items.listModel.clear() items.girlWidget.current = 0 items.girlWidget.canDrag = true items.girlWidget.element.opacity = 1 items.boyWidget.current = 0 items.boyWidget.canDrag = true items.boyWidget.element.opacity = 1 items.candyWidget.canDrag = true items.candyWidget.element.opacity = 1 if (items.totalCandies - items.background.currentCandies == 0) items.candyWidget.element.opacity = 0.6 items.basketWidget.canDrag = true } function saveVariables() { savedTotalBoys = items.totalBoys savedTotalGirls = items.totalGirls savedTotalCandies = items.totalCandies savedPlacedInGirls = items.background.placedInGirls savedPlacedInBoys = items.background.placedInBoys savedCurrentCandies = items.background.currentCandies } function loadVariables() { items.totalBoys = savedTotalBoys items.totalGirls = savedTotalGirls items.totalCandies = savedTotalCandies items.background.placedInGirls = savedPlacedInGirls items.background.placedInBoys = savedPlacedInBoys items.background.currentCandies = savedCurrentCandies } function reloadRandom() { if (currentLevel < 7) { initLevel() } else { loadVariables() resetBoard() items.background.rest = items.totalCandies - Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) items.background.showCount = false items.basketWidget.element.opacity = 1 } } function nextSubLevel() { items.currentSubLevel ++ if (items.currentSubLevel === items.nbSubLevel) { nextLevel() } else { setUp() } } function nextLevel() { if(numberOfLevel <= ++currentLevel) { currentLevel = 0 } items.currentSubLevel = 0; initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } items.currentSubLevel = 0; initLevel(); }