Commit 3b5f6e96 authored by Akshat Tandon's avatar Akshat Tandon Committed by Johnny Jazeix
Browse files

letter-in-word, initial working version

parent 5de7cea6
......@@ -62,6 +62,7 @@ intro_gravity
land_safe
lang
leftright
letter-in-word
lightsoff
louis-braille
magic-hat-minus
......
advanced_colors
algebra_by
algebra_div
algebra_minus
algebra_plus
algorithm
align4
align4-2players
alphabet-sequence
babymatch
babyshapes
baby_wordprocessor
balancebox
ballcatch
braille_alphabets
braille_fun
canal_lock
chess
chess_2players
chess_partyend
chronos
clickanddraw
clickgame
click_on_letter
click_on_letter_up
clockgame
color_mix
color_mix_light
colors
details
drawnumber
enumerate
erase
erase_2clic
erase_clic
explore_farm_animals
explore_monuments
explore_world_animals
explore_world_music
fifteen
followline
football
geo-country
geography
gletters
gnumch-equality
gnumch-factors
gnumch-inequality
gnumch-multiples
gnumch-primes
graph-coloring
guessnumber
hangman
hanoi
hanoi_real
hexagon
imagename
instruments
intro_gravity
lang
leftright
letter-in-word
lightsoff
louis-braille
magic-hat-minus
magic-hat-plus
maze
mazeinvisible
mazerelative
melody
memory
memory-enumerate
memory-math-add
memory-math-add-minus
memory-math-add-minus-mult-div
memory-math-add-minus-mult-div-tux
memory-math-add-minus-tux
memory-math-add-tux
memory-math-div
memory-math-div-tux
memory-math-minus
memory-math-minus-tux
memory-math-mult
memory-math-mult-div
memory-math-mult-div-tux
memory-math-mult-tux
memory-sound
memory-sound-tux
memory-tux
memory-wordnumber
mining
missing-letter
money
money_back
money_back_cents
money_cents
mosaic
numbers-odd-even
paintings
penalty
planegame
readingh
readingv
redraw
redraw_symmetrical
renewable_energy
reversecount
scalesboard
scalesboard_weight
scalesboard_weight_avoirdupois
simplepaint
smallnumbers
smallnumbers2
sudoku
superbrain
target
tic_tac_toe
tic_tac_toe_2players
traffic
watercycle
wordsgame
/* GCompris - ActivityInfo.qml
*
* Copyright (C) 2015 Your Name <yy@zz.org>
*
* 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 GCompris 1.0
ActivityInfo {
name: "letter-in-word/LetterInWord.qml"
difficulty: 1
icon: "letter-in-word/letter-in-word.svg"
author: "Akshat Tandon &lt;akshat.tandon@research.iiit.ac.ins&gt;"
demo: true
title: "Letter in which Word "
description: ""
//intro: "put here in comment the text for the intro voice"
goal: ""
prerequisite: ""
manual: ""
credit: ""
section: "fun"
}
GCOMPRIS_ADD_RCC(activities/letter-in-word *.qml *.svg *.js resource/* resource/images/*)
/* GCompris - Card.qml
*
* Copyright (C) 2014 Holger Kaelberer <holger.k@elberer.de>
*
* Authors:
* Pascal Georges <pascal.georges1@free.fr> (GTK+ version)
* Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ Mostly full rewrite)
* Holger Kaelberer <holger.k@elberer.de> (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 "letter-in-word.js" as Activity
Item {
id: cardItem
Image{
id: wordPic
anchors.bottom: cardImage.top
sourceSize.width: cardItem.width
fillMode: Image.PreserveAspectFit
source: imgurl
z:-5
}
Image {
id: cardImage
sourceSize.width: cardItem.width
fillMode: Image.PreserveAspectFit
source: Activity.url + "cloud.svg"
z: (state == 'scaled') ? 1 : -1
GCText {
id: text
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
z: 11
text: spelling
font.pointSize: NaN // need to clear font.pointSize explicitly
font.pixelSize: parent.width * 0.30
font.bold: true
style: Text.Outline
styleColor: "#2a2a2a"
color: "white"
}
DropShadow {
anchors.fill: text
cached: false
horizontalOffset: 1
verticalOffset: 1
radius: 3
samples: 16
color: "#422a2a2a"
source: text
}
ParticleSystemStarLoader {
id: particle
clip: false
}
states: State {
name: "scaled"; when: mouseArea.containsMouse
PropertyChanges {
target: cardItem
scale: /*carriageImage.scale * */ 1.2
z: 2}
}
transitions: Transition {
NumberAnimation { properties: "scale"; easing.type: Easing.OutCubic }
}
SequentialAnimation {
id: successAnimation
running: selected
loops: Animation.Infinite
NumberAnimation {
target: cardImage
easing.type: Easing.InOutQuad
property: "rotation"
to: 20; duration: 500
}
NumberAnimation {
target: cardImage
easing.type: Easing.InOutQuad
property: "rotation"; to: -20
duration: 500 }
}
SequentialAnimation {
id: failureAnimation
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 1; duration: 400
}
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 0; duration: 200
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: ApplicationInfo.isMobile ? false : true
onClicked: {
if (Activity.checkWord(index)) {
successAnimation.restart();
particle.burst(30)
} else {
failureAnimation.restart()
}
}
}
}
Colorize {
id: colorCardImage
z: 5
anchors.fill: cardImage
source: cardImage
hue: 0.0
saturation: 1
opacity: 0
}
}
/* GCompris - LetterInWord.qml
*
* Copyright (C) 2014 Holger Kaelberer <holger.k@elberer.de>
* 2016 Akshat Tandon <akshat.tandon@research.iiit.ac.in>
*
* Authors:
* Holger Kaelberer <holger.k@elberer.de> (Click on Letter - Qt Quick port)
* Akshat Tandon <akshat.tandon@research.iiit.ac.in> (Modifications to Click on Letter code
* to make Letter in which word activity)
*
* 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 QtGraphicalEffects 1.0
import GCompris 1.0
import "../../core"
import "letter-in-word.js" as Activity
import "qrc:/gcompris/src/core/core.js" as Core
ActivityBase {
id: activity
focus: true
onStart: focus = true
pageComponent: Image {
id: background
source: Activity.url + "background.svg"
sourceSize.width: parent.width
fillMode: Image.PreserveAspectCrop
focus: true
// system locale by default
property string locale: "system"
signal start
signal stop
signal voiceError
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
activity.start.connect(start)
activity.stop.connect(stop)
}
QtObject {
id: items
property Item main: activity.main
property alias bar: bar
property alias wordsModel: wordsModel
property GCAudio audioVoices: activity.audioVoices
property alias parser: parser
property alias animateX: animateX
property alias repeatItem: repeatItem
property alias score: score
property alias bonus: bonus
property alias locale: background.locale
property string question
}
onVoiceError: {
repeatItem.visible = false
}
onStart: {
activity.audioVoices.error.connect(voiceError)
Activity.start(items);
}
onStop: Activity.stop()
DialogActivityConfig {
id: dialogActivityConfig
currentActivity: activity
content: Component {
Item {
property alias localeBox: localeBox
height: column.height
property alias availableLangs: langs.languages
LanguageList {
id: langs
}
Column {
id: column
spacing: 10
width: parent.width
Flow {
spacing: 5
width: dialogActivityConfig.width
GCComboBox {
id: localeBox
model: langs.languages
background: dialogActivityConfig
label: qsTr("Select your locale")
}
}
}
}
}
onClose: home()
onLoadData: {
if(dataToSave && dataToSave["locale"]) {
background.locale = dataToSave["locale"];
}
}
onSaveData: {
var oldLocale = background.locale;
var newLocale =
dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
if(newLocale.indexOf('.') != -1) {
newLocale = newLocale.substring(0, newLocale.indexOf('.'))
}
dataToSave = {"locale": newLocale }
background.locale = newLocale;
// Restart the activity with new information
if(oldLocale !== newLocale) {
background.stop();
background.start();
}
}
function setDefaultValues() {
var localeUtf8 = background.locale;
if(background.locale != "system") {
localeUtf8 += ".UTF-8";
}
for(var i = 0 ; i < dialogActivityConfig.configItem.availableLangs.length ; i ++) {
if(dialogActivityConfig.configItem.availableLangs[i].locale === localeUtf8) {
dialogActivityConfig.loader.item.localeBox.currentIndex = i;
break;
}
}
}
}
DialogHelp {
id: dialogHelpLeftRight
onClose: home()
}
Bar {
id: bar
content: BarEnumContent { value: help | home | level | config }
onHelpClicked: {
displayDialog(dialogHelpLeftRight)
}
onPreviousLevelClicked: Activity.previousLevel()
onNextLevelClicked: Activity.nextLevel()
onHomeClicked: home()
onConfigClicked: {
dialogActivityConfig.active = true
dialogActivityConfig.setDefaultValues()
displayDialog(dialogActivityConfig)
}
}
Score {
id: score
anchors.top: parent.top
anchors.topMargin: 10 * ApplicationInfo.ratio
anchors.left: parent.left
anchors.leftMargin: 10 * ApplicationInfo.ratio
anchors.bottom: undefined
anchors.right: undefined
}
Bonus {
id: bonus
Component.onCompleted: win.connect(Activity.nextSubLevel)
}
BarButton {
id: repeatItem
source: "qrc:/gcompris/src/core/resource/bar_repeat.svg";
sourceSize.width: 80 * ApplicationInfo.ratio
anchors {
top: parent.top
right: parent.right
margins: 10
}
onClicked: Activity.playLetter(Activity.currentLetter);
}
Item {
id: planeText
width: plane.width
height: plane.height
x: - width
anchors.top: parent.top
anchors.topMargin: 20 * ApplicationInfo.ratio
Image {
id: plane
anchors.centerIn: planeText
anchors.top: parent.top
source: Activity.url + "plane.svg"
sourceSize.height: 90 * ApplicationInfo.ratio
}
GCText {
id: questionItem
anchors.right: planeText.right
anchors.rightMargin: plane.width / 2
anchors.verticalCenter: planeText.verticalCenter
fontSize: hugeSize
font.weight: Font.DemiBold
color: "#2a2a2a"
text: items.question
}
PropertyAnimation {
id: animateX
target: planeText
properties: "x"
from: - planeText.width
to: background.width
duration: 11000
easing.type: Easing.OutInCirc
}
}
ListModel {
id: wordsModel
}
property int itemWidth: Math.min(parent.width / 7.5, parent.height / 5)
property int itemHeight: itemWidth * 1.11
GridView {
id: wordsView
anchors.bottom: bar.top
anchors.left: parent.left
anchors.right: parent.right
anchors.top: planeText.bottom
anchors.leftMargin: 35 * ApplicationInfo.ratio
anchors.rightMargin: 35 * ApplicationInfo.ratio
anchors.bottomMargin: 13 * ApplicationInfo.ratio
cellWidth: itemWidth
cellHeight: itemHeight
clip: false
interactive: false
verticalLayoutDirection: GridView.BottomToTop
layoutDirection: Qt.LeftToRight
model: wordsModel
delegate: Card{
width: background.itemWidth
}
}
JsonParser {
id: parser
onError: console.error("Click_on_letter: Error parsing JSON: " + msg);
}
}
}
/* GCompris - letter-in-word.js
*
* Copyright (C) 2014 Holger Kaelberer
* 2016 Akshat Tandon
*
* Authors:
* Holger Kaelberer <holger.k@elberer.de> (Qt Quick port)
* Akshat Tandon <akshat.tandon@research.iiit.ac.in>
*