Add: TypingExamButton
This commit is contained in:
@@ -75,12 +75,13 @@ MainMenu.prototype.create = function() {
|
||||
|
||||
this.typingAppButtons = new Array();
|
||||
this.makeTypingAppButtons();
|
||||
this.writingAppButtons = new Array();
|
||||
this.typingExamButtons = new Array();
|
||||
this.makeTypingExamButtons();
|
||||
this.playAppButtons = new Array();
|
||||
this.makePlayAppButtons();
|
||||
|
||||
this.selectedAppGroup = MainMenu.APP_GROUP_TYPING_PRACTICE;
|
||||
// this.selectedAppGroup = MainMenu.APP_GROUP_TYPING_PLAY;
|
||||
// this.selectedAppGroup = MainMenu.APP_GROUP_TYPING_PRACTICE;
|
||||
this.selectedAppGroup = MainMenu.APP_GROUP_TYPING_EXAM;
|
||||
this.selectedLanguage = MainMenu.LANGUAGE_KOREAN;
|
||||
// this.animalRecordList.printScore(Animal.TYPE_PRACTICE);
|
||||
}
|
||||
@@ -195,6 +196,22 @@ MainMenu.prototype.makeTypingAppButtons = function() {
|
||||
}
|
||||
}
|
||||
|
||||
MainMenu.prototype.makeTypingExamButtons = function() {
|
||||
var offsetX = 95;
|
||||
var startY = 190;
|
||||
var offsetY = 110;
|
||||
|
||||
var buttonHalfWidth = TypingExamButton.WIDTH / 2;
|
||||
for(var i = 0; i < MainMenu.TYPING_APP_COUNT; i++) {
|
||||
var x = (i % 2) === 0 ? buttonHalfWidth + offsetX : GAME_SCREEN_SIZE.x - buttonHalfWidth - offsetX;
|
||||
var y = startY + Math.floor(i / 2) * offsetY;
|
||||
|
||||
var button = new TypingExamButton(x, y);
|
||||
// button.setActive(false);
|
||||
this.typingExamButtons.push(button);
|
||||
}
|
||||
}
|
||||
|
||||
MainMenu.prototype.makePlayAppButtons = function() {
|
||||
var startX = 150;
|
||||
var startY = 300;
|
||||
@@ -219,6 +236,10 @@ MainMenu.prototype.hideAllButtons = function() {
|
||||
this.typingAppButtons[i].setActive(false);
|
||||
}
|
||||
|
||||
for(var i = 0; i < MainMenu.TYPING_EXAM_COUNT; i++) {
|
||||
this.typingExamButtons[i].setActive(false);
|
||||
}
|
||||
|
||||
for(var i = 0; i < MainMenu.PLAY_APP_COUNT; i++) {
|
||||
this.playAppButtons[i].setActive(false);
|
||||
}
|
||||
@@ -242,12 +263,10 @@ MainMenu.prototype.updateAppButtons = function(appGroup, appData) {
|
||||
|
||||
case MainMenu.APP_GROUP_TYPING_PLAY:
|
||||
this.updatePlayAppButtons(appData);
|
||||
// this.updateTypingPlayAppButtons(appData);
|
||||
break;
|
||||
|
||||
case MainMenu.APP_GROUP_MOUSE_PLAY:
|
||||
this.updatePlayAppButtons(appData);
|
||||
// this.updateMousePlayAppButtons(appData);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -265,6 +284,16 @@ MainMenu.prototype.isActivatedApp = function(appID, activeAppList) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MainMenu.prototype.isActivatedWriting = function(writingID, activeAppList) {
|
||||
var count = activeAppList.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
if(writingID === activeAppList[i].writingID)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MainMenu.prototype.getAppHighestRecord = function(appID, highestRecordList) {
|
||||
var count = highestRecordList.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
@@ -275,6 +304,16 @@ MainMenu.prototype.getAppHighestRecord = function(appID, highestRecordList) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MainMenu.prototype.getWritingHighestRecord = function(writingID, highestRecordList) {
|
||||
var count = highestRecordList.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
if(writingID === highestRecordList[i].writingID)
|
||||
return highestRecordList[i].highestRecord;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MainMenu.prototype.makeTypingPracticeAppDataList = function(appGroup, appData) {
|
||||
var appDataList = new Array();
|
||||
|
||||
@@ -297,6 +336,28 @@ MainMenu.prototype.makeTypingPracticeAppDataList = function(appGroup, appData) {
|
||||
return appDataList;
|
||||
}
|
||||
|
||||
MainMenu.prototype.makeTypingExamAppDataList = function(appData) {
|
||||
var appDataList = new Array();
|
||||
|
||||
var appList = appData.appList;
|
||||
if(appList.length === 0)
|
||||
return [];
|
||||
|
||||
var count = appList.length;
|
||||
for(var appDataIndex = 0; appDataIndex < count; appDataIndex++) {
|
||||
var data = {};
|
||||
data["writingID"] = appList[appDataIndex].writingID;
|
||||
data["name"] = appList[appDataIndex].name;
|
||||
data["filename"] = appList[appDataIndex].filename;
|
||||
data["letterCount"] = appList[appDataIndex].letterCount;
|
||||
data["activated"] = this.isActivatedWriting(appList[appDataIndex].writingID, appData.activeAppList);
|
||||
data["highestRecord"] = this.getWritingHighestRecord(appList[appDataIndex].writingID, appData.highestRecordList);
|
||||
appDataList.push(data);
|
||||
}
|
||||
|
||||
return appDataList;
|
||||
}
|
||||
|
||||
MainMenu.prototype.makePlayAppDataList = function(appData) {
|
||||
var appDataList = new Array();
|
||||
|
||||
@@ -357,6 +418,21 @@ MainMenu.prototype.updateTypingTestAppButtons = function(appGroup, appData) {
|
||||
MainMenu.prototype.updateTypingExamAppButtons = function(appData) {
|
||||
console.log("updateTypingExamAppButtons");
|
||||
console.log(appData);
|
||||
|
||||
var buttonIndex = 0;
|
||||
var appDataList = this.makeTypingExamAppDataList(appData);
|
||||
console.log(appDataList);
|
||||
var count = appDataList.length;
|
||||
for(var i = 0; i < MainMenu.TYPING_APP_COUNT; i++) {
|
||||
var button = this.typingExamButtons[i];
|
||||
if(i < count) {
|
||||
button.setActive(true);
|
||||
button.updateAppData(appDataList[i]);
|
||||
} else {
|
||||
button.setActive(true);
|
||||
button.showEmptyDisabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainMenu.prototype.updatePlayAppButtons = function(appData) {
|
||||
@@ -678,4 +754,5 @@ MainMenu.LANGUAGE_KOREAN = 0;
|
||||
MainMenu.LANGUAGE_ENGLISH = 1;
|
||||
|
||||
MainMenu.TYPING_APP_COUNT = 10;
|
||||
MainMenu.TYPING_EXAM_COUNT = 10;
|
||||
MainMenu.PLAY_APP_COUNT = 10;
|
||||
Reference in New Issue
Block a user