From c061e305f0162055e5f67d17879673ca6435365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 30 Aug 2018 20:33:42 +0900 Subject: [PATCH] Fix: show all app list and disable some buttons --- src/game/lib/button/game_app_button.js | 1 - src/game/lib/button/typing_tab_button.js | 24 ++--- src/game/menu/menu_app.js | 44 +++++--- src/game/menu/menu_typing_practice.js | 2 +- src/game/typing/practice/game.js | 3 +- src/game/typing/test/game.js | 3 +- src/web/server/app/menu_active_app_list.php | 105 +++++++++++++------- src/web/sql/insert_maestro_player.sql | 4 +- 8 files changed, 120 insertions(+), 66 deletions(-) diff --git a/src/game/lib/button/game_app_button.js b/src/game/lib/button/game_app_button.js index a44bb05..c295a01 100644 --- a/src/game/lib/button/game_app_button.js +++ b/src/game/lib/button/game_app_button.js @@ -1,7 +1,6 @@ class GameAppButton extends RoundRectButton { constructor(x, y, type, iconName, buttonText, clickEvent) { - console.log(type); let setting = new RoundRectButtonSetting( x, y, GameAppButton.BUTTON_WIDTH, GameAppButton.BUTTON_HEIGHT diff --git a/src/game/lib/button/typing_tab_button.js b/src/game/lib/button/typing_tab_button.js index d5ed7d4..645934d 100644 --- a/src/game/lib/button/typing_tab_button.js +++ b/src/game/lib/button/typing_tab_button.js @@ -10,21 +10,21 @@ class TypingTabButton extends RoundRectButton { setting.strokeWidthPx = 5; setting.setStrokeColor( - 0x444488, - 0x6666aa, - 0x6666aa, + 0x446688, + 0x6688aa, + 0x6688aa, 0x333333 ); setting.setButtonColor( - 0xaaaadd, - 0xddddff, - 0xddddff, + 0xaabbdd, + 0xddeeff, + 0xddeeff, 0x666666 ); setting.setTextColor( - "#844", - "#a66", - "#a66", + "#468", + "#68a", + "#68a", "#333" ); @@ -41,13 +41,13 @@ class TypingTabButton extends RoundRectButton { } -TypingTabButton.BUTTON_WIDTH = 500; +TypingTabButton.BUTTON_WIDTH = 480; TypingTabButton.BUTTON_HEIGHT = 80; TypingTabButton.BUTTON_GAP = 20; TypingTabButton.MARGIN_VERTICAL = 100; -TypingTabButton.PRACTICE_BUTTON_POS_X = GAME_SCREEN_SIZE.x / 4; -TypingTabButton.TEST_BUTTON_POS_X = GAME_SCREEN_SIZE.x / 4 * 3; +TypingTabButton.PRACTICE_BUTTON_POS_X = GAME_SCREEN_SIZE.x / 4 + TypingTabButton.BUTTON_GAP / 2; +TypingTabButton.TEST_BUTTON_POS_X = GAME_SCREEN_SIZE.x / 4 * 3 - TypingTabButton.BUTTON_GAP / 2; TypingTabButton.BUTTON_POS_Y = GAME_SCREEN_SIZE.y - (TypingTabButton.BUTTON_HEIGHT / 3 * 4); \ No newline at end of file diff --git a/src/game/menu/menu_app.js b/src/game/menu/menu_app.js index 4df673b..8880d64 100644 --- a/src/game/menu/menu_app.js +++ b/src/game/menu/menu_app.js @@ -49,25 +49,38 @@ class MenuApp { loadSucceeded(replyJSON) { console.log(replyJSON); - self.makeMouseAppButtons(replyJSON.MouseAppList); + self.makeMouseAppButtons( + replyJSON.MouseAppList, + replyJSON.MouseActiveAppList + ); self.makeTypingButtons( replyJSON.TypingPracticeAppCount, replyJSON.TypingTestAppCount, - replyJSON.TypingAppList + replyJSON.TypingAppList, + replyJSON.TypingActiveAppList ); } - makeMouseAppButtons(mouseAppJSON) { - // console.log(mouseAppJSON); + hasApp(appID, appList) { + for(let i = 0; i < appList.length; i++) { + if(appList[i].AppID === appID) + return true; + } - let mouseAppCount = Object.keys(mouseAppJSON).length; + return false; + } + + makeMouseAppButtons(appList, activeAppList) { + // console.log(appList); + + let mouseAppCount = Object.keys(appList).length; for(let i = 0; i < mouseAppCount; i++) { let posX = self.getButtonPosX(i, mouseAppCount); let posY = self.getButtonPosY(i, mouseAppCount, GameAppButton.BUTTON_UPPER_POS_Y); - let app = mouseAppJSON[i]; - new GameAppButton( + let app = appList[i]; + let gameAppButton = new GameAppButton( posX, posY, GameAppButton.TYPE_MOUSE_APP, "icon_fullscreen", app.KoreanName, () => { @@ -77,18 +90,21 @@ class MenuApp { location.href = '../../web/client/start.html'; } ); + + if(!self.hasApp(app.AppID, activeAppList)) + gameAppButton.inputEnabled = false; } } - makeTypingButtons(typingPracticeAppCount, typingTestAppCount, typingAppJSON) { + makeTypingButtons(typingPracticeAppCount, typingTestAppCount, appList, activeAppList) { // console.log(typingPracticeAppCount); // console.log(typingTestAppCount); - // console.log(typingAppJSON); + // console.log(appList); let isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false; let isTypingTestAppExist = typingTestAppCount > 0 ? true : false; - let typingAppTotalCount = Object.keys(typingAppJSON).length; + let typingAppTotalCount = Object.keys(appList).length; let typingAppIndex = 0; @@ -124,10 +140,10 @@ class MenuApp { typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y ); - let app = typingAppJSON[typingAppIndex]; + let app = appList[typingAppIndex]; let isKoreanTypingApp = app.AppID < 32 ? true : false; - new GameAppButton( + let gameAppButton = new GameAppButton( posX, posY, GameAppButton.TYPE_TYPING_APP, "icon_fullscreen", // (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName, @@ -139,6 +155,10 @@ class MenuApp { location.href = '../../web/client/start.html'; } ); + + if(!self.hasApp(app.AppID, activeAppList)) + gameAppButton.inputEnabled = false; + typingAppIndex++; } } diff --git a/src/game/menu/menu_typing_practice.js b/src/game/menu/menu_typing_practice.js index 830bc79..94a7b6f 100644 --- a/src/game/menu/menu_typing_practice.js +++ b/src/game/menu/menu_typing_practice.js @@ -109,7 +109,7 @@ class MenuTypingPractice { TypingPracticeButton.BUTTON_LOWER_POS_Y ); - new TypingPracticeButton( + let typingPracticeButton = new TypingPracticeButton( posX, posY, TypingPracticeButton.NONE_ICON, activeApp.KoreanName, diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index 0e6aac0..31cbc42 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -20,7 +20,8 @@ class TypingPractice { location.href = '../../web/client/menu_typing_practice.html'; }); - this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX - 200, 30); + // this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX - 200, 30); + this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX, 90); this.animalOnTitle.setSpecies(Animal.SPECIES_DATA[0]); this.animalOnTitle.startAnimation(); diff --git a/src/game/typing/test/game.js b/src/game/typing/test/game.js index 7f80dc1..2cc1111 100644 --- a/src/game/typing/test/game.js +++ b/src/game/typing/test/game.js @@ -18,7 +18,8 @@ class TypingTest { location.href = '../../web/client/menu_typing_test.html'; }); - this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX - 200, 30); + // this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX - 200, 30); + this.animalOnTitle = new Animal(Animal.TYPE_ON_TITLE, game.world.centerX, GAME_SCREEN_SIZE.y - 110); this.animalOnTitle.setSpecies(Animal.SPECIES_DATA[0]); this.animalOnTitle.startAnimation(); diff --git a/src/web/server/app/menu_active_app_list.php b/src/web/server/app/menu_active_app_list.php index 20fa630..c05b695 100644 --- a/src/web/server/app/menu_active_app_list.php +++ b/src/web/server/app/menu_active_app_list.php @@ -3,27 +3,60 @@ header("Content-Type: application/json"); $maestro_id = $_POST["maestro_id"]; +include "./../lib/send_reply_json.php"; include "./../setup/connect_db.php"; -$replyJSON = array(); -$replyJSON["MouseAppList"] = get_mouse_app_list($maestro_id); -$replyJSON["TypingPracticeAppCount"] = get_typing_practice_app_count($maestro_id); -$replyJSON["TypingTestAppCount"] = get_typing_test_app_count($maestro_id); -$replyJSON["TypingAppList"] = get_typing_app_list($maestro_id); -$db_conn->close(); +$mouseAppList = get_app_list(100); +$typingAppList = get_app_list(50); +$mouseActiveAppList = get_active_mouse_app_list($maestro_id); +$typingActiveAppList = get_active_typing_app_list($maestro_id); +$typingPracticeAppCount = get_typing_practice_app_count($maestro_id); +$typingTestAppCount = get_typing_test_app_count($maestro_id); if($replyJSON.length === 0) { - send_error_message($replyJSON, "앱 목록 가져오기 실패"); - $db_conn->close(); + set_error_code("no_app_list"); + set_error_message("앱 목록을 가져오지 못했습니다."); + send_result_fail(); exit; } -echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE); -$db_conn->close(); +set_data("MouseAppList", $mouseAppList); +set_data("TypingAppList", $typingAppList); +set_data("MouseActiveAppList", $mouseActiveAppList); +set_data("TypingActiveAppList", $typingActiveAppList); +set_data("TypingPracticeAppCount", $typingPracticeAppCount); +set_data("TypingTestAppCount", $typingTestAppCount); +send_result_success(); +exit; -function get_mouse_app_list($maestro_id) { +function get_app_list($appType) { + global $db_conn; + + $query = " + SELECT AppID, AppName, KoreanName + FROM app + WHERE AppType = ? AND Status = 1 + ORDER BY AppID ASC"; + $stmt = $db_conn->prepare($query); + $stmt->bind_param('i', $appType); + $stmt->execute(); + $stmt->bind_result($app_id, $app_name, $korean_name); + + $return_array = array(); + while($stmt->fetch()) { + $row_array['AppID'] = $app_id; + $row_array['AppName'] = $app_name; + $row_array['KoreanName'] = $korean_name; + array_push($return_array, $row_array); + } + $stmt->close(); + + return $return_array; +} + +function get_active_mouse_app_list($maestro_id) { global $db_conn; $query = " @@ -48,6 +81,31 @@ function get_mouse_app_list($maestro_id) { return $return_array; } +function get_active_typing_app_list($maestro_id) { + global $db_conn; + + $query = " + SELECT A.AppID, A.AppName, A.KoreanName, A.AppType + FROM app AS A + INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = 50 AND AA.MaestroID=?"; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("i", $maestro_id); + $stmt->execute(); + $stmt->bind_result($app_id, $app_name, $korean_name, $app_type); + + $return_array = array(); + while($stmt->fetch()) { + $row_array["AppID"] = $app_id; + $row_array["AppName"] = $app_name; + $row_array["KoreanName"] = $korean_name; + $row_array["AppType"] = $app_type; + array_push($return_array, $row_array); + } + $stmt->close(); + + return $return_array; +} + function get_typing_practice_app_count($maestro_id) { global $db_conn; @@ -82,29 +140,4 @@ function get_typing_test_app_count($maestro_id) { return $typing_practice_app_count; } -function get_typing_app_list($maestro_id) { - global $db_conn; - - $query = " - SELECT A.AppID, A.AppName, A.KoreanName, A.AppType - FROM app AS A - INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = 50 AND AA.MaestroID=?"; - $stmt = $db_conn->prepare($query); - $stmt->bind_param("i", $maestro_id); - $stmt->execute(); - $stmt->bind_result($app_id, $app_name, $korean_name, $app_type); - - $return_array = array(); - while($stmt->fetch()) { - $row_array["AppID"] = $app_id; - $row_array["AppName"] = $app_name; - $row_array["KoreanName"] = $korean_name; - $row_array["AppType"] = $app_type; - array_push($return_array, $row_array); - } - $stmt->close(); - - return $return_array; -} - ?> \ No newline at end of file diff --git a/src/web/sql/insert_maestro_player.sql b/src/web/sql/insert_maestro_player.sql index 85927e9..b7582a9 100644 --- a/src/web/sql/insert_maestro_player.sql +++ b/src/web/sql/insert_maestro_player.sql @@ -2,11 +2,11 @@ USE moty; INSERT INTO `maestro` (`MaestroID`, `Name`, `Password`, `Email`, `AccountType`, `ActivateStatus`, `AvailableActivateDateTime`, `PlayerCount`, `AcceptClausesDateTime`, `MaestroTestID`) VALUES (1, 'testplayer', '', 'test@jinaju.com', 100, 1, '2100-12-31 00:00:00', 0, '2018-05-27 17:13:35', 1), -(2, '마에스트로 체험', '', 'test@jinaju.com', 101, 1, '2100-12-31 00:00:00', 0, '2018-07-08 00:00:00', 2); +(2, '체험 마에스트로', '', 'test@jinaju.com', 101, 1, '2100-12-31 00:00:00', 0, '2018-07-08 00:00:00', 2); INSERT INTO `player` (`PlayerID`, `MaestroID`, `Name`, `EnterCode`, `AccountType`) VALUES -(1, 1, '학생 체험', '', 0), +(1, 1, '체험 학생', '', 0), (2, 2, '마에스트로', '', 0); INSERT INTO `admin` (`AdminID`, `Name`, `Password`, `Email`, `AccountType`, `ActivateStatus`) VALUES