Commit d35d1112 authored by 李维's avatar 李维

bug fix for fd-15

parent 63d7b54b
......@@ -66,8 +66,6 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control [nzSpan]="4">
<div class="text-label">填空设置</div>
......@@ -75,7 +73,7 @@
<nz-form-control [nzSpan]="20">
<div *ngFor="let oneRow of grid; let x = index" class="clearfix">
<div *ngFor="let oneGrid of oneRow; let y = index" style="float: left; padding: 2px;">
<input style="width: 38px" (focus)="selectContent($event)" class="inputBlock" [disabled]="(oneGrid.index != currentSet && oneGrid.index!=-1)" [maxLength]="1" type="text" nz-input [(ngModel)]="oneGrid.text" (blur)="handeGridChange($event, oneGrid, x, y)" >
<input style="width: 38px" (focus)="selectContent($event)" class="inputBlock" [maxLength]="1" type="text" nz-input [(ngModel)]="oneGrid.text" (blur)="handeGridChange($event, oneGrid, x, y)" >
</div>
</div>
</nz-form-control>
......
......@@ -95,79 +95,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log(this.item)
}
disableInput(row, col) {
if(this.currentSet==-1) {
return true
} else {
let currentIndex = this.getIndexNumberByIndex(this.currentSet)
let dir = this.getDirectionByIndex(this.currentSet)
let res = false;
switch(dir) {
case "up":
if(col==currentIndex.colIndex) {
if(row>currentIndex.rowIndex) {
res= true;
} else {
res = false
}
} else {
res = true;
}
break;
case "down":
if(col==currentIndex.colIndex) {
if(row<currentIndex.rowIndex) {
res= true;
} else {
res = false
}
} else {
res = true;
}
break;
case "left":
if(row==currentIndex.rowIndex) {
if(col>currentIndex.colIndex) {
res= true;
} else {
res = false
}
} else {
res = true;
}
break;
case "right":
if(row==currentIndex.rowIndex) {
if(col<currentIndex.colIndex) {
res= true;
} else {
res = false
}
} else {
res = true;
}
break;
default: res = false;
}
if(res) {
if(this.currentSet>=0) {
this.grid[row][col].index = -1
if(this.grid[row][col].index == 0) {
this.grid[row][col].text = ""
}
this.saveItem()
}
}
return res
}
}
handeGridChange(e, item, row, col) {
if(item.text != "" && e.target.value != "") {
item.index = this.currentSet
this.setIndex(item.index, this.currentSet)
} else {
item.index = -1;
item.index = [];
}
this.saveItem()
}
......@@ -175,18 +107,19 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
resetByIndex(index, del) {
for(let i=0; i<this.grid.length; i++) {
for(let j=0; j<this.grid[i].length; j++) {
if(this.grid[i][j].index == index) {
this.grid[i][j].index = -1; // = {index: -1, text: ""}
if(this.checkIndex(this.grid[i][j].index, index)) {
this.grid[i][j].index = [];
this.grid[i][j].text = "";
}
if(del) {
if(this.grid[i][j].index > index) {
this.grid[i][j].index--;
}
this.grid[i][j].index.forEach(temIndex => {
if(temIndex > index) {
temIndex--;
}
});
}
}
}
// this.grid = JSON.parse(JSON.stringify(this.grid))
this.saveItem();
}
......@@ -241,7 +174,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.grid.forEach((row, rowIndex)=>{
row.forEach((item, colIndex) => {
if(item.index == numberIndex) {
if(this.checkIndex(item.index, numberIndex)) {
if(!gotIt && item.text) {
gotIt = true;
number.status = true;
......@@ -266,7 +199,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 检查上格
if(numIndex.rowIndex-1 != -1) {
if(this.grid[numIndex.rowIndex-1][numIndex.colIndex].index == numIndex){
if(this.checkIndex(this.grid[numIndex.rowIndex-1][numIndex.colIndex].index, numIndex)){
return "up"
}
} else {
......@@ -275,14 +208,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 检查下格
if(numIndex.rowIndex+1 != this.rowNum) {
if(this.grid[numIndex.rowIndex+1][numIndex.colIndex].index == numIndex){
if(this.checkIndex(this.grid[numIndex.rowIndex+1][numIndex.colIndex].index, numIndex)){
return "down"
}
}
// 检查左格
if(numIndex.colIndex-1 != -1) {
if(this.grid[numIndex.rowIndex][numIndex.colIndex-1].index == numIndex){
if(this.checkIndex(this.grid[numIndex.rowIndex][numIndex.colIndex-1].index, numIndex)){
return "left"
}
} else {
......@@ -291,7 +224,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 检查右格
if(numIndex.colIndex+1 != this.colNum) {
if(this.grid[numIndex.rowIndex][numIndex.colIndex+1].index == numIndex){
if(this.checkIndex(this.grid[numIndex.rowIndex][numIndex.colIndex+1].index, numIndex)){
return "right"
}
}
......@@ -300,7 +233,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
getHighlightInput(item) {
if(item.index == this.currentSet) {
if(this.checkIndex(item.index, this.currentSet)) {
return {highLight: true}
} else {
return {highLight: false}
......@@ -320,8 +253,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
cleanCurrentText() {
this.grid.forEach(row=>{
row.forEach(item => {
if(item.index == this.currentSet) {
item.index = -1;
if(this.checkIndex(item.index, this.currentSet)) {
item.index = [];
item.text = "";
}
});
......@@ -329,10 +262,27 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.saveItem()
}
setIndex(arr, index) {
if(arr.indexOf(index) == -1) {
arr.push(index)
}
}
delIndex(arr, index) {
let i = arr.indexOf(index)
if(i != -1) {
arr.splice(i,1)
}
}
checkIndex(arr, index) {
return arr.indexOf(index) == -1? false: true;
}
deleteItem(index) {
this.grid.forEach(row=>{
row.forEach(item => {
if(item.index == this.currentSet) {
if(this.checkIndex(item.index, this.currentSet)) {
item.index = -1;
item.text = "";
}
......
......@@ -130,7 +130,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------
m_openShift: boolean = false;
m_blockGroup = null;
m_wordAll = null;
m_allBlocks = [];
m_currentInput = "";
m_currentQuestionIndex = 0;
......@@ -219,7 +218,6 @@ export class PlayComponent implements OnInit, OnDestroy {
cleanGameVar(){
this.m_openShift = false;
this.m_blockGroup = null;
this.m_wordAll = null;
this.m_allBlocks = [];
this.m_currentInput = "";
this.m_currentQuestionIndex = 0;
......@@ -531,7 +529,7 @@ export class PlayComponent implements OnInit, OnDestroy {
initOutputWindow() {
const createBlock = (letter, questionIndex, li, x, y, width=80, height=80)=> {
let container = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}`, "bg_letter_target", (w, h)=>{
let container = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}`, "bg_letter_target", (w, h)=>{
return {
sx: 80 / w * width / 80,
sy: 80 / h * height / 80,
......@@ -543,7 +541,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
})
let text = this.g_cartoon.createCartoonElementLabelFunc(`block_${x}_${y}_letter`, "", "Aileron-Bold", "#FFFFFF", 72, (w, h)=>{
let text = this.g_cartoon.createCartoonElementLabelFunc(`block_${questionIndex}_${li}_letter`, "", "Aileron-Bold", "#FFFFFF", 72, (w, h)=>{
return {
x: 0,
y: 0,
......@@ -551,7 +549,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
let bgInit = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}_container_init`, "bg_block_init", (w, h)=>{
let bgInit = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}_container_init`, "bg_block_init", (w, h)=>{
return {
sx: 80 / w,
sy: 80 / h,
......@@ -564,7 +562,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
bgInit.ref.alpha = 0;
let bgDisable = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}_container_disable`, "bg_block_disable", (w, h)=>{
let bgDisable = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}_container_disable`, "bg_block_disable", (w, h)=>{
return {
sx: 80 / w,
sy: 80 / h,
......@@ -577,7 +575,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
bgDisable.ref.alpha = 0;
let bgRight = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}_container_right`, "bg_block_right", (w, h)=>{
let bgRight = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}_container_right`, "bg_block_right", (w, h)=>{
return {
sx: 80 / w,
sy: 80 / h,
......@@ -590,7 +588,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
bgRight.ref.alpha = 0;
let bgFocus = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}_container_focus`, "bg_block_focus", (w, h)=>{
let bgFocus = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}_container_focus`, "bg_block_focus", (w, h)=>{
return {
sx: 80 / w,
sy: 80 / h,
......@@ -603,7 +601,7 @@ export class PlayComponent implements OnInit, OnDestroy {
})
bgFocus.ref.alpha = 0;
let bgWrong = this.g_cartoon.createCartoonElementImageFunc(`block_${x}_${y}_container_wrong`, "bg_block_wrong", (w, h)=>{
let bgWrong = this.g_cartoon.createCartoonElementImageFunc(`block_${questionIndex}_${li}_container_wrong`, "bg_block_wrong", (w, h)=>{
return {
sx: 80 / w,
sy: 80 / h,
......@@ -633,7 +631,7 @@ export class PlayComponent implements OnInit, OnDestroy {
bgFocus.ref.alpha = 0;
bgWrong.ref.alpha = 0;
text.ref.fontColor = "#b17d5a";
container.modified = false;
// container.modified = false;
break;
case "disable":
bgInit.ref.alpha = 0;
......@@ -680,7 +678,7 @@ export class PlayComponent implements OnInit, OnDestroy {
container.switchStatus("right")
}
if(status) {
this.m_currentInput = `block_${x}_${y}`;
this.m_currentInput = `block_${questionIndex}_${li}`;
}
}
......@@ -739,7 +737,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// container.active(false);
if(groupIndex!= this.m_currentQuestionIndex) {
if(container.getContentText() == "") {
container.switchStatus("init")
// container.switchStatus("init")
} else {
if(this.m_submitedTimes == 0) {
container.switchStatus("disable")
......@@ -818,22 +816,24 @@ export class PlayComponent implements OnInit, OnDestroy {
let step = (width/colNum)<(height/rolNum)?(width/colNum):(height/rolNum);
this.m_blockGroup = new Array(this.g_formData.dataArray.length);
this.m_wordAll = new Array(this.g_formData.dataArray.length).fill("");
for(let i=0; i<this.g_formData.dataArray.length; i++) {
this.m_blockGroup[i] = []
}
let indexArr = new Array(this.g_formData.dataArray.length).fill(0)
let existId = []
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) {
if(this.g_formData.grid[j][i].index != "") {
let qi = this.g_formData.grid[j][i].index.join("-")
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)
this.m_blockGroup[qi].push(newBlock)
qi.split("-").forEach(qqi => {
this.m_blockGroup[qqi].push(newBlock)
});
// let qi = this.g_formData.grid[j][i].index
}
}
}
......@@ -1489,10 +1489,23 @@ export class PlayComponent implements OnInit, OnDestroy {
// 切换题目,主要是变蓝/变红输入框
switchQuestion(fromIndex, toIndex) {
if(toIndex.toString().indexOf("-") != -1) {
let indexArr = toIndex.split("-")
fromIndex = indexArr[0]
indexArr.some(itemIndex => {
if(fromIndex == itemIndex) {
return false
} else {
toIndex = itemIndex;
return true
}
})
}
this.m_currentQuestionIndex = toIndex;
this.m_currentInputIndex = 0;
this.m_hasActiveBlock = false;
this.resetAllBlockStatus();
this.m_blockGroup.forEach((group, groupIndex) => {
group.forEach((block, index) => {
block.checkWhenSwitchQuestion(false, fromIndex, groupIndex, this.m_wordLetterInputCatch[index]?this.m_wordLetterInputCatch[index]:"")
......@@ -1605,6 +1618,13 @@ export class PlayComponent implements OnInit, OnDestroy {
});
}
resetAllBlockStatus() {
this.m_blockGroup.forEach(group => {
group.forEach(block => {
block.switchStatus("init")
});
});
}
......
......@@ -11,18 +11,18 @@ export const defaultData = {
},
dataArray: [{ image_url: "", audio_url: "", text: "", uuid: "9803c50c-3638-4a6a-a4f8-719bdeaacede", direction: "Across" }],
grid: [
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}],
[{index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}, {index: -1, text: ""}]
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}],
[{index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}, {index: [], text: ""}]
]
}
export const demoData = {
......
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