Commit cd8f8ea9 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

letter-in-word, better display on multiple words

parent 57826b5c
......@@ -31,45 +31,43 @@ Item {
height: wordPic.height + cardImage.height - 30 * ApplicationInfo.ratio
property bool mouseActive: true
Image{
Image {
id: wordPic
sourceSize.width: cardItem.width -6
sourceSize.height: cardItem.width -5
fillMode: Image.PreserveAspectFit
source: imgurl
z:-5
z: -5
//visible: index % 2 != 0 ? false : true
}
Image {
id: cardImage
anchors.top:wordPic.bottom
anchors.top: wordPic.bottom
anchors.topMargin: -30 * ApplicationInfo.ratio
sourceSize.width: cardItem.width - 10
fillMode: Image.PreserveAspectFit
source: Activity.resUrl2 + "cloud.svg"
source: Activity.resUrl2 + "cloud.svg"
z: (state == 'scaled') ? 1 : -1
//visible: index % 2 != 0 ? false : true
Row {
anchors.verticalCenter: cardImage.verticalCenter
anchors.horizontalCenter: cardImage.horizontalCenter
Repeater {
model: components
GCText {
id: textbox
z: 11
text: textdata
font.pointSize: NaN // need to clear font.pointSize explicitly
font.pixelSize: spelling.length > 5 ? (spelling.length > 7 ? cardImage.width * 0.19 : cardImage.width * 0.25): cardImage.width * 0.30
font.bold: true
style: Text.Outline
styleColor: "#2a2a2a"
color: selected && textdata.length == 1 && textdata == Activity.currentLetter ? "green" : "white"
}
}
GCText {
id: textItem
z: 11
// textData is the rich text with letter found, spelling is the text in the dataset
text: selected ? textData : spelling
textFormat: Text.RichText
font.pointSize: NaN // need to clear font.pointSize explicitly
font.pixelSize: spelling.length > 5 ? (spelling.length > 7 ? cardImage.width * 0.19 : cardImage.width * 0.25): cardImage.width * 0.30
font.bold: true
style: Text.Outline
width: cardImage.width
height: cardImage.height
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
styleColor: "#2a2a2a"
color: "white"
}
ParticleSystemStarLoader {
......@@ -122,6 +120,7 @@ Item {
to: 0; duration: 200
}
}
NumberAnimation {
id: rotationStop
running: !selected
......@@ -156,26 +155,8 @@ Item {
if(mouseActive && !successAnimation.running) {
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) {
components.append({"textdata": tempword})
}
components.append({"textdata": Activity.currentLetter});
j = i + 1;
}
}
if(j < spelling.length) {
tempword = spelling.substring(j, spelling.length);
components.append({"textdata": tempword})
}
particle.burst(30);
textData = spelling.replace(RegExp(Activity.currentLetter, "g"), "<font color=\"green\">"+Activity.currentLetter+"</font>");
}
else {
failureAnimation.restart()
......
......@@ -108,14 +108,13 @@ function shuffleString(s) {
}
function initLevel() {
var componentsArr;
items.bar.level = currentLevel + 1;
if (currentSubLevel == 0 && !incorrectFlag) {
var level = levels[currentLevel];
words = Lang.getLessonWords(dataset, level);
Core.shuffle(words);
var limit = Math.min(11, words.length)
words = words.slice(0,limit)
words = words.slice(0, limit)
frequency = calculateFrequency();
var tempQuestions = generateQuestions();
maxSubLevel = tempQuestions.length;
......@@ -124,14 +123,11 @@ function initLevel() {
questions = shuffleString(tempQuestions);
items.wordsModel.clear();
for (var i = 0; i < words.length; i++) {
componentsArr = [];
componentsArr.push({"textdata": words[i].translatedTxt});
items.wordsModel.append({
"spelling": words[i].translatedTxt,
"imgurl": words[i].image,
"selected": false,
"components": componentsArr
"textData": words[i].translatedTxt
});
}
}
......
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