Commit bda450a7 authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

Merge branch 'explore_activities'

parents 44be9f7c 449f9f21
......@@ -34,6 +34,9 @@ enumerate
erase
erase_2clic
erase_clic
explore_farm_animals
explore_world_animals
explore_world_music
fifteen
followline
football
......
/* GCompris - ActivityInfo.qml
*
* Copyright (C) 2015 Your Name <yy@zz.org>
* Copyright (C) 2015 Djalil Mesli <djalilmesli@gmail.com>
*
* 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
......@@ -21,7 +21,7 @@ ActivityInfo {
name: "explore_farm_animals/ExploreFarmAnimals.qml"
difficulty: 2
icon: "explore_farm_animals/explore_farm_animals.svg"
author: "Beth Hadley &lt;bethmhadley@gmail.com&gt;"
author: "Djalil Mesli &lt;djalilmesli@gmail.com&gt;"
demo: true
title: qsTr("Explore Farm Animals")
description: qsTr("Learn about farm animals, what sounds they make, and interesting facts.")
......@@ -36,5 +36,5 @@ In level two, a random animal sound is played and you must choose which animal m
In level three, a random text prompt is displayed and you must click on the animal that matches the text. When you have matched all texts correctly, you win!
")
credit: ""
section: "/discovery/sound_group"
section: "discovery sound_group"
}
/* GCompris - AnimalDescription.qml
*
* Copyright (C) 2015 Djalil MESLI <djalilmesli@gmail.com>
*
* Authors:
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
* Djalil MESLI <djalilmesli@gmail.com> (Qt Quick port)
* Johnny Jazeix <jazeix@gmail.com> (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/>.
*/
import QtQuick 2.2
import GCompris 1.0
import "../../core"
import "explore.js" as Activity
Rectangle {
id: rectangleDesc
radius: 30
border.width: 5
border.color: "black"
width: parent.width
height: parent.height
MouseArea {
anchors.fill: parent
onPressed: parent.close()
}
property alias title: heading.text
property alias description: descriptionText.text
property alias imageSource: animalImage.source
property bool horizontalLayout: background.width > background.height
GCText {
id: heading
fontSize: largeSize
horizontalAlignment: Text.AlignHCenter
font.weight: Font.DemiBold
anchors.centerIn: parent.Center
color: "#2a2a2a"
width: parent.width
wrapMode: Text.WordWrap
}
Image {
id: animalImage
width: rectangleDesc.horizontalLayout ? parent.width / 2 : parent.width * 0.9
height: rectangleDesc.horizontalLayout ?
parent.height * 0.8 :
(parent.height - heading.height - descriptionText.height) * 0.9
fillMode: Image.PreserveAspectFit
anchors {
top: rectangleDesc.horizontalLayout ? heading.bottom : descriptionText.bottom
horizontalCenter: rectangleDesc.horizontalLayout ? undefined : heading.horizontalCenter
left: rectangleDesc.horizontalLayout ? parent.left : undefined
leftMargin: rectangleDesc.horizontalLayout ? 30 * ApplicationInfo.ratio : 0
}
}
GCText {
id: descriptionText
font.weight: Font.DemiBold
fontSizeMode: Text.Fit
horizontalAlignment: Text.AlignJustify
anchors {
top: heading.bottom
right: parent.right
rightMargin: 30 * ApplicationInfo.ratio
left: rectangleDesc.horizontalLayout ? animalImage.right : parent.left
leftMargin: 30 * ApplicationInfo.ratio
}
color: "#2a2a2a"
width: rectangleDesc.horizontalLayout ? parent.width * 0.45 : parent.width
height: rectangleDesc.horizontalLayout ? parent.height * 0.5 : parent.height * 0.3
wrapMode: Text.WordWrap
}
// The cancel button
GCButtonCancel {
onClose: parent.close()
}
function close() {
rectangleDesc.visible = false;
if (Activity.isComplete()) {
Activity.items.bonus.good("flower");
Activity.nextLevel();
}
}
}
/* GCompris - Animals.qml
*
* Copyright (C) 2015 Djalil MESLI <djalilmesli@gmail.com>
*
* Authors:
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
* Djalil MESLI <djalilmesli@gmail.com> (Qt Quick port)
* Johnny Jazeix <jazeix@gmail.com> (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/>.
*/
import QtQuick 2.2
import GCompris 1.0
import "../../core"
import "explore.js" as Activity
Image {
id: animalImg
width: animalWidth
height: animalHeight
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
property string name: name
property alias starVisible: star.visible
property int questionId
property string title
property string description
property string imageSource
property string question
property string audio
signal displayDescription(variant animal)
SequentialAnimation {
id: anim
running: true
loops: 1
NumberAnimation {
target: animalImg
property: "rotation"
from: 0; to: 360
duration: 400 + Math.floor(Math.random() * 400)
easing.type: Easing.InOutQuad
}
}
Image {
id: star
x: animalImg.width / 2.5
y: animalImg.height * 0.8
visible: false
source:"qrc:/gcompris/src/core/resource/star.png"
}
MultiPointTouchArea {
id: touchArea
anchors.centerIn: parent
// Make the item big enough to be clicked easily
width: Math.max(parent.width, 70 * ApplicationInfo.ratio)
height: Math.max(parent.height, 70 * ApplicationInfo.ratio)
touchPoints: [ TouchPoint { id: point1 } ]
mouseEnabled: true
onPressed: {
var questionTargetId = items.questionOrder[Activity.items.score.currentSubLevel]
Activity.items.instruction.visible = false
if (Activity.items.currentLevel == 0) {
audioEffects.play(animalImg.audio);
displayDescription(animalImg)
star.visible = true;
} else {
if (questionId === questionTargetId) {
animWin.start();
items.bonus.good("smiley");
Activity.nextSubLevel();
} else {
items.bonus.bad("smiley")
}
}
}
}
SequentialAnimation {
id: animWin
running: false
loops: 1
NumberAnimation {
target: animalImg
property: "rotation"
from: 0; to: 360
duration: 600
easing.type: Easing.InOutQuad
}
}
}
GCOMPRIS_ADD_RCC(activities/explore_farm_animals *.qml *.svg *.js resource/*)
/* GCompris - Explore.qml
*
* Copyright (C) 2015 Djalil MESLI <djalilmesli@gmail.com>
*
* Authors:
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
* Djalil MESLI <djalilmesli@gmail.com> (Qt Quick port)
* Johnny Jazeix <jazeix@gmail.com> (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/>.
*/
import QtQuick 2.1
import GCompris 1.0
import QtGraphicalEffects 1.0
import "../../core"
import "explore.js" as Activity
ActivityBase {
id: activity
property string backgroundImage
property var dataset
property bool hasAudioQuestions
onStart: focus = true
onStop: {}
pageComponent: Item {
id: background
/* In order to accept any screen ratio the play area is always a 1000x1000
* square and is centered in a big background image that is 2000x2000
*/
Image {
id: bg
source: backgroundImage
sourceSize.width: 2000 * ApplicationInfo.ratio
sourceSize.height: 2000 * ApplicationInfo.ratio
width: 2000 * background.playRatio
height: width
anchors.centerIn: parent
}
Rectangle {
width: background.playWidth
height: background.playHeight
anchors.centerIn: parent
border.width: 2
border.color: "black"
color: "transparent"
visible: false /* debug to see the play area */
}
property bool horizontalLayout: background.width > background.height
property int playX: (activity.width - playWidth) / 2
property int playY: (activity.height - playHeight) / 2
property int playWidth: horizontalLayout ? activity.height : activity.width
property int playHeight: playWidth
property double playRatio: playWidth / 1000
focus: true
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 GCAudio audioEffects: activity.audioEffects
property Item main: activity.main
property alias background: background
property alias bar: bar
property alias bonus: bonus
property alias score: score
property alias dataModel: dataModel
property alias instruction: instruction
property alias instructionText: instructionText
property alias descriptionPanel: descriptionPanel
property bool hasAudioQuestions: activity.hasAudioQuestions
property int currentLevel
property string currentAudio
property var questionOrder
property var currentQuestion: activity.dataset.tab[items.questionOrder[score.currentSubLevel]]
}
onStart: { Activity.start(items, dataset) }
onStop: { Activity.stop() }
Keys.onEscapePressed: {
descriptionPanel.visible ? descriptionPanel.visible = false : home()
}
Repeater {
id: dataModel
model: dataset.tab.length
Animals {
questionId: index
source: dataset.tab[index].image
x: background.playX + background.playWidth * dataset.tab[index].x - width / 2
y: background.playY + background.playHeight * dataset.tab[index].y - height / 2
width: background.playWidth * dataset.tab[index].width
height: background.playHeight * dataset.tab[index].height
title: dataset.tab[index].title
description: dataset.tab[index].text
imageSource: dataset.tab[index].image2
question: dataset.tab[index].text2
audio: dataset.tab[index].audio !== undefined ? dataset.tab[index].audio : ""
Component.onCompleted: {
displayDescription.connect(displayDescriptionItem)
}
}
}
function displayDescriptionItem(animal) {
descriptionPanel.title = animal.title
descriptionPanel.description = animal.description
descriptionPanel.imageSource = animal.imageSource
descriptionPanel.visible = true
}
AnimalDescription {
id: descriptionPanel
width: parent.width
height: parent.height
visible: false
z: instruction.z + 1
onVisibleChanged: {
if(visible) {
animDescription.start()
}
else {
// stop if audio was playing
items.audioEffects.stop()
}
}
NumberAnimation {
id: animDescription
target: descriptionPanel
property: horizontalLayout ? "x" : "y"
from: horizontalLayout ? -width : -height
to: 0
duration: 1200
easing.type: Easing.OutBack
}
}
Row {
id: row
spacing: 10 * ApplicationInfo.ratio
anchors.fill: parent
anchors.margins: 10 * ApplicationInfo.ratio
layoutDirection: leftCol.width === 0 ? Qt.RightToLeft : Qt.LeftToRight
Column {
id: leftCol
spacing: 10 * ApplicationInfo.ratio
Rectangle {
id: question
width: row.width - rightCol.width - 10 * ApplicationInfo.ratio
height: questionText.height
color: '#CCCCCCCC'
radius: 10
border.width: 3
border.color: "black"
visible: items.currentLevel == 2 || (items.currentLevel == 1 && !items.hasAudioQuestions)
GCText {
id: questionText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.centerIn: parent.Center
color: "black"
width: parent.width
wrapMode: Text.Wrap
text: items.currentQuestion.text2
}
}
Rectangle {
id: instruction
width: row.width - rightCol.width - 10 * ApplicationInfo.ratio
height: instructionText.height
color: "#CCCCCCCC"
radius: 10
border.width: 3
border.color: "black"
GCText {
id: instructionText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.centerIn: parent.Center
color: "black"
width: parent.width
wrapMode: Text.Wrap
text: activity.dataset.instruction[bar.level - 1].text
}
MouseArea {
anchors.fill: parent
onClicked: instruction.visible = false
enabled: instruction.visible
}
}
}
Column {
id: rightCol
spacing: 10 * ApplicationInfo.ratio
Score {
id: score
visible: items.currentLevel != 0
anchors {
bottom: undefined
right: undefined
}
}
BarButton {
id: repeatItem
source: "qrc:/gcompris/src/core/resource/bar_repeat.svg";
sourceSize.width: 60 * ApplicationInfo.ratio
anchors.right: parent.right
visible: items.currentLevel == 1 && activity.hasAudioQuestions //&& ApplicationSettings.isAudioVoicesEnabled
onClicked: Activity.repeat();
}
}
}
DialogHelp {
id: dialogHelp
onClose: home()
}
Bar {
id: bar
content: BarEnumContent { value: help | home | level }
onHelpClicked: {
displayDialog(dialogHelp)
}
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: activity.home()
}
Bonus {
id: bonus
}
}
}
/* GCompris - ExploreFarmAnimals.qml
*
* Copyright (C) 2015 Djalil MESLI <djalilmesli@gmail.com>
*
* Authors:
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
* Djalil MESLI <djalilmesli@gmail.com> (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/>.
*/
import QtQuick 2.1
import GCompris 1.0
import "explore_farm_animals.js" as Dataset
Explore {
id: activity
dataset: Dataset
backgroundImage: "qrc:/gcompris/src/activities/explore_farm_animals/resource/farm-animals.svg"
hasAudioQuestions: true
}
/* GCompris - explore.js
*
* Copyright (C) 2015 Djalil MESLI <djalilmesli@gmail.com>
*
* Authors:
* Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
* Djalil MESLI <djalilmesli@gmail.com> (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/>.
*/
.pragma library
.import GCompris 1.0 as GCompris
.import "qrc:/gcompris/src/core/core.js" as Core
var numberOfLevel
var items
var dataset