diff --git a/activeGameState.cpp b/activeGameState.cpp index 8ef6eca..5c663d3 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -219,8 +219,6 @@ namespace battleship{ int numVerts = 3 * meshData.numTris; LuaManager *lm = LuaManager::getSingleton(); - string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{pathBase + "defPaths.lua", pathBase + "unitData.lua", pathBase + "structureData.lua"}); float maxUnevenness = lm->getFloat("maxUnevenness"); string table = "unitCornerPoints"; diff --git a/consoleCommand.cpp b/consoleCommand.cpp index c15ff98..f08ea35 100755 --- a/consoleCommand.cpp +++ b/consoleCommand.cpp @@ -63,8 +63,6 @@ namespace battleship{ int unitId = atoi(fullCommand[2].c_str()); LuaManager *lm = LuaManager::getSingleton(); - string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{pathBase + "defPaths.lua", pathBase + "unitData.lua"}); if(!(0 <= unitId && unitId <= lm->getInt("numUnits"))) return; @@ -78,7 +76,6 @@ namespace battleship{ Vehicle *vehicle = nullptr; LuaManager *luaManager = LuaManager::getSingleton(); - luaManager->buildScript(vector{gm->getPath() + "Scripts/unitData.lua"}); int unitClass = luaManager->getIntFromTable("unitClass", vector{Index(unitId + 1)}); switch((UnitClass)unitClass){ diff --git a/defConfigs.h b/defConfigs.h index 882f925..e94f1aa 100755 --- a/defConfigs.h +++ b/defConfigs.h @@ -2,6 +2,8 @@ #define DEF_CONFIGS_H #include +#include + #include #include @@ -22,6 +24,15 @@ namespace battleship{ const static int numConfBinds[numAppStates]{0, 1, 22}; const static int maxStaticBinds = 6; const static int maxConfBinds = 22; + const static int numScripts = 5; + + const static std::string scriptPathBase = GameManager::getSingleton()->getPath() + "Scripts/"; + const static std::vector scripts = std::vector{ + scriptPathBase + "options.lua", + scriptPathBase + "unitData.lua", + scriptPathBase + "vehicleData.lua", + scriptPathBase + "structureData.lua" + }; const static Bind staticBinds[numAppStates][maxStaticBinds]{ { diff --git a/gameManager.cpp b/gameManager.cpp index ae83c26..a402cab 100755 --- a/gameManager.cpp +++ b/gameManager.cpp @@ -10,6 +10,7 @@ #include "gameManager.h" #include "guiAppState.h" +#include "defConfigs.h" using namespace std; using namespace vb01; @@ -30,16 +31,18 @@ namespace battleship{ string pathBase = "../Assets/Scripts/"; luaManager->buildScript(vector{pathBase + "defPaths.lua"}); path = luaManager->getString("PATH"); - - luaManager->buildScript(vector{pathBase + "options.lua"}); - string ind1 = "graphics", ind2 = "resolution"; - width = luaManager->getIntFromTable(ind1, vector{Index(ind2), Index("x")}); - height = luaManager->getIntFromTable(ind1, vector{Index(ind2), Index("y")}); } GameManager::~GameManager() {} void GameManager::start() { + LuaManager *luaManager = LuaManager::getSingleton(); + luaManager->buildScript(configData::scripts); + + string ind1 = "graphics", ind2 = "resolution"; + width = luaManager->getIntFromTable(ind1, vector{Index(ind2), Index("x")}); + height = luaManager->getIntFromTable(ind1, vector{Index(ind2), Index("y")}); + Root *root = Root::getSingleton(); root->start(width, height, "../../vb01/", "Battleship"); diff --git a/inGameAppState.cpp b/inGameAppState.cpp index e8f2a77..5434d48 100755 --- a/inGameAppState.cpp +++ b/inGameAppState.cpp @@ -263,12 +263,7 @@ namespace battleship{ void InGameAppState::loadModels(){ LuaManager *lm = LuaManager::getSingleton(); string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{ - pathBase + "defPaths.lua", - pathBase + "unitData.lua", - pathBase + "vehicleData.lua", - pathBase + "structureData.lua" - }); + lm->buildScript(configData::scripts); int numUnits = lm->getInt("numUnits"); modelPaths.clear(); diff --git a/projectile.cpp b/projectile.cpp index f41bc5d..74ace5a 100755 --- a/projectile.cpp +++ b/projectile.cpp @@ -44,9 +44,6 @@ namespace battleship{ void Projectile::initProperties(int weaponId){ LuaManager *lm = LuaManager::getSingleton(); - string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{pathBase + "defPaths.lua", pathBase + "unitData.lua", pathBase + "projectileData.lua"}); - vector indices = vector{Index(id + 1), Index(weaponTypeId + 1), Index(weaponId + 1)}; rayLength = lm->getFloatFromTable("rayLength", indices); damage = lm->getIntFromTable("damage", indices); diff --git a/unit.cpp b/unit.cpp index cc16ff7..d802cb3 100755 --- a/unit.cpp +++ b/unit.cpp @@ -40,9 +40,6 @@ namespace battleship{ void Unit::initProperties(){ LuaManager *lm = LuaManager::getSingleton(); - string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{pathBase + "defPaths.lua", pathBase + "unitData.lua"}); - health = lm->getIntFromTable("health", vector{Index(id + 1)}); maxHealth = health; diff --git a/vehicle.cpp b/vehicle.cpp index 48a87b7..aea8c43 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -61,9 +61,6 @@ namespace battleship{ Unit::initProperties(); LuaManager *lm = LuaManager::getSingleton(); - string pathBase = GameManager::getSingleton()->getPath() + "Scripts/"; - lm->buildScript(vector{pathBase + "defPaths.lua", pathBase + "vehicleData.lua"}); - maxTurnAngle = lm->getFloatFromTable("maxTurnAngle", vector{Index(id + 1)}); speed = lm->getFloatFromTable("speed", vector{Index(id + 1)}); anglePrecision = lm->getFloatFromTable("anglePrecision", vector{Index(id + 1)});