Add: typing practice app button
This commit is contained in:
@@ -20,9 +20,29 @@ class AppInfoManager {
|
||||
}
|
||||
|
||||
registerAppInfoList() {
|
||||
// menu
|
||||
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
||||
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
||||
this.registerAppInfo(new AppInfo("menu", "메뉴", ""));
|
||||
|
||||
// typing
|
||||
this.registerAppInfo(new AppInfo("korean_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_lower", "오른손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper_double", "쌍자음", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper_double", "쌍모음", ""));
|
||||
|
||||
this.registerAppInfo(new AppInfo("english_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_lower", "오른손 밑글쇠", ""));
|
||||
|
||||
// mouse
|
||||
this.registerAppInfo(new AppInfo("space_invaders", "외계인 침공",
|
||||
"외계인이 나타났다!\n마우스 왼쪽 버튼으로\n외계인을 클릭해서 물리쳐 주세요."
|
||||
));
|
||||
|
||||
@@ -81,6 +81,23 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON.length > 0)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
requestPlayerHistory(maestroID, date, listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ class MenuTypingPractice {
|
||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||
|
||||
|
||||
this.makeActiveAppButtons();
|
||||
this.makeActiveTypingPracticeAppButtons();
|
||||
}
|
||||
|
||||
|
||||
makeActiveAppButtons() {
|
||||
makeActiveTypingPracticeAppButtons() {
|
||||
let dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestActiveAppList(
|
||||
dbConnectManager.requestTypingPracticeAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
self.loginSucceeded,
|
||||
self.loginFailed
|
||||
@@ -43,19 +43,25 @@ class MenuTypingPractice {
|
||||
}
|
||||
|
||||
loginSucceeded(replyJSON) {
|
||||
// console.log(replyJSON);
|
||||
console.log(replyJSON);
|
||||
|
||||
let koreanTypingPracticeAppCount = 1; // self.getAppCount(replyJSON, AppButton.TYPE_MOUSE);
|
||||
let englishTypingPracticeAppCount = 1; // self.getAppCount(replyJSON, AppButton.TYPE_TYPING);
|
||||
let buttonWidthGap = MenuTypingPractice.BUTTON_WIDTH + MenuTypingPractice.BUTTON_GAP;
|
||||
|
||||
let startX = game.world.width / 2 - (150 * koreanTypingPracticeAppCount / 2) - (150 / 2);
|
||||
let koreanTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_KOREAN);
|
||||
let englishTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_ENGLISH);
|
||||
|
||||
let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||
let koreanTypingPracticeAppIndex = 0;
|
||||
for(let i = 0; i < replyJSON.length; i++) {
|
||||
let activeApp = replyJSON[i];
|
||||
if(self.isMouseApp(activeApp)) {
|
||||
if(self.isKoreanApp(activeApp)) {
|
||||
koreanTypingPracticeAppIndex++;
|
||||
new TypingPracticeButton(startX + 150 * koreanTypingPracticeAppIndex, 300, TypingPracticeButton.TYPE_ENGLISH,
|
||||
TypingPracticeButton.NONE_ICON, "양손 기본",
|
||||
console.log(activeApp);
|
||||
new TypingPracticeButton(
|
||||
startX + buttonWidthGap * koreanTypingPracticeAppIndex, 300,
|
||||
TypingPracticeButton.TYPE_KOREAN,
|
||||
TypingPracticeButton.NONE_ICON,
|
||||
appInfoManager.getAppNameKorean(activeApp.AppName),
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
@@ -65,6 +71,28 @@ class MenuTypingPractice {
|
||||
}
|
||||
}
|
||||
|
||||
startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||
let englishTypingPracticeAppIndex = 0;
|
||||
for(let i = 0; i < replyJSON.length; i++) {
|
||||
let activeApp = replyJSON[i];
|
||||
if(!self.isKoreanApp(activeApp)) {
|
||||
englishTypingPracticeAppIndex++;
|
||||
console.log(activeApp);
|
||||
new TypingPracticeButton(
|
||||
startX + buttonWidthGap * englishTypingPracticeAppIndex, 500,
|
||||
TypingPracticeButton.TYPE_ENGLISH,
|
||||
TypingPracticeButton.NONE_ICON,
|
||||
appInfoManager.getAppNameKorean(activeApp.AppName),
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(englishTypingPracticeAppCount > 0) {
|
||||
new TypingPracticeButton(game.world.width / 2, 500, TypingPracticeButton.TYPE_KOREAN,
|
||||
TypingPracticeButton.NONE_ICON, "검지 글쇠",
|
||||
@@ -75,10 +103,11 @@ class MenuTypingPractice {
|
||||
}
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
isMouseApp(app) {
|
||||
if(app.AppType > 100)
|
||||
isKoreanApp(app) {
|
||||
if(app.AppType === MenuTypingPractice.TYPE_KOREAN)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -88,9 +117,7 @@ class MenuTypingPractice {
|
||||
let appCount = 0;
|
||||
for(let i = 0; i < replyJSON.length; i++) {
|
||||
let activeApp = replyJSON[i];
|
||||
if(type == AppButton.TYPE_TYPING && activeApp.AppType <= 100)
|
||||
appCount++;
|
||||
else if(type == AppButton.TYPE_MOUSE && activeApp.AppType > 100)
|
||||
if(activeApp.AppType === type)
|
||||
appCount++;
|
||||
}
|
||||
|
||||
@@ -101,4 +128,11 @@ class MenuTypingPractice {
|
||||
console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MenuTypingPractice.TYPE_KOREAN = 10;
|
||||
MenuTypingPractice.TYPE_ENGLISH = 20;
|
||||
|
||||
MenuTypingPractice.BUTTON_WIDTH = 200;
|
||||
MenuTypingPractice.BUTTON_GAP = 20;
|
||||
Reference in New Issue
Block a user