diff --git a/src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx b/src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx index 48e0e9162d..9644bd177a 100644 --- a/src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx +++ b/src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx @@ -114,7 +114,7 @@ const getStaffNavlinkInfo = ({ hiddenInBreakpoints: ['xs', 'sm', 'md'] }, { - to: `/courses/${courseId}/storysimulator`, + to: `/courses/${courseId}/gamesimulator`, icon: IconNames.CROWN, text: 'Game Simulator', disabled: !isStaffOrAdmin, diff --git a/src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.tsx b/src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.tsx index f4c464f7fc..1256b291a7 100644 --- a/src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.tsx +++ b/src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.tsx @@ -11,7 +11,7 @@ jest.mock('react-redux', () => ({ const useSelectorMock = useSelector as jest.Mock; const assessmentTypes = ['Missions', 'Quests', 'Paths', 'Contests', 'Others']; -const staffRoutes = ['grading', 'groundcontrol', 'sourcereel', 'storysimulator', 'dashboard']; +const staffRoutes = ['grading', 'groundcontrol', 'sourcereel', 'gamesimulator', 'dashboard']; const adminRoutes = ['adminpanel']; const courseId = 0; const createCoursePath = (path: string) => `/courses/${courseId}/${path}`; @@ -43,7 +43,7 @@ const mockProps = { }; const element = ; -test('MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, Grading and AdminPanel NavLinks do NOT render for Role.Student', () => { +test('MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard, Grading and AdminPanel NavLinks do NOT render for Role.Student', () => { useSelectorMock.mockReturnValue({ role: Role.Student, courseId @@ -57,7 +57,7 @@ test('MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, Grad validateAdminPaths(tree, false); }); -test('MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard and Grading NavLinks render for Role.Staff', () => { +test('MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard and Grading NavLinks render for Role.Staff', () => { useSelectorMock.mockReturnValueOnce({ role: Role.Staff, courseId @@ -71,7 +71,7 @@ test('MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard and G validateAdminPaths(tree, false); }); -test('MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, Grading and AdminPanel NavLinks render for Role.Admin', () => { +test('MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard, Grading and AdminPanel NavLinks render for Role.Admin', () => { useSelectorMock.mockReturnValueOnce({ role: Role.Admin, courseId diff --git a/src/commons/navigationBar/subcomponents/__tests__/__snapshots__/AcademyNavigationBar.tsx.snap b/src/commons/navigationBar/subcomponents/__tests__/__snapshots__/AcademyNavigationBar.tsx.snap index 7f2e757576..85b0c57c33 100644 --- a/src/commons/navigationBar/subcomponents/__tests__/__snapshots__/AcademyNavigationBar.tsx.snap +++ b/src/commons/navigationBar/subcomponents/__tests__/__snapshots__/AcademyNavigationBar.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard and Grading NavLinks render for Role.Staff 1`] = ` +exports[`MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard and Grading NavLinks render for Role.Staff 1`] = ` @@ -182,7 +182,7 @@ exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard an `; -exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, Grading and AdminPanel NavLinks do NOT render for Role.Student 1`] = ` +exports[`MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard, Grading and AdminPanel NavLinks do NOT render for Role.Student 1`] = ` @@ -346,7 +346,7 @@ exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, G `; -exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, Grading and AdminPanel NavLinks render for Role.Admin 1`] = ` +exports[`MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard, Grading and AdminPanel NavLinks render for Role.Admin 1`] = ` @@ -528,7 +528,7 @@ exports[`MissionControl, GroundControl, Sourcereel, StorySimulator, Dashboard, G ; saveManager: GameSaveManager; - setStorySimState: (value: React.SetStateAction) => void; + setGameSimState: (value: React.SetStateAction) => void; soundManager: GameSoundManager; ssChapterSimFilenames: string[]; userStateManager: GameUserStateManager; @@ -74,7 +74,7 @@ export default class SourceAcademyGame extends Phaser.Game { roomCode: '', roomPreviewMapping: new Map(), saveManager: new GameSaveManager(), - setStorySimState: Constants.nullFunction, + setGameSimState: Constants.nullFunction, soundManager: new GameSoundManager(), ssChapterSimFilenames: [], userStateManager: new GameUserStateManager() @@ -107,8 +107,8 @@ export default class SourceAcademyGame extends Phaser.Game { this.global.goals = goals; } - public setStorySimStateSetter(setStorySimState: (value: React.SetStateAction) => void) { - this.setStorySimState = setStorySimState; + public setGameSimStateSetter(setGameSimState: (value: React.SetStateAction) => void) { + this.setGameSimState = setGameSimState; } public setRoomPreviewMapping(mapping: Map) { @@ -123,8 +123,8 @@ export default class SourceAcademyGame extends Phaser.Game { this.global.roomCode = await getRoomPreviewCode(); } - public setStorySimState(state: StorySimState) { - this.global.setStorySimState(state); + public setGameSimState(state: GameSimState) { + this.global.setGameSimState(state); } public setCurrentSceneRef(scene: Phaser.Scene) { diff --git a/src/features/game/escape/GameEscapeManager.ts b/src/features/game/escape/GameEscapeManager.ts index 2ce5a18014..ca5ddcece7 100644 --- a/src/features/game/escape/GameEscapeManager.ts +++ b/src/features/game/escape/GameEscapeManager.ts @@ -155,7 +155,7 @@ class GameEscapeManager implements IGameUI { callback: () => { this.cleanUp(); if (SourceAcademyGame.getInstance().isGameType(GameType.Simulator)) { - this.scene.scene.start('StorySimulatorMenu'); + this.scene.scene.start('GameSimulatorMenu'); } else { this.scene.scene.start('MainMenu'); } diff --git a/src/features/game/save/GameSaveManager.ts b/src/features/game/save/GameSaveManager.ts index d957d68455..8932827064 100644 --- a/src/features/game/save/GameSaveManager.ts +++ b/src/features/game/save/GameSaveManager.ts @@ -32,7 +32,7 @@ export default class GameSaveManager { * Updates the save manager with chapter number and checkpoint number * if player has chosen a chapter/checkpoint to play with. * - * Chapter number and checkpoint number can be -1 if inside the Story Simulator, + * Chapter number and checkpoint number can be -1 if inside the Game Simulator, * * @param chapterNum chapter number * @param checkpointNum checkpoint number @@ -56,7 +56,7 @@ export default class GameSaveManager { * informtion from GameManager, GameStateManager, or other in-game managers, * and converts them into JSON format to be saved to backend. * - * Only called when playing the Game (not Story Simulator), because Story Simulator + * Only called when playing the Game (not Game Simulator), because Game Simulator * shouldn't save game state to backend. */ public async saveGame() { diff --git a/src/features/game/scenes/checkpointTransition/CheckpointTransition.ts b/src/features/game/scenes/checkpointTransition/CheckpointTransition.ts index 13d63988f7..fd15749d9c 100644 --- a/src/features/game/scenes/checkpointTransition/CheckpointTransition.ts +++ b/src/features/game/scenes/checkpointTransition/CheckpointTransition.ts @@ -13,7 +13,7 @@ import CheckpointConstants, { transitionTextStyle } from './CheckpointTransition * Internally, we use this scene to fully load the next checkpoint, * before finally loading the next scene. * - * In story simulator, the next checkpoint is loaded based on the + * In Game simulator, the next checkpoint is loaded based on the * chapterSimStack using the callGameManagerForSim function. * * We cannot load these informations at the start of GameManager as diff --git a/src/features/game/utils/TxtLoaderUtils.ts b/src/features/game/utils/TxtLoaderUtils.ts index 0dcb1e55af..5a06de5663 100644 --- a/src/features/game/utils/TxtLoaderUtils.ts +++ b/src/features/game/utils/TxtLoaderUtils.ts @@ -51,7 +51,7 @@ export async function callGameManagerForSim() { const scene = SourceAcademyGame.getInstance().getCurrentSceneRef(); const checkpointFilenames = SourceAcademyGame.getInstance().getSSChapterSimFilenames(); if (!checkpointFilenames.length) { - scene.scene.start('StorySimulatorMenu'); + scene.scene.start('GameSimulatorMenu'); return; } const filename = checkpointFilenames.pop() as string; diff --git a/src/features/storySimulator/StorySimulatorRequest.ts b/src/features/gameSimulator/GameSimulatorRequest.ts similarity index 100% rename from src/features/storySimulator/StorySimulatorRequest.ts rename to src/features/gameSimulator/GameSimulatorRequest.ts diff --git a/src/features/storySimulator/StorySimulatorService.ts b/src/features/gameSimulator/GameSimulatorService.ts similarity index 97% rename from src/features/storySimulator/StorySimulatorService.ts rename to src/features/gameSimulator/GameSimulatorService.ts index ec6982b585..a8cafb305c 100644 --- a/src/features/storySimulator/StorySimulatorService.ts +++ b/src/features/gameSimulator/GameSimulatorService.ts @@ -1,7 +1,7 @@ import _ from 'lodash'; -import { sendAdminStoryRequest, sendAssetRequest, sendStoryRequest } from './StorySimulatorRequest'; -import { ChapterDetail } from './StorySimulatorTypes'; +import { sendAdminStoryRequest, sendAssetRequest, sendStoryRequest } from './GameSimulatorRequest'; +import { ChapterDetail } from './GameSimulatorTypes'; /** * List of all folders to fetch S3 assets from diff --git a/src/features/storySimulator/StorySimulatorTypes.ts b/src/features/gameSimulator/GameSimulatorTypes.ts similarity index 92% rename from src/features/storySimulator/StorySimulatorTypes.ts rename to src/features/gameSimulator/GameSimulatorTypes.ts index 77d18e6bac..13de83e858 100644 --- a/src/features/storySimulator/StorySimulatorTypes.ts +++ b/src/features/gameSimulator/GameSimulatorTypes.ts @@ -1,4 +1,4 @@ -export enum StorySimState { +export enum GameSimState { Default = 'Default', ObjectPlacement = 'ObjectPlacement', AssetUploader = 'AssetUploader', diff --git a/src/features/storySimulator/assets/ImageAssets.ts b/src/features/gameSimulator/assets/ImageAssets.ts similarity index 98% rename from src/features/storySimulator/assets/ImageAssets.ts rename to src/features/gameSimulator/assets/ImageAssets.ts index 661d67577e..fcadb05256 100644 --- a/src/features/storySimulator/assets/ImageAssets.ts +++ b/src/features/gameSimulator/assets/ImageAssets.ts @@ -1,7 +1,7 @@ import { AssetMap, AssetType, ImageAsset } from 'src/features/game/assets/AssetsTypes'; const SSImageAssets: AssetMap = { - storySimBg: { + gameSimBg: { type: AssetType.Image, key: 'student-room', path: '/locations/deathCube_ext/shields-down.png' diff --git a/src/features/storySimulator/background/SSBackgroundManager.ts b/src/features/gameSimulator/background/SSBackgroundManager.ts similarity index 96% rename from src/features/storySimulator/background/SSBackgroundManager.ts rename to src/features/gameSimulator/background/SSBackgroundManager.ts index d977d6bd49..8210f70ffb 100644 --- a/src/features/storySimulator/background/SSBackgroundManager.ts +++ b/src/features/gameSimulator/background/SSBackgroundManager.ts @@ -7,7 +7,7 @@ import { loadImage } from '../../game/utils/LoaderUtils'; import ObjectPlacement from '../scenes/ObjectPlacement/ObjectPlacement'; /** - * This manager manages the background for Story Simulator's Object Placement scene + * This manager manages the background for Game Simulator's Object Placement scene * It handles (1) storing of information on the chosen background (2) Rendering background */ export default class SSBackgroundManager { diff --git a/src/features/storySimulator/boundingBoxes/SSBBoxManager.ts b/src/features/gameSimulator/boundingBoxes/SSBBoxManager.ts similarity index 98% rename from src/features/storySimulator/boundingBoxes/SSBBoxManager.ts rename to src/features/gameSimulator/boundingBoxes/SSBBoxManager.ts index fe14608aa5..7c9ab085dd 100644 --- a/src/features/storySimulator/boundingBoxes/SSBBoxManager.ts +++ b/src/features/gameSimulator/boundingBoxes/SSBBoxManager.ts @@ -11,7 +11,7 @@ import ObjectPlacement from '../scenes/ObjectPlacement/ObjectPlacement'; import { SSBBoxDetail } from './SSBBoxManagerTypes'; /** - * This manager manages the bounding boxes for Story Simulator's Object Placement scene + * This manager manages the bounding boxes for Game Simulator's Object Placement scene * * It handles: * (1) Storing of information on bounding boxes diff --git a/src/features/storySimulator/boundingBoxes/SSBBoxManagerTypes.ts b/src/features/gameSimulator/boundingBoxes/SSBBoxManagerTypes.ts similarity index 100% rename from src/features/storySimulator/boundingBoxes/SSBBoxManagerTypes.ts rename to src/features/gameSimulator/boundingBoxes/SSBBoxManagerTypes.ts diff --git a/src/features/storySimulator/cursorMode/SSCursorMode.ts b/src/features/gameSimulator/cursorMode/SSCursorMode.ts similarity index 100% rename from src/features/storySimulator/cursorMode/SSCursorMode.ts rename to src/features/gameSimulator/cursorMode/SSCursorMode.ts diff --git a/src/features/storySimulator/cursorMode/SSCursorModeConstants.ts b/src/features/gameSimulator/cursorMode/SSCursorModeConstants.ts similarity index 100% rename from src/features/storySimulator/cursorMode/SSCursorModeConstants.ts rename to src/features/gameSimulator/cursorMode/SSCursorModeConstants.ts diff --git a/src/features/storySimulator/cursorMode/SSCursorModeTypes.ts b/src/features/gameSimulator/cursorMode/SSCursorModeTypes.ts similarity index 100% rename from src/features/storySimulator/cursorMode/SSCursorModeTypes.ts rename to src/features/gameSimulator/cursorMode/SSCursorModeTypes.ts diff --git a/src/features/storySimulator/logger/SSLogConstants.ts b/src/features/gameSimulator/logger/SSLogConstants.ts similarity index 100% rename from src/features/storySimulator/logger/SSLogConstants.ts rename to src/features/gameSimulator/logger/SSLogConstants.ts diff --git a/src/features/storySimulator/logger/SSLogManager.ts b/src/features/gameSimulator/logger/SSLogManager.ts similarity index 100% rename from src/features/storySimulator/logger/SSLogManager.ts rename to src/features/gameSimulator/logger/SSLogManager.ts diff --git a/src/features/storySimulator/logger/SSLogManagerHelper.ts b/src/features/gameSimulator/logger/SSLogManagerHelper.ts similarity index 100% rename from src/features/storySimulator/logger/SSLogManagerHelper.ts rename to src/features/gameSimulator/logger/SSLogManagerHelper.ts diff --git a/src/features/storySimulator/logger/SSLogManagerTypes.ts b/src/features/gameSimulator/logger/SSLogManagerTypes.ts similarity index 100% rename from src/features/storySimulator/logger/SSLogManagerTypes.ts rename to src/features/gameSimulator/logger/SSLogManagerTypes.ts diff --git a/src/features/storySimulator/objects/SSObjectManager.ts b/src/features/gameSimulator/objects/SSObjectManager.ts similarity index 98% rename from src/features/storySimulator/objects/SSObjectManager.ts rename to src/features/gameSimulator/objects/SSObjectManager.ts index c279b8b288..f7093f4764 100644 --- a/src/features/storySimulator/objects/SSObjectManager.ts +++ b/src/features/gameSimulator/objects/SSObjectManager.ts @@ -11,7 +11,7 @@ import ObjectPlacement from '../scenes/ObjectPlacement/ObjectPlacement'; import { SSObjectDetail } from './SSObjectManagerTypes'; /** - * This manager manages the object (image assets) for Story Simulator's Object Placement scene + * This manager manages the object (image assets) for Game Simulator's Object Placement scene * * It handles: * (1) Storing of information on image assets used diff --git a/src/features/storySimulator/objects/SSObjectManagerTypes.ts b/src/features/gameSimulator/objects/SSObjectManagerTypes.ts similarity index 100% rename from src/features/storySimulator/objects/SSObjectManagerTypes.ts rename to src/features/gameSimulator/objects/SSObjectManagerTypes.ts diff --git a/src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacement.ts b/src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacement.ts similarity index 97% rename from src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacement.ts rename to src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacement.ts index 7e92ea860c..5acbfdc3e6 100644 --- a/src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacement.ts +++ b/src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacement.ts @@ -12,9 +12,9 @@ import SSBackgroundManager from '../../background/SSBackgroundManager'; import SSBBoxManager from '../../boundingBoxes/SSBBoxManager'; import SSCursorMode from '../../cursorMode/SSCursorMode'; import { CursorMode } from '../../cursorMode/SSCursorModeTypes'; +import { GameSimState } from '../../GameSimulatorTypes'; import SSLogManager from '../../logger/SSLogManager'; import SSObjectManager from '../../objects/SSObjectManager'; -import { StorySimState } from '../../StorySimulatorTypes'; import SSTransformManager from '../../transform/SSTransformManager'; import ObjPlacementConstants from './ObjectPlacementConstants'; @@ -95,8 +95,8 @@ export default class ObjectPlacement extends Phaser.Scene { const uiContainer = new Phaser.GameObjects.Container(this, 0, 0); const backButton = new CommonBackButton(this, () => { this.cleanUp(); - SourceAcademyGame.getInstance().setStorySimState(StorySimState.Default); - this.scene.start('StorySimulatorMenu'); + SourceAcademyGame.getInstance().setGameSimState(GameSimState.Default); + this.scene.start('GameSimulatorMenu'); }); this.cursorModes = new SSCursorMode( @@ -117,7 +117,7 @@ export default class ObjectPlacement extends Phaser.Scene { this, screenCenter.x, screenCenter.y, - SSImageAssets.storySimBg.key + SSImageAssets.gameSimBg.key ); backgroundImg.setDisplaySize(screenSize.x, screenSize.y); diff --git a/src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacementConstants.ts b/src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacementConstants.ts similarity index 100% rename from src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacementConstants.ts rename to src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacementConstants.ts diff --git a/src/features/storySimulator/scenes/mainMenu/MainMenu.ts b/src/features/gameSimulator/scenes/mainMenu/MainMenu.ts similarity index 88% rename from src/features/storySimulator/scenes/mainMenu/MainMenu.ts rename to src/features/gameSimulator/scenes/mainMenu/MainMenu.ts index 6f4996975b..a82ab84282 100644 --- a/src/features/storySimulator/scenes/mainMenu/MainMenu.ts +++ b/src/features/gameSimulator/scenes/mainMenu/MainMenu.ts @@ -12,20 +12,20 @@ import { mandatory, toS3Path } from 'src/features/game/utils/GameUtils'; import { calcTableFormatPos } from 'src/features/game/utils/StyleUtils'; import SSImageAssets from '../../assets/ImageAssets'; -import { StorySimState } from '../../StorySimulatorTypes'; +import { GameSimState } from '../../GameSimulatorTypes'; import mainMenuConstants, { mainMenuOptStyle } from './MainMenuConstants'; /** - * Entry point for story simulator. + * Entry point for Game simulator. * - * User can access different story simulator + * User can access different Game simulator * functionalities from here. */ class MainMenu extends Phaser.Scene { private layerManager?: GameLayerManager; constructor() { - super('StorySimulatorMenu'); + super('GameSimulatorMenu'); } public preload() { @@ -47,7 +47,7 @@ class MainMenu extends Phaser.Scene { public async create() { if (SourceAcademyGame.getInstance().getAccountInfo().role === 'student') { - console.log('Students cannot use story sim'); + console.log('Students cannot use Game sim'); return; } this.renderBackground(); @@ -84,7 +84,7 @@ class MainMenu extends Phaser.Scene { { text: 'Object Placement', callback: () => { - SourceAcademyGame.getInstance().setStorySimState(StorySimState.ObjectPlacement); + SourceAcademyGame.getInstance().setGameSimState(GameSimState.ObjectPlacement); this.getLayerManager().clearAllLayers(); this.scene.start('ObjectPlacement'); } @@ -92,19 +92,19 @@ class MainMenu extends Phaser.Scene { { text: 'Checkpoint Simulator', callback: () => { - SourceAcademyGame.getInstance().setStorySimState(StorySimState.CheckpointSim); + SourceAcademyGame.getInstance().setGameSimState(GameSimState.CheckpointSim); } }, { text: 'Asset Uploader', callback: () => { - SourceAcademyGame.getInstance().setStorySimState(StorySimState.AssetUploader); + SourceAcademyGame.getInstance().setGameSimState(GameSimState.AssetUploader); } }, { text: 'Chapter Simulator', callback: () => { - SourceAcademyGame.getInstance().setStorySimState(StorySimState.ChapterSim); + SourceAcademyGame.getInstance().setGameSimState(GameSimState.ChapterSim); } } ]; @@ -149,7 +149,7 @@ class MainMenu extends Phaser.Scene { this, screenCenter.x, screenCenter.y, - SSImageAssets.storySimBg.key + SSImageAssets.gameSimBg.key ); backgroundImg.setDisplaySize(screenSize.x, screenSize.y); const backgroundUnderlay = new Phaser.GameObjects.Image( diff --git a/src/features/storySimulator/scenes/mainMenu/MainMenuConstants.ts b/src/features/gameSimulator/scenes/mainMenu/MainMenuConstants.ts similarity index 100% rename from src/features/storySimulator/scenes/mainMenu/MainMenuConstants.ts rename to src/features/gameSimulator/scenes/mainMenu/MainMenuConstants.ts diff --git a/src/features/storySimulator/transform/SSTransformManager.ts b/src/features/gameSimulator/transform/SSTransformManager.ts similarity index 100% rename from src/features/storySimulator/transform/SSTransformManager.ts rename to src/features/gameSimulator/transform/SSTransformManager.ts diff --git a/src/features/storySimulator/transform/SSTransformManagerConstants.ts b/src/features/gameSimulator/transform/SSTransformManagerConstants.ts similarity index 100% rename from src/features/storySimulator/transform/SSTransformManagerConstants.ts rename to src/features/gameSimulator/transform/SSTransformManagerConstants.ts diff --git a/src/pages/academy/Academy.tsx b/src/pages/academy/Academy.tsx index 1602aa37ae..b15efdfb80 100644 --- a/src/pages/academy/Academy.tsx +++ b/src/pages/academy/Academy.tsx @@ -22,11 +22,11 @@ import Sourcecast from '../sourcecast/Sourcecast'; import AdminPanel from './adminPanel/AdminPanel'; import Dashboard from './dashboard/Dashboard'; import Game from './game/Game'; +import GameSimulator from './gameSimulator/GameSimulator'; import Grading from './grading/Grading'; import GroundControl from './groundControl/GroundControlContainer'; import NotiPreference from './notiPreference/NotiPreference'; import Sourcereel from './sourcereel/Sourcereel'; -import StorySimulator from './storySimulator/StorySimulator'; const Academy: React.FC<{}> = () => { const dispatch = useDispatch(); @@ -42,7 +42,7 @@ const Academy: React.FC<{}> = () => { } key={0} />, } key={1} />, } key={2} />, - } key={3} />, + } key={3} />, } key={4} /> ] : null; diff --git a/src/pages/academy/gameSimulator/GameSimulator.tsx b/src/pages/academy/gameSimulator/GameSimulator.tsx new file mode 100644 index 0000000000..06d97aaada --- /dev/null +++ b/src/pages/academy/gameSimulator/GameSimulator.tsx @@ -0,0 +1,67 @@ +import React from 'react'; +import { useTypedSelector } from 'src/commons/utils/Hooks'; +import SourceAcademyGame, { AccountInfo } from 'src/features/game/SourceAcademyGame'; +import { GameSimState } from 'src/features/gameSimulator/GameSimulatorTypes'; + +import GameSimulatorAssetFileUploader from './subcomponents/GameSimulatorAssetFileUploader'; +import GameSimulatorAssetSelection from './subcomponents/GameSimulatorAssetSelection'; +import GameSimulatorChapterSim from './subcomponents/GameSimulatorChapterSim'; +import GameSimulatorCheckpointSim from './subcomponents/GameSimulatorCheckpointSim'; +import { createGameSimulatorGame } from './subcomponents/GameSimulatorGame'; + +/** + * Game simulator main page + * + * Displays the following elements: + * (1) Game Simulator phaser canvas + * (2) Game Simulator control panel + * + * Game Simulator control panel's content can be altered using + * `setGameSimState` function. This function is passed into story + * simulator phaser game, so that the GameSimulatorMainMenu buttons + * are able to control what is shown on the Game Simulator panel. + */ +function GameSimulator() { + const session = useTypedSelector(state => state.session); + const [gameSimState, setGameSimState] = React.useState(GameSimState.Default); + + React.useEffect(() => { + createGameSimulatorGame().setGameSimStateSetter(setGameSimState); + }, []); + + React.useEffect(() => { + SourceAcademyGame.getInstance().setAccountInfo({ + accessToken: session.accessToken, + refreshToken: session.refreshToken, + role: session.role, + name: session.name + } as AccountInfo); + }, [session]); + + return ( +
+
+
+ {gameSimState === GameSimState.Default &&

Welcome to Game simulator!

} + {gameSimState === GameSimState.CheckpointSim && } + {gameSimState === GameSimState.ObjectPlacement && ( + <> +

Asset Selection

+ + + )} + {gameSimState === GameSimState.AssetUploader && ( + <> +

Asset uploader

+ +

Asset Viewer

+ + + )} + {gameSimState === GameSimState.ChapterSim && } +
+
+ ); +} + +export default GameSimulator; diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetFileUploader.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetFileUploader.tsx similarity index 94% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetFileUploader.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetFileUploader.tsx index eccf1b9111..8368b97d44 100644 --- a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetFileUploader.tsx +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetFileUploader.tsx @@ -1,17 +1,14 @@ import { Button, InputGroup, Menu, MenuItem, Position } from '@blueprintjs/core'; import { Popover2 } from '@blueprintjs/popover2'; import React from 'react'; -import { - s3AssetFolders, - uploadAssetsToS3 -} from 'src/features/storySimulator/StorySimulatorService'; +import { s3AssetFolders, uploadAssetsToS3 } from 'src/features/gameSimulator/GameSimulatorService'; const specifyFolderText = 'Specify own folder...'; const folderOverwritePlaceholder = "Or specify your own, e.g. 'locations/hallway'"; /** * This is component allows storywriters to upload any assets into to - * specific folders into Story Sim's Asset Uploader + * specific folders into Game Sim's Asset Uploader */ const AssetFileUploader = () => { const [fileList, setFileList] = React.useState(); diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetSelection.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetSelection.tsx similarity index 82% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetSelection.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetSelection.tsx index a1d8840e3e..7a001ec3d1 100644 --- a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetSelection.tsx +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetSelection.tsx @@ -6,10 +6,10 @@ import { deleteS3File, fetchAssetPaths, s3AssetFolders -} from 'src/features/storySimulator/StorySimulatorService'; +} from 'src/features/gameSimulator/GameSimulatorService'; -import { assetPathsToTree, treeMap } from './StorySimulatorAssetSelectionHelper'; -import StorySimulatorAssetViewer from './StorySimulatorAssetViewer'; +import { assetPathsToTree, treeMap } from './GameSimulatorAssetSelectionHelper'; +import GameSimulatorAssetViewer from './GameSimulatorAssetViewer'; type TreeState = { nodes: TreeNodeInfo[]; @@ -19,9 +19,9 @@ type TreeState = { * This component provides a preview of all the S3 asset files. * * When a image is selected, the filename of the image is stored in session storage, - * so Story Simulator's Object Placement can read the filename and load the image. + * so Game Simulator's Object Placement can read the filename and load the image. */ -const StorySimulatorAssetSelection = () => { +const GameSimulatorAssetSelection = () => { const { value: assetPaths } = useRequest(fetchAssetPaths, []); const [currentAsset, setCurrentAsset] = React.useState(''); @@ -45,7 +45,7 @@ const StorySimulatorAssetSelection = () => { return ( <> - + ); @@ -75,4 +75,4 @@ const deleteFile = (filePath: string) => async () => { alert(confirm ? await deleteS3File(filePath) : 'Whew'); }; -export default StorySimulatorAssetSelection; +export default GameSimulatorAssetSelection; diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetSelectionHelper.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetSelectionHelper.tsx similarity index 100% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetSelectionHelper.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetSelectionHelper.tsx diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetViewer.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetViewer.tsx similarity index 100% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorAssetViewer.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorAssetViewer.tsx diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterEditor.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterEditor.tsx similarity index 96% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterEditor.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterEditor.tsx index 63cd157f10..fb53c28a09 100644 --- a/src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterEditor.tsx +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterEditor.tsx @@ -10,10 +10,10 @@ import { callGameManagerForSim } from 'src/features/game/utils/TxtLoaderUtils'; import { deleteChapterRequest, updateChapterRequest -} from 'src/features/storySimulator/StorySimulatorService'; -import { ChapterDetail } from 'src/features/storySimulator/StorySimulatorTypes'; +} from 'src/features/gameSimulator/GameSimulatorService'; +import { ChapterDetail } from 'src/features/gameSimulator/GameSimulatorTypes'; -import { createChapterIndex, inAYear } from './StorySimulatorChapterSim'; +import { createChapterIndex, inAYear } from './GameSimulatorChapterSim'; type ChapterSimProps = { chapterDetail: ChapterDetail; diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterSim.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterSim.tsx similarity index 84% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterSim.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterSim.tsx index 879f15d478..a744496f95 100644 --- a/src/pages/academy/storySimulator/subcomponents/StorySimulatorChapterSim.tsx +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorChapterSim.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { useRequest } from 'src/commons/utils/Hooks'; -import { fetchChapters, fetchTextAssets } from 'src/features/storySimulator/StorySimulatorService'; -import { ChapterDetail } from 'src/features/storySimulator/StorySimulatorTypes'; +import { fetchChapters, fetchTextAssets } from 'src/features/gameSimulator/GameSimulatorService'; +import { ChapterDetail } from 'src/features/gameSimulator/GameSimulatorTypes'; -import StorySimulatorChapterEditor from './StorySimulatorChapterEditor'; +import GameSimulatorChapterEditor from './GameSimulatorChapterEditor'; export const inAYear = (date: Date) => { date.setFullYear(date.getFullYear() + 1); @@ -47,7 +47,7 @@ const ChapterSim = React.memo(() => {
- diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorCheckpointSim.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorCheckpointSim.tsx similarity index 82% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorCheckpointSim.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorCheckpointSim.tsx index 94bc9403ab..efd1defef9 100644 --- a/src/pages/academy/storySimulator/subcomponents/StorySimulatorCheckpointSim.tsx +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorCheckpointSim.tsx @@ -1,11 +1,11 @@ import { Button } from '@blueprintjs/core'; import { useRequest } from 'src/commons/utils/Hooks'; import SourceAcademyGame from 'src/features/game/SourceAcademyGame'; -import MainMenu from 'src/features/storySimulator/scenes/mainMenu/MainMenu'; -import mainMenuConstants from 'src/features/storySimulator/scenes/mainMenu/MainMenuConstants'; -import { fetchTextAssets } from 'src/features/storySimulator/StorySimulatorService'; +import { fetchTextAssets } from 'src/features/gameSimulator/GameSimulatorService'; +import MainMenu from 'src/features/gameSimulator/scenes/mainMenu/MainMenu'; +import mainMenuConstants from 'src/features/gameSimulator/scenes/mainMenu/MainMenuConstants'; -import CheckpointTxtLoader from './StorySimulatorCheckpointTxtLoader'; +import CheckpointTxtLoader from './GameSimulatorCheckpointTxtLoader'; /** * This component helps one simulate a checkpoint by diff --git a/src/pages/academy/storySimulator/subcomponents/StorySimulatorCheckpointTxtLoader.tsx b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorCheckpointTxtLoader.tsx similarity index 100% rename from src/pages/academy/storySimulator/subcomponents/StorySimulatorCheckpointTxtLoader.tsx rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorCheckpointTxtLoader.tsx diff --git a/src/pages/academy/storySimulator/subcomponents/storySimulatorGame.ts b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorGame.ts similarity index 75% rename from src/pages/academy/storySimulator/subcomponents/storySimulatorGame.ts rename to src/pages/academy/gameSimulator/subcomponents/GameSimulatorGame.ts index 87cc330e81..0cbf1a5876 100644 --- a/src/pages/academy/storySimulator/subcomponents/storySimulatorGame.ts +++ b/src/pages/academy/gameSimulator/subcomponents/GameSimulatorGame.ts @@ -3,8 +3,8 @@ import { screenSize } from 'src/features/game/commons/CommonConstants'; import CheckpointTransition from 'src/features/game/scenes/checkpointTransition/CheckpointTransition'; import GameManager from 'src/features/game/scenes/gameManager/GameManager'; import SourceAcademyGame, { GameType } from 'src/features/game/SourceAcademyGame'; -import MainMenu from 'src/features/storySimulator/scenes/mainMenu/MainMenu'; -import ObjectPlacement from 'src/features/storySimulator/scenes/ObjectPlacement/ObjectPlacement'; +import MainMenu from 'src/features/gameSimulator/scenes/mainMenu/MainMenu'; +import ObjectPlacement from 'src/features/gameSimulator/scenes/ObjectPlacement/ObjectPlacement'; const config = { debug: true, @@ -23,9 +23,9 @@ const config = { } }; -export const createStorySimulatorGame = () => { +export const createGameSimulatorGame = () => { const game = new SourceAcademyGame(config, GameType.Simulator); - game.scene.add('StorySimulatorMenu', MainMenu, true); + game.scene.add('GameSimulatorMenu', MainMenu, true); game.scene.add('ObjectPlacement', ObjectPlacement); game.scene.add('GameManager', GameManager); game.scene.add('CheckpointTransition', CheckpointTransition); diff --git a/src/pages/academy/storySimulator/StorySimulator.tsx b/src/pages/academy/storySimulator/StorySimulator.tsx deleted file mode 100644 index f3084fbd54..0000000000 --- a/src/pages/academy/storySimulator/StorySimulator.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; -import { useTypedSelector } from 'src/commons/utils/Hooks'; -import SourceAcademyGame, { AccountInfo } from 'src/features/game/SourceAcademyGame'; -import { StorySimState } from 'src/features/storySimulator/StorySimulatorTypes'; - -import StorySimulatorAssetFileUploader from './subcomponents/StorySimulatorAssetFileUploader'; -import StorySimulatorAssetSelection from './subcomponents/StorySimulatorAssetSelection'; -import StorySimulatorChapterSim from './subcomponents/StorySimulatorChapterSim'; -import StorySimulatorCheckpointSim from './subcomponents/StorySimulatorCheckpointSim'; -import { createStorySimulatorGame } from './subcomponents/storySimulatorGame'; - -/** - * Story simulator main page - * - * Displays the following elements: - * (1) Story Simulator phaser canvas - * (2) Story Simulator control panel - * - * Story Simulator control panel's content can be altered using - * `setStorySimState` function. This function is passed into story - * simulator phaser game, so that the StorySimulatorMainMenu buttons - * are able to control what is shown on the Story Simulator panel. - */ -function StorySimulator() { - const session = useTypedSelector(state => state.session); - const [storySimState, setStorySimState] = React.useState(StorySimState.Default); - - React.useEffect(() => { - createStorySimulatorGame().setStorySimStateSetter(setStorySimState); - }, []); - - React.useEffect(() => { - SourceAcademyGame.getInstance().setAccountInfo({ - accessToken: session.accessToken, - refreshToken: session.refreshToken, - role: session.role, - name: session.name - } as AccountInfo); - }, [session]); - - return ( -
-
-
- {storySimState === StorySimState.Default &&

Welcome to story simulator!

} - {storySimState === StorySimState.CheckpointSim && } - {storySimState === StorySimState.ObjectPlacement && ( - <> -

Asset Selection

- - - )} - {storySimState === StorySimState.AssetUploader && ( - <> -

Asset uploader

- -

Asset Viewer

- - - )} - {storySimState === StorySimState.ChapterSim && } -
-
- ); -} - -export default StorySimulator; diff --git a/src/styles/_storysimulator.scss b/src/styles/_gamesimulator.scss similarity index 90% rename from src/styles/_storysimulator.scss rename to src/styles/_gamesimulator.scss index 709e0cf9e3..a0e5968a8a 100644 --- a/src/styles/_storysimulator.scss +++ b/src/styles/_gamesimulator.scss @@ -7,7 +7,7 @@ } } -.StorySimulatorWrapper { +.GameSimulatorWrapper { display: flex; flex-direction: row; margin: 30px; @@ -26,7 +26,7 @@ align-items: flex-start; } -.StorySimulatorPanel { +.GameSimulatorPanel { background-color: white; width: 800px; height: 100%; diff --git a/src/styles/index.scss b/src/styles/index.scss index db866d7bee..6e0c675f15 100755 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -31,7 +31,7 @@ @import 'envvisualizer'; @import 'game'; @import 'github'; -@import 'storysimulator'; +@import 'gamesimulator'; @import 'groundcontrol'; @import 'mobileworkspace'; @import 'navigationBar';