Commit cef31024 authored by 李维's avatar 李维

Bug fix

parent d2e528a9
......@@ -601,7 +601,7 @@ export class PlayComponent implements OnInit, OnDestroy {
bgRight.ref.alpha = 0;
bgFocus.ref.alpha = 1;
bgWrong.ref.alpha = 0;
text.ref.fontColor = "#b17d5a"
text.ref.fontColor = "#ffffff"
break;
case "wrong":
bgInit.ref.alpha = 0;
......@@ -616,11 +616,9 @@ export class PlayComponent implements OnInit, OnDestroy {
container.active = (status=false) => {
if(status) {
if(container.getContentText() == "") {
container.switchStatus("focus")
}
container.switchStatus("focus")
} else {
container.switchStatus("disable")
container.switchStatus("right")
}
if(status) {
this.m_currentInput = `block_${x}_${y}`;
......@@ -642,6 +640,10 @@ export class PlayComponent implements OnInit, OnDestroy {
container.setContentText = (letter) => {
text.ref.text = letter?letter:"";
if(!this.checkAllFill()) {
let btnSub = this.g_cartoon.getCartoonElement("button_submit")
btnSub.switchActive(true)
}
}
container.getContentText = () => {
......@@ -673,32 +675,39 @@ export class PlayComponent implements OnInit, OnDestroy {
container.checkWhenSwitchQuestion = (withRed, fromIndex, groupIndex, contentSaved?) => {
container.active(false);
// 没有点击提交就切换,清空
if(!this.m_submited && questionIndex==fromIndex) {
container.setContentText(contentSaved)
}
// if(!this.m_submited && questionIndex==fromIndex) {
// container.setContentText(contentSaved)
// }
if(groupIndex!= this.m_currentQuestionIndex) {
if(container.getContentText() == "") {
container.switchStatus("init")
} else if(letter != container.getContentText()) {
container.switchStatus("wrong")
} else {
container.switchStatus("right")
container.switchStatus("disable")
}
// if(container.getContentText() == "") {
// container.switchStatus("init")
// } else if(letter != container.getContentText()) {
// container.switchStatus("wrong")
// } else {
// container.switchStatus("right")
// }
} else {
if(container.getContentText() == "") {
container.switchStatus("right");
if(!this.m_hasActiveBlock) {
this.m_hasActiveBlock = true;
container.active(true)
}
} else if(withRed && (letter != container.getContentText())) {
this.m_hasErrorLetter = true;
container.switchStatus("wrong");
if(!this.m_hasActiveBlock) {
this.m_hasActiveBlock = true;
this.m_currentInputIndex = groupIndex;
container.active(true)
}
// if(container.getContentText() == "") {
// container.switchStatus("right");
// } else {
// container.switchStatus("right");
// this.m_hasErrorLetter = true;
// container.switchStatus("wrong");
// if(!this.m_hasActiveBlock) {
// this.m_hasActiveBlock = true;
// this.m_currentInputIndex = groupIndex;
// container.active(true)
// }
// }
container.switchStatus("right")
if(!this.m_hasActiveBlock) {
this.m_hasActiveBlock = true;
container.active(true)
}
}
}
......@@ -708,6 +717,8 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.m_currentInput) {
let currentAcitveNode = this.g_cartoon.getCartoonElement(this.m_currentInput)
currentAcitveNode.active(false)
this.m_currentInputIndex = li
console.log(this.m_currentInputIndex)
}
container.active(true);
}
......@@ -749,11 +760,12 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_blockFirstSubmit[i] = true;
}
let indexArr = new Array(this.g_formData.dataArray.length).fill(0)
for(let j=0; j<rolNum; j++) {
for(let i=0; i<colNum; i++) {
let qi = this.g_formData.grid[j][i].index
if(qi>=0) {
let newBlock = createBlock(this.g_formData.grid[j][i].text, qi, i, sX+i*step, sY+j*step, 900/colNum-5, 900/colNum-5)
let newBlock = createBlock(this.g_formData.grid[j][i].text, qi, indexArr[qi]++, sX+i*step, sY+j*step, 900/colNum-5, 900/colNum-5)
this.m_wordAll[qi] += this.g_formData.grid[j][i].text
this.m_allBlocks.push(newBlock)
element.ref.addChild(newBlock.ref)
......@@ -761,6 +773,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
}
console.log(indexArr)
this.render(element.ref)
}
......@@ -830,7 +843,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_blockGroup.forEach((group, groupIndex) => {
group.forEach((block, index) => {
block.checkWhenSwitchQuestion(true, fromIndex, groupIndex, this.m_wordLetterInputCatch[index]?this.m_wordLetterInputCatch[index]:"")
block.checkWhenSwitchQuestion(false, fromIndex, groupIndex, this.m_wordLetterInputCatch[index]?this.m_wordLetterInputCatch[index]:"")
});
});
......@@ -907,26 +920,34 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.m_currentInputIndex>=blocks.length) {
// 没有获取焦点的输入框,启用提交功能
if(!this.m_hasActiveBlock) {
let btn = this.g_cartoon.getCartoonElement("button_submit")
btn.switchActive(true);
}
// if(!this.m_hasActiveBlock) {
// let btn = this.g_cartoon.getCartoonElement("button_submit")
// btn.switchActive(true);
// }
// 切换当前输入从头开始
this.m_currentInputIndex = -1;
checkNextActive();
// 判断是否需要激活(绿色不需要激活,红色或者蓝色没有文字需要激活)
if(blocks[this.m_currentInputIndex].canSetActive()) {
blocks[this.m_currentInputIndex].active(true)
}
} else {
// 判断是否需要激活(绿色不需要激活,红色或者蓝色没有文字需要激活)
if(blocks[this.m_currentInputIndex].canSetActive()) {
blocks[this.m_currentInputIndex].active(true)
}
}
// 判断是否需要激活(绿色不需要激活,红色或者蓝色没有文字需要激活)
if(blocks[this.m_currentInputIndex].canSetActive()) {
blocks[this.m_currentInputIndex].active(true)
}
}
checkAllFill() {
let empty = false;
this.m_blockGroup.forEach(group => {
group.forEach(block => {
if(!empty) {
if(block.getContentText() == "") {
empty = true;
}
}
});
})
return empty;
}
......
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