[Client] Add game selection view to start page
Some changes in the existing code have been also made to avoid code duplication and fix some issues. Co-authored-by: Cazals Mathias <mathiascazals@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									72a5967b90
								
							
						
					
					
						commit
						6a0d7547c2
					
				| @ -53,7 +53,7 @@ body { | |||||||
| 
 | 
 | ||||||
| /* Utility classes */ | /* Utility classes */ | ||||||
| .hidden { | .hidden { | ||||||
|     display: none; |     display: none !important; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Links */ | /* Links */ | ||||||
|  | |||||||
| @ -3,6 +3,32 @@ | |||||||
|     --header-actions-height: 3em; |     --header-actions-height: 3em; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | button { | ||||||
|  |     background-color: transparent; | ||||||
|  |     border: none; | ||||||
|  |     cursor: pointer; | ||||||
|  |     padding: 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | input { | ||||||
|  |     background-color: white; | ||||||
|  |     border: none; | ||||||
|  |     border-radius: 1em; | ||||||
|  |     font-family: "Titan One", sans-serif; | ||||||
|  |     font-size: 1em; | ||||||
|  |     padding: 0.5em; | ||||||
|  |     color: black; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | input::placeholder { | ||||||
|  |     color: black; | ||||||
|  |     opacity: 0.5; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .back_btn { | ||||||
|  |     fill: #BD1E1E; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .game_begin { | .game_begin { | ||||||
|     align-items: center; |     align-items: center; | ||||||
|     border-radius: 1.5em; |     border-radius: 1.5em; | ||||||
| @ -30,19 +56,12 @@ | |||||||
|     font-family: "Spicy Rice", serif; |     font-family: "Spicy Rice", serif; | ||||||
|     font-weight: bold; |     font-weight: bold; | ||||||
|     font-size: 5em; |     font-size: 5em; | ||||||
|     margin-block-start: 0; |     margin: 0.25em; | ||||||
|     margin-block-end: 0; |  | ||||||
|     margin-top: 0.5em; |  | ||||||
|     margin-bottom: 0.5em; |  | ||||||
|     text-align: center; |     text-align: center; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .top_button { | .ingame { | ||||||
|     background-color: transparent; |     margin: 0; | ||||||
|     border: none; |  | ||||||
|     fill: white; |  | ||||||
|     cursor: pointer; |  | ||||||
|     padding: 0; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .header_actions { | .header_actions { | ||||||
| @ -59,7 +78,6 @@ | |||||||
|     border-radius: var(--button-and-dialog-border-radius); |     border-radius: var(--button-and-dialog-border-radius); | ||||||
|     cursor: pointer; |     cursor: pointer; | ||||||
|     font-family: "Titan One", sans-serif; |     font-family: "Titan One", sans-serif; | ||||||
|     font-size: 3em; |  | ||||||
|     margin-left: auto; |     margin-left: auto; | ||||||
|     margin-right: auto; |     margin-right: auto; | ||||||
|     padding-top: 0.5em; |     padding-top: 0.5em; | ||||||
| @ -75,3 +93,80 @@ | |||||||
|     transform: translate(0.1em, 0.1em); |     transform: translate(0.1em, 0.1em); | ||||||
|     box-shadow: 10px -10px 25px 0px black, -10px 10px 25px 0px black; |     box-shadow: 10px -10px 25px 0px black, -10px 10px 25px 0px black; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | .game_mode_selection { | ||||||
|  |     align-items: center; | ||||||
|  |     background-image: url("../images/start_background.png"); | ||||||
|  |     background-position: center; | ||||||
|  |     background-repeat: no-repeat; | ||||||
|  |     background-size: cover; | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: column; | ||||||
|  |     flex-wrap: nowrap; | ||||||
|  |     height: 100vh; | ||||||
|  |     justify-content: center; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .game_mode_item { | ||||||
|  |     margin: 0.5em; | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: column; | ||||||
|  |     align-content: center; | ||||||
|  |     justify-content: center; | ||||||
|  |     align-items: center; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .game_mode_item_title { | ||||||
|  |     font-family: "Titan One", sans-serif; | ||||||
|  |     font-size: 2em; | ||||||
|  |     margin: 0.25em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .game_mode_item_input_text_single_line { | ||||||
|  |     align-items: center; | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: row; | ||||||
|  |     flex-wrap: wrap; | ||||||
|  |     justify-content: center; | ||||||
|  |     margin-top: 0.5em; | ||||||
|  |     margin-bottom: 0.5em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .game_mode_items { | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: row; | ||||||
|  |     flex-wrap: wrap; | ||||||
|  |     justify-content: center; | ||||||
|  |     align-items: center; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .game_mode_choice_selector { | ||||||
|  |     background-color: black; | ||||||
|  |     border-color: white; | ||||||
|  |     border-style: solid; | ||||||
|  |     border-radius: 1.5em; | ||||||
|  |     padding: 1em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .theme_switcher { | ||||||
|  |     fill: white; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #back_button { | ||||||
|  |     position: absolute; | ||||||
|  |     left: 0; | ||||||
|  |     top: 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #create_room_button, #join_room_button, #start_solo_game_button { | ||||||
|  |     font-size: 1.5em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #game_username { | ||||||
|  |     margin: 0.5em; | ||||||
|  |     width: calc(100% - 1.5em); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #play_button { | ||||||
|  |     font-size: 3em; | ||||||
|  | } | ||||||
|  | |||||||
							
								
								
									
										33
									
								
								truthseeker/static/js/game_start_page.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								truthseeker/static/js/game_start_page.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | /** | ||||||
|  |  * Show the game selection view. | ||||||
|  |  * | ||||||
|  |  * <p> | ||||||
|  |  * The "hidden" class is added on the footer, the game_start elements and the game_mode_selection | ||||||
|  |  * elements are show. The body margin is also set to 0 by adding the ingame class. | ||||||
|  |  * </p> | ||||||
|  |  */ | ||||||
|  | function showGameModeSelection() { | ||||||
|  |     document.getElementsByTagName("body")[0].classList.add("ingame"); | ||||||
|  |     document.getElementsByTagName("footer")[0].classList.add("hidden"); | ||||||
|  |     document.getElementsByClassName("game_start")[0].classList.add("hidden"); | ||||||
|  |     document.getElementsByClassName("game_mode_selection")[0].classList.remove("hidden"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Show the game selection view. | ||||||
|  |  * | ||||||
|  |  * <p> | ||||||
|  |  * The "hidden" class is removed on the footer, the game_start elements and the game_mode_selection | ||||||
|  |  * elements are hidden. The body margin is also set to its normal value by removing the ingame | ||||||
|  |  * class. | ||||||
|  |  * </p> | ||||||
|  |  */ | ||||||
|  | function hideGameModeSelection() { | ||||||
|  |     document.getElementsByTagName("body")[0].classList.remove("ingame"); | ||||||
|  |     document.getElementsByTagName("footer")[0].classList.remove("hidden"); | ||||||
|  |     document.getElementsByClassName("game_start")[0].classList.remove("hidden"); | ||||||
|  |     document.getElementsByClassName("game_mode_selection")[0].classList.add("hidden"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | document.getElementById("play_button").addEventListener("click", showGameModeSelection); | ||||||
|  | document.getElementById("back_button").addEventListener("click", hideGameModeSelection); | ||||||
| @ -12,7 +12,7 @@ | |||||||
|         <div class="alert_dialog_background"></div> |         <div class="alert_dialog_background"></div> | ||||||
|         <div class="game_start"> |         <div class="game_start"> | ||||||
|             <div class="header_actions"> |             <div class="header_actions"> | ||||||
|                 <button class="top_button theme_switcher" aria-label="Changer de thème"> |                 <button class="theme_switcher" aria-label="Changer de thème"> | ||||||
|                     <svg class="theme_switcher_btn" xmlns="http://www.w3.org/2000/svg" height="48" width="48"> |                     <svg class="theme_switcher_btn" xmlns="http://www.w3.org/2000/svg" height="48" width="48"> | ||||||
|                         <path d="M24 34q-4.15 0-7.075-2.925T14 24q0-4.15 2.925-7.075T24 14q4.15 0 7.075 2.925T34 24q0 4.15-2.925 7.075T24 34ZM2 25.5v-3h8v3Zm36 0v-3h8v3ZM22.5 10V2h3v8Zm0 36v-8h3v8Zm-9.45-30.85L8.1 10.2l2.1-2.1 4.95 4.95ZM37.8 39.9l-4.95-4.95 2.1-2.1 4.95 4.95Zm-2.85-24.75-2.1-2.1L37.8 8.1l2.1 2.1ZM10.2 39.9l-2.1-2.1 4.95-4.95 2.1 2.1Z"/> |                         <path d="M24 34q-4.15 0-7.075-2.925T14 24q0-4.15 2.925-7.075T24 14q4.15 0 7.075 2.925T34 24q0 4.15-2.925 7.075T24 34ZM2 25.5v-3h8v3Zm36 0v-3h8v3ZM22.5 10V2h3v8Zm0 36v-8h3v8Zm-9.45-30.85L8.1 10.2l2.1-2.1 4.95 4.95ZM37.8 39.9l-4.95-4.95 2.1-2.1 4.95 4.95Zm-2.85-24.75-2.1-2.1L37.8 8.1l2.1 2.1ZM10.2 39.9l-2.1-2.1 4.95-4.95 2.1 2.1Z"/> | ||||||
|                     </svg> |                     </svg> | ||||||
| @ -23,6 +23,32 @@ | |||||||
|                 <button class="action_button" id="play_button">Jouer</button> |                 <button class="action_button" id="play_button">Jouer</button> | ||||||
|             </div> |             </div> | ||||||
|         </div> |         </div> | ||||||
|  |         <div class="game_mode_selection hidden"> | ||||||
|  |             <button id="back_button" aria-label="Retourner à la page précédente"> | ||||||
|  |                 <svg class="back_btn" xmlns="http://www.w3.org/2000/svg" height="48" width="48"> | ||||||
|  |                     <path d="m23.15 36.95-17.3-11.1Q4.7 25.25 4.7 24t1.15-1.9L23.15 11q1.15-.7 2.35-.075 1.2.625 1.2 2.025v8.75h15.8q.95 0 1.625.675T44.8 24q0 .95-.675 1.6-.675.65-1.625.65H26.7V35q0 1.45-1.2 2.075-1.2.625-2.35-.125Z"/> | ||||||
|  |                 </svg> | ||||||
|  |             </button> | ||||||
|  |             <h1 class="game_title">Thruth Inquiry</h1> | ||||||
|  |             <div class="game_mode_choice_selector"> | ||||||
|  |                 <input type="text" id="game_username" placeholder="Entrez un pseudo" value="" required="required" maxlength="20"> | ||||||
|  |                 <div class="game_mode_items"> | ||||||
|  |                     <div class="game_mode_item"> | ||||||
|  |                         <h2 class="game_mode_item_title">Mode Solo</h2> | ||||||
|  |                         <button class="action_button" id="start_solo_game_button">Jouer</button> | ||||||
|  |                     </div> | ||||||
|  |                     <div class="game_mode_item"> | ||||||
|  |                         <h2 class="game_mode_item_title">Mode Multi</h2> | ||||||
|  |                         <button class="action_button" id="create_room_button">Créer un salon</button> | ||||||
|  |                         <div class="game_mode_item_input_text_single_line"> | ||||||
|  |                             <h3 class="game_mode_item_title">Code :</h3> | ||||||
|  |                             <input type="text" id="game_room_code" placeholder="" value="" required="required"> | ||||||
|  |                         </div> | ||||||
|  |                         <button class="action_button" id="join_room_button">Rejoindre</button> | ||||||
|  |                     </div> | ||||||
|  |                 </div> | ||||||
|  |             </div> | ||||||
|  |         </div> | ||||||
|         <div class="unsupported_browser"> |         <div class="unsupported_browser"> | ||||||
|             <div id="unsupported_browser_dialog" class="alert_dialog"> |             <div id="unsupported_browser_dialog" class="alert_dialog"> | ||||||
|                 <h3 class="alert_dialog_title">Navigateur non supporté</h3> |                 <h3 class="alert_dialog_title">Navigateur non supporté</h3> | ||||||
| @ -46,5 +72,6 @@ | |||||||
|             </div> |             </div> | ||||||
|         </footer> |         </footer> | ||||||
|         <script src="/static/js/game_common.js"></script> |         <script src="/static/js/game_common.js"></script> | ||||||
|  |         <script src="/static/js/game_start_page.js"></script> | ||||||
|     </body> |     </body> | ||||||
| </html> | </html> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user