Commit 7b987935 authored by Akshat Tandon's avatar Akshat Tandon Committed by Johnny Jazeix
Browse files

letter-in-word, added letter highlighting for correct word selection.

parent 10202314
......@@ -28,140 +28,197 @@ import "letter-in-word.js" as Activity
Item {
id: cardItem
Image{
id: wordPic
sourceSize.width: cardItem.width -6
sourceSize.height: cardItem.width -5
Image{
id: wordPic
sourceSize.width: cardItem.width -6
sourceSize.height: cardItem.width -5
fillMode: Image.PreserveAspectFit
source: imgurl
z:-5
Image {
id: cardImage
anchors.top:parent.bottom
anchors.topMargin: -30 * ApplicationInfo.ratio
sourceSize.width: cardItem.width - 10
fillMode: Image.PreserveAspectFit
source: imgurl
z:-5
Image {
id: cardImage
anchors.top:parent.bottom
anchors.topMargin: -30 * ApplicationInfo.ratio
sourceSize.width: cardItem.width - 10
fillMode: Image.PreserveAspectFit
source: Activity.url + "images/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: spelling.length > 5 ? parent.width * 0.23 : parent.width * 0.30
font.bold: true
style: Text.Outline
styleColor: "#2a2a2a"
color: "white"
source: Activity.url + "images/cloud.svg"
z: (state == 'scaled') ? 1 : -1
/*ListView{
//anchors.horizontalCenter:parent.horizontalCenter
//anchors.verticalCenter: parent.verticalCenter
model:components
delegate:GCText {
//id: textbox
z: 11
//anchors.horizontalCenter:cardImage.horizontalCenter
//anchors.verticalCenter: cardImage.verticalCenter
text:
font.pointSize: NaN // need to clear font.pointSize explicitly
font.pixelSize: spelling.length > 5 ? cardImage.width * 0.23 : cardImage.width * 0.30
font.bold: true
style: Text.Outline
styleColor: "#2a2a2a"
color: "white"
}
}*/
Row{
anchors.verticalCenter: cardImage.verticalCenter
Repeater{
//anchors.verticalCenter: cardImage.verticalCenter
model: components
GCText {
id: textbox
z: 11
//anchors.horizontalCenter:cardImage.horizontalCenter
//anchors.verticalCenter: cardImage.verticalCenter
text: textdata
font.pointSize: NaN // need to clear font.pointSize explicitly
font.pixelSize: spelling.length > 5 ? cardImage.width * 0.23 : cardImage.width * 0.30
font.bold: true
style: Text.Outline
styleColor: "#2a2a2a"
color: selected && textdata.length == 1 && textdata == Activity.currentLetter ? "green" : "white"
}
}
}
/*
DropShadow {
anchors.fill: text
anchors.fill: textbox
cached: false
horizontalOffset: 1
verticalOffset: 1
radius: 3
samples: 16
color: "#422a2a2a"
source: text
}
ParticleSystemStarLoader {
id: particle
clip: false
}
source: textbox
}*/
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 }
}
ParticleSystemStarLoader {
id: particle
clip: false
}
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 }
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: failureAnimation
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 1; duration: 400
}
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 0; duration: 200
}
}
SequentialAnimation {
id: successAnimation
running: selected
loops: Animation.Infinite
NumberAnimation {
id: rotationStop
running: !selected
target: cardImage
property: "rotation"
to: 0
duration: 500
easing.type: Easing.InOutQuad
property: "rotation"
to: 20; duration: 500
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: ApplicationInfo.isMobile ? false : true
NumberAnimation {
target: cardImage
easing.type: Easing.InOutQuad
property: "rotation"; to: -20
duration: 500 }
onClicked: {
}
if (Activity.checkWord(index)) {
SequentialAnimation {
id: failureAnimation
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 1; duration: 400
}
NumberAnimation {
target: colorCardImage
property: "opacity"
to: 0; duration: 200
}
}
NumberAnimation {
id: rotationStop
running: !selected
target: cardImage
property: "rotation"
to: 0
duration: 500
easing.type: Easing.InOutQuad
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: ApplicationInfo.isMobile ? false : true
onClicked: {
if (Activity.checkWord(index)) {
successAnimation.restart();
particle.burst(30)
components.clear();
var tempword;
var j = 0;
for(var i = 0; i < spelling.length; i++){
if(spelling.charAt(i) == Activity.currentLetter){
tempword = spelling.substring(j,i);
if(i!=j){
console.log(tempword)
components.append({"textdata": tempword})
}
components.append({"textdata": Activity.currentLetter});
console.log(Activity.currentLetter)
//console.log('qwe:')
//console.log(tempword)
j = i + 1;
}
}
if(j < spelling.length){
tempword = spelling.substring(j, spelling.length);
components.append({"textdata": tempword})
console.log(tempword)
//console.log(tempword)
//console.log(componenetsArr.length)
}
console.log('*/*/')
console.log(components.length)
successAnimation.restart();
particle.burst(30)
} else {
failureAnimation.restart()
}
} else {
failureAnimation.restart()
}
}
}
Colorize {
id: colorCardImage
z: 5
anchors.fill: cardImage
source: cardImage
hue: 0.0
saturation: 1
opacity: 0
}
}
Colorize {
id: colorCardImage
z: 5
anchors.fill: cardImage
source: cardImage
hue: 0.0
saturation: 1
opacity: 0
}
}
}
......@@ -127,6 +127,7 @@ function shuffleString(s)
}
function initLevel() {
var componentsArr;
items.bar.level = currentLevel + 1;
if (currentSubLevel == 0 && !incorrectFlag) {
level = levels[currentLevel];
......@@ -142,10 +143,14 @@ function initLevel() {
questions = shuffleString(tempQuestions);
items.wordsModel.clear();
for (var i = 0; i < words.length; i++) {
componentsArr = [];
componentsArr.push({"textdata": words[i].translatedTxt});
//console.log(componentsArr.length)
items.wordsModel.append({
"spelling": words[i].translatedTxt,
"imgurl": words[i].image,
"selected": false
"selected": false,
"components": componentsArr
});
}
} else {
......@@ -156,6 +161,7 @@ function initLevel() {
for(var i = 0; i < words.length; i++){
items.wordsModel.setProperty(i, "selected", false);
}
var locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale);
......@@ -214,12 +220,12 @@ function generateQuestions(){
freqArr.sort(function(a, b) {return b[1] - a[1]});
/*
for(var i = 0; i < freqArr.length; i++){
console.log('freq arr')
console.log(freqArr[i][0])
console.log(freqArr[i][1])
}
}*/
var limit = Math.min(10, freqArr.length);
//console.log(freqArr.length)
......@@ -298,6 +304,14 @@ function checkWord(index)
}
}
if(checkFlag == true){
//items.wordsModel.setProperty(index, "components", componenetsArr)
//items.wordsModel.setProperty(index, "imgurl","qrc:/gcompris/src/activities/lang/resource/words_sample/one.png")
/*for(var i = 0; i < componenetsArr.length; i++){
console.log(componenetsArr[i].textdata)
}*/
return true;
}
else{
......
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