diff --git a/src/activities/family/Family.qml b/src/activities/family/Family.qml index ce52e3e2e..f29c3ad94 100644 --- a/src/activities/family/Family.qml +++ b/src/activities/family/Family.qml @@ -1,379 +1,376 @@ /* GCompris - family.qml * * Copyright (C) 2015 RAJDEEP KAUR * * Authors: * RAJDEEP KAUR (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 . */ import QtQuick 2.1 import GCompris 1.0 import QtQuick.Controls 1.0 import "../../core" import "family.js" as Activity ActivityBase { id: activity property string url : "qrc:/gcompris/src/activities/family/resource/" onStart: focus = true onStop: {} pageComponent: Image { id: background anchors.fill: parent fillMode: Image.PreserveAspectCrop source: "qrc:/gcompris/src/activities/family/resource/background.svg" sourceSize.width: parent.width signal start signal stop Component.onCompleted: { 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 pic1: pic1 property alias pic2: pic2 property alias pic3: pic3 /* d stands for the data of the various */ property string caption1d property string caption2d property string caption3d property string answered property string circle1d property string circle2d property string circle3d property string button1d property string button2d property string button3d property string imageOrtext /* to check whether we are using image or text in this level */ } onStart: { Activity.start(items) } onStop: { Activity.stop() } DialogHelp { id: dialogHelp onClose: home() } Image { id:bambo1 source: url + "bambo.svg" x:background.width/14+2*circleContent2.width y:background.height/2.3 width:background.width/30 height:background.height/2.2 rotation:90 } Item { id: caption1 visible: items.imageOrtext === "image" ? true : items.caption1d === "?" ? true : false GCText { id: caption1text text:items.caption1d visible:items.caption1d === "?" ? false : true x: background.width/14+2*circleContent2.width y: background.height/1.5 } Image { id: caption1image source: url+"questionmark.svg" visible: items.caption1d === "?" ? true : false x: background.width/14+2*circleContent2.width y: background.height/1.5 } } Image { id:bambo2 source:url + "bambo.svg" x:background.width/5.5 y:background.height/5.5 height:background.height/1.9 width:background.width/28 rotation:40 } Item{ id:caption2 x:background.width/7 y:background.height/2.5 visible: items.imageOrtext === "image" ? true : items.caption2d === "?" ? true : false GCText { id:captiontext2 text:items.caption2d visible:items.caption2d === "?" ? false : true } Image { source:url+"questionmark.svg" visible:items.caption2d === "?" ? true : false } } Image { id:bambo3 source:url+ "bambo.svg" height:background.height/2.7 width:background.width/20 x:background.width/120+background.width/3.5+(circleContent2.width) y:background.height/4.5 rotation:150 } Item { id:caption3 y:background.height/2.5 x:background.width/14+background.width/4+(1.3*circleContent2.width) visible: items.imageOrtext === "image" ? true : items.caption3d === "?" ? true : false GCText { id:captiontext3 text:items.caption3d visible:items.caption3d === "?" ? false : true } Image { source:url+"questionmark.svg" visible:items.caption3d === "?" ? true : false } } Item { id:circleContent1 x:background.width/3.6 y:background.height/10 width:background.width/9 height:background.width/9 Rectangle { id:circlef width:parent.width height:parent.height radius:parent.width/2 border.color:"black" border.width:5 Image { id:pic1 visible: items.imageOrtext === "image" ? true : false - source: items.imageOrtext === "image" ? (url+ items.circle1d):(url+"text_background.svg") width:parent.width height:parent.height anchors { horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } GCText{ id:text1 visible: items.imageOrtext === "text" ? true : false text:qsTr(items.circle1d) fontSize:19 anchors{ horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } } } Grid { columns:2 columnSpacing:background.width/4 x:background.width/14 y:background.height/1.8 Item { id:circleContent2 width:background.width/9 height:background.width/9 Rectangle { id:circlef1 width:parent.width height:parent.height border.color:"black" radius:parent.width/2 border.width: 5 Image { id:pic2 visible: items.imageOrtext === "image" ? true : false - source: items.imageOrtext === "image" ? (url+items.circle2d) :(url+"text_background.svg") width:parent.width height:parent.height anchors{ horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } GCText{ id:text2 visible:items.imageOrtext === "text" ? true : false text:qsTr(items.circle2d) fontSize:19 anchors{ horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } } } Item { id:circleContent3 width:background.width/9 height:background.width/9 Rectangle { id:cirlef2 width:parent.width height:parent.height radius:parent.width/2 border.color:"black" border.width: 5 Image { id:pic3 visible:items.imageOrtext === "image" ? true : false - source:items.imageOrtext === "image" ? (url+items.circle3d) : (url+"text_background.svg") width:parent.width height:parent.height anchors { horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } GCText{ id:text3 visible:items.imageOrtext === "text" ? true : false text:qsTr(items.circle3d) fontSize:19 anchors{ horizontalCenter:parent.horizontalCenter verticalCenter: parent.verticalCenter } } } } } Grid { columns: 1 rowSpacing:background.width/10 x:background.width/1.5 y:background.height/14 AnswerButton { id:button1 width:background.width/5 height:background.height/6 textLabel:qsTr(items.button1d) onPressed: { if(button1.textLabel === items.answered) { bonus.good("lion") } else { bonus.bad("lion") } } } AnswerButton { id:button2 width:background.width/5 height:background.height/6 textLabel:qsTr(items.button2d) onPressed: { if(button2.textLabel === items.answered) { bonus.good("lion") } else { bonus.bad("lion") console.log(items.answered) } } } AnswerButton { id:button3 width:background.width/5 height:background.height/6 textLabel:qsTr(items.button3d) onPressed: { if(button3.textLabel === items.answered) { bonus.good("lion") } else { bonus.bad("lion") } } } } Bar { id: bar content: BarEnumContent { value: help | home | level } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } } } diff --git a/src/activities/family/family.js b/src/activities/family/family.js index fc35e2437..c3c95bce0 100644 --- a/src/activities/family/family.js +++ b/src/activities/family/family.js @@ -1,191 +1,192 @@ /* GCompris - family.js * * Copyright (C) 2015 RAJDEEP KAUR * * Authors: * "RAJDEEP KAUR" (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 . */ .pragma library .import QtQuick 2.0 as Quick .import "qrc:/gcompris/src/core/core.js" as Core var currentLevel = 0 var numberOfLevel = 35 var flag var items var currentdata /* The first three elements of dataset is refer to the circle elements the next three elements refer to the content of answer button and then 7th element refer to the correct answer then next three element refer to the how we are related to other people, the contents that will be displayed next to bambo at last we will mention a flag that is either image or text */ var dataset = [ [ "man1.svg","girl1.svg","grandmother.svg","Grand Mother","Grand Father","Father","Grand Mother", "?","Father","Mother","image"], [ "grandpa.svg","girl2.svg","man1.svg","Grand Mother", "Mother", "Grand Father","Grand Father", "Father","?","Son","image"], [ "girl3.svg","man1.svg","man2.svg","Uncle","Aunty","father","Uncle","Brother","Daughter","?", "image"], [ "lady.svg","boy1.svg","lady1.svg","Mother","Aunty","GrandMother","Aunty","Mother","?","Sister", "image"], [ "lady.svg","boy1.svg","girl2.svg","Brother","Sister","Cousin","Cousin","?","Mother","Niece", "image"], [ "man1.svg","man2.svg","boy1.svg","Daughter","Son","Newphew","Newphew","Son","Brother","?", "image"], [ "girl3.svg","man1.svg","man2.svg","Newphew","Niece","Daughter","Niece","Brother","?","Father", "image"], [ "grandmother.svg","man1.svg","boy1.svg","Grand Son", "Son","Son In Law","Grand Son", "Son","Son","?","image"], [ "lady.svg","girl1.svg","grandpa.svg","Grand Daughter","Daughter","Daughter In Law","Grand Daughter", "?","Mother","Father","image"] , [ "man1.svg","lady1.svg","grandmother.svg","Mother","Mother in law","Aunty","Mother in law", "Mother","Husband","?","image"], [ "girl2.svg","man2.svg","grandpa.svg","Father", "Father in Law", "Uncle","Father in Law", "Father","Wife","?","image"], [ "girl3.svg","man1.svg","girl2.svg","Sister","Cousin","Sister in Law","Sister in Law", "?","Wife","Sister","image"], [ "man2.svg","girl3.svg","man1.svg","Brother","Brother in law","Cousin","Brother in law", "?","Husband","Brother","image"], [ "man1.svg","boy1.svg","lady1.svg","Mother","Aunty","Step-Mother","Step-Mother", "?","Father","Second Wife","image"], [ "lady.svg","girl2.svg","man2.svg","Father","Uncle","Step-Father","Step-Father", "?","Mother","Second Husband","image"], [ "boy2.svg","man1.svg","lady.svg","Son","Step-Son","Newphew","Step-Son", "Second Wife","?","Mother","image"], [ "lady1.svg","man2.svg","girl2.svg","Step-Daughter","Niece","Daughter","Step-Daughter", "Daughter","Second wife","?","image"], [ "Father","You","Mother","Grand Mother","Grand Father","Father","Grand Mother", "?","","","text"], [ "Father","You","Father","Grand Mother","Mother", "Grand Father","Grand Father", "?","","","text"], [ "You","Son","Brother","Uncle","Aunty","father","Uncle","","","?","text"], [ "You","Daughter","Sister","Mother","Aunty","GrandMother","Aunty","","","?", "text"], [ "Father","You","Newphew","Brother","Sister","Cousin","Cousin","?","","", "text"], [ "Father","You","Niece","Brother","Sister","Cousin","Cousin","?","","", "text"], ["Father","You","Cousin","Daughter","Son","Newphew","Newphew","","","?", "text"], ["Mother","You","Cousin","Son","Niece","Daughter","Niece","","","?", "text"], ["Son","You","Son","Grand Son", "Son","Son In Law","Grand Son","?","","","text"], ["Son","You","Daughter","Grand Daughter","Daughter","Daughter In Law","Grand Daughter", "?","","","text"], ["Wife","You","Mother","Mother","Mother in law","Aunty","Mother in law", "?","","","text"], ["husband","You","Father","Father", "Father in Law", "Uncle","Father in Law", "?","","","text"], ["Wife","You","Brother","Brother","Brother in law","Cousin","Brother in law", "?","","","text"], ["Wife","You","Sister","Sister","Cousin","Sister in Law","Sister in Law", "?","","","text"], ["Father","Second\nWife","You", "Mother","Aunty","Step-Mother","Step-Mother", "?","","","text"], ["Mother","Second\nHusband","You","Father","Uncle","Step-Father","Step-Father", "?","","","text"], ["Second\nWife","You","Son","Son","Step-Son","Newphew","Step-Son","?","","","text"], ["Second\nWife","You","Daughter","Step-Daughter","Niece","Daughter","Step-Daughter", "?","","","text"] ]; function start(items_) { items = items_ currentLevel = 0 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 dataset = Core.shuffle(dataset); currentdata = dataset[items.bar.level]; items.imageOrtext = currentdata[10]; if(currentdata[10] === "text") { items.pic1.source = "qrc:/gcompris/src/activities/family/resource/" + "text_background.svg" items.pic1.visible = false items.pic2.source = "qrc:/gcompris/src/activities/family/resource/" + "text_background.svg" items.pic2.visible = false items.pic3.source = "qrc:/gcompris/src/activities/family/resource/" + "text_background.svg" items.pic3.visible = false }else { items.pic1.source = "qrc:/gcompris/src/activities/family/resource/" + currentdata[0] items.pic1.visible = true items.pic2.source = "qrc:/gcompris/src/activities/family/resource/" + currentdata[1] items.pic2.visible = true items.pic3.source = "qrc:/gcompris/src/activities/family/resource/" + currentdata[2] items.pic3.visible = true } items.circle1d = currentdata[0]; items.circle2d = currentdata[1]; items.circle3d = currentdata[2]; - items.answered = currentdata[6]; items.button1d = currentdata[3]; items.button2d = currentdata[4]; items.button3d = currentdata[5]; + items.answered = currentdata[6]; + items.button1d = currentdata[3]; items.button2d = currentdata[4]; items.button3d = currentdata[5]; items.caption1d = currentdata[7]; items.caption2d = currentdata[8]; items.caption3d = currentdata[9]; } function nextLevel() { if(numberOfLevel <= ++currentLevel ) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); }