RDI/src/Krennic.cpp

99 lines
2.4 KiB
C++

/**
* @file Krennic.cpp
* @date 24/09/2022
* @author JackCarterSmith
* @copyright GPL-v3.0
* @brief Main game assets parser and interface.
*
* Complete class would take Erso legacy files tree and extract levels, objects,
* textures, animations, etc. adapted datas for OpenGL/Direct3D application.
*
*/
#include <RSPModel.h>
#include <RSPTerrain.h>
#include <RSPTexture.h>
#include <boost/filesystem.hpp>
#include "Erso.hpp"
#include "Krennic.hpp"
namespace RDI {
Krennic::Krennic( Erso* pErso ) {
BuildLevelList(pErso);
BuildModelList(pErso);
BuildTextureList(pErso);
BuildMusicList(pErso);
BuildSampleList(pErso);
}
Krennic::~Krennic() {}
void Krennic::BuildLevelList( Erso* pErso ) {
const static std::string legacyLvlPath = "data/level";
ErsoEntryDir* levelDir = nullptr;
listLevel.clear();
levelDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(legacyLvlPath)));
if (levelDir != nullptr) {
for ( ErsoEntry* fl : levelDir->getFiles() ) {
if (fl->isDirectory()) {
if (pErso->getElement(boost::filesystem::path(legacyLvlPath).append(fl->getName()).append("dat")) != nullptr) {
listLevel.push_back(legacyLvlPath + "/" + fl->getName());
}
}
}
}
//TODO: LvlClass builder
}
void Krennic::BuildModelList( Erso* pErso ) {
const static std::vector<std::string> legacyModelPath = {
"data/pl_crafts", "data/reb_stuff", "data/imp_stuff",
"data/gnrc_stuff", "data2"
};
ErsoEntryDir* curModelDir = nullptr;
listModel.clear();
for ( std::string path_it : legacyModelPath ) {
curModelDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(path_it)));
if (curModelDir != nullptr) {
for ( ErsoEntry* fl : curModelDir->getFiles() ) {
if (fl->getName().find("_HOB") != std::string::npos) {
listModel.push_back(path_it + "/" + fl->getName());
}
}
}
}
}
void Krennic::BuildTextureList( Erso* pErso ) {
}
void Krennic::BuildMusicList( Erso* pErso ) {
const static std::string legacyMusicPath = "data/sound";
ErsoEntryDir* musicDir = nullptr;
listMusic.clear();
musicDir = dynamic_cast<ErsoEntryDir*>(pErso->getElement(boost::filesystem::path(legacyMusicPath)));
if (musicDir != nullptr) {
for ( ErsoEntry* fl : musicDir->getFiles() ) {
//TODO: MusyX-Class builder
if (fl->getName().find("_SNG") != std::string::npos) {
listMusic.push_back(legacyMusicPath + "/" + fl->getName());
}
}
}
}
void Krennic::BuildSampleList( Erso* pErso ) {
}
}