From 66356b5a7935b1b4a6691a46d4bb0c367aba6b3f Mon Sep 17 00:00:00 2001 From: devZoGok Date: Fri, 28 Mar 2025 20:24:24 +0200 Subject: [PATCH] loading the map after loading the assets --- Assets/Scripts/Gui/loadingScreen.lua | 2 +- external/vb01 | 2 +- inGameAppState.cpp | 7 +++++-- inGameAppState.h | 3 ++- loadingAppState.cpp | 2 +- playButton.cpp | 8 ++------ 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Gui/loadingScreen.lua b/Assets/Scripts/Gui/loadingScreen.lua index cac1de5..159a0c6 100644 --- a/Assets/Scripts/Gui/loadingScreen.lua +++ b/Assets/Scripts/Gui/loadingScreen.lua @@ -17,7 +17,7 @@ gui = { guiType = GuiType.GUI_RECTANGLE, pos = {x = initPos.x, y = initPos.y + Size.y, z = initPos.z}, size = Size, - color = {x = 0, y = 0, z = 0, w = 1} + color = {x = .3, y = .3, z = .3, w = 1} }, { guiType = GuiType.GUI_RECTANGLE, diff --git a/external/vb01 b/external/vb01 index 044828c..8938958 160000 --- a/external/vb01 +++ b/external/vb01 @@ -1 +1 @@ -Subproject commit 044828c7cf4bb61a12f0b887ebc409710056c711 +Subproject commit 89389589de8b1ef87483b9974aa87f083a3ab476 diff --git a/inGameAppState.cpp b/inGameAppState.cpp index e3c38f5..232a947 100755 --- a/inGameAppState.cpp +++ b/inGameAppState.cpp @@ -48,18 +48,21 @@ namespace battleship{ Console::execute(wstringToString(textbox->getText())); } - InGameAppState::InGameAppState() : AbstractAppState( + InGameAppState::InGameAppState(std::string mn) : AbstractAppState( AppStateType::IN_GAME_STATE, configData::calcSumBinds(AppStateType::IN_GAME_STATE, true), configData::calcSumBinds(AppStateType::IN_GAME_STATE, false), GameManager::getSingleton()->getPath() + scripts[(int)ScriptFiles::OPTIONS] ), + mapName(mn), playerId(0){} void InGameAppState::onAttached() { AbstractAppState::onAttached(); - Map::getSingleton()->loadPlayerGameObjects(); + Map *map = Map::getSingleton(); + map->load(mapName); + map->loadPlayerGameObjects(); Camera *cam = Root::getSingleton()->getCamera(); cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId) + Vector3(1, 1, 1) * configData::CAMERA_DISTANCE); diff --git a/inGameAppState.h b/inGameAppState.h index 811b345..1f2c036 100755 --- a/inGameAppState.h +++ b/inGameAppState.h @@ -39,7 +39,7 @@ namespace battleship{ private: }; - InGameAppState(); + InGameAppState(std::string); ~InGameAppState(){} void onAttached(); void onDettached(); @@ -53,6 +53,7 @@ namespace battleship{ std::vector modelPaths; Player *mainPlayer; int playerId; + std::string mapName = ""; ActiveGameState* activeState; }; } diff --git a/loadingAppState.cpp b/loadingAppState.cpp index 84fc754..dd655dc 100644 --- a/loadingAppState.cpp +++ b/loadingAppState.cpp @@ -27,8 +27,8 @@ namespace battleship{ {} void LoadingAppState::onDettached(){ - GameManager::getSingleton()->getStateManager()->attachAppState(newState); ConcreteGuiManager::getSingleton()->readLuaScreenScript(newScreen); + GameManager::getSingleton()->getStateManager()->attachAppState(newState); AbstractAppState::onDettached(); } diff --git a/playButton.cpp b/playButton.cpp index 7811ea1..785f5ef 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -18,7 +18,6 @@ namespace battleship{ PlayButton::PlayButton(Listbox *ml, Vector3 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_P, separate), mapListbox(ml) {} void PlayButton::onClick() { - ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); vector factionsListboxes, difficultiesListboxes, colorsListboxes, teamsListboxes; @@ -36,10 +35,7 @@ namespace battleship{ int selectedMap = mapListbox->getSelectedOption(); string mapName = wstringToString(mapListbox->getContents()[selectedMap]); - - Map *map = Map::getSingleton(); - map->load(mapName); - int numPlayers = map->getNumSpawnPoints(); + int numPlayers = Map::getSingleton()->getNumMapSpawnPoints(mapName); for(int i = 0; i < numPlayers; i++){ int factionChoice = factionsListboxes[i]->getSelectedOption(); @@ -71,6 +67,6 @@ namespace battleship{ game->addPlayer(new Player(difficulty, faction, team, color, cpuPlayer, i, name)); } - handleLoadingGui(new LoadingAppState(new InGameAppState(), "inGame.lua")); + handleLoadingGui(new LoadingAppState(new InGameAppState(mapName), "inGame.lua")); } }