mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
code cleanup
This commit is contained in:
+8
-111
@@ -35,119 +35,16 @@ namespace battleship{
|
||||
|
||||
void InGameAppState::ConsoleButton::onClick() {
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("console.lua");
|
||||
/*
|
||||
vector<string> 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<string> difficultyLevels, vector<string> 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);
|
||||
}
|
||||
|
||||
@@ -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<std::string> difficultyLevels, factions, modelPaths;
|
||||
std::vector<Projectile*> 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;}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Button*>{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<Button*>{this});
|
||||
|
||||
string basePath = gm->getPath();
|
||||
vector<string> 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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
+2
-97
@@ -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 <ray.h>
|
||||
#include <box.h>
|
||||
#include <text.h>
|
||||
#include <node.h>
|
||||
#include <quad.h>
|
||||
#include <model.h>
|
||||
@@ -23,11 +22,10 @@
|
||||
#include <listbox.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
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<string> 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>{Index(i + 1)});
|
||||
string name = lm->getStringFromTable("name", vector<Index>{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<string> 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<string> 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<string> 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<string> 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<Texture*> &textures){
|
||||
AssetManager *assetManager = AssetManager::getSingleton();
|
||||
assetManager->load(basePath, skybox);
|
||||
|
||||
@@ -1,32 +1,8 @@
|
||||
#include "mapEditorButton.h"
|
||||
#include "guiAppState.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "mapEditorAppState.h"
|
||||
#include "concreteGuiManager.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
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<Button*>{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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Button*>{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<Button*>{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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-139
@@ -1,153 +1,15 @@
|
||||
#include "optionsButton.h"
|
||||
#include "util.h"
|
||||
#include "defConfigs.h"
|
||||
#include "gameManager.h"
|
||||
#include "concreteGuiManager.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
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<string> 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<string> 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
#include <button.h>
|
||||
|
||||
#include "guiAppState.h"
|
||||
#include "gameManager.h"
|
||||
|
||||
namespace battleship {
|
||||
class OptionsButton : public vb01Gui::Button {
|
||||
public:
|
||||
|
||||
+1
-71
@@ -1,20 +1,13 @@
|
||||
#include "singlePlayerButton.h"
|
||||
#include "gameManager.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "concreteGuiManager.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <listbox.h>
|
||||
|
||||
#include <glfw3.h>
|
||||
|
||||
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<string> 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<string> 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");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-10
@@ -12,15 +12,6 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void TabButton::onClick() {
|
||||
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
|
||||
guiManager->removeAllButtons(vector<Button*>{this});
|
||||
guiManager->removeAllListboxes();
|
||||
guiManager->removeAllCheckboxes();
|
||||
guiManager->removeAllSliders();
|
||||
guiManager->removeAllTextboxes();
|
||||
|
||||
guiManager->readLuaScreenScript(screenScript);
|
||||
|
||||
guiManager->removeButton(this);
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript(screenScript);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user