mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
using base path value from Lua script
This commit is contained in:
+1
-1
@@ -37,7 +37,7 @@ namespace battleship{
|
|||||||
AppStateType::ACTIVE_STATE,
|
AppStateType::ACTIVE_STATE,
|
||||||
configData::calcSumBinds(AppStateType::ACTIVE_STATE, true),
|
configData::calcSumBinds(AppStateType::ACTIVE_STATE, true),
|
||||||
configData::calcSumBinds(AppStateType::ACTIVE_STATE, false),
|
configData::calcSumBinds(AppStateType::ACTIVE_STATE, false),
|
||||||
PATH + "Scripts/options.lua"){
|
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
|
||||||
this->guiState = guiState;
|
this->guiState = guiState;
|
||||||
this->map = map;
|
this->map = map;
|
||||||
this->players = players;
|
this->players = players;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
basePath=$(pwd)
|
||||||
|
file="Assets/Scripts/defPaths.lua"
|
||||||
|
touch $file
|
||||||
|
echo "PATH = \"$basePath/Assets/\"" > $file
|
||||||
|
|
||||||
cd external
|
cd external
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -7,13 +7,13 @@
|
|||||||
#include <mapping.h>
|
#include <mapping.h>
|
||||||
|
|
||||||
#include "binds.h"
|
#include "binds.h"
|
||||||
|
#include "gameManager.h"
|
||||||
|
|
||||||
namespace battleship{
|
namespace battleship{
|
||||||
namespace configData{
|
namespace configData{
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
const std::string PATH = "/home/dominykas/c++/Battleship/Assets/";
|
const std::string DEFAULT_TEXTURE = GameManager::getSingleton()->getPath() + "Textures/defaultTexture.jpg";
|
||||||
const std::string DEFAULT_TEXTURE = PATH + "Textures/defaultTexture.jpg";
|
|
||||||
const double camPanSpeed = .1;
|
const double camPanSpeed = .1;
|
||||||
|
|
||||||
const static int numAppStates = 3;
|
const static int numAppStates = 3;
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ using namespace std;
|
|||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
|
|
||||||
namespace battleship{
|
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() {
|
void ExitButton::onClick() {
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ namespace battleship{
|
|||||||
void detonate(InGameAppState *inGameState, Vector3 pos, Vector3 dir){
|
void detonate(InGameAppState *inGameState, Vector3 pos, Vector3 dir){
|
||||||
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
||||||
sf::Sound *sfx = nullptr;
|
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())){
|
if(sfxBuffer->loadFromFile(p.c_str())){
|
||||||
sfx = new sf::Sound(*sfxBuffer);
|
sfx = new sf::Sound(*sfxBuffer);
|
||||||
@@ -30,7 +30,7 @@ namespace battleship{
|
|||||||
void detonateDepthCharge(InGameAppState *inGameState, Vector3){
|
void detonateDepthCharge(InGameAppState *inGameState, Vector3){
|
||||||
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
||||||
sf::Sound *sfx = nullptr;
|
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())){
|
if(sfxBuffer->loadFromFile(p.c_str())){
|
||||||
sfx = new sf::Sound(*sfxBuffer);
|
sfx = new sf::Sound(*sfxBuffer);
|
||||||
@@ -47,7 +47,7 @@ namespace battleship{
|
|||||||
void detonateTorpedo(InGameAppState *inGameState, Vector3){
|
void detonateTorpedo(InGameAppState *inGameState, Vector3){
|
||||||
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
sf::SoundBuffer *sfxBuffer = new sf::SoundBuffer();
|
||||||
sf::Sound *sfx = nullptr;
|
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())){
|
if(sfxBuffer->loadFromFile(p.c_str())){
|
||||||
sfx = new sf::Sound(*sfxBuffer);
|
sfx = new sf::Sound(*sfxBuffer);
|
||||||
|
|||||||
+6
-2
@@ -1,11 +1,12 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <root.h>
|
|
||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
#include <inputManager.h>
|
#include <inputManager.h>
|
||||||
|
|
||||||
#include <assetManager.h>
|
#include <assetManager.h>
|
||||||
|
#include <root.h>
|
||||||
|
|
||||||
|
#include <luaManager.h>
|
||||||
|
|
||||||
#include "gameManager.h"
|
#include "gameManager.h"
|
||||||
#include "guiAppState.h"
|
#include "guiAppState.h"
|
||||||
@@ -25,6 +26,9 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameManager::GameManager() {
|
GameManager::GameManager() {
|
||||||
|
LuaManager *luaManager = LuaManager::getSingleton();
|
||||||
|
luaManager->buildScript(vector<string>{"../Assets/Scripts/defPaths.lua"});
|
||||||
|
path = luaManager->getString("PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
GameManager::~GameManager() {}
|
GameManager::~GameManager() {}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace battleship{
|
|||||||
void update();
|
void update();
|
||||||
inline int getWidth(){return width;}
|
inline int getWidth(){return width;}
|
||||||
inline int getHeight(){return height;}
|
inline int getHeight(){return height;}
|
||||||
|
inline std::string getPath(){return path;}
|
||||||
inline gameBase::InputManager* getInputManager(){return inputManager;}
|
inline gameBase::InputManager* getInputManager(){return inputManager;}
|
||||||
inline bool isServerSide(){return serverSide;}
|
inline bool isServerSide(){return serverSide;}
|
||||||
inline gameBase::StateManager* getStateManager(){return stateManager;}
|
inline gameBase::StateManager* getStateManager(){return stateManager;}
|
||||||
@@ -33,6 +34,7 @@ namespace battleship{
|
|||||||
gameBase::StateManager *stateManager = nullptr;
|
gameBase::StateManager *stateManager = nullptr;
|
||||||
gameBase::InputManager *inputManager = nullptr;
|
gameBase::InputManager *inputManager = nullptr;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
std::string path = "";
|
||||||
bool serverSide;
|
bool serverSide;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ namespace battleship{
|
|||||||
AppStateType::GUI_STATE,
|
AppStateType::GUI_STATE,
|
||||||
configData::calcSumBinds(AppStateType::GUI_STATE, true),
|
configData::calcSumBinds(AppStateType::GUI_STATE, true),
|
||||||
configData::calcSumBinds(AppStateType::GUI_STATE, false),
|
configData::calcSumBinds(AppStateType::GUI_STATE, false),
|
||||||
PATH + "Scripts/options.lua"){
|
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiAppState::~GuiAppState() {}
|
GuiAppState::~GuiAppState() {}
|
||||||
|
|||||||
+9
-9
@@ -19,7 +19,7 @@ using namespace std;
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
using namespace configData;
|
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->guiState = guiState;
|
||||||
this->inGameState = inGameState;
|
this->inGameState = inGameState;
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace battleship{
|
|||||||
return guiState;
|
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->guiState = guiState;
|
||||||
this->inGameState = inGameState;
|
this->inGameState = inGameState;
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace battleship{
|
|||||||
class ConsoleCommandEntryButton : public Button {
|
class ConsoleCommandEntryButton : public Button {
|
||||||
public:
|
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;
|
this->inGameState = inGameState;
|
||||||
textbox = t;
|
textbox = t;
|
||||||
listbox = l;
|
listbox = l;
|
||||||
@@ -64,16 +64,16 @@ namespace battleship{
|
|||||||
list.push_back("");
|
list.push_back("");
|
||||||
|
|
||||||
Vector2 pos = Vector2(300, 100);
|
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();
|
consoleListbox->openUp();
|
||||||
guiState->addListbox(consoleListbox);
|
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);
|
guiState->addTextbox(consoleTextbox);
|
||||||
ConsoleCommandEntryButton *entryButton = new ConsoleCommandEntryButton(inGameState, consoleTextbox, consoleListbox, Vector2(pos.x + 320, pos.y + 20 * (emptyEntries + 1)), Vector2(100, 20), "Enter", true);
|
ConsoleCommandEntryButton *entryButton = new ConsoleCommandEntryButton(inGameState, consoleTextbox, consoleListbox, Vector2(pos.x + 320, pos.y + 20 * (emptyEntries + 1)), Vector2(100, 20), "Enter", true);
|
||||||
guiState->addButton(entryButton);
|
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->guiState = guiState;
|
||||||
this->inGameState = inGameState;
|
this->inGameState = inGameState;
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ namespace battleship{
|
|||||||
OptionsButton::onClick();
|
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->guiState = guiState;
|
||||||
this->inGameState = inGameState;
|
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() {
|
void InGameAppState::UnitCreationButton::onClick() {
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ namespace battleship{
|
|||||||
AppStateType::IN_GAME_STATE,
|
AppStateType::IN_GAME_STATE,
|
||||||
configData::calcSumBinds(AppStateType::IN_GAME_STATE, true),
|
configData::calcSumBinds(AppStateType::IN_GAME_STATE, true),
|
||||||
configData::calcSumBinds(AppStateType::IN_GAME_STATE, false),
|
configData::calcSumBinds(AppStateType::IN_GAME_STATE, false),
|
||||||
PATH + "Scripts/options.lua"){
|
GameManager::getSingleton()->getPath() + "Scripts/options.lua"){
|
||||||
this->playerId = 0;
|
this->playerId = 0;
|
||||||
this->difficultyLevels = difficultyLevels;
|
this->difficultyLevels = difficultyLevels;
|
||||||
this->factions = factions;
|
this->factions = factions;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace battleship{
|
|||||||
|
|
||||||
void Map::loadSkybox(LuaManager *luaManager){
|
void Map::loadSkybox(LuaManager *luaManager){
|
||||||
int numPaths = 6;
|
int numPaths = 6;
|
||||||
string table = "skybox", basePath = configData::PATH + "Models/Maps/" + mapName + "/";
|
string table = "skybox", basePath = GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/";
|
||||||
string path[] = {
|
string path[] = {
|
||||||
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("left", true)}),
|
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("left", true)}),
|
||||||
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("right", true)}),
|
basePath + luaManager->getStringFromTable(table, vector<Index>{Index("right", true)}),
|
||||||
@@ -50,7 +50,7 @@ namespace battleship{
|
|||||||
string albedoFile = luaManager->getString("albedoMap");
|
string albedoFile = luaManager->getString("albedoMap");
|
||||||
|
|
||||||
AssetManager *assetManager = AssetManager::getSingleton();
|
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 + terrainFile);
|
||||||
assetManager->load(basePath + albedoFile);
|
assetManager->load(basePath + albedoFile);
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ namespace battleship{
|
|||||||
mat->addBoolUniform("texturingEnabled", true);
|
mat->addBoolUniform("texturingEnabled", true);
|
||||||
mat->addBoolUniform("lightingEnabled", false);
|
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]);
|
AssetManager::getSingleton()->load(fr[0]);
|
||||||
Texture *t = new Texture(fr, 1, false);
|
Texture *t = new Texture(fr, 1, false);
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ namespace battleship{
|
|||||||
|
|
||||||
void Map::load() {
|
void Map::load() {
|
||||||
LuaManager *luaManager = LuaManager::getSingleton();
|
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);
|
loadSkybox(luaManager);
|
||||||
loadTerrain(luaManager);
|
loadTerrain(luaManager);
|
||||||
|
|||||||
+13
-11
@@ -1,6 +1,7 @@
|
|||||||
#include "optionsButton.h"
|
#include "optionsButton.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
|
#include "gameManager.h"
|
||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
|
|
||||||
@@ -11,21 +12,21 @@ using namespace std;
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
using namespace configData;
|
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));
|
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
|
||||||
}
|
}
|
||||||
void OptionsButton::OkButton::onClick() {
|
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));
|
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
|
||||||
}
|
}
|
||||||
void OptionsButton::DefaultsButton::onClick() {
|
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));
|
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
|
||||||
}
|
}
|
||||||
void OptionsButton::BackButton::onClick() {
|
void OptionsButton::BackButton::onClick() {
|
||||||
@@ -41,7 +42,7 @@ namespace battleship{
|
|||||||
state->removeButton("Back");
|
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));
|
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::GUI_STATE));
|
||||||
}
|
}
|
||||||
void OptionsButton::TabButton::onClick() {
|
void OptionsButton::TabButton::onClick() {
|
||||||
@@ -63,10 +64,11 @@ namespace battleship{
|
|||||||
void OptionsButton::ControlsTab::onClick() {
|
void OptionsButton::ControlsTab::onClick() {
|
||||||
TabButton::onClick();
|
TabButton::onClick();
|
||||||
std::vector<string> lines;
|
std::vector<string> lines;
|
||||||
readFile(PATH + "../options.cfg", lines);
|
string path = GameManager::getSingleton()->getPath();
|
||||||
|
readFile(path + "../options.cfg", lines);
|
||||||
|
|
||||||
GameManager *gm = GameManager::getSingleton();
|
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->addListbox(listbox);
|
||||||
state->removeButton("Mouse");
|
state->removeButton("Mouse");
|
||||||
@@ -88,7 +90,7 @@ namespace battleship{
|
|||||||
GameManager *gm = GameManager::getSingleton();
|
GameManager *gm = GameManager::getSingleton();
|
||||||
Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 4);
|
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.);
|
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);
|
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);
|
Checkbox *reverseMouseCheckbox = new Checkbox(Vector2(pos.x, pos.y + 50), font);
|
||||||
@@ -115,7 +117,7 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameManager *gm = GameManager::getSingleton();
|
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);
|
Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 8);
|
||||||
Listbox *resolutionsListbox = new Listbox(Vector2(pos.x, pos.y), Vector2(100, 20), lines, 5, font);
|
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();
|
GameManager *gm = GameManager::getSingleton();
|
||||||
Vector2 pos(gm->getWidth() / 3, gm->getHeight() / 8);
|
Vector2 pos(gm->getWidth() / 3, gm->getHeight() / 8);
|
||||||
Slider *volumeSlider = new Slider(Vector2(pos.x, pos.y), Vector2(300, 10), 0., 2.);
|
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);
|
volumeSlider->setTextbox(volumeTextbox);
|
||||||
volumeTextbox->setSlider(volumeSlider);
|
volumeTextbox->setSlider(volumeSlider);
|
||||||
state->addTextbox(volumeTextbox);
|
state->addTextbox(volumeTextbox);
|
||||||
@@ -161,7 +163,7 @@ namespace battleship{
|
|||||||
void OptionsButton::MultiplayerTab::onClick() {
|
void OptionsButton::MultiplayerTab::onClick() {
|
||||||
TabButton::onClick();
|
TabButton::onClick();
|
||||||
GameManager *gm = GameManager::getSingleton();
|
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);
|
Vector2 pos = Vector2(gm->getWidth() / 3, gm->getHeight() / 6);
|
||||||
Textbox *tcpTextbox = new Textbox(Vector2(pos.x, pos.y), Vector2(100, 20), font);
|
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 *udpTextbox = new Textbox(Vector2(pos.x, pos.y + 30), Vector2(100, 20), font);
|
||||||
@@ -177,7 +179,7 @@ namespace battleship{
|
|||||||
state->removeButton("Multiplayer");
|
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));
|
this->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::GUI_STATE));
|
||||||
}
|
}
|
||||||
void OptionsButton::onClick() {
|
void OptionsButton::onClick() {
|
||||||
|
|||||||
+2
-2
@@ -52,8 +52,8 @@ namespace battleship{
|
|||||||
float angle = dirVec.getAngleBetween(Vector3(0, 0, -1));
|
float angle = dirVec.getAngleBetween(Vector3(0, 0, -1));
|
||||||
angle = Quaternion(angle, upVec) * Vector3(0, 0, -1) == dirVec ? angle : -angle;
|
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 p1 = gm->getPath() + "Sounds/" + unitData::name[id] + "s/" + projectileData::name[id][weaponTypeId] + ".ogg";
|
||||||
string p2 = PATH + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
|
string p2 = gm->getPath() + "Sounds/Explosions/explosion03" + to_string(rand() % 4) + ".ogg";
|
||||||
this->shotSfxBuffer = new sf::SoundBuffer();
|
this->shotSfxBuffer = new sf::SoundBuffer();
|
||||||
this->explosionSfxBuffer=new sf::SoundBuffer();
|
this->explosionSfxBuffer=new sf::SoundBuffer();
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -229,16 +229,16 @@ namespace battleship{
|
|||||||
{"missile","missile"},
|
{"missile","missile"},
|
||||||
};
|
};
|
||||||
const std::string meshPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
|
const std::string meshPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
|
||||||
{PATH + "Models/Shell/shell.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x"},
|
||||||
{PATH + "Models/Shell/shell.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x"},
|
||||||
{PATH + "Models/Shell/shell.x", PATH + "Models/Depth charge/depthCharge.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Depth charge/depthCharge.x"},
|
||||||
{PATH + "Models/Shell/shell.x", PATH + "Models/Depth charge/depthCharge.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "Models/Depth charge/depthCharge.x"},
|
||||||
{PATH + "Models/Shell/shell.x", PATH + "Models/Guided missile/guidedMissile.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Shell/shell.x", GameManager::getSingleton()->getPath() + "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/Guided missile/guidedMissile.x"},
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{PATH + "Models/Torpedo/torpedo.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Torpedo/torpedo.x"},
|
||||||
{PATH + "Models/Jets/aam.x", PATH + "Models/Jets/awm.x"},
|
{GameManager::getSingleton()->getPath() + "Models/Jets/aam.x", GameManager::getSingleton()->getPath() + "Models/Jets/awm.x"},
|
||||||
};
|
};
|
||||||
const std::string diffuseMapTextPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
|
const std::string diffuseMapTextPath[unitData::numberOfUnits][numberOfTypesOfWeapons]{
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace battleship{
|
|||||||
placeUnit(pos);
|
placeUnit(pos);
|
||||||
|
|
||||||
selectionSfxBuffer = new sf::SoundBuffer();
|
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()))
|
if(selectionSfxBuffer->loadFromFile(p.c_str()))
|
||||||
selectionSfx = new sf::Sound(*selectionSfxBuffer);
|
selectionSfx = new sf::Sound(*selectionSfxBuffer);
|
||||||
|
|||||||
+6
-6
@@ -280,12 +280,12 @@ namespace battleship {
|
|||||||
"jet00.x", "jet01.x"
|
"jet00.x", "jet01.x"
|
||||||
};
|
};
|
||||||
const std::string basePath[numberOfUnits]{
|
const std::string basePath[numberOfUnits]{
|
||||||
PATH + "Models/Battleships/", PATH + "Models/Battleships/",
|
GameManager::getSingleton()->getPath() + "Models/Battleships/", GameManager::getSingleton()->getPath() + "Models/Battleships/",
|
||||||
PATH + "Models/Destroyers/", PATH + "Models/Destroyers/",
|
GameManager::getSingleton()->getPath() + "Models/Destroyers/", GameManager::getSingleton()->getPath() + "Models/Destroyers/",
|
||||||
PATH + "Models/Cruisers/", PATH + "Models/Cruisers/",
|
GameManager::getSingleton()->getPath() + "Models/Cruisers/", GameManager::getSingleton()->getPath() + "Models/Cruisers/",
|
||||||
PATH + "Models/Aircraft carriers/", PATH + "Models/Aircraft carriers/",
|
GameManager::getSingleton()->getPath() + "Models/Aircraft carriers/", GameManager::getSingleton()->getPath() + "Models/Aircraft carriers/",
|
||||||
PATH + "Models/Submarines/",
|
GameManager::getSingleton()->getPath() + "Models/Submarines/",
|
||||||
PATH + "Models/Jets/", PATH + "Models/Jets/"};
|
GameManager::getSingleton()->getPath() + "Models/Jets/", GameManager::getSingleton()->getPath() + "Models/Jets/"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -22,7 +22,8 @@ namespace battleship{
|
|||||||
|
|
||||||
UnitDataManager::UnitDataManager(){
|
UnitDataManager::UnitDataManager(){
|
||||||
LuaManager *luaManager = LuaManager::getSingleton();
|
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");
|
numUnits = luaManager->getInt("numUnits");
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace battleship{
|
|||||||
|
|
||||||
class SpButton : public Button {
|
class SpButton : public Button {
|
||||||
public:
|
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;
|
this->state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ namespace battleship{
|
|||||||
|
|
||||||
class PlayButton : public Button {
|
class PlayButton : public Button {
|
||||||
public:
|
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->state = ((GuiAppState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::GUI_STATE));
|
||||||
this->lengths[0] = lengths[0];
|
this->lengths[0] = lengths[0];
|
||||||
this->lengths[1] = lengths[1];
|
this->lengths[1] = lengths[1];
|
||||||
@@ -88,7 +88,7 @@ namespace battleship{
|
|||||||
class ReturnButton : public Button {
|
class ReturnButton : public Button {
|
||||||
public:
|
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;
|
this->state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,11 +114,10 @@ namespace battleship{
|
|||||||
factions.push_back("1");
|
factions.push_back("1");
|
||||||
|
|
||||||
tinydir_dir dir;
|
tinydir_dir dir;
|
||||||
int i;
|
tinydir_open_sorted(&dir, (gm->getPath() + "Models/Maps").c_str());
|
||||||
tinydir_open_sorted(&dir, (PATH + "Models/Maps").c_str());
|
|
||||||
vector<string> folders;
|
vector<string> folders;
|
||||||
|
|
||||||
for (i = 0; i < dir.n_files; i++) {
|
for (int i = 0; i < dir.n_files; i++) {
|
||||||
tinydir_file file;
|
tinydir_file file;
|
||||||
tinydir_readfile_n(&dir, &file, i);
|
tinydir_readfile_n(&dir, &file, i);
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ namespace battleship{
|
|||||||
|
|
||||||
tinydir_close(&dir);
|
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 *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 *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);
|
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 {
|
class ReturnButton : public Button {
|
||||||
public:
|
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;
|
this->state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +216,7 @@ namespace battleship{
|
|||||||
};
|
};
|
||||||
|
|
||||||
GameManager *gm = GameManager::getSingleton();
|
GameManager *gm = GameManager::getSingleton();
|
||||||
string font = PATH + "Fonts/batang.ttf";
|
string font = gm->getPath() + "Fonts/batang.ttf";
|
||||||
AssetManager::getSingleton()->load(font);
|
AssetManager::getSingleton()->load(font);
|
||||||
SpButton *spButton = new SpButton(state, Vector2(gm->getWidth() / 16, gm->getHeight() / 12), Vector2(150, 40), "Singleplayer", true);
|
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);
|
MainMenuOptionsButton *optionsButton = new MainMenuOptionsButton(state, Vector2(gm->getWidth() / 16, gm->getHeight() / 12 * 2), Vector2(150, 40), "Options", true);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace battleship {
|
|||||||
inline bool canFire(){return vb01::getTime() - lastShotTime > rateOfFire;}
|
inline bool canFire(){return vb01::getTime() - lastShotTime > rateOfFire;}
|
||||||
inline vb01::Node* getNode(){return node;}
|
inline vb01::Node* getNode(){return node;}
|
||||||
private:
|
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::Node *fxNode;
|
||||||
vb01::ParticleEmitter *emitter;
|
vb01::ParticleEmitter *emitter;
|
||||||
|
|||||||
Reference in New Issue
Block a user