diff --git a/inGameAppState.cpp b/inGameAppState.cpp index c54ca10..1589e1b 100755 --- a/inGameAppState.cpp +++ b/inGameAppState.cpp @@ -35,119 +35,16 @@ namespace battleship{ void InGameAppState::ConsoleButton::onClick() { ConcreteGuiManager::getSingleton()->readLuaScreenScript("console.lua"); - /* - vector list; - int emptyEntries = 20; - - for (int i = 0; i < emptyEntries; i++) - list.push_back(""); - - Vector2 pos = Vector2(300, 100); - Listbox *consoleListbox = new Listbox( - Vector2(pos.x, pos.y), - Vector2(420, 20), - list, - 20, - GameManager::getSingleton()->getPath() + "Fonts/batang.ttf" - ); - consoleListbox->openUp(); - guiState->addListbox(consoleListbox); - - Textbox *consoleTextbox = new Textbox( - Vector2(pos.x, pos.y + 20 * (emptyEntries + 1)), - Vector2(300, 20), - GameManager::getSingleton()->getPath() + "Fonts/batang.ttf" - ); - guiState->addTextbox(consoleTextbox); - - entryButton = new ConsoleCommandEntryButton( - inGameState, - consoleTextbox, - consoleListbox, - Vector2(pos.x + 320, pos.y + 20 * (emptyEntries + 1)), - Vector2(100, 20), - "Enter", - true - ); - guiState->addButton(entryButton); - */ } - InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) { - textbox = t; - listbox = l; - } + InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) { + textbox = t; + listbox = l; + } - void InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::onClick() { - ConsoleCommand::execute(wstringToString(textbox->getText())); - } - - InGameAppState::InGameOptionsButton::ReturnButton::ReturnButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) { - this->guiState = guiState; - this->inGameState = inGameState; - } - - //TODO: replace string literals removeButton() lines - void InGameAppState::InGameOptionsButton::ReturnButton::onClick() { - /* - guiState->removeAllCheckboxes(); - guiState->removeAllListboxes(); - guiState->removeAllSliders(); - guiState->removeAllTextboxes(); - guiState->removeButton("Controls"); - guiState->removeButton("Mouse"); - guiState->removeButton("Video"); - guiState->removeButton("Audio"); - guiState->removeButton("Multiplayer"); - - Vector2 pos = Vector2(100, 100), size = Vector2(150, 50); - ResumeButton *resumeButton = new ResumeButton(guiState, inGameState, Vector2(pos.x, pos.y), size); - ConsoleButton *consoleButton = new ConsoleButton(guiState, inGameState, Vector2(pos.x, pos.y + 60), size); - InGameOptionsButton *optionsButton = new InGameOptionsButton(guiState, inGameState, Vector2(pos.x, pos.y + 120), size); - MainMenuButton *mainMenuButton = new MainMenuButton(guiState, inGameState, Vector2(pos.x, pos.y + 180), size); - ExitButton *exitButton = new ExitButton(Vector2(pos.x, pos.y + 240), size); - - inGameState->setResumeButton(resumeButton); - inGameState->setConsoleButton(consoleButton); - inGameState->setOptionsButton(optionsButton); - inGameState->setMainMenuButton(mainMenuButton); - inGameState->setExitButton(exitButton); - - guiState->addButton(resumeButton); - guiState->addButton(consoleButton); - guiState->addButton(optionsButton); - guiState->addButton(mainMenuButton); - guiState->addButton(exitButton); - - guiState->removeButton("Back"); - */ - } - - InGameAppState::InGameOptionsButton::InGameOptionsButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size) : OptionsButton(pos, size, "Options", true) { - this->guiState = guiState; - this->inGameState = inGameState; - } - - void InGameAppState::InGameOptionsButton::onClick() { - /* - returnButton = new ReturnButton(guiState, inGameState, Vector2(50, GameManager::getSingleton()->getHeight() - 150), Vector2(150, 50), "Back", true); - guiState->addButton(returnButton); - guiState->removeButton(inGameState->getResumeButton()); - guiState->removeButton(inGameState->getConsoleButton()); - guiState->removeButton(inGameState->getMainMenuButton()); - guiState->removeButton(inGameState->getExitButton()); - OptionsButton::onClick(); - */ - } - - InGameAppState::MainMenuButton::MainMenuButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size) : Button(pos, size, "Main menu", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) { - this->guiState = guiState; - this->inGameState = inGameState; - } - - void InGameAppState::MainMenuButton::onClick() { - - } + void InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::onClick() { + ConsoleCommand::execute(wstringToString(textbox->getText())); + } InGameAppState::InGameAppState(vector difficultyLevels, vector factions, string mapName) : AbstractAppState( AppStateType::IN_GAME_STATE, @@ -197,7 +94,7 @@ namespace battleship{ GameManager *gm = GameManager::getSingleton(); StateManager *stateManager = gm->getStateManager(); - guiState = ((GuiAppState*)stateManager->getAppStateByType((int)AppStateType::GUI_STATE)); + GuiAppState *guiState = ((GuiAppState*)stateManager->getAppStateByType((int)AppStateType::GUI_STATE)); activeState = new ActiveGameState(guiState, playerId); stateManager->attachAppState(activeState); } diff --git a/inGameAppState.h b/inGameAppState.h index 65a2e8a..cfd1c8f 100755 --- a/inGameAppState.h +++ b/inGameAppState.h @@ -55,39 +55,6 @@ namespace battleship{ inline void addFx(Fx fx){this->fx.push_back(fx);} inline void addProjectile(Projectile *p){projectiles.push_back(p);} private: - class MainMenuButton : public vb01Gui::Button { - public: - MainMenuButton(GuiAppState*, InGameAppState*, vb01::Vector2, vb01::Vector2); - void onClick(); - private: - GuiAppState *guiState; - InGameAppState *inGameState; - }; - - class InGameOptionsButton : public OptionsButton { - public: - InGameOptionsButton(GuiAppState*, InGameAppState*, vb01::Vector2, vb01::Vector2); - void onClick(); - private: - class ReturnButton : public vb01Gui::Button { - public: - ReturnButton(GuiAppState*, InGameAppState*, vb01::Vector2, vb01::Vector2, std::string, bool); - void onClick(); - private: - GuiAppState *guiState; - InGameAppState *inGameState; - }; - - GuiAppState *guiState; - InGameAppState *inGameState; - ReturnButton *returnButton; - }; - - ResumeButton *resumeButton; - ConsoleButton *consoleButton; - InGameOptionsButton *optionsButton; - MainMenuButton *mainMenuButton; - ExitButton *exitButton; bool isMainMenuActive = false; std::vector difficultyLevels, factions, modelPaths; std::vector projectiles; @@ -96,20 +63,8 @@ namespace battleship{ Player *mainPlayer; int playerId; ActiveGameState* activeState; - GuiAppState* guiState; void toggleMainMenu(); - public: - inline void setResumeButton(ResumeButton *r){this->resumeButton = r;} - inline void setConsoleButton(ConsoleButton *c){this->consoleButton = c;} - inline void setOptionsButton(InGameOptionsButton *o){this->optionsButton = o;} - inline void setMainMenuButton(MainMenuButton *m){this->mainMenuButton = m;} - inline void setExitButton(ExitButton *e){this->exitButton = e;} - inline ResumeButton* getResumeButton(){return resumeButton;} - inline ConsoleButton* getConsoleButton(){return consoleButton;} - inline InGameOptionsButton* getOptionsButton(){return optionsButton;} - inline MainMenuButton* getMainMenuButton(){return mainMenuButton;} - inline ExitButton* getExitButton(){return exitButton;} }; } diff --git a/loadMapButton.cpp b/loadMapButton.cpp index e7dd42b..3456f44 100644 --- a/loadMapButton.cpp +++ b/loadMapButton.cpp @@ -14,18 +14,6 @@ namespace battleship{ LoadMapButton::OkButton::OkButton(vb01::Vector2 pos, vb01::Vector2 size, vb01Gui::Listbox *listbox) : Button(pos, size, "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){ this->listbox = listbox; } void LoadMapButton::OkButton::onClick(){ - /* - string name = wstringToString(listbox->getContents()[listbox->getSelectedOption()]); - - StateManager *sm = GameManager::getSingleton()->getStateManager(); - GuiAppState *guiState = (GuiAppState*)sm->getAppStateByType((int)AppStateType::GUI_STATE); - guiState->removeAllListboxes(); - guiState->removeAllButtons(vector{this}); - - sm->attachAppState(new MapEditorAppState(name, Vector2::VEC_ZERO, false)); - - guiState->removeButton(this); - */ StateManager *sm = GameManager::getSingleton()->getStateManager(); string name = wstringToString(listbox->getContents()[listbox->getSelectedOption()]); sm->attachAppState(new MapEditorAppState(name, Vector2::VEC_ZERO, false)); @@ -36,21 +24,5 @@ namespace battleship{ void LoadMapButton::onClick(){ ConcreteGuiManager::getSingleton()->readLuaScreenScript("loadMap.lua"); - /* - - GameManager *gm = GameManager::getSingleton(); - StateManager *sm = gm->getStateManager(); - GuiAppState *guiState = (GuiAppState*)sm->getAppStateByType((int)AppStateType::GUI_STATE); - guiState->removeAllButtons(vector{this}); - - string basePath = gm->getPath(); - vector maps = readDir(basePath + "Models/Maps/", true); - int displayLimit = 2; - Listbox *mapsListbox = new Listbox(Vector2(100, 150), Vector2(140, 20), maps, (maps.size() > displayLimit ? maps.size() : displayLimit), basePath + "Fonts/batang.ttf"); - guiState->addListbox(mapsListbox); - guiState->addButton(new OkButton(Vector2(100, 350), Vector2(100, 20), mapsListbox)); - - guiState->removeButton(this); - */ } } diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 969547c..af4158d 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -1,7 +1,5 @@ #include "mapEditorAppState.h" #include "gameManager.h" -#include "stateManager.h" -#include "guiAppState.h" #include "defConfigs.h" #include "cameraController.h" #include "unitFrameController.h" @@ -12,6 +10,7 @@ #include #include +#include #include #include #include @@ -23,11 +22,10 @@ #include #include +#include #include -#include - namespace battleship{ using namespace tinyxml2; using namespace configData; @@ -180,99 +178,6 @@ namespace battleship{ prepareCellMarkers(map->getTerrainObject(0)); } - /* - void MapEditorAppState::MapEditor::prepareGui(){ - GameManager *gm = GameManager::getSingleton(); - StateManager *sm = gm->getStateManager(); - GuiAppState *state = (GuiAppState*)sm->getAppStateByType((int)AppStateType::GUI_STATE); - string fontPath = gm->getPath() + "Fonts/batang.ttf"; - - Vector2 startPos = Vector2((float)gm->getWidth() / 16, gm->getHeight() - guiThreshold); - Vector2 size = Vector2(140, 20), offset = Vector2(size.x + 10, 0); - - class ExportButton : public Button{ - public: - ExportButton(Vector2 pos, Vector2 size) : Button(pos, size, "Export", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){} - void onClick(){ - StateManager *sm = GameManager::getSingleton()->getStateManager(); - MapEditor *mapEditor = ((MapEditorAppState*)sm->getAppStateByType((int)AppStateType::MAP_EDITOR))->getMapEditor(); - mapEditor->exportMap(); - } - }; - - state->addButton(new ExportButton(startPos, size)); - - int maxDisplay = 2; - - vector vehicles, structures; - - LuaManager *lm = LuaManager::getSingleton(); - int numUnits = lm->getInt("numUnits"); - - for(int i = 0; i < numUnits; i++){ - bool vehicle = lm->getBoolFromTable("isVehicle", vector{Index(i + 1)}); - string name = lm->getStringFromTable("name", vector{Index(i + 1)}); - (vehicle ? vehicles : structures).push_back(name); - } - - vehicleListbox = new UnitListbox(0, startPos + offset, size, vehicles, maxDisplay, fontPath); - state->addListbox(vehicleListbox); - - structureListbox = new UnitListbox(3, startPos + 2 * offset, size, structures, (structures.size() > maxDisplay ? maxDisplay : structures.size()), fontPath); - state->addListbox(structureListbox); - - class SkyboxListbox : public Listbox{ - public: - SkyboxListbox(Vector2 pos, Vector2 size, vector lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath){} - - void onClose(){ - Root *root = Root::getSingleton(); - StateManager *sm = GameManager::getSingleton()->getStateManager(); - MapEditor *mapEditor = ((MapEditorAppState*)sm->getAppStateByType((int)AppStateType::MAP_EDITOR))->getMapEditor(); - Texture *skyTexture = mapEditor->getSkyTexture(selectedOption); - - if(!root->getSkybox()) - root->createSkybox(skyTexture); - else - root->getSkybox()->getMaterial()->setTexUniform("tex", skyTexture, true); - } - private: - }; - - vector skyboxFolders = readDir(gm->getPath() + "Textures/Skyboxes", true); - skyListbox = new SkyboxListbox(startPos + 3 * offset, size, skyboxFolders, (skyboxFolders.size() > maxDisplay ? maxDisplay : skyboxFolders.size()), fontPath); - state->addListbox(skyListbox); - - class LandTexListbox : public Listbox{ - public: - LandTexListbox(Vector2 pos, Vector2 size, vector lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath){} - - void onClose(){ - StateManager *sm = GameManager::getSingleton()->getStateManager(); - MapEditor *mapEditor = ((MapEditorAppState*)sm->getAppStateByType((int)AppStateType::MAP_EDITOR))->getMapEditor(); - - Map *map = Map::getSingleton(); - Material *mat = map->getTerrainObject(0).node->getMesh(0)->getMaterial(); - Material::BoolUniform *texturingUniform = (Material::BoolUniform*)mat->getUniform("texturingEnabled"); - Texture *landTex = mapEditor->getLandmassTexture(selectedOption); - string texUni = "textures[0]"; - - if(!texturingUniform->value){ - texturingUniform->value = true; - mat->addTexUniform(texUni, landTex, false); - } - else - mat->setTexUniform(texUni, landTex, false); - } - private: - }; - - vector landTextures = readDir(gm->getPath() + "Textures/Landmass", false); - LandTexListbox *landTexListbox = new LandTexListbox(startPos + 4 * offset, size, landTextures, (landTextures.size() > maxDisplay ? maxDisplay : landTextures.size()), fontPath); - state->addListbox(landTexListbox); - } - */ - void MapEditorAppState::MapEditor::prepareTextures(string basePath, bool skybox, vector &textures){ AssetManager *assetManager = AssetManager::getSingleton(); assetManager->load(basePath, skybox); diff --git a/mapEditorButton.cpp b/mapEditorButton.cpp index ed810a3..2e7ef4e 100644 --- a/mapEditorButton.cpp +++ b/mapEditorButton.cpp @@ -1,32 +1,8 @@ #include "mapEditorButton.h" -#include "guiAppState.h" -#include "inGameAppState.h" -#include "mapEditorAppState.h" #include "concreteGuiManager.h" -#include - namespace battleship{ - using namespace std; - using namespace vb01; - using namespace vb01Gui; - using namespace gameBase; - void MapEditorButton::onClick(){ ConcreteGuiManager::getSingleton()->readLuaScreenScript("mapEditorMenu.lua"); - /* - GameManager *gm = GameManager::getSingleton(); - GuiAppState *guiState = (GuiAppState*)gm->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE); - guiState->removeAllButtons(vector{this}); - - int width = gm->getWidth(), height = gm->getHeight(); - Vector2 size = Vector2(150, 40); - - NewMapButton *newMapButton = new NewMapButton(Vector2(width / 16, height / 12), size); - LoadMapButton *loadMapButton = new LoadMapButton(Vector2(width / 16, height / 12 * 2), size); - guiState->addButton(newMapButton); - guiState->addButton(loadMapButton); - guiState->removeButton(this); - */ } } diff --git a/newMapButton.cpp b/newMapButton.cpp index a6459ad..602a21e 100644 --- a/newMapButton.cpp +++ b/newMapButton.cpp @@ -29,49 +29,12 @@ namespace battleship{ stateManager->attachAppState(new MapEditorAppState(wstringToString(name->getText()), size, true)); ConcreteGuiManager::getSingleton()->readLuaScreenScript("mapEditor.lua"); - /* - GameManager *gm = GameManager::getSingleton(); - StateManager *stateManager = gm->getStateManager(); - GuiAppState *state = (GuiAppState*)stateManager->getAppStateByType((int)AppStateType::GUI_STATE); - - state->removeAllTextboxes(); - state->removeAllButtons(vector{this}); - - Vector2 size = Vector2( - atof(wstringToString(sizeX->getText()).c_str()), - atof(wstringToString(sizeY->getText()).c_str()) - ); - stateManager->attachAppState(new MapEditorAppState(wstringToString(name->getText()), size, true)); - - state->removeButton(this); - */ } NewMapButton::NewMapButton(Vector2 pos, Vector2 size) : Button(pos, size, "New map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){} void NewMapButton::onClick(){ ConcreteGuiManager::getSingleton()->readLuaScreenScript("newMap.lua"); - /* - - GameManager *gm = GameManager::getSingleton(); - StateManager *stateManager = gm->getStateManager(); - GuiAppState *state = (GuiAppState*)stateManager->getAppStateByType((int)AppStateType::GUI_STATE); - state->removeAllButtons(vector{this}); - - Vector2 size = Vector2(140, 20); - - string fontPath = gm->getPath() + "Fonts/batang.ttf"; - Textbox *name = new Textbox(Vector2(100, 150), size, fontPath); - Textbox *sizeX = new Textbox(Vector2(100, 150 + (size.y + 10)), size, fontPath); - Textbox *sizeY = new Textbox(Vector2(100, 150 + 2 * (size.y + 10)), size, fontPath); - state->addTextbox(name); - state->addTextbox(sizeX); - state->addTextbox(sizeY); - - state->addButton(new OkButton(Vector2(200, gm->getHeight() - 150), Vector2(140, 50), name, sizeX, sizeY)); - - state->removeButton(this); - */ } } diff --git a/optionsButton.cpp b/optionsButton.cpp index ae1154d..50a2264 100755 --- a/optionsButton.cpp +++ b/optionsButton.cpp @@ -1,153 +1,15 @@ #include "optionsButton.h" -#include "util.h" -#include "defConfigs.h" #include "gameManager.h" #include "concreteGuiManager.h" -#include - using namespace vb01Gui; using namespace vb01; using namespace std; namespace battleship{ - using namespace configData; - - /* - OptionsButton::ControlsTab::ControlsTab() : TabButton( - Vector2(GameManager::getSingleton()->getWidth() / 4, GameManager::getSingleton()->getHeight() / 10), - Vector2(100, 50), - "Controls" - ) {} - - void OptionsButton::ControlsTab::onClick() { - TabButton::onClick(); - std::vector lines; - string path = GameManager::getSingleton()->getPath(); - readFile(path + "../options.cfg", lines); - - GameManager *gm = GameManager::getSingleton(); - Listbox *listbox = new Listbox(Vector2(gm->getWidth() / 4, gm->getHeight() / 10), Vector2(360, 20), lines, lines.size() < 5 ? lines.size() : 5, path + "Fonts/batang.ttf"); - - state->addListbox(listbox); - state->removeButton("Mouse"); - state->removeButton("Video"); - state->removeButton("Audio"); - state->removeButton("Multiplayer"); - state->removeButton("Controls"); - } - - OptionsButton::MouseTab::MouseTab() : TabButton( - Vector2(GameManager::getSingleton()->getWidth() / 4, GameManager::getSingleton()->getHeight() / 10 + 60), - Vector2(100, 50), - "Mouse" - ) {} - - void OptionsButton::MouseTab::onClick() { - TabButton::onClick(); - - GameManager *gm = GameManager::getSingleton(); - Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 4); - - string font = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; - Slider *mouseSensitivitySlider = new Slider(Vector2(pos.x, pos.y), Vector2(300, 10), .1, 3.); - Textbox *mouseSensitivityTextbox = new Textbox(Vector2(pos.x + 320, pos.y - 10), Vector2(100, 20), font); - Checkbox *reverseMouseCheckbox = new Checkbox(Vector2(pos.x, pos.y + 50), font); - - state->addTextbox(mouseSensitivityTextbox); - state->addSlider(mouseSensitivitySlider); - state->addCheckbox(reverseMouseCheckbox); - state->removeButton("Controls"); - state->removeButton("Video"); - state->removeButton("Audio"); - state->removeButton("Multiplayer"); - state->removeButton("Mouse"); - } - - OptionsButton::VideoTab::VideoTab() : TabButton(Vector2(GameManager::getSingleton()->getWidth() / 4, GameManager::getSingleton()->getHeight() / 10 + 120), Vector2(100, 50), "Video") {} - void OptionsButton::VideoTab::onClick() { - TabButton::onClick(); - std::vector lines; - - for (int i = 0; i < 10; i++) { - string s; - s += to_string(i); - lines.push_back(s); - } - - GameManager *gm = GameManager::getSingleton(); - string font = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; - Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 8); - Listbox *resolutionsListbox = new Listbox(Vector2(pos.x, pos.y), Vector2(100, 20), lines, 5, font); - - Checkbox *fullscreenCheckbox = new Checkbox(Vector2(pos.x, pos.y + 30), font); - Checkbox *vsyncCheckbox = new Checkbox(Vector2(pos.x, pos.y + 50), font); - Checkbox *normalMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 70), font); - Checkbox *parallaxMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 90), font); - Checkbox *specularMapCheckbox = new Checkbox(Vector2(pos.x, pos.y + 110), font); - - state->addListbox(resolutionsListbox); - state->addCheckbox(fullscreenCheckbox); - state->addCheckbox(vsyncCheckbox); - state->addCheckbox(normalMapCheckbox); - state->addCheckbox(parallaxMapCheckbox); - state->addCheckbox(specularMapCheckbox); - - state->removeButton("Controls"); - state->removeButton("Mouse"); - state->removeButton("Audio"); - state->removeButton("Multiplayer"); - state->removeButton("Video"); - } - - OptionsButton::AudioTab::AudioTab() : TabButton(Vector2(GameManager::getSingleton()->getWidth() / 4, GameManager::getSingleton()->getHeight() / 10 + 180), Vector2(100, 50), "Audio") {} - void OptionsButton::AudioTab::onClick() { - TabButton::onClick(); - GameManager *gm = GameManager::getSingleton(); - Vector2 pos(gm->getWidth() / 3, gm->getHeight() / 8); - Slider *volumeSlider = new Slider(Vector2(pos.x, pos.y), Vector2(300, 10), 0., 2.); - Textbox *volumeTextbox = new Textbox(Vector2(pos.x + 320, pos.y), Vector2(100, 20), GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"); - volumeSlider->setTextbox(volumeTextbox); - volumeTextbox->setSlider(volumeSlider); - state->addTextbox(volumeTextbox); - state->addSlider(volumeSlider); - state->removeButton("Controls"); - state->removeButton("Mouse"); - state->removeButton("Video"); - state->removeButton("Multiplayer"); - state->removeButton("Audio"); - } - - OptionsButton::MultiplayerTab::MultiplayerTab() : TabButton(Vector2(GameManager::getSingleton()->getWidth() / 4, GameManager::getSingleton()->getHeight() / 10 + 240), Vector2(100, 50), "Multiplayer") {} - void OptionsButton::MultiplayerTab::onClick() { - TabButton::onClick(); - GameManager *gm = GameManager::getSingleton(); - string font = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; - Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 6); - Textbox *tcpTextbox = new Textbox(Vector2(pos.x, pos.y), Vector2(100, 20), font); - Textbox *udpTextbox = new Textbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), font); - Textbox *playerNameTextbox = new Textbox(Vector2(pos.x, pos.y + 60), Vector2(100, 20), font); - - state->addTextbox(tcpTextbox); - state->addTextbox(udpTextbox); - state->addTextbox(playerNameTextbox); - state->removeButton("Controls"); - state->removeButton("Mouse"); - state->removeButton("Video"); - state->removeButton("Audio"); - state->removeButton("Multiplayer"); - } - - */ OptionsButton::OptionsButton(Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {} void OptionsButton::onClick() { - ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); - guiManager->removeAllButtons(); - guiManager->removeAllListboxes(); - guiManager->removeAllCheckboxes(); - guiManager->removeAllSliders(); - guiManager->removeAllTextboxes(); - guiManager->readLuaScreenScript("options.lua"); + ConcreteGuiManager::getSingleton()->readLuaScreenScript("options.lua"); } } diff --git a/optionsButton.h b/optionsButton.h index d389c86..7a68c5f 100755 --- a/optionsButton.h +++ b/optionsButton.h @@ -4,9 +4,6 @@ #include -#include "guiAppState.h" -#include "gameManager.h" - namespace battleship { class OptionsButton : public vb01Gui::Button { public: diff --git a/singlePlayerButton.cpp b/singlePlayerButton.cpp index f5acb85..1d36885 100644 --- a/singlePlayerButton.cpp +++ b/singlePlayerButton.cpp @@ -1,20 +1,13 @@ #include "singlePlayerButton.h" #include "gameManager.h" -#include "inGameAppState.h" #include "concreteGuiManager.h" -#include - -#include -#include - #include namespace battleship{ - using namespace gameBase; + using namespace std; using namespace vb01; using namespace vb01Gui; - using namespace std; SinglePlayerButton::SinglePlayerButton(Vector2 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_S, true) {} @@ -27,69 +20,6 @@ namespace battleship{ } void SinglePlayerButton::onClick() { - vector difficulties, factions; - - - /* - - class ReturnButton : public Button { - public: - - ReturnButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_B, separate) { - this->state = state; - } - - void onClick() { - state->removeAllCheckboxes(); - state->removeAllListboxes(); - state->removeAllSliders(); - state->removeAllTextboxes(); - makeTitlescreenButtons(state); - state->removeButton("Play"); - state->removeButton("Back"); - } - private: - GuiAppState *state; - }; - - GameManager *gm = GameManager::getSingleton(); - Vector2 pos(gm->getWidth() / 8, gm->getHeight() / 8); - difficulties.push_back("Easy"); - difficulties.push_back("Medium"); - difficulties.push_back("Hard"); - factions.push_back("0"); - factions.push_back("1"); - - - string font = gm->getPath() + "Fonts/batang.ttf"; - Listbox *cpuDifficulty = new Listbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), difficulties, 3, font); - Listbox *cpuFaction = new Listbox(Vector2(pos.x + 110, pos.y + 30), Vector2(100, 20), factions, 2, font); - Listbox *playerFaction = new Listbox(Vector2(pos.x + 110, pos.y), Vector2(100, 20), factions, 2, font); - - vector folders = readDir(gm->getPath() + "Models/Maps", true); - int numMinDirs = 3; - int numShowDirs = folders.size() < numMinDirs ? folders.size() : numMinDirs; - Listbox *map = new Listbox(Vector2(pos.x + 110, pos.y + 100), Vector2(100, 20), folders, numShowDirs, font); - Listbox **difficultyListboxes = new Listbox*[1]; - Listbox **factionListboxes = new Listbox*[2]; - - difficultyListboxes[0] = cpuDifficulty; - factionListboxes[0] = playerFaction; - factionListboxes[1] = cpuFaction; - - int lengths[]{1, 2}; - PlayButton *playButton = new PlayButton(difficultyListboxes, factionListboxes, map, lengths, Vector2(50, gm->getHeight() - 150), Vector2(140, 50), "Play", true); - ReturnButton *returnButton = new ReturnButton(state, Vector2(200, gm->getHeight() - 150), Vector2(140, 50), "Back", true); - state->addButton(playButton); - state->addButton(returnButton); - state->addListbox(cpuDifficulty); - state->addListbox(cpuFaction); - state->addListbox(playerFaction); - state->addListbox(map); - state->removeButton("Options"); - state->removeButton("Exit"); - state->removeButton("Singleplayer"); - */ ConcreteGuiManager::getSingleton()->readLuaScreenScript("singlePlayerMenu.lua"); } } diff --git a/tabButton.cpp b/tabButton.cpp index 98adba8..23bf546 100644 --- a/tabButton.cpp +++ b/tabButton.cpp @@ -12,15 +12,6 @@ namespace battleship{ } void TabButton::onClick() { - ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); - guiManager->removeAllButtons(vector{this}); - guiManager->removeAllListboxes(); - guiManager->removeAllCheckboxes(); - guiManager->removeAllSliders(); - guiManager->removeAllTextboxes(); - - guiManager->readLuaScreenScript(screenScript); - - guiManager->removeButton(this); + ConcreteGuiManager::getSingleton()->readLuaScreenScript(screenScript); } }