Commit 8552402a authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

scalesboard, added dataset support and right drop disabling

parent 39a67fa2
import GCompris 1.0
ActivityInfo {
name: "scalesboard/Scalesboard.qml"
name: "scalesboard/ScaleNumber.qml"
difficulty: 2
icon: "scalesboard/scalesboard.svgz"
author: "Bruno Coudoin <bruno.coudoin@gcompris.net>"
......
......@@ -30,6 +30,7 @@ Rectangle {
border.width: 2
border.color: dropArea.containsDrag ? "#33666666" : "#00000000"
property alias dropEnabled: dropArea.enabled
property int nbColumns
property int nbLines: background.width > background.height ? 1 : 2
property int itemWidth: (width - masseFlow.spacing * nbColumns) / nbColumns
......
/* GCompris - Scalesboard.qml
*
* Copyright (C) 2014 Bruno Coudoin
*
* Authors:
* miguel DE IZARRA <miguel2i@free.fr> (GTK+ version)
* Bruno Coudoin <bruno.coudoin@gcompris.net> (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 <http://www.gnu.org/licenses/>.
*/
Scalesboard {
dataset: [
{
"masses": [1, 2, 2, 5, 5, 10, 10],
"targets": [3, 4, 6, 7, 8, 9],
"rightDrop": false
},
{
"masses": [1, 2, 2, 5, 5, 10, 10],
"targets": [12, 13, 14, 15, 16],
"rightDrop": false
},
{
"masses": [2, 2, 5, 5, 5],
"targets": [8, 11, 13],
"rightDrop": true
},
{
"masses": [2, 5, 10, 10],
"targets": [3, 8, 13],
"rightDrop": true
},
{
"masses": [2, 4, 7, 10],
"targets": [3, 5, 8, 9],
"rightDrop": true
},
{
"masses": [5, 8, 9, 10, 11, 12],
"targets": [6, 7, 13, 14, 15, 16, 17, 18],
"rightDrop": true
}
]
}
......@@ -27,6 +27,8 @@ import "scalesboard.js" as Activity
ActivityBase {
id: activity
property variant dataset
onStart: focus = true
onStop: {}
......@@ -53,6 +55,7 @@ ActivityBase {
property alias background: background
property alias bar: bar
property alias bonus: bonus
property variant dataset: activity.dataset
property alias masseAreaCenter: masseAreaCenter
property alias masseAreaLeft: masseAreaLeft
property alias masseAreaRight: masseAreaRight
......@@ -134,6 +137,7 @@ ActivityBase {
masseAreaLeft: masseAreaLeft
masseAreaRight: masseAreaRight
nbColumns: 4
dropEnabled: true
Behavior on anchors.verticalCenterOffset {
NumberAnimation {
......@@ -180,6 +184,7 @@ ActivityBase {
masseAreaLeft: masseAreaLeft
masseAreaRight: masseAreaRight
nbColumns: 4
dropEnabled: items.dataset[bar.level - 1].rightDrop
Behavior on anchors.verticalCenterOffset {
NumberAnimation {
......@@ -201,6 +206,7 @@ ActivityBase {
masseAreaLeft: masseAreaLeft
masseAreaRight: masseAreaRight
nbColumns: masseModel.count / nbLines
dropEnabled: true
}
DialogHelp {
......
......@@ -25,36 +25,9 @@
var url = "qrc:/gcompris/src/activities/scalesboard/resource/"
var dataset = [
{
"masses": [1, 2, 2, 5, 5, 10, 10],
"targets": [3, 4, 6, 7, 8, 9]
},
{
"masses": [1, 2, 2, 5, 5, 10, 10],
"targets": [12, 13, 14, 15, 16]
},
{
"masses": [2, 2, 5, 5, 5],
"targets": [8, 11, 13]
},
{
"masses": [2, 5, 10, 10],
"targets": [3, 8, 13]
},
{
"masses": [2, 4, 7, 10],
"targets": [3, 5, 8, 9]
},
{
"masses": [5, 8, 9, 10, 11, 12],
"targets": [6, 7, 13, 14, 15, 16, 17, 18]
}
]
var currentLevel = 0
var currentSubLevel = 0
var numberOfLevel = dataset.length
var numberOfLevel
var items
var currentTargets = []
var initCompleted = false
......@@ -62,6 +35,7 @@ var initCompleted = false
function start(items_) {
items = items_
currentLevel = 0
numberOfLevel = items.dataset.length
initLevel()
}
......@@ -71,7 +45,7 @@ function stop() {
function initLevel() {
items.bar.level = currentLevel + 1
currentSubLevel = 0
currentTargets = Core.shuffle(dataset[currentLevel].targets)
currentTargets = Core.shuffle(items.dataset[currentLevel].targets)
displayLevel()
}
......@@ -81,7 +55,7 @@ function displayLevel()
items.masseAreaLeft.init()
items.masseAreaRight.init()
items.masseAreaCenter.init()
var data = dataset[currentLevel]
var data = items.dataset[currentLevel]
for(var i=0; i < data.masses.length; i++)
items.masseAreaCenter.addMasse("masse" + (i % 5 + 1) + ".svg",
data.masses[i],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment