diff --git a/Assets/Scripts/Gui/loadMap.lua b/Assets/Scripts/Gui/loadMap.lua index f77ec44..6538fda 100644 --- a/Assets/Scripts/Gui/loadMap.lua +++ b/Assets/Scripts/Gui/loadMap.lua @@ -4,6 +4,7 @@ gui = { pos = {x = 110, y = 190, z = 0}, size = {x = 360, y = 20}, guiType = GuiType.LISTBOX, + addPlayerGui = false, listboxType = ListboxType.MAPS, numMaxDisplay = 5 }, diff --git a/Assets/Scripts/Gui/main.lua b/Assets/Scripts/Gui/main.lua index 9075486..0affb41 100644 --- a/Assets/Scripts/Gui/main.lua +++ b/Assets/Scripts/Gui/main.lua @@ -52,6 +52,8 @@ ListboxType = { LAND_TEXTURES = 7, CPU_DIFFICULTIES = 8, FACTIONS = 9, - CONSOLE = 10, - TRADE_OFFERS = 11 + COLORS = 10, + TEAMS = 11, + CONSOLE = 12, + TRADE_OFFERS = 13 } diff --git a/Assets/Scripts/Gui/playerSelection.lua b/Assets/Scripts/Gui/playerSelection.lua index f6f09d2..20bc65d 100644 --- a/Assets/Scripts/Gui/playerSelection.lua +++ b/Assets/Scripts/Gui/playerSelection.lua @@ -1,62 +1,49 @@ -Pos = {x = 110, y = 150, z = 0} -Size = {x = 100, y = 20} -space = 60 +playerListboxPos = {x = 110, y = 10, z = 0} +Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z} +Size = {x = 150, y = 20} +gap = 10 +gapFactor = 3 + +factions = {'None', "America inc.", "European Republic", "Asian Co-Prosperity Sphere"} +difficulties = {"Easy", "Medium", "Hard"} +colors = {'White', 'Black', 'Red'} +teams = {'0', '1', '2', '3', '4'} gui = { { - pos = Pos, + pos = {x = Pos.x, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, size = Size, guiType = GuiType.LISTBOX, + name = 'factions', numMaxDisplay = 3, + lines = factions, listboxType = ListboxType.FACTIONS }, { - pos = {x = Pos.x, y = Pos.y + Size.y + space}, + pos = {x = Pos.x + Size.x + gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, size = Size, guiType = GuiType.LISTBOX, + name = 'difficulties', numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS + lines = difficulties, + listboxType = ListboxType.CPU_DIFFICULTIES }, { - pos = {x = Pos.x, y = Pos.y + 2 * (Size.y + space)}, + pos = {x = Pos.x + 2 * (Size.x + gap), y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, size = Size, guiType = GuiType.LISTBOX, + name = 'colors', numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS + lines = colors, + listboxType = ListboxType.COLORS }, { - pos = {x = Pos.x, y = Pos.y + 3 * (Size.y + space)}, + pos = {x = Pos.x + 3 * (Size.x + gap), y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, size = Size, guiType = GuiType.LISTBOX, + name = 'teams', numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = Pos.x, y = Pos.y + 4 * (Size.y + space)}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = Pos.x, y = Pos.y + 5 * (Size.y + space)}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = Pos.x, y = Pos.y + 6 * (Size.y + space)}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = Pos.x, y = Pos.y + 7 * (Size.y + space)}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS + lines = teams, + listboxType = ListboxType.TEAMS }, } diff --git a/Assets/Scripts/Gui/singlePlayerMenu.lua b/Assets/Scripts/Gui/singlePlayerMenu.lua index d43e620..3653569 100644 --- a/Assets/Scripts/Gui/singlePlayerMenu.lua +++ b/Assets/Scripts/Gui/singlePlayerMenu.lua @@ -1,32 +1,11 @@ Size = {x = 100, y = 20} -numGui = 6 gui = { - { - pos = {x = 100, y = 100, z = 0}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.CPU_DIFFICULTIES - }, - { - pos = {x = 210, y = 100, z = 0}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = 100, y = 230, z = 0}, - size = Size, - guiType = GuiType.LISTBOX, - numMaxDisplay = 3, - listboxType = ListboxType.FACTIONS - }, { pos = {x = 110, y = 310, z = 0}, size = Size, guiType = GuiType.LISTBOX, + addPlayerGui = true, listboxType = ListboxType.MAPS, numMaxDisplay = 5 }, @@ -37,12 +16,7 @@ gui = { buttonType = ButtonType.PLAY, name = 'Play', numDependencies = 4, - dependencies = { - {id = 0}, - {id = 1}, - {id = 2}, - {id = 3} - } + dependencies = {{id = 0}} }, { pos = {x = 110 + Size.x + 10, y = 460, z = 0}, diff --git a/CMakeLists.txt b/CMakeLists.txt index 92806cf..cb5a78a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(MENU_BUTTONS mainMenuButton.cpp singlePlayerButton.cpp exitButton.cpp backBu set(MAP_EDITOR_BUTTONS mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp exportButton.cpp) set(BUTTONS statsButton.cpp activeStateButton.cpp minimapButton.cpp ${TRADING_BUTTONS} ${OPTIONS_BUTTONS} ${MENU_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS}) -set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp) +set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp mapListbox.cpp) set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES}) set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp) diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index d8c950a..6527717 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -15,6 +15,7 @@ #include "newMapButton.h" #include "loadMapButton.h" #include "exportButton.h" +#include "mapListbox.h" #include "skyboxTextureListbox.h" #include "landTextureListbox.h" #include "gameObjectListbox.h" @@ -155,21 +156,9 @@ namespace battleship{ button = new ExportButton(pos, size); break; case PLAY:{ - int did = guiTable["dependencies"][1]["id"]; - vector difficultyListboxes = vector{(Listbox*)guiElements[did].second}; - - vector factionsListboxes; - int numPlayers = 2; - - for(int i = 0; i < numPlayers; i++){ - int did = guiTable["dependencies"][i + 2]["id"]; - factionsListboxes.push_back((Listbox*)guiElements[did].second); - } - - int mid = guiTable["dependencies"][4]["id"]; - Listbox *mapListbox = (Listbox*)guiElements[mid].second; - - button = new PlayButton(difficultyListboxes, factionsListboxes, mapListbox, pos, size, name, true); + int mid = guiTable["dependencies"][1]["id"]; + Listbox *mapListbox = (MapListbox*)guiElements[mid].second; + button = new PlayButton(mapListbox, pos, size, name, true); break; } case RESUME: @@ -293,12 +282,24 @@ namespace battleship{ int numMaxDisplay = guiTable["numMaxDisplay"]; ListboxType listboxType = (ListboxType)guiTable["listboxType"]; - vector lines; int maxDisplay, numLines; bool closable; - Listbox *listbox = nullptr; + vector lines; + sol::optional linesOpt = guiTable["lines"]; + if(linesOpt != sol::nullopt){ + sol::table linesTbl = guiTable["lines"]; + + for(int i = 0; i < linesTbl.size(); i++) + lines.push_back(guiTable["lines"][i + 1]); + } + + Listbox *listbox = nullptr; string fontPath = fontBasePath + "batang.ttf"; + sol::optional nameOpt = guiTable["name"]; + string name = ""; + + if(nameOpt != sol::nullopt) name = guiTable["name"]; switch(listboxType){ case CONTROLS:{ @@ -326,14 +327,16 @@ namespace battleship{ break; } - case MAPS: + case MAPS:{ lines = readDir(GameManager::getSingleton()->getPath() + "Models/Maps/", true); numLines = lines.size(); closable = true; maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines); + bool addPlayers = guiTable["addPlayerGui"]; - listbox = new Listbox(pos, size, lines, maxDisplay, fontPath, closable); + listbox = new MapListbox(pos, size, lines, maxDisplay, addPlayers, fontPath, closable); break; + } case VEHICLES: case STRUCTURES: case RESOURCE_DEPOSITS:{ @@ -378,15 +381,9 @@ namespace battleship{ listbox = new LandTextureListbox(pos, size, lines, maxDisplay, fontPath); break; case CPU_DIFFICULTIES: - lines = vector{"Easy", "Medium", "Hard"}; - numLines = lines.size(); - closable = true; - maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines); - - listbox = new Listbox(pos, size, lines, maxDisplay, fontPath); - break; case FACTIONS: - lines = vector{"Empire", "Mutants", "Shapeshifters"}; + case COLORS: + case TEAMS: numLines = lines.size(); closable = true; maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines); @@ -412,6 +409,8 @@ namespace battleship{ int typeArr[2]{(int)GuiElementType::LISTBOX, (int)listboxType}; guiElements.push_back(make_pair(typeArr, (void*)listbox)); + listbox->setName(name); + return listbox; } @@ -552,7 +551,10 @@ namespace battleship{ ){ removeAllGuiElements(buttonExceptions, listboxExceptions, checkboxExceptions, sliderExceptions, textboxExceptions, guiRecttboxExceptions, textExceptions); guiElements.clear(); + parseLuaScript(script); + } + void ConcreteGuiManager::parseLuaScript(string script){ string basePath = GameManager::getSingleton()->getPath() + "Scripts/Gui/"; sol::state_view SOL_LUA_VIEW = generateView(); SOL_LUA_VIEW.script_file(basePath + script); diff --git a/concreteGuiManager.h b/concreteGuiManager.h index 36b3340..1f0dec5 100644 --- a/concreteGuiManager.h +++ b/concreteGuiManager.h @@ -65,6 +65,8 @@ namespace battleship{ LAND_TEXTURES, CPU_DIFFICULTIES, FACTIONS, + COLORS, + TEAMS, CONSOLE, TRADE_OFFERS }; @@ -82,6 +84,7 @@ namespace battleship{ std::vector = std::vector{}, std::vector = std::vector{} ); + void parseLuaScript(std::string); private: ConcreteGuiManager(); vb01Gui::Button* parseButton(int); diff --git a/inGameAppState.cpp b/inGameAppState.cpp index 26a4c23..c9ff629 100755 --- a/inGameAppState.cpp +++ b/inGameAppState.cpp @@ -45,41 +45,19 @@ namespace battleship{ Console::execute(wstringToString(textbox->getText())); } - InGameAppState::InGameAppState(vector difficultyLevels, vector factions) : AbstractAppState( + InGameAppState::InGameAppState() : 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]){ - this->playerId = 1; - this->difficultyLevels = difficultyLevels; - this->factions = factions; - } - - InGameAppState::~InGameAppState() { - } + GameManager::getSingleton()->getPath() + scripts[(int)ScriptFiles::OPTIONS] + ), + playerId(0){} void InGameAppState::onAttached() { AbstractAppState::onAttached(); - for (int i = 0; i < factions.size(); i++) { - int faction, difficulty; - - if (i == 0) - difficulty = -1; - else { - if (difficultyLevels[i - 1] == "Easy") - difficulty = 0; - else if (difficultyLevels[i - 1] == "Medium") - difficulty = 1; - else - difficulty = 2; - } - - faction = factions[i][0] - 48; - } - Camera *cam = Root::getSingleton()->getCamera(); - cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId - 1) + Vector3(1, 1, 1) * configData::CAMERA_DISTANCE); + cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId) + Vector3(1, 1, 1) * configData::CAMERA_DISTANCE); cam->lookAt(Vector3(0, -1, -1).norm(), Vector3(0, 1, -1).norm()); mainPlayer = Game::getSingleton()->getPlayer(playerId); diff --git a/inGameAppState.h b/inGameAppState.h index 0bb77e4..811b345 100755 --- a/inGameAppState.h +++ b/inGameAppState.h @@ -39,8 +39,8 @@ namespace battleship{ private: }; - InGameAppState(std::vector, std::vector); - ~InGameAppState(); + InGameAppState(); + ~InGameAppState(){} void onAttached(); void onDettached(); void update(); @@ -50,7 +50,7 @@ namespace battleship{ inline ActiveGameState* getActiveState(){return activeState;} private: bool isMainMenuActive = false; - std::vector difficultyLevels, factions, modelPaths; + std::vector modelPaths; Player *mainPlayer; int playerId; ActiveGameState* activeState; diff --git a/map.cpp b/map.cpp index 749e2e4..6b9a3c4 100755 --- a/map.cpp +++ b/map.cpp @@ -374,14 +374,20 @@ namespace battleship{ } } + int Map::getNumMapSpawnPoints(string name){ + if(name != "") + generateView().script_file(GameManager::getSingleton()->getPath() + "Models/Maps/" + name + "/" + name + ".lua"); + + sol::table spawnPointsTbl = generateView()["map"]["spawnPoints"]; + return spawnPointsTbl.size(); + } + void Map::loadSpawnPoints(){ sol::state_view SOL_LUA_VIEW = generateView(); - string spawnPointInd = "spawnPoints"; - sol::table spawnPointsTbl = SOL_LUA_VIEW[mapTable][spawnPointInd]; - int numSpawnPoints = spawnPointsTbl.size(); + int numSpawnPoints = getNumMapSpawnPoints(); for(int i = 0; i < numSpawnPoints; i++){ - sol::table posTable = SOL_LUA_VIEW[mapTable][spawnPointInd][i + 1]; + sol::table posTable = SOL_LUA_VIEW[mapTable]["spawnPoints"][i + 1]; spawnPoints.push_back(Vector3(posTable["x"], posTable["y"], posTable["z"])); } } @@ -397,9 +403,8 @@ namespace battleship{ assetManager->load(path + vfxPrefix, true); assetManager->load(path + gameObjPrefix, true); + int numPlayers = Game::getSingleton()->getNumPlayers(); string playerInd = "players"; - SOL_LUA_VIEW.script("numPlayers = #" + mapTable + "." + playerInd); - int numPlayers = SOL_LUA_VIEW["numPlayers"]; for(int i = 0; i < numPlayers; i++){ string resDepInd = "resourceDeposits"; diff --git a/map.h b/map.h index 1348358..3dfb454 100755 --- a/map.h +++ b/map.h @@ -76,6 +76,7 @@ namespace battleship{ int getCellId(vb01::Vector3, bool = true); bool isPointWithinTerrainObject(vb01::Vector3, int); void loadPlayerGameObjects(); + int getNumMapSpawnPoints(std::string = ""); inline std::string getMapName(){return mapName;} inline vb01::Node* getNodeParent(){return terrainNode;} inline vb01::Vector3 getCellSize(){return CELL_SIZE;} diff --git a/mapListbox.cpp b/mapListbox.cpp index f187d3f..19338a2 100644 --- a/mapListbox.cpp +++ b/mapListbox.cpp @@ -3,6 +3,8 @@ #include "concreteGuiManager.h" #include "gameManager.h" +#include + #include #include #include @@ -14,21 +16,37 @@ namespace battleship{ using namespace vb01; using namespace vb01Gui; using namespace std; + using namespace gameBase; - MapListbox::MapListbox(Vector2 pos, Vector2 size, std::vector &lines, int maxDisplay, string fontPath, bool closeable) : Listbox(pos, size, lines, maxDisplay, fontPath, closeable){} + MapListbox::MapListbox(Vector3 pos, Vector2 size, std::vector &lines, int maxDisplay, bool adg, string fontPath, bool closeable) : + Listbox(pos, size, lines, maxDisplay, fontPath, closeable), + addPlayerGui(adg) {} void MapListbox::onClose(){ - ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); + if(addPlayerGui){ + ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); - Listbox *mapListbox = guiManager->getListboxes()[0]; - int selectedMap = mapListbox->getSelectedOption(); - string mapName = wstringToString(mapListbox->getContents()[selectedMap]); - string mapPath = GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/" + mapName + ".lua"; - int numSpawnPoints = Map::getNumSpawnPointsByMap(mapPath); + for(Listbox *listbox : cpuPlayerListboxes) + guiManager->removeListbox(listbox); - guiManager->readLuaScreenScript("singlePlayerMenu.lua"); - mapListbox = guiManager->getListboxes()[0]; - vector buttons = guiManager->getButtons(); - guiManager->readLuaScreenScript("playerSelection.lua", buttons, vector{mapListbox}, vector{}, vector{}, vector{}, vector{}, vector{}, numSpawnPoints); + cpuPlayerListboxes.clear(); + + string mapName = wstringToString(getContents()[getSelectedOption()]); + int numSpawnPoints = Map::getSingleton()->getNumMapSpawnPoints(mapName); + sol::state_view SOL_LUA_VIEW = generateView(); + + for(int i = 0; i < numSpawnPoints; i++){ + int prevNumListboxes = guiManager->getListboxes().size(); + + SOL_LUA_VIEW.script("lineId = " + to_string(i)); + guiManager->parseLuaScript("playerSelection.lua"); + + std::vector listboxes = guiManager->getListboxes(); + int diffNumListboxes = listboxes.size() - prevNumListboxes; + + for(int j = 0; j < diffNumListboxes; j++) + cpuPlayerListboxes.push_back(listboxes[listboxes.size() - 1 - j]); + } + } } } diff --git a/mapListbox.h b/mapListbox.h index ffe9c16..3464735 100644 --- a/mapListbox.h +++ b/mapListbox.h @@ -3,12 +3,19 @@ #include +namespace vb01Gui{ + class Listbox; +} + namespace battleship{ class MapListbox : public vb01Gui::Listbox{ public: - MapListbox(vb01::Vector2, vb01::Vector2, std::vector&, int, std::string, bool); + MapListbox(vb01::Vector3, vb01::Vector2, std::vector&, int, bool, std::string, bool); private: void onClose(); + + bool addPlayerGui; + std::vector cpuPlayerListboxes; }; } diff --git a/playButton.cpp b/playButton.cpp index c3457ea..a91bc52 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -14,42 +14,67 @@ namespace battleship{ using namespace vb01Gui; using namespace gameBase; - PlayButton::PlayButton(vector difficulties, vector factions, Listbox *mapListbox, Vector3 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_P, separate) { - difficultiesListboxes = difficulties; - factionsListboxes = factions; - this->mapListbox = mapListbox; - } + 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() { - std::vector difficulties, factions; + void PlayButton::onClick() { - for(int i = 0; i < difficultiesListboxes.size(); i++) - difficulties.push_back(wstringToString(difficultiesListboxes[i]->getContents()[difficultiesListboxes[i]->getSelectedOption()])); + ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); + vector factionsListboxes, difficultiesListboxes, colorsListboxes, teamsListboxes; + + for(Listbox *listbox : guiManager->getListboxes()){ + string name = listbox->getName(); + + if(name == "factions") factionsListboxes.push_back(listbox); + else if(name == "difficulties") difficultiesListboxes.push_back(listbox); + else if(name == "colors") colorsListboxes.push_back(listbox); + else if(name == "teams") teamsListboxes.push_back(listbox); + } + + Game *game = Game::getSingleton(); + game->initTechnologies(); + + int selectedMap = mapListbox->getSelectedOption(); + string mapName = wstringToString(mapListbox->getContents()[selectedMap]); + + Map *map = Map::getSingleton(); + map->load(mapName); + int numPlayers = map->getNumSpawnPoints(); - for(int i = 0; i < factionsListboxes.size(); i++) - factions.push_back(to_string(factionsListboxes[i]->getSelectedOption())); + for(int i = 0; i < numPlayers; i++){ + int factionChoice = factionsListboxes[i]->getSelectedOption(); - Game *game = Game::getSingleton(); - game->initTechnologies(); + if(factionChoice == 0) continue; + + int faction = factionChoice - 1; + + bool cpuPlayer = (i > 0); + string diffStr = (cpuPlayer ? wstringToString(difficultiesListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]) : ""); + int difficulty = -1; + + if(diffStr == "Easy") difficulty = 0; + else if(diffStr == "Medium") difficulty = 1; + else if(diffStr == "Hard") difficulty = 2; + + string colorStr = wstringToString(colorsListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]); + Vector3 color; + + if(colorStr == "Black") color = Vector3::VEC_ZERO; + else if(colorStr == "Red") color = Vector3::VEC_I; + else if(colorStr == "Green") color = Vector3::VEC_J; + else if(colorStr == "Blue") color = Vector3::VEC_K; + else if(colorStr == "White") color = Vector3::VEC_IJK; + + int team = stoi(teamsListboxes[i]->getContents()[teamsListboxes[i]->getSelectedOption()]); + + string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player"); + game->addPlayer(new Player(difficulty, faction, team, color, cpuPlayer, map->getSpawnPoint(i), name)); + } - int selectedMap = mapListbox->getSelectedOption(); - string mapName = wstringToString(mapListbox->getContents()[selectedMap]); - Map *map = Map::getSingleton(); - map->load(mapName); - - int numPlayers = map->getNumSpawnPoints(); - - for(int i = 0; i < numPlayers; i++){ - bool cpuPlayer = (i < numPlayers - 1); - string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player"); - game->addPlayer(new Player(0, 0, i, Vector3(i, i, i), cpuPlayer, map->getSpawnPoint(i), name)); - } - - map->loadPlayerGameObjects(); - - ConcreteGuiManager::getSingleton()->readLuaScreenScript("inGame.lua"); - - StateManager *stateManager = GameManager::getSingleton()->getStateManager(); - stateManager->attachAppState(new InGameAppState(difficulties, factions)); - } + map->loadPlayerGameObjects(); + + guiManager->readLuaScreenScript("inGame.lua"); + + StateManager *stateManager = GameManager::getSingleton()->getStateManager(); + stateManager->attachAppState(new InGameAppState()); + } } diff --git a/playButton.h b/playButton.h index 2c2565a..d265cdc 100644 --- a/playButton.h +++ b/playButton.h @@ -10,12 +10,10 @@ namespace vb01Gui{ namespace battleship{ class PlayButton : public vb01Gui::Button { public: - PlayButton(std::vector, std::vector, vb01Gui::Listbox*, vb01::Vector3, vb01::Vector2, std::string, bool); + PlayButton(vb01Gui::Listbox*, vb01::Vector3, vb01::Vector2, std::string, bool); void onClick(); private: - std::vector difficultiesListboxes, factionsListboxes; vb01Gui::Listbox *mapListbox = nullptr; - int lengths[2]; }; } diff --git a/singlePlayerButton.cpp b/singlePlayerButton.cpp index f0ff156..ef29559 100644 --- a/singlePlayerButton.cpp +++ b/singlePlayerButton.cpp @@ -2,6 +2,8 @@ #include "gameManager.h" #include "concreteGuiManager.h" +#include + #include namespace battleship{ @@ -21,5 +23,9 @@ namespace battleship{ void SinglePlayerButton::onClick() { ConcreteGuiManager::getSingleton()->readLuaScreenScript("singlePlayerMenu.lua"); + + Listbox *listbox = ConcreteGuiManager::getSingleton()->getListboxes()[0]; + listbox->openUp(); + listbox->close(); } }