#include "mapListbox.h" #include "map.h" #include "concreteGuiManager.h" #include "gameManager.h" #include #include #include #include #include #include #include namespace battleship{ using namespace vb01; using namespace vb01Gui; using namespace std; using namespace gameBase; 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(){ if(addPlayerGui){ ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); for(Listbox *listbox : cpuPlayerListboxes) guiManager->removeListbox(listbox); 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]); } } } }