Fix: typing app menu
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const LANGUAGE_KOREAN = "korean";
|
const LANGUAGE_KOREAN = "korean";
|
||||||
const LANGUAGE_ENGLISH = "english";
|
const LANGUAGE_ENGLISH = "english";
|
||||||
|
|
||||||
const MODE_RELEASE = "release";
|
const MODE_RELEASE = "release";
|
||||||
const MODE_DEBUG = "debug";
|
const MODE_DEBUG = "debug";
|
||||||
const runMode = MODE_DEBUG;
|
const runMode = MODE_DEBUG;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class DBConnectManager {
|
|||||||
|
|
||||||
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
|
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app_list.php", true);
|
xhr.open("POST", this.phpPath + "server/app/menu_active_typing_practice_app_list.php", true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||||
|
|||||||
@@ -73,10 +73,11 @@ class GameAppButton extends AppButton {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameAppButton.BUTTON_WIDTH = 150;
|
GameAppButton.BUTTON_WIDTH = 150;
|
||||||
GameAppButton.BUTTON_HEIGHT = 150;
|
GameAppButton.BUTTON_HEIGHT = 150;
|
||||||
|
|
||||||
GameAppButton.BUTTON_GAP = 20;
|
GameAppButton.BUTTON_GAP = 20;
|
||||||
|
GameAppButton.MARGIN_VERTICAL = 100;
|
||||||
|
|
||||||
GameAppButton.BUTTON_UPPER_POS_Y = 200;
|
GameAppButton.BUTTON_UPPER_POS_Y = 200;
|
||||||
GameAppButton.BUTTON_LOWER_POS_Y = 540;
|
GameAppButton.BUTTON_LOWER_POS_Y = 540;
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
class TypingPracticeButton extends AppButton {
|
class TypingPracticeButton extends AppButton {
|
||||||
|
|
||||||
constructor(x, y, type, iconName, buttonText, clickEvent) {
|
constructor(x, y, type, iconName, buttonText, clickEvent) {
|
||||||
let setting = new RoundRectButtonSetting(200, 100);
|
let setting = new RoundRectButtonSetting(TypingPracticeButton.BUTTON_WIDTH, TypingPracticeButton.BUTTON_HEIGHT);
|
||||||
setting.fontStyle.boundsAlignH = "center"; // left, center. right
|
setting.fontStyle.boundsAlignH = "center"; // left, center. right
|
||||||
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
|
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
|
||||||
setting.strokeWidthPx = 5;
|
setting.strokeWidthPx = 5;
|
||||||
|
|
||||||
if(type === TypingPracticeButton.TYPE_KOREAN) {
|
if(type === LANGUAGE_KOREAN) {
|
||||||
setting.setStrokeColor(
|
setting.setStrokeColor(
|
||||||
0xaa6666,
|
0xaa6666,
|
||||||
0x884444,
|
0x884444,
|
||||||
@@ -25,7 +25,7 @@ class TypingPracticeButton extends AppButton {
|
|||||||
"#844",
|
"#844",
|
||||||
"#333"
|
"#333"
|
||||||
);
|
);
|
||||||
} else { // TYPE_ENGLISH
|
} else { // LANGUAGE_ENGLISH
|
||||||
setting.setStrokeColor(
|
setting.setStrokeColor(
|
||||||
0x444488,
|
0x444488,
|
||||||
0x6666aa,
|
0x6666aa,
|
||||||
@@ -72,5 +72,11 @@ class TypingPracticeButton extends AppButton {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypingPracticeButton.TYPE_KOREAN = "한글";
|
TypingPracticeButton.BUTTON_WIDTH = 200;
|
||||||
TypingPracticeButton.TYPE_ENGLISH = "영문";
|
TypingPracticeButton.BUTTON_HEIGHT = 100;
|
||||||
|
|
||||||
|
TypingPracticeButton.BUTTON_GAP = 20;
|
||||||
|
TypingPracticeButton.MARGIN_VERTICAL = 100;
|
||||||
|
|
||||||
|
TypingPracticeButton.BUTTON_UPPER_POS_Y = 200;
|
||||||
|
TypingPracticeButton.BUTTON_LOWER_POS_Y = 540;
|
||||||
@@ -120,7 +120,7 @@ class MenuApp {
|
|||||||
|
|
||||||
getButtonPosX(index, buttonCount) {
|
getButtonPosX(index, buttonCount) {
|
||||||
let gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP;
|
let gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP;
|
||||||
let maxColumnNum = Math.floor( (game.world.width - MenuApp.MARGIN_VERTICAL) / gap );
|
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
|
||||||
// console.log("maxColumnNum : " + maxColumnNum);
|
// console.log("maxColumnNum : " + maxColumnNum);
|
||||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||||
// console.log("rowCount : " + rowCount);
|
// console.log("rowCount : " + rowCount);
|
||||||
@@ -143,7 +143,7 @@ class MenuApp {
|
|||||||
|
|
||||||
getButtonPosY(index, buttonCount, startPosY) {
|
getButtonPosY(index, buttonCount, startPosY) {
|
||||||
let gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP;
|
let gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP;
|
||||||
let maxColumnNum = Math.floor( (game.world.width - MenuApp.MARGIN_VERTICAL) / gap );
|
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
|
||||||
// console.log("maxColumnNum : " + maxColumnNum);
|
// console.log("maxColumnNum : " + maxColumnNum);
|
||||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||||
// console.log("rowCount : " + rowCount);
|
// console.log("rowCount : " + rowCount);
|
||||||
@@ -159,6 +159,4 @@ class MenuApp {
|
|||||||
// console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
// console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuApp.MARGIN_VERTICAL = 100;
|
|
||||||
@@ -23,8 +23,7 @@ class MenuTypingPractice {
|
|||||||
let screenBottom = new ScreenBottom();
|
let screenBottom = new ScreenBottom();
|
||||||
screenBottom.makeBottomLine();
|
screenBottom.makeBottomLine();
|
||||||
// screenBottom.printBottomLeftText("게임 진행 정보");
|
// screenBottom.printBottomLeftText("게임 진행 정보");
|
||||||
let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
|
screenBottom.printBottomCenterText("타자 연습");
|
||||||
screenBottom.printBottomCenterText(playingAppName);
|
|
||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
|
|
||||||
|
|
||||||
@@ -43,96 +42,97 @@ class MenuTypingPractice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginSucceeded(replyJSON) {
|
loginSucceeded(replyJSON) {
|
||||||
console.log(replyJSON);
|
// console.log(replyJSON);
|
||||||
|
|
||||||
let buttonWidthGap = MenuTypingPractice.BUTTON_WIDTH + MenuTypingPractice.BUTTON_GAP;
|
let buttonWidthGap = TypingPracticeButton.BUTTON_WIDTH + MenuTypingPractice.BUTTON_GAP;
|
||||||
|
|
||||||
let koreanTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_KOREAN);
|
let koreanTypingPracticeAppCount = Object.keys(replyJSON.Korean).length;
|
||||||
let englishTypingPracticeAppCount = self.getAppCount(replyJSON, MenuTypingPractice.TYPE_ENGLISH);
|
let englishTypingPracticeAppCount = Object.keys(replyJSON.English).length;
|
||||||
|
|
||||||
let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
// let startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||||
let koreanTypingPracticeAppIndex = 0;
|
// let koreanTypingPracticeAppIndex = 0;
|
||||||
for(let i = 0; i < replyJSON.length; i++) {
|
for(let i = 0; i < koreanTypingPracticeAppCount; i++) {
|
||||||
let activeApp = replyJSON[i];
|
let activeApp = replyJSON.Korean[i];
|
||||||
if(self.isKoreanApp(activeApp)) {
|
|
||||||
koreanTypingPracticeAppIndex++;
|
|
||||||
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;
|
|
||||||
location.href = '../../web/client/start.html';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startX = game.world.width / 2 - (buttonWidthGap * koreanTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
let posX = self.getButtonPosX(i, koreanTypingPracticeAppCount);
|
||||||
let englishTypingPracticeAppIndex = 0;
|
let posY = self.getButtonPosY(i, koreanTypingPracticeAppCount,
|
||||||
for(let i = 0; i < replyJSON.length; i++) {
|
TypingPracticeButton.BUTTON_UPPER_POS_Y
|
||||||
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';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
new TypingPracticeButton(
|
||||||
if(englishTypingPracticeAppCount > 0) {
|
posX, posY, LANGUAGE_KOREAN,
|
||||||
new TypingPracticeButton(game.world.width / 2, 500, TypingPracticeButton.TYPE_KOREAN,
|
TypingPracticeButton.NONE_ICON,
|
||||||
TypingPracticeButton.NONE_ICON, "검지 글쇠",
|
activeApp.KoreanName,
|
||||||
() => {
|
() => {
|
||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
location.href = '../../web/client/start.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
isKoreanApp(app) {
|
// startX = game.world.width / 2 - (buttonWidthGap * englishTypingPracticeAppCount / 2) - (buttonWidthGap / 2);
|
||||||
if(app.AppType === MenuTypingPractice.TYPE_KOREAN)
|
for(let i = 0; i < englishTypingPracticeAppCount; i++) {
|
||||||
return true;
|
let activeApp = replyJSON.English[i];
|
||||||
|
|
||||||
return false;
|
let posX = self.getButtonPosX(i, englishTypingPracticeAppCount);
|
||||||
}
|
let posY = self.getButtonPosY(i, englishTypingPracticeAppCount,
|
||||||
|
TypingPracticeButton.BUTTON_LOWER_POS_Y
|
||||||
|
);
|
||||||
|
|
||||||
getAppCount(replyJSON, type) {
|
new TypingPracticeButton(
|
||||||
let appCount = 0;
|
posX, posY, LANGUAGE_ENGLISH,
|
||||||
for(let i = 0; i < replyJSON.length; i++) {
|
TypingPracticeButton.NONE_ICON,
|
||||||
let activeApp = replyJSON[i];
|
activeApp.KoreanName,
|
||||||
if(activeApp.AppType === type)
|
() => {
|
||||||
appCount++;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
|
location.href = '../../web/client/start.html';
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return appCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getButtonPosX(index, buttonCount) {
|
||||||
|
let gap = TypingPracticeButton.BUTTON_WIDTH + TypingPracticeButton.BUTTON_GAP;
|
||||||
|
let maxColumnNum = Math.floor( (game.world.width - TypingPracticeButton.MARGIN_VERTICAL) / gap );
|
||||||
|
// console.log("maxColumnNum : " + maxColumnNum);
|
||||||
|
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||||
|
// console.log("rowCount : " + rowCount);
|
||||||
|
|
||||||
|
let columnIndex = index % maxColumnNum;
|
||||||
|
// console.log("columnIndex : " + columnIndex);
|
||||||
|
let rowIndex = Math.floor(index / maxColumnNum);
|
||||||
|
// console.log("rowIndex : " + rowIndex);
|
||||||
|
|
||||||
|
let columnCountForThisRow = 0;
|
||||||
|
if(rowIndex < rowCount - 1)
|
||||||
|
columnCountForThisRow = maxColumnNum;
|
||||||
|
else
|
||||||
|
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
|
||||||
|
// console.log("columnCountForThisRow : " + columnCountForThisRow);
|
||||||
|
|
||||||
|
let startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
|
||||||
|
return startX + gap * columnIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
getButtonPosY(index, buttonCount, startPosY) {
|
||||||
|
let gap = TypingPracticeButton.BUTTON_HEIGHT + TypingPracticeButton.BUTTON_GAP;
|
||||||
|
let maxColumnNum = Math.floor( (game.world.width - TypingPracticeButton.MARGIN_VERTICAL) / gap );
|
||||||
|
// console.log("maxColumnNum : " + maxColumnNum);
|
||||||
|
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||||
|
// console.log("rowCount : " + rowCount);
|
||||||
|
|
||||||
|
let rowIndex = Math.floor(index / maxColumnNum);
|
||||||
|
// console.log("rowIndex : " + rowIndex);
|
||||||
|
|
||||||
|
let startY = startPosY - ( (gap / 2) * (rowCount - 1) );
|
||||||
|
return startY + gap * rowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
loginFailed(replyJSON) {
|
loginFailed(replyJSON) {
|
||||||
console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MenuTypingPractice.TYPE_KOREAN = 10;
|
|
||||||
MenuTypingPractice.TYPE_ENGLISH = 20;
|
|
||||||
|
|
||||||
MenuTypingPractice.BUTTON_WIDTH = 200;
|
|
||||||
MenuTypingPractice.BUTTON_GAP = 20;
|
|
||||||
+9
-7
@@ -8,7 +8,8 @@ $maestro_id = $_POST["maestro_id"];
|
|||||||
include "./../setup/connect_db.php";
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
|
||||||
$replyJSON = get_active_typing_practice_app_list($maestro_id);
|
$replyJSON["Korean"] = get_active_typing_practice_app_list($maestro_id, 10);
|
||||||
|
$replyJSON["English"] = get_active_typing_practice_app_list($maestro_id, 20);
|
||||||
$db_conn->close();
|
$db_conn->close();
|
||||||
|
|
||||||
if($replyJSON.length === 0) {
|
if($replyJSON.length === 0) {
|
||||||
@@ -22,23 +23,24 @@ $db_conn->close();
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_active_typing_practice_app_list($maestro_id) {
|
function get_active_typing_practice_app_list($maestro_id, $type) {
|
||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT A.AppID, A.AppName, A.AppType
|
SELECT A.AppID, A.AppName, A.KoreanName
|
||||||
FROM moty_app AS A
|
FROM moty_app AS A
|
||||||
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID=?";
|
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID = ? AND A.AppType = ?
|
||||||
|
ORDER BY A.AppID ASC";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('i', $maestro_id);
|
$stmt->bind_param('ii', $maestro_id, $type);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($app_id, $app_name, $app_type);
|
$stmt->bind_result($app_id, $app_name, $korean_name);
|
||||||
|
|
||||||
$return_array = array();
|
$return_array = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
$row_array['AppID'] = $app_id;
|
$row_array['AppID'] = $app_id;
|
||||||
$row_array['AppName'] = $app_name;
|
$row_array['AppName'] = $app_name;
|
||||||
$row_array['AppType'] = $app_type;
|
$row_array['KoreanName'] = $korean_name;
|
||||||
array_push($return_array, $row_array);
|
array_push($return_array, $row_array);
|
||||||
}
|
}
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
@@ -38,12 +38,12 @@ QUnit.test( "Player history", function( assert ) {
|
|||||||
// console.log(historyRecordManager);
|
// console.log(historyRecordManager);
|
||||||
|
|
||||||
assert.equal(historyRecordManager.getAppNameAt(0), "korean_word");
|
assert.equal(historyRecordManager.getAppNameAt(0), "korean_word");
|
||||||
assert.equal(historyRecordManager.getDateAt(0), "2018-05-14");
|
assert.equal(historyRecordManager.getDateAt(0), "2018-05-16");
|
||||||
assert.equal(historyRecordManager.getBestRecordAt(0), 101.78);
|
assert.equal(historyRecordManager.getBestRecordAt(0), 108.248);
|
||||||
|
|
||||||
assert.equal(historyRecordManager.getAppNameAt(4), "korean_word");
|
assert.equal(historyRecordManager.getAppNameAt(4), "korean_word");
|
||||||
assert.equal(historyRecordManager.getDateAt(4), "2018-04-18");
|
assert.equal(historyRecordManager.getDateAt(4), "2018-04-23");
|
||||||
assert.equal(historyRecordManager.getBestRecordAt(4), 51.6102);
|
assert.equal(historyRecordManager.getBestRecordAt(4), 74.2234);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user