Commit 3662175c authored by limingzhe's avatar limingzhe

fix: debug

parent d289974f
{
"ver": "1.1.2",
"uuid": "e9f579c0-59b7-4567-93ad-5b17f799e827",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
{"ver":"1.1.2","uuid":"e9f579c0-59b7-4567-93ad-5b17f799e827","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
......@@ -204,6 +204,11 @@ cc.Class({
this.initAudio();
this.initView();
setTimeout(() => {
cc.debug.setDisplayStats(true);
}, 2000);
const node = cc.find('middleLayer/ConsoleNode/BtnOpen');
if (node) {
......@@ -226,7 +231,7 @@ cc.Class({
this.dataPool = [];
this.nodePoolArr = [];
this.centerItemArr = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '1');
this.benchmark1Data = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '3')[0];
......@@ -247,6 +252,7 @@ cc.Class({
const bgRect = this.data.bgItem2.rect;
const regionRect = regionItem.rect;
this.regionRect = regionRect;
const left = Math.round( (regionRect.x ) / bgRect.width * 1000 ) / 1000;
const right = Math.round( (regionRect.x + regionRect.width) / bgRect.width * 1000 ) / 1000;
......@@ -393,10 +399,10 @@ cc.Class({
// console.log('unitY: ', unitY)
}
console.log('unitH: ', unitH)
console.log('unitW: ', unitW)
console.log('baseX: ', baseX)
console.log('baseY: ', baseY)
// console.log('unitH: ', unitH)
// console.log('unitW: ', unitW)
// console.log('baseX: ', baseX)
// console.log('baseY: ', baseY)
const centerX = this.data.bgItem2.rect.width / 2;
this.centerUnitW = (centerX - baseX) / unitW;
......@@ -474,14 +480,14 @@ cc.Class({
// setTimeout(() => {
// this.getPhotoData((data) => {
// this.photoEnd(data);
// });
// }, 300);
setInterval(() => {
this.getPhotoData((data) => {
this.photoEnd(data);
});
}, 300);
// return;
return;
const cw = window.courseware;
if (!cw || !cw.openOsmoHandwriting) {
......@@ -1159,7 +1165,7 @@ cc.Class({
console.log(' in initDebugLayer');
const layer = new cc.Node();
if (this.data.isDebug || true) {
if (this.data.isDebug) {
layer.parent = cc.find('Canvas');
}
......@@ -1180,6 +1186,9 @@ cc.Class({
cc.loader.load({url: this.data.bgItem2.url}, (err, img) => {
this.debugBgImg = img;
this.changeNumToInt(img, ['x', 'y', 'width', 'height'], 0.01);
this.checkBg = img;
layer.width = img.width;
layer.height = img.height;
......@@ -1216,23 +1225,6 @@ cc.Class({
getColorRectByPos(posArr, color='red') {
const topLeft = posArr[0];
const bottomRight = posArr[2];
const sample = this.sample;
const x = topLeft.x1 * sample.width;
const y = topLeft.y1 * sample.height;
const width = (bottomRight.x3 - topLeft.x1) * sample.width;
const height = (bottomRight.y3 - topLeft.y1) * sample.height;
const rect = {x, y: -y - height, width, height};
// console.log('rect ', rect);
const colorRect = this.getColorRect(rect, color);
colorRect.opacity = 100;
return colorRect;
},
gameStart() {
......@@ -1974,11 +1966,11 @@ cc.Class({
// console.log(' this.photo end ', data);
if (!this.canTouch && isPool == false) {
this.dataPool.push(data);
console.log('! cantouch')
return;
}
// if (!this.canTouch && isPool == false) {
// this.dataPool.push(data);
// console.log('! cantouch')
// return;
// }
// this.changeBboxPos(data);
......@@ -1988,26 +1980,31 @@ cc.Class({
return;
}
// return;
if (this.isCanDraw) {
return;
}
this.isCanDraw = true;
// if (this.isCanDraw) {
// return;
// }
// this.isCanDraw = true;
delayCall(0.01, () => {
this.isCanDraw = false;
})
// delayCall(0.01, () => {
// this.isCanDraw = false;
// })
this.debugDrawLayer.removeAllChildren();
this.pushNodePoolArr();
const answerData = this.getAnswerData(data);
// return;
this.showUserRight(answerData, data);
......@@ -2039,7 +2036,17 @@ cc.Class({
console.log('answerWrongData: ', JSON.stringify( answerWrongData) );
},
pushNodePoolArr() {
const arr = this.debugDrawLayer.children;
for (let i=0; i<arr.length; i++) {
const node = arr[i];
if (node.isPoolNode) {
this.nodePoolArr.push(node);
} else {
node.removeFromParent();
}
}
},
photoEndOld(data, isPool = false) {
......@@ -2447,7 +2454,9 @@ cc.Class({
if (answerData[keyB]) {
this.showLetter(i, null, false);
delayCall(Math.random() * 0.3, () => {
this.showLetter(i, null, false);
})
} else {
let writeRect = bigNodeArr[i];
......@@ -2455,8 +2464,9 @@ cc.Class({
}
if (answerData[keyS]) {
this.showLetter(i, null, true);
delayCall(Math.random() * 0.3, () => {
this.showLetter(i, null, true);
})
} else {
let writeRect = smallNodeArr[i];
......@@ -2677,7 +2687,8 @@ cc.Class({
text = text.trim();
const topY = -benchmark1Data.top;
const topY = this.regionRect.top;
const bottomY = this.regionRect.bottom;
for(let j=0; j<block.length; j++) {
......@@ -2686,6 +2697,9 @@ cc.Class({
continue;
}
if (line.top > topY || line.bottom < bottomY) {
continue;
}
const sentence = line.content;
if (sentence.indexOf(text) != -1 ) {
......@@ -2869,7 +2883,7 @@ cc.Class({
height: Math.abs( topLabelData.bottom - topLabelData.top ),
}
const colorRect = this.getColorRect(rect, "green");
this.debugDrawLayer.addChild(colorRect);
// this.debugDrawLayer.addChild(colorRect);
......@@ -2893,14 +2907,14 @@ cc.Class({
console.log('tempUnitW: ', tempUnitW);
console.log('tempUnitH: ', tempUnitH);
console.log('tempBaseX: ', tempBaseX);
console.log('tempBaseY: ', tempBaseY);
// console.log('tempUnitW: ', tempUnitW);
// console.log('tempUnitH: ', tempUnitH);
// console.log('tempBaseX: ', tempBaseX);
// console.log('tempBaseY: ', tempBaseY);
console.log('firstItemY: ', firstItemY);
console.log('tempBaseY: ', tempBaseY);
console.log('tempUnitH: ', tempUnitH);
// console.log('firstItemY: ', firstItemY);
// console.log('tempBaseY: ', tempBaseY);
// console.log('tempUnitH: ', tempUnitH);
firstItemData.unitX = unitX;
firstItemData.unitY = unitY;
......@@ -2922,9 +2936,9 @@ cc.Class({
const checkLetter = firstItemData;
console.log('baseY: ', baseY);
console.log('checkLetter.unitY: ', checkLetter.unitY);
console.log('unitH: ', unitH);
// console.log('baseY: ', baseY);
// console.log('checkLetter.unitY: ', checkLetter.unitY);
// console.log('unitH: ', unitH);
let x = baseX + checkLetter.unitX * unitW;
......@@ -2934,13 +2948,13 @@ cc.Class({
const r = Math.min(w, h) / 2;
console.log(' baseX: ', baseX);
console.log(' checkLetter.unitX: ', checkLetter.unitX);
console.log(' unitW: ', unitW);
console.log(' x: ', x);
console.log(' y: ', y);
console.log(' r: ', r);
console.log(' checkLetter: ', checkLetter);
// console.log(' baseX: ', baseX);
// console.log(' checkLetter.unitX: ', checkLetter.unitX);
// console.log(' unitW: ', unitW);
// console.log(' x: ', x);
// console.log(' y: ', y);
// console.log(' r: ', r);
// console.log(' checkLetter: ', checkLetter);
const dot = this.getColorDot(x, -y, r, r, 'blue');
this.debugDrawLayer.addChild(dot, 5);
......@@ -2975,7 +2989,7 @@ cc.Class({
}
const colorRect = this.getColorRect(rect, "purple");
colorRect.labelText = content;
this.debugDrawLayer.addChild(colorRect);
// this.debugDrawLayer.addChild(colorRect);
// console.log('colorRect: ', colorRect);
......@@ -3055,42 +3069,7 @@ cc.Class({
return identifierArr;
},
getAnswerDataNew(data, isSmall) {
let letter = this.data.letter || 'a';
let checkLetter, dotArr;
if (isSmall) {
checkLetter = letter.toLowerCase();
dotArr = this.dotArr2;
} else {
checkLetter = letter.toUpperCase();
dotArr = this.dotArr1;
}
const answerData = {};
const resultTextArr = data.result.text;
for (let i=0; i<resultTextArr.length; i++) {
const wordData = resultTextArr[i];
if (wordData.content != checkLetter) {
continue;
}
const colorRect = this.getColorRectByPos(wordData.bbox)
colorRect.data = wordData;
this.sample.addChild(colorRect);
this.setOneAnswerDataNew(colorRect, dotArr, answerData);
}
return answerData;
},
......@@ -3143,8 +3122,11 @@ cc.Class({
height: Math.abs( benchmark2Top - benchmark2Bottom ),
}
const colorbenchmark2Rect = this.getColorRect(benchmark2Rect, 'green');
this.debugDrawLayer.addChild(colorbenchmark2Rect);
if (this.debugLayer.parent && this.debugLayer.active) {
const colorbenchmark2Rect = this.getColorRect(benchmark2Rect, 'green');
// this.debugDrawLayer.addChild(colorbenchmark2Rect);
}
}
......@@ -3155,11 +3137,11 @@ cc.Class({
const firstItemTop = location.top;
const firstItemBottom = location.bottom;
console.log(' location: ', location);
console.log(' firstItemLeft: ', firstItemLeft);
console.log(' firstItemRight: ', firstItemRight);
console.log(' firstItemTop: ', firstItemTop);
console.log(' firstItemBottom: ', firstItemBottom);
// console.log(' location: ', location);
// console.log(' firstItemLeft: ', firstItemLeft);
// console.log(' firstItemRight: ', firstItemRight);
// console.log(' firstItemTop: ', firstItemTop);
// console.log(' firstItemBottom: ', firstItemBottom);
baseX = firstItemLeft + (firstItemRight - firstItemLeft) / 2;
baseY = firstItemTop + (firstItemBottom - firstItemTop) / 2;
......@@ -3167,10 +3149,10 @@ cc.Class({
unitH = ( firstItemTop + (firstItemBottom - firstItemTop) / 2 ) - (benchmark1Top + (benchmark1Bottom - benchmark1Top) / 2);
}
console.log(' baseX ~~~ ', baseX);
console.log(' baseY ~~~ ', baseY);
console.log(' unitW ~~~ ', unitW);
console.log(' unitH ~~~ ', unitH);
// console.log(' baseX ~~~ ', baseX);
// console.log(' baseY ~~~ ', baseY);
// console.log(' unitW ~~~ ', unitW);
// console.log(' unitH ~~~ ', unitH);
const dotArr = [];
......@@ -3186,7 +3168,9 @@ cc.Class({
const dot = this.getColorDot(x, -y, w / 2, h / 2);
this.debugDrawLayer.addChild(dot, 5);
if (this.debugLayer.parent && this.debugLayer.active) {
this.debugDrawLayer.addChild(dot, 5);
}
// dot.key = centerItemArr[i].index + 1;
......@@ -3203,7 +3187,7 @@ cc.Class({
// console.log('dotArr: ', dotArr);
console.log('benchmark1LabelData: ', benchmark1LabelData);
// console.log('benchmark1LabelData: ', benchmark1LabelData);
const answerData = {};
......@@ -3212,13 +3196,16 @@ cc.Class({
const wordDataArr = this.getPhotoWordArr(checkLetter.labelText, text, benchmark1LabelData);
console.log('~~~wordDataArr: ', wordDataArr);
// console.log('~~~wordDataArr: ', wordDataArr);
for (let i=0; i<wordDataArr.length; i++) {
const tempWordArr = this.getTempWordArr(wordDataArr[i],['']); // wordDataArr[i].word;
for (let k=0; k<tempWordArr.length; k++) {
const {location , content} = tempWordArr[k];
......@@ -3228,19 +3215,28 @@ cc.Class({
y: -location.bottom,
width: Math.abs( location.right - location.left ),
height: Math.abs( location.bottom - location.top ),
}
}
const colorRect = this.getColorRect(rect, "purple");
colorRect.labelText = content;
this.debugDrawLayer.addChild(colorRect);
// this.debugDrawLayer.addChild(colorRect);
// console.log('colorRect: ', colorRect);
const label = this.getLabel(content, colorRect.scaleX * colorRect.width);
label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX;
label.y = colorRect.y + colorRect.height / 2 * colorRect.scaleY;
label.color = cc.Color.BLACK;
if (this.debugLayer.parent && this.debugLayer.active) {
const label = this.getLabel(content, colorRect.scaleX * colorRect.width);
label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX;
label.y = colorRect.y + colorRect.height / 2 * colorRect.scaleY;
label.color = cc.Color.BLACK;
this.debugDrawLayer.addChild(label);
}
// console.log('colorRect: ', colorRect);
this.debugDrawLayer.addChild(label);
this.setOneAnswerData(colorRect, dotArr, answerData, wordDataArr[i]);
......@@ -3260,10 +3256,10 @@ cc.Class({
height: Math.abs( benchmark1Top - benchmark1Bottom ),
}
console.log('benchmark1Rect: ', benchmark1Rect);
// console.log('benchmark1Rect: ', benchmark1Rect);
const colorbenchmark1Rect = this.getColorRect(benchmark1Rect, 'green');
this.debugDrawLayer.addChild(colorbenchmark1Rect);
// this.debugDrawLayer.addChild(colorbenchmark1Rect);
return answerData;
......@@ -3515,10 +3511,10 @@ cc.Class({
setOneAnswerData(colorRect, dotArr, answerData, line) {
console.log(' in setOneAnswerData')
console.log('colorRect: ', colorRect)
console.log('dotArr: ', dotArr)
console.log('answerData: ', answerData)
// console.log(' in setOneAnswerData')
// console.log('colorRect: ', colorRect)
// console.log('dotArr: ', dotArr)
// console.log('answerData: ', answerData)
const rect = colorRect.ccRect;
......@@ -3528,14 +3524,14 @@ cc.Class({
const {dotRect, labelText, key} = dotArr[i];
console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() );
console.log('labelText.toLowerCase() : ', labelText.toLowerCase() );
console.log('rect.intersects(dotRect) : ', rect.intersects(dotRect) );
// console.log('targetLabelText.toLowerCase() : ', targetLabelText.toLowerCase() );
// console.log('labelText.toLowerCase() : ', labelText.toLowerCase() );
// console.log('rect.intersects(dotRect) : ', rect.intersects(dotRect) );
if (labelText.toLowerCase().indexOf(targetLabelText.toLowerCase()) != -1 && rect.intersects(dotRect)) {
const len = targetLabelText.trim().length;
console.log('len: ', len);
// console.log('len: ', len);
if (!answerData[key]) {
answerData[key] = {colorRect, count: len};
......@@ -3584,13 +3580,16 @@ cc.Class({
color = 'red'
}
// console.log('rect.x1: ', rect.x);
this.changeNumToInt(rect, ['x', 'y', 'width', 'height'], 0.0001);
// console.log('rect.x2: ', rect.x);
rect.x *= this.debugBgImg.width;
rect.y *= this.debugBgImg.height;
rect.width *= this.debugBgImg.width;
rect.height *= this.debugBgImg.height;
let node = new cc.Node();
let node
if (this.debugLayer.parent && this.debugLayer.active) {
......@@ -3602,15 +3601,40 @@ cc.Class({
node.y = rect.y;
node.scaleX = rect.width / node.width;
node.scaleY = rect.height / node.height;
this.debugDrawLayer.addChild(node);
} else {
node = this.getNewNode();
}
node.ccRect = new cc.Rect(rect.x, rect.y, rect.width, rect.height);
return node;
},
getNewNode() {
if (this.nodePoolArr.length > 0) {
const node = this.nodePoolArr.pop();
return node;
} else {
const node = new cc.Node();
this.debugDrawLayer.addChild(node);
node.isPoolNode = true;
return node;
}
},
changeNumToInt(obj, opt, digit) {
for (let i=0; i<opt.length; i++) {
const prop = opt[i];
if (obj[prop]) {
// console.log('prop: ', prop);
obj[prop] = Math.floor( obj[prop] / digit ) * digit;
}
}
},
......
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