loading the map after loading the assets

This commit is contained in:
devZoGok
2025-03-28 20:24:24 +02:00
parent 12c3a67122
commit 66356b5a79
6 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -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,
+1 -1
+5 -2
View File
@@ -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);
+2 -1
View File
@@ -39,7 +39,7 @@ namespace battleship{
private:
};
InGameAppState();
InGameAppState(std::string);
~InGameAppState(){}
void onAttached();
void onDettached();
@@ -53,6 +53,7 @@ namespace battleship{
std::vector<std::string> modelPaths;
Player *mainPlayer;
int playerId;
std::string mapName = "";
ActiveGameState* activeState;
};
}
+1 -1
View File
@@ -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();
}
+2 -6
View File
@@ -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<Listbox*> 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"));
}
}