Merge branch 'demo' into pathfinding

This commit is contained in:
devZoGok
2022-07-25 11:45:34 +03:00
18 changed files with 95 additions and 62 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ namespace battleship{
AppStateType::ACTIVE_STATE,
configData::calcSumBinds(AppStateType::ACTIVE_STATE, true),
configData::calcSumBinds(AppStateType::ACTIVE_STATE, false),
PATH + "Scripts/options.lua"){
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
this->guiState = guiState;
this->map = map;
this->players = players;
Executable
+25
View File
@@ -0,0 +1,25 @@
basePath=$(pwd)
file="Assets/Scripts/defPaths.lua"
touch $file
echo "PATH = \"$basePath/Assets/\"" > $file
cd external
git submodule update --init --recursive
deps=("gameBase" "vb01" "vb01Gui")
ind=${!deps[@]}
for i in $ind
do
cd ${deps[$i]}
git checkout develop
cd external
git submodule update --init --recursive
cd ../..
done
cd ..
buildDir="build"
cmake -S . -B $buildDir
cd $buildDir
make -j8
+2 -2
View File
@@ -7,13 +7,13 @@
#include <mapping.h>
#include "binds.h"
#include "gameManager.h"
namespace battleship{
namespace configData{
using namespace gameBase;
const std::string PATH = "/home/dominykas/c++/Battleship/Assets/";
const std::string DEFAULT_TEXTURE = PATH + "Textures/defaultTexture.jpg";
const std::string DEFAULT_TEXTURE = GameManager::getSingleton()->getPath() + "Textures/defaultTexture.jpg";
const double camPanSpeed = .1;
const static int numAppStates = 3;
+1 -1
View File
@@ -7,7 +7,7 @@ using namespace std;
using namespace vb01;
namespace battleship{
ExitButton::ExitButton(Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, configData::PATH + "Fonts/batang.ttf", -1, separate) {
ExitButton::ExitButton(Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {
}
void ExitButton::onClick() {
+3 -3
View File
@@ -13,7 +13,7 @@ namespace battleship{
void detonate(InGameAppState *inGameState, Vector3 pos, Vector3 dir){
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
sf::Sound *sfx = nullptr;
string p = PATH + "Sounds/Explosions/explosion0" + to_string(rand() % 4) + ".ogg";
string p = GameManager::getSingleton()->getPath() + "Sounds/Explosions/explosion0" + to_string(rand() % 4) + ".ogg";
if(sfxBuffer->loadFromFile(p.c_str())){
sfx = new sf::Sound(*sfxBuffer);
@@ -30,7 +30,7 @@ namespace battleship{
void detonateDepthCharge(InGameAppState *inGameState, Vector3){
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
sf::Sound *sfx = nullptr;
string p = PATH + "Sounds/Destroyers/depthCharge.ogg";
string p = GameManager::getSingleton()->getPath() + "Sounds/Destroyers/depthCharge.ogg";
if(sfxBuffer->loadFromFile(p.c_str())){
sfx = new sf::Sound(*sfxBuffer);
@@ -47,7 +47,7 @@ namespace battleship{
void detonateTorpedo(InGameAppState *inGameState, Vector3){
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
sf::Sound *sfx = nullptr;
string p = PATH + "Sounds/Submarines/torpedo.ogg";
string p = GameManager::getSingleton()->getPath() + "Sounds/Submarines/torpedo.ogg";
if(sfxBuffer->loadFromFile(p.c_str())){
sfx = new sf::Sound(*sfxBuffer);
+6 -2
View File
@@ -1,11 +1,12 @@
#include <algorithm>
#include <root.h>
#include <stateManager.h>
#include <inputManager.h>
#include <assetManager.h>
#include <root.h>
#include <luaManager.h>
#include "gameManager.h"
#include "guiAppState.h"
@@ -25,6 +26,9 @@ namespace battleship{
}
GameManager::GameManager() {
LuaManager *luaManager = LuaManager::getSingleton();
luaManager->buildScript(vector<string>{"../Assets/Scripts/defPaths.lua"});
path = luaManager->getString("PATH");
}
GameManager::~GameManager() {}
+2
View File
@@ -23,6 +23,7 @@ namespace battleship{
void update();
inline int getWidth(){return width;}
inline int getHeight(){return height;}
inline std::string getPath(){return path;}
inline gameBase::InputManager* getInputManager(){return inputManager;}
inline bool isServerSide(){return serverSide;}
inline gameBase::StateManager* getStateManager(){return stateManager;}
@@ -33,6 +34,7 @@ namespace battleship{
gameBase::StateManager *stateManager = nullptr;
gameBase::InputManager *inputManager = nullptr;
int width, height;
std::string path = "";
bool serverSide;
};
+1 -1
View File
@@ -19,7 +19,7 @@ namespace battleship{
AppStateType::GUI_STATE,
configData::calcSumBinds(AppStateType::GUI_STATE, true),
configData::calcSumBinds(AppStateType::GUI_STATE, false),
PATH + "Scripts/options.lua"){
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
}
GuiAppState::~GuiAppState() {}
+9 -9
View File
@@ -19,7 +19,7 @@ using namespace std;
namespace battleship{
using namespace configData;
InGameAppState::ResumeButton::ResumeButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
InGameAppState::ResumeButton::ResumeButton(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;
}
@@ -32,7 +32,7 @@ namespace battleship{
return guiState;
}
InGameAppState::ConsoleButton::ConsoleButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
InGameAppState::ConsoleButton::ConsoleButton(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;
}
@@ -42,7 +42,7 @@ namespace battleship{
class ConsoleCommandEntryButton : public Button {
public:
ConsoleCommandEntryButton(InGameAppState *inGameState, Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
ConsoleCommandEntryButton(InGameAppState *inGameState, Textbox *t, Listbox *l, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {
this->inGameState = inGameState;
textbox = t;
listbox = l;
@@ -64,16 +64,16 @@ namespace battleship{
list.push_back("");
Vector2 pos = Vector2(300, 100);
Listbox *consoleListbox = new Listbox(Vector2(pos.x, pos.y), Vector2(420, 20), list, 20, PATH + "Fonts/batang.ttf");
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), PATH + "Fonts/batang.ttf");
Textbox *consoleTextbox = new Textbox(Vector2(pos.x, pos.y + 20 * (emptyEntries + 1)), Vector2(300, 20), GameManager::getSingleton()->getPath() + "Fonts/batang.ttf");
guiState->addTextbox(consoleTextbox);
ConsoleCommandEntryButton *entryButton = new ConsoleCommandEntryButton(inGameState, consoleTextbox, consoleListbox, Vector2(pos.x + 320, pos.y + 20 * (emptyEntries + 1)), Vector2(100, 20), "Enter", true);
guiState->addButton(entryButton);
}
InGameAppState::InGameOptionsButton::ReturnButton::ReturnButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
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;
}
@@ -122,7 +122,7 @@ namespace battleship{
OptionsButton::onClick();
}
InGameAppState::MainMenuButton::MainMenuButton(GuiAppState *guiState, InGameAppState *inGameState, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
InGameAppState::MainMenuButton::MainMenuButton(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;
}
@@ -131,7 +131,7 @@ namespace battleship{
}
InGameAppState::UnitCreationButton::UnitCreationButton(string icon, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {}
InGameAppState::UnitCreationButton::UnitCreationButton(string icon, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {}
void InGameAppState::UnitCreationButton::onClick() {
}
@@ -179,7 +179,7 @@ namespace battleship{
AppStateType::IN_GAME_STATE,
configData::calcSumBinds(AppStateType::IN_GAME_STATE, true),
configData::calcSumBinds(AppStateType::IN_GAME_STATE, false),
PATH + "Scripts/options.lua"){
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
this->playerId = 0;
this->difficultyLevels = difficultyLevels;
this->factions = factions;
+4 -4
View File
@@ -29,7 +29,7 @@ namespace battleship{
void Map::loadSkybox(LuaManager *luaManager){
int numPaths = 6;
string table = "skybox", basePath = configData::PATH + "Models/Maps/" + mapName + "/";
string table = "skybox", basePath = GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/";
string path[] = {
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("left", true)}),
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("right", true)}),
@@ -50,7 +50,7 @@ namespace battleship{
string albedoFile = luaManager->getString("albedoMap");
AssetManager *assetManager = AssetManager::getSingleton();
string basePath = configData::PATH + "Models/Maps/" + mapName + "/";
string basePath = GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/";
assetManager->load(basePath + terrainFile);
assetManager->load(basePath + albedoFile);
@@ -82,7 +82,7 @@ namespace battleship{
mat->addBoolUniform("texturingEnabled", true);
mat->addBoolUniform("lightingEnabled", false);
string fr[]{PATH + "Models/Maps/" + mapName + "/" + luaManager->getStringFromTable(table, vector<Index>{Index("albedoMap", true)})};
string fr[]{GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/" + luaManager->getStringFromTable(table, vector<Index>{Index("albedoMap", true)})};
AssetManager::getSingleton()->load(fr[0]);
Texture *t = new Texture(fr, 1, false);
@@ -102,7 +102,7 @@ namespace battleship{
void Map::load() {
LuaManager *luaManager = LuaManager::getSingleton();
luaManager->buildScript(vector<string>{configData::PATH + "Models/Maps/" + mapName + "/" + mapName + ".lua"});
luaManager->buildScript(vector<string>{GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/" + mapName + ".lua"});
loadSkybox(luaManager);
loadTerrain(luaManager);
+13 -11
View File
@@ -1,6 +1,7 @@
#include "optionsButton.h"
#include "util.h"
#include "defConfigs.h"
#include "gameManager.h"
#include <stateManager.h>
@@ -11,21 +12,21 @@ using namespace std;
namespace battleship{
using namespace configData;
OptionsButton::OkButton::OkButton() : Button(Vector2(50, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Ok", PATH + "Fonts/batang.ttf", -1, true) {
OptionsButton::OkButton::OkButton() : Button(Vector2(50, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
}
void OptionsButton::OkButton::onClick() {
}
OptionsButton::DefaultsButton::DefaultsButton() : Button(Vector2(200, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Restore defaults", PATH + "Fonts/batang.ttf", -1, true) {
OptionsButton::DefaultsButton::DefaultsButton() : Button(Vector2(200, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Restore defaults", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
}
void OptionsButton::DefaultsButton::onClick() {
}
OptionsButton::BackButton::BackButton() : Button(Vector2(350, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Back", PATH + "Fonts/batang.ttf", -1, true) {
OptionsButton::BackButton::BackButton() : Button(Vector2(350, GameManager::getSingleton()->getHeight() - 150), Vector2(140, 50), "Back", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
}
void OptionsButton::BackButton::onClick() {
@@ -41,7 +42,7 @@ namespace battleship{
state->removeButton("Back");
}
OptionsButton::TabButton::TabButton(Vector2 pos, Vector2 size, string name) :Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, true) {
OptionsButton::TabButton::TabButton(Vector2 pos, Vector2 size, string name) :Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
}
void OptionsButton::TabButton::onClick() {
@@ -63,10 +64,11 @@ namespace battleship{
void OptionsButton::ControlsTab::onClick() {
TabButton::onClick();
std::vector<string> lines;
readFile(PATH + "../options.cfg", 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");
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");
@@ -88,7 +90,7 @@ namespace battleship{
GameManager *gm = GameManager::getSingleton();
Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 4);
string font = PATH + "Fonts/batang.ttf";
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);
@@ -115,7 +117,7 @@ namespace battleship{
}
GameManager *gm = GameManager::getSingleton();
string font = PATH + "Fonts/batang.ttf";
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);
@@ -145,7 +147,7 @@ namespace battleship{
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), PATH + "Fonts/batang.ttf");
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);
@@ -161,7 +163,7 @@ namespace battleship{
void OptionsButton::MultiplayerTab::onClick() {
TabButton::onClick();
GameManager *gm = GameManager::getSingleton();
string font = PATH + "Fonts/batang.ttf";
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);
@@ -177,7 +179,7 @@ namespace battleship{
state->removeButton("Multiplayer");
}
OptionsButton::OptionsButton(Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
OptionsButton::OptionsButton(Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::GUI_STATE));
}
void OptionsButton::onClick() {
+2 -2
View File
@@ -52,8 +52,8 @@ namespace battleship{
float angle = dirVec.getAngleBetween(Vector3(0, 0, -1));
angle = Quaternion(angle, upVec) * Vector3(0, 0, -1) == dirVec ? angle : -angle;
string p1 = PATH + "Sounds/" + unitData::name[id] + "s/" + projectileData::name[id][weaponTypeId] + ".ogg";
string p2 = PATH + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
string p1 = gm->getPath() + "Sounds/" + unitData::name[id] + "s/" + projectileData::name[id][weaponTypeId] + ".ogg";
string p2 = gm->getPath() + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
this->shotSfxBuffer = new sf::SoundBuffer();
this->explosionSfxBuffer=new sf::SoundBuffer();
+8 -8
View File
@@ -229,16 +229,16 @@ namespace battleship{
{"missile","missile"},
};
const std::string meshPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
{PATH + "Models/Shell/shell.x"},
{PATH + "Models/Shell/shell.x"},
{PATH + "Models/Shell/shell.x", PATH + "Models/Depth charge/depthCharge.x"},
{PATH + "Models/Shell/shell.x", PATH + "Models/Depth charge/depthCharge.x"},
{PATH + "Models/Shell/shell.x", PATH + "Models/Guided missile/guidedMissile.x"},
{PATH + "Models/Shell/shell.x", PATH + "Models/Guided missile/guidedMissile.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Depth charge/depthCharge.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Depth charge/depthCharge.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Guided missile/guidedMissile.x"},
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Guided missile/guidedMissile.x"},
{},
{},
{PATH + "Models/Torpedo/torpedo.x"},
{PATH + "Models/Jets/aam.x", PATH + "Models/Jets/awm.x"},
{GameManager::getSingleton()->getPath() + "Models/Torpedo/torpedo.x"},
{GameManager::getSingleton()->getPath() + "Models/Jets/aam.x", GameManager::getSingleton()->getPath() + "Models/Jets/awm.x"},
};
const std::string diffuseMapTextPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
{},
+1 -1
View File
@@ -50,7 +50,7 @@ namespace battleship{
placeUnit(pos);
selectionSfxBuffer = new sf::SoundBuffer();
string p = PATH + "Sounds/" + unitData::name[id] + "s/selection.ogg";
string p = GameManager::getSingleton()->getPath() + "Sounds/" + unitData::name[id] + "s/selection.ogg";
if(selectionSfxBuffer->loadFromFile(p.c_str()))
selectionSfx = new sf::Sound(*selectionSfxBuffer);
+6 -6
View File
@@ -280,12 +280,12 @@ namespace battleship {
"jet00.x", "jet01.x"
};
const std::string basePath[numberOfUnits]{
PATH + "Models/Battleships/", PATH + "Models/Battleships/",
PATH + "Models/Destroyers/", PATH + "Models/Destroyers/",
PATH + "Models/Cruisers/", PATH + "Models/Cruisers/",
PATH + "Models/Aircraft carriers/", PATH + "Models/Aircraft carriers/",
PATH + "Models/Submarines/",
PATH + "Models/Jets/", PATH + "Models/Jets/"};
GameManager::getSingleton()->getPath() + "Models/Battleships/", GameManager::getSingleton()->getPath() + "Models/Battleships/",
GameManager::getSingleton()->getPath() + "Models/Destroyers/", GameManager::getSingleton()->getPath() + "Models/Destroyers/",
GameManager::getSingleton()->getPath() + "Models/Cruisers/", GameManager::getSingleton()->getPath() + "Models/Cruisers/",
GameManager::getSingleton()->getPath() + "Models/Aircraft carriers/", GameManager::getSingleton()->getPath() + "Models/Aircraft carriers/",
GameManager::getSingleton()->getPath() + "Models/Submarines/",
GameManager::getSingleton()->getPath() + "Models/Jets/", GameManager::getSingleton()->getPath() + "Models/Jets/"};
}
}
+2 -1
View File
@@ -22,7 +22,8 @@ namespace battleship{
UnitDataManager::UnitDataManager(){
LuaManager *luaManager = LuaManager::getSingleton();
luaManager->buildScript(vector<string>{configData::PATH + "Scripts/defPaths.lua", configData::PATH + "Scripts/unitData.lua"});
string path = GameManager::getSingleton()->getPath();
luaManager->buildScript(vector<string>{path + "Scripts/defPaths.lua", path + "Scripts/unitData.lua"});
numUnits = luaManager->getInt("numUnits");
+8 -9
View File
@@ -30,7 +30,7 @@ namespace battleship{
class SpButton : public Button {
public:
SpButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", GLFW_KEY_S, separate) {
SpButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_S, separate) {
this->state = state;
}
@@ -47,7 +47,7 @@ namespace battleship{
class PlayButton : public Button {
public:
PlayButton(Listbox **difficulties, Listbox **factions, Listbox *mapListbox, int lengths[2], Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", GLFW_KEY_P, separate) {
PlayButton(Listbox **difficulties, Listbox **factions, Listbox *mapListbox, int lengths[2], Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_P, separate) {
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::GUI_STATE));
this->lengths[0] = lengths[0];
this->lengths[1] = lengths[1];
@@ -88,7 +88,7 @@ namespace battleship{
class ReturnButton : public Button {
public:
ReturnButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", GLFW_KEY_B, separate) {
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;
}
@@ -114,11 +114,10 @@ namespace battleship{
factions.push_back("1");
tinydir_dir dir;
int i;
tinydir_open_sorted(&dir, (PATH + "Models/Maps").c_str());
tinydir_open_sorted(&dir, (gm->getPath() + "Models/Maps").c_str());
vector<string> folders;
for (i = 0; i < dir.n_files; i++) {
for (int i = 0; i < dir.n_files; i++) {
tinydir_file file;
tinydir_readfile_n(&dir, &file, i);
@@ -128,7 +127,7 @@ namespace battleship{
tinydir_close(&dir);
string font = PATH + "Fonts/batang.ttf";
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);
@@ -188,7 +187,7 @@ namespace battleship{
class ReturnButton : public Button {
public:
ReturnButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, PATH + "Fonts/batang.ttf", -1, separate) {
ReturnButton(GuiAppState *state, Vector2 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {
this->state = state;
}
@@ -217,7 +216,7 @@ namespace battleship{
};
GameManager *gm = GameManager::getSingleton();
string font = PATH + "Fonts/batang.ttf";
string font = gm->getPath() + "Fonts/batang.ttf";
AssetManager::getSingleton()->load(font);
SpButton *spButton = new SpButton(state, Vector2(gm->getWidth() / 16, gm->getHeight() / 12), Vector2(150, 40), "Singleplayer", true);
MainMenuOptionsButton *optionsButton = new MainMenuOptionsButton(state, Vector2(gm->getWidth() / 16, gm->getHeight() / 12 * 2), Vector2(150, 40), "Options", true);
+1 -1
View File
@@ -41,7 +41,7 @@ namespace battleship {
inline bool canFire(){return vb01::getTime() - lastShotTime > rateOfFire;}
inline vb01::Node* getNode(){return node;}
private:
inline std::string getExplosionSfxPath(){return configData::PATH + "Sounds/Explosions/explosion0" + std::to_string(rand() % 4) + ".ogg";}
inline std::string getExplosionSfxPath(){return GameManager::getSingleton()->getPath() + "Sounds/Explosions/explosion0" + std::to_string(rand() % 4) + ".ogg";}
vb01::Node *fxNode;
vb01::ParticleEmitter *emitter;