Fix: load how to play from server

This commit is contained in:
2018-06-05 14:17:58 +09:00
parent c50015a991
commit 1bcce524e3
18 changed files with 128 additions and 139 deletions
+1 -2
View File
@@ -36,6 +36,7 @@ let sessionStorageManager = new SessionStorageManager();
console.log("playerUserID : " + sessionStorageManager.playerUserID);
console.log("playingAppID : " + sessionStorageManager.playingAppID);
console.log("playingAppName : " + sessionStorageManager.playingAppName);
console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName);
console.log("record : " + sessionStorageManager.record);
console.log("BestRecord : " + sessionStorageManager.bestRecord);
}
@@ -50,6 +51,4 @@ function isTypingGame() {
return true;
}
let appInfoManager = new AppInfoManager();
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
+21 -2
View File
@@ -102,7 +102,7 @@ class DBConnectManager {
requestMenuAppList(maestroID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/app/menu_app_list.php", true);
xhr.open("POST", this.phpPath + "server/app/menu_active_app_list.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
@@ -119,7 +119,7 @@ class DBConnectManager {
requestTypingPracticeAppList(maestroID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app.php", true);
xhr.open("POST", this.phpPath + "server/app/active_typing_practice_app_list.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
@@ -335,6 +335,25 @@ class DBConnectManager {
return xhr;
}
requestHowToPlay(appID, onSucceededListener, onFailedListener) {
let xhr = new XMLHttpRequest();
xhr.open("POST", this.phpPath + "server/app/how_to_play.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);
console.log(replyJSON);
console.log(replyJSON["HowToPlay"]);
if(replyJSON != null && replyJSON["HowToPlay"] != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
};
xhr.send("AppID=" + appID);
}
loadTempPlayerHistory(historyRecordManager) {
+8
View File
@@ -51,6 +51,14 @@ class SessionStorageManager {
return sessionStorage.getItem("playingAppName");
}
// playing app korean name
set playingAppKoreanName(value) {
sessionStorage.setItem("playingAppKoreanName", value);
}
get playingAppKoreanName() {
return sessionStorage.getItem("playingAppKoreanName");
}
// record
set record(value) {
sessionStorage.setItem("record", value);
+1
View File
@@ -66,6 +66,7 @@ class MenuApp {
() => {
sessionStorageManager.playingAppID = app.AppID;
sessionStorageManager.playingAppName = app.AppName;
sessionStorageManager.playingAppKoreanName = app.AppKoreanName;
location.href = '../../web/client/start.html';
}
);
+19 -4
View File
@@ -23,7 +23,8 @@ class Start {
// contents
this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
// this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
this.loadHowToPlay(sessionStorageManager.playingAppID);
this.makeStartButton();
let today = new Date();
let date = DateUtil.getYYYYMMDD(today);
@@ -58,14 +59,28 @@ class Start {
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
screenBottom.printBottomLeftText("게임 진행 정보");
let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
screenBottom.printBottomCenterText(playingAppName);
let playingAppKoreanName = sessionStorageManager.playingAppKoreanName;
screenBottom.printBottomCenterText(playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
}
loadHowToPlay(appID) {
this.dbConnectManager.requestHowToPlay(
101, // space_invaders app ID
(jsonData) => {
let howToPlay = jsonData["HowToPlay"].replace(/\\n/g, "\n");
this.printHowToPlay(howToPlay);
},
(jsonData) => {
this.printHowToPlay("No data");
}
);
}
printHowToPlay(text) {
const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
let howToPlayText = game.add.text(0, 0, appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName), style);
let howToPlayText = game.add.text(0, 0, text, style);
howToPlayText.setTextBounds(100, 100, game.world.width - 100, 200);
howToPlayText.stroke = "#333";
howToPlayText.strokeThickness = 5;