2022-03-10 02:01:03 +00:00
|
|
|
#include "dynos.cpp.h"
|
2024-04-17 17:02:28 +00:00
|
|
|
#include "pc/loading.h"
|
2022-03-10 02:01:03 +00:00
|
|
|
|
2022-03-17 04:26:29 +00:00
|
|
|
void DynOS_Gfx_GeneratePacks(const char* directory) {
|
2024-06-01 03:40:58 +00:00
|
|
|
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In Path:\n\\#808080\\%s", directory));
|
2023-11-20 04:40:43 +00:00
|
|
|
|
2022-03-17 04:26:29 +00:00
|
|
|
DIR *modsDir = opendir(directory);
|
|
|
|
if (!modsDir) { return; }
|
|
|
|
|
|
|
|
struct dirent *dir = NULL;
|
2023-11-04 23:55:34 +00:00
|
|
|
DIR* d = opendir(directory);
|
|
|
|
u32 pathCount = 0;
|
|
|
|
while ((dir = readdir(d)) != NULL) pathCount++;
|
|
|
|
closedir(d);
|
|
|
|
|
|
|
|
for (u32 i = 0; (dir = readdir(modsDir)) != NULL; ++i) {
|
2022-03-17 04:26:29 +00:00
|
|
|
// 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);
|
|
|
|
}
|
2023-11-04 23:55:34 +00:00
|
|
|
|
2022-04-01 08:43:50 +00:00
|
|
|
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
|
|
|
}
|
2023-11-04 23:55:34 +00:00
|
|
|
|
2022-06-02 19:19:54 +00:00
|
|
|
SysPath _BehaviorPackFolder = fstring("%s/%s/data", directory, dir->d_name);
|
|
|
|
if (fs_sys_dir_exists(_BehaviorPackFolder.c_str())) {
|
|
|
|
DynOS_Bhv_GeneratePack(_BehaviorPackFolder);
|
|
|
|
}
|
2023-11-04 23:55:34 +00:00
|
|
|
|
2022-05-07 05:03:12 +00:00
|
|
|
SysPath _TexturePackFolder = fstring("%s/%s", directory, dir->d_name);
|
|
|
|
SysPath _TexturePackOutputFolder = fstring("%s/%s/textures", directory, dir->d_name);
|
|
|
|
if (fs_sys_dir_exists(_TexturePackFolder.c_str())) {
|
2022-05-07 22:54:27 +00:00
|
|
|
DynOS_Tex_GeneratePack(_TexturePackFolder, _TexturePackOutputFolder, true);
|
2022-05-07 05:03:12 +00:00
|
|
|
}
|
2023-11-04 23:55:34 +00:00
|
|
|
|
2024-03-19 09:48:48 +00:00
|
|
|
REFRESH_MUTEX(gCurrLoadingSegment.percentage = (f32) i / (f32) pathCount);
|
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
|
|
|
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())) {
|
2024-03-19 19:17:55 +00:00
|
|
|
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Pack:\n\\#808080\\%s", _PackFolder.c_str()));
|
2023-02-27 16:22:31 +00:00
|
|
|
DynOS_Pack_Add(_PackFolder);
|
2022-04-02 02:50:42 +00:00
|
|
|
DynOS_Actor_GeneratePack(_PackFolder);
|
2022-05-07 22:54:27 +00:00
|
|
|
DynOS_Tex_GeneratePack(_PackFolder, _PackFolder, false);
|
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-04-20 04:06:18 +00:00
|
|
|
void DynOS_Gfx_Init() {
|
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
|
2024-05-16 21:15:25 +00:00
|
|
|
SysPath _DynosPacksUserFolder = fstring("%s%s", DYNOS_USER_FOLDER, DYNOS_PACKS_FOLDER);
|
2022-03-31 06:04:41 +00:00
|
|
|
ScanPacksFolder(_DynosPacksUserFolder);
|
2022-03-10 02:01:03 +00:00
|
|
|
}
|