mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
using recursive asset loading
This commit is contained in:
@@ -261,8 +261,9 @@ meshPath = {
|
||||
"submarine.xml",
|
||||
"jet00.xml", "jet01.xml"
|
||||
}
|
||||
vehiclePrefix = "Models/Units/Vehicles/"
|
||||
structurePrefix = "Models/Units/Structures/"
|
||||
modelPrefix = "Models/"
|
||||
vehiclePrefix = modelPrefix .. "Units/Vehicles/"
|
||||
structurePrefix = modelPrefix .. "Units/Structures/"
|
||||
basePath = {
|
||||
PATH .. vehiclePrefix .. "Battleships/", PATH .. vehiclePrefix .. "Battleships/",
|
||||
PATH .. vehiclePrefix .. "Battleships/", PATH .. structurePrefix .. "Sample/",
|
||||
|
||||
+3
-4
@@ -515,12 +515,11 @@ namespace battleship{
|
||||
if(!engineersSelected)
|
||||
break;
|
||||
|
||||
StateManager *sm = GameManager::getSingleton()->getStateManager();
|
||||
InGameAppState *inGameState = (InGameAppState*)sm->getAppStateByType(int(AppStateType::IN_GAME_STATE));
|
||||
|
||||
//TODO fix the magic value
|
||||
int id = 3;
|
||||
structureFrames.push_back(StructureFrame(inGameState->getModelPath(id), id, (int)UnitType::LAND));
|
||||
LuaManager *lm = LuaManager::getSingleton();
|
||||
string modelPath = lm->getStringFromTable("basePath", vector<Index>{Index(id + 1)}) + lm->getStringFromTable("meshPath", vector<Index>{Index(id + 1)});
|
||||
structureFrames.push_back(StructureFrame(modelPath, id, (int)UnitType::LAND));
|
||||
|
||||
placingStructures = true;
|
||||
}
|
||||
|
||||
+4
-20
@@ -189,15 +189,15 @@ namespace battleship{
|
||||
|
||||
mainPlayer = players[playerId];
|
||||
|
||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||
GameManager *gm = GameManager::getSingleton();
|
||||
StateManager *stateManager = gm->getStateManager();
|
||||
guiState = ((GuiAppState*)stateManager->getAppStateByType((int)AppStateType::GUI_STATE));
|
||||
activeState = new ActiveGameState(guiState, players, playerId);
|
||||
stateManager->attachAppState(activeState);
|
||||
|
||||
AssetManager *assetManager = AssetManager::getSingleton();
|
||||
assetManager->load(DEFAULT_TEXTURE);
|
||||
|
||||
loadModels();
|
||||
assetManager->load(gm->getPath() + LuaManager::getSingleton()->getString("modelPrefix"), true);
|
||||
}
|
||||
|
||||
void InGameAppState::onDettached() {}
|
||||
@@ -262,22 +262,6 @@ namespace battleship{
|
||||
updateProjectiles();
|
||||
}
|
||||
|
||||
void InGameAppState::loadModels(){
|
||||
LuaManager *lm = LuaManager::getSingleton();
|
||||
string pathBase = GameManager::getSingleton()->getPath() + "Scripts/";
|
||||
lm->buildScript(configData::scripts);
|
||||
int numUnits = lm->getInt("numUnits");
|
||||
modelPaths.clear();
|
||||
|
||||
for(int i = 0; i < numUnits; ++i){
|
||||
string basePath = lm->getStringFromTable("basePath", vector<Index>{Index(i + 1)});
|
||||
string meshPath = lm->getStringFromTable("meshPath", vector<Index>{Index(i + 1)});
|
||||
string modelPath = basePath + meshPath;
|
||||
AssetManager::getSingleton()->load(modelPath);
|
||||
modelPaths.push_back(modelPath);
|
||||
}
|
||||
}
|
||||
|
||||
void InGameAppState::toggleMainMenu() {
|
||||
GameManager *gm = GameManager::getSingleton();
|
||||
|
||||
@@ -312,7 +296,7 @@ namespace battleship{
|
||||
guiState->removeButton(exitButton);
|
||||
guiState->removeButton(resumeButton);
|
||||
|
||||
loadModels();
|
||||
AssetManager::getSingleton()->load(gm->getPath() + LuaManager::getSingleton()->getString("modelPrefix"), true);
|
||||
|
||||
for(Player *p : players)
|
||||
for(Unit *u : p->getUnits())
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace battleship{
|
||||
std::vector<Unit*> getSelectedUnits(Player*);
|
||||
inline std::vector<Player*> getPlayers() {return players;}
|
||||
inline std::vector<Projectile*>& getProjectiles(){return projectiles;}
|
||||
inline std::string getModelPath(int i){return modelPaths[i];}
|
||||
inline void addFx(Fx fx){this->fx.push_back(fx);}
|
||||
inline void addProjectile(Projectile *p){projectiles.push_back(p);}
|
||||
private:
|
||||
@@ -109,7 +108,6 @@ namespace battleship{
|
||||
ActiveGameState* activeState;
|
||||
GuiAppState* guiState;
|
||||
|
||||
void loadModels();
|
||||
void toggleMainMenu();
|
||||
void updateUnits(Player*);
|
||||
void updateProjectiles();
|
||||
|
||||
Reference in New Issue
Block a user