2022-03-10 02:01:03 +00:00
|
|
|
#include "dynos.cpp.h"
|
|
|
|
|
|
|
|
Array<ActorGfx> &DynOS_Gfx_GetActorList() {
|
|
|
|
static Array<ActorGfx> sActorGfxList;
|
|
|
|
return sActorGfxList;
|
|
|
|
}
|
|
|
|
|
|
|
|
Array<PackData *> &DynOS_Gfx_GetPacks() {
|
|
|
|
static Array<PackData *> sPacks;
|
|
|
|
return sPacks;
|
|
|
|
}
|
|
|
|
|
2022-03-11 02:16:12 +00:00
|
|
|
Array<bool> &DynOS_Gfx_GetPacksEnabled() {
|
|
|
|
static Array<bool> sPacksEnabled;
|
|
|
|
return sPacksEnabled;
|
|
|
|
}
|
2022-03-17 04:26:29 +00:00
|
|
|
|
|
|
|
void DynOS_Gfx_GeneratePacks(const char* directory) {
|
|
|
|
DIR *modsDir = opendir(directory);
|
|
|
|
if (!modsDir) { return; }
|
|
|
|
|
|
|
|
struct dirent *dir = NULL;
|
|
|
|
while ((dir = readdir(modsDir)) != NULL) {
|
|
|
|
// Skip . and ..
|
|
|
|
if (SysPath(dir->d_name) == ".") continue;
|
|
|
|
if (SysPath(dir->d_name) == "..") continue;
|
|
|
|
|
|
|
|
// If pack folder exists, generate bins
|
2022-04-01 08:43:50 +00:00
|
|
|
SysPath _LevelPackFolder = fstring("%s/%s/levels", directory, dir->d_name);
|
|
|
|
if (fs_sys_dir_exists(_LevelPackFolder.c_str())) {
|
|
|
|
DynOS_Lvl_GeneratePack(_LevelPackFolder);
|
|
|
|
}
|
|
|
|
SysPath _ActorPackFolder = fstring("%s/%s/actors", directory, dir->d_name);
|
|
|
|
if (fs_sys_dir_exists(_ActorPackFolder.c_str())) {
|
2022-04-02 02:50:42 +00:00
|
|
|
DynOS_Actor_GeneratePack(_ActorPackFolder);
|
2022-03-17 04:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(modsDir);
|
|
|
|
}
|
2022-03-11 02:16:12 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
static void ScanPacksFolder(SysPath _DynosPacksFolder) {
|
2022-03-10 02:01:03 +00:00
|
|
|
Array<PackData *> &pDynosPacks = DynOS_Gfx_GetPacks();
|
|
|
|
DIR *_DynosPacksDir = opendir(_DynosPacksFolder.c_str());
|
|
|
|
if (_DynosPacksDir) {
|
|
|
|
struct dirent *_DynosPacksEnt = NULL;
|
|
|
|
while ((_DynosPacksEnt = readdir(_DynosPacksDir)) != NULL) {
|
|
|
|
|
|
|
|
// Skip . and ..
|
|
|
|
if (SysPath(_DynosPacksEnt->d_name) == ".") continue;
|
|
|
|
if (SysPath(_DynosPacksEnt->d_name) == "..") continue;
|
|
|
|
|
|
|
|
// If pack folder exists, add it to the pack list
|
|
|
|
SysPath _PackFolder = fstring("%s/%s", _DynosPacksFolder.c_str(), _DynosPacksEnt->d_name);
|
|
|
|
if (fs_sys_dir_exists(_PackFolder.c_str())) {
|
|
|
|
PackData *_Pack = New<PackData>();
|
|
|
|
|
|
|
|
// Scan folder for subfolders to convert into .bin files
|
|
|
|
_Pack->mPath = _PackFolder;
|
2022-04-02 02:50:42 +00:00
|
|
|
DynOS_Actor_GeneratePack(_PackFolder);
|
2022-03-10 02:01:03 +00:00
|
|
|
|
|
|
|
// Add pack to pack list
|
|
|
|
pDynosPacks.Add(_Pack);
|
2022-03-31 06:04:41 +00:00
|
|
|
|
2022-03-11 03:23:38 +00:00
|
|
|
// Add enabled flag
|
|
|
|
DynOS_Gfx_GetPacksEnabled().Add(true);
|
2022-03-10 02:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(_DynosPacksDir);
|
|
|
|
}
|
2022-03-31 06:04:41 +00:00
|
|
|
}
|
2022-03-10 02:01:03 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
Array<String> DynOS_Gfx_Init() {
|
2022-03-14 01:09:57 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
// Alloc and init the actors gfx list
|
|
|
|
Array<ActorGfx> &pActorGfxList = DynOS_Gfx_GetActorList();
|
2022-04-09 01:56:22 +00:00
|
|
|
pActorGfxList.Resize(DynOS_Actor_GetCount());
|
|
|
|
for (s32 i = 0; i != DynOS_Actor_GetCount(); ++i) {
|
2022-03-31 06:04:41 +00:00
|
|
|
pActorGfxList[i].mPackIndex = -1;
|
|
|
|
pActorGfxList[i].mGfxData = NULL;
|
2022-04-09 01:56:22 +00:00
|
|
|
pActorGfxList[i].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(DynOS_Actor_GetLayoutFromIndex(i), false);
|
2022-03-31 06:04:41 +00:00
|
|
|
}
|
2022-03-14 01:09:57 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
// Scan the DynOS packs folder
|
|
|
|
SysPath _DynosPacksFolder = fstring("%s/%s", DYNOS_EXE_FOLDER, DYNOS_PACKS_FOLDER);
|
|
|
|
ScanPacksFolder(_DynosPacksFolder);
|
2022-03-14 01:09:57 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
// Scan the user path folder
|
|
|
|
SysPath _DynosPacksUserFolder = fstring("%s/%s", DYNOS_USER_FOLDER, DYNOS_PACKS_FOLDER);
|
|
|
|
ScanPacksFolder(_DynosPacksUserFolder);
|
2022-03-14 01:09:57 +00:00
|
|
|
|
2022-03-31 06:04:41 +00:00
|
|
|
// Return a list of pack names
|
|
|
|
Array<PackData *> &pDynosPacks = DynOS_Gfx_GetPacks();
|
|
|
|
Array<String> _PackNames;
|
|
|
|
for (const auto& _Pack : pDynosPacks) {
|
2022-03-14 01:09:57 +00:00
|
|
|
u64 _DirSep1 = _Pack->mPath.find_last_of('\\');
|
|
|
|
u64 _DirSep2 = _Pack->mPath.find_last_of('/');
|
|
|
|
if (_DirSep1++ == SysPath::npos) _DirSep1 = 0;
|
|
|
|
if (_DirSep2++ == SysPath::npos) _DirSep2 = 0;
|
|
|
|
SysPath _DirName = _Pack->mPath.substr(MAX(_DirSep1, _DirSep2));
|
|
|
|
_PackNames.Add(_DirName.c_str());
|
|
|
|
}
|
2022-03-31 06:04:41 +00:00
|
|
|
|
2022-03-10 02:01:03 +00:00
|
|
|
return _PackNames;
|
|
|
|
}
|