mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
using main() arguments to set the game dir
This commit is contained in:
@@ -1 +0,0 @@
|
||||
PATH = "/home/dominykas/c++/Battleship/Assets/"
|
||||
+7
-7
@@ -17,7 +17,7 @@ namespace battleship{
|
||||
namespace configData{
|
||||
using namespace gameBase;
|
||||
|
||||
const std::string DEFAULT_TEXTURE = GameManager::getSingleton()->getPath() + "Textures/defaultTexture.jpg";
|
||||
const std::string DEFAULT_TEXTURE = "Textures/defaultTexture.jpg";
|
||||
const double camPanSpeed = .1, cellLength = 14, cellWidth = 14, cellDepth = 7;
|
||||
const int maxNumGroups = 10;
|
||||
const vb01::u32 IMPASS_NODE_VAL = 65535;
|
||||
@@ -29,13 +29,13 @@ namespace battleship{
|
||||
const static int maxConfBinds = 22;
|
||||
const static int numScripts = 5;
|
||||
|
||||
const static std::string scriptPathBase = GameManager::getSingleton()->getPath() + "Scripts/";
|
||||
const static std::string scriptPathBase = "Scripts/";
|
||||
const static std::vector<std::string> scripts = std::vector<std::string>{
|
||||
scriptPathBase + "options.lua",
|
||||
scriptPathBase + "unitData.lua",
|
||||
scriptPathBase + "vehicleData.lua",
|
||||
scriptPathBase + "structureData.lua",
|
||||
scriptPathBase + "player.lua"
|
||||
"Scripts/options.lua",
|
||||
"Scripts/unitData.lua",
|
||||
"Scripts/vehicleData.lua",
|
||||
"Scripts/structureData.lua",
|
||||
"Scripts/player.lua"
|
||||
};
|
||||
|
||||
const static Bind staticBinds[numAppStates][maxStaticBinds]{
|
||||
|
||||
+12
-12
@@ -26,26 +26,26 @@ namespace battleship{
|
||||
return gameManager;
|
||||
}
|
||||
|
||||
GameManager::GameManager() {
|
||||
LuaManager *luaManager = LuaManager::getSingleton();
|
||||
string pathBase = "../Assets/Scripts/";
|
||||
luaManager->buildScript(vector<string>{pathBase + "defPaths.lua"});
|
||||
path = luaManager->getString("PATH");
|
||||
}
|
||||
void GameManager::start(string gameDir) {
|
||||
path = gameDir + "Assets/";
|
||||
|
||||
GameManager::~GameManager() {}
|
||||
|
||||
void GameManager::start() {
|
||||
LuaManager *luaManager = LuaManager::getSingleton();
|
||||
luaManager->buildScript(vector<string>{path + "Scripts/main.lua"});
|
||||
luaManager->buildScript(configData::scripts);
|
||||
luaManager->executeCode("PATH = \"" + path + "\";");
|
||||
|
||||
vector<string> files = configData::scripts;
|
||||
files.emplace(files.begin(), "Scripts/main.lua");
|
||||
|
||||
for(string &f : files)
|
||||
f = path + f;
|
||||
|
||||
luaManager->buildScript(files);
|
||||
|
||||
string ind1 = "graphics", ind2 = "resolution";
|
||||
width = luaManager->getIntFromTable(ind1, vector<Index>{Index(ind2), Index("x")});
|
||||
height = luaManager->getIntFromTable(ind1, vector<Index>{Index(ind2), Index("y")});
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
root->start(width, height, "../../vb01/", "Battleship");
|
||||
root->start(width, height, path + "../external/vb01/", "Battleship");
|
||||
|
||||
stateManager = new StateManager();
|
||||
inputManager = new InputManager(stateManager, root->getWindow());
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ namespace battleship{
|
||||
class GameManager {
|
||||
public:
|
||||
static GameManager* getSingleton();
|
||||
void start();
|
||||
void start(std::string);
|
||||
void update();
|
||||
inline int getWidth(){return width;}
|
||||
inline int getHeight(){return height;}
|
||||
@@ -27,8 +27,8 @@ namespace battleship{
|
||||
inline bool isServerSide(){return serverSide;}
|
||||
inline gameBase::StateManager* getStateManager(){return stateManager;}
|
||||
private:
|
||||
GameManager();
|
||||
~GameManager();
|
||||
GameManager(){}
|
||||
~GameManager(){}
|
||||
|
||||
gameBase::StateManager *stateManager = nullptr;
|
||||
gameBase::InputManager *inputManager = nullptr;
|
||||
|
||||
@@ -7,12 +7,18 @@
|
||||
|
||||
#include <assetManager.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace battleship;
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int main(int argc, char **argv) {
|
||||
GameManager *gm = GameManager::getSingleton();
|
||||
gm->start();
|
||||
|
||||
string gamePath = string(argv[0]);
|
||||
gamePath = gamePath.substr(0, gamePath.find_last_of("/") + 1) + "../";
|
||||
gm->start(gamePath);
|
||||
gm->getStateManager()->attachAppState(new GuiAppState());
|
||||
|
||||
AssetManager::getSingleton()->load(gm->getPath() + "Fonts/batang.ttf");
|
||||
|
||||
Reference in New Issue
Block a user