more loading screen fixes for non supported builds (#74)

This commit is contained in:
Isaac0-dev 2024-06-19 11:43:01 +10:00 committed by GitHub
parent 1c495d8cd4
commit eeebfecca4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 22 deletions

View File

@ -9082,6 +9082,9 @@ WATER_STEP_HIT_WALL = 4
--- @type integer --- @type integer
WATER_STEP_NONE = 0 WATER_STEP_NONE = 0
--- @type integer
MAX_HOOKED_MOD_MENU_ELEMENTS = 256
--- @class LuaActionHookType --- @class LuaActionHookType
--- @type LuaActionHookType --- @type LuaActionHookType

View File

@ -2,7 +2,7 @@
#include "pc/loading.h" #include "pc/loading.h"
void DynOS_Gfx_GeneratePacks(const char* directory) { void DynOS_Gfx_GeneratePacks(const char* directory) {
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In Path:\n\\#808080\\%s", directory)); LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In Path:\n\\#808080\\%s", directory));
DIR *modsDir = opendir(directory); DIR *modsDir = opendir(directory);
if (!modsDir) { return; } if (!modsDir) { return; }
@ -40,7 +40,7 @@ void DynOS_Gfx_GeneratePacks(const char* directory) {
DynOS_Tex_GeneratePack(_TexturePackFolder, _TexturePackOutputFolder, true); DynOS_Tex_GeneratePack(_TexturePackFolder, _TexturePackOutputFolder, true);
} }
REFRESH_MUTEX(gCurrLoadingSegment.percentage = (f32) i / (f32) pathCount); LOADING_SCREEN_MUTEX(gCurrLoadingSegment.percentage = (f32) i / (f32) pathCount);
} }
closedir(modsDir); closedir(modsDir);
@ -59,7 +59,7 @@ static void ScanPacksFolder(SysPath _DynosPacksFolder) {
// If pack folder exists, add it to the pack list // If pack folder exists, add it to the pack list
SysPath _PackFolder = fstring("%s/%s", _DynosPacksFolder.c_str(), _DynosPacksEnt->d_name); SysPath _PackFolder = fstring("%s/%s", _DynosPacksFolder.c_str(), _DynosPacksEnt->d_name);
if (fs_sys_dir_exists(_PackFolder.c_str())) { if (fs_sys_dir_exists(_PackFolder.c_str())) {
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Pack:\n\\#808080\\%s", _PackFolder.c_str())); LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Pack:\n\\#808080\\%s", _PackFolder.c_str()));
DynOS_Pack_Add(_PackFolder); DynOS_Pack_Add(_PackFolder);
DynOS_Actor_GeneratePack(_PackFolder); DynOS_Actor_GeneratePack(_PackFolder);
DynOS_Tex_GeneratePack(_PackFolder, _PackFolder, false); DynOS_Tex_GeneratePack(_PackFolder, _PackFolder, false);

View File

@ -3239,6 +3239,7 @@
<br /> <br />
## [smlua_hooks.h](#smlua_hooks.h) ## [smlua_hooks.h](#smlua_hooks.h)
- MAX_HOOKED_MOD_MENU_ELEMENTS
### [enum LuaActionHookType](#LuaActionHookType) ### [enum LuaActionHookType](#LuaActionHookType)
| Identifier | Value | | Identifier | Value |

View File

@ -3,6 +3,8 @@
#include <pthread.h> #include <pthread.h>
#include "cliopts.h"
struct LoadingSegment { struct LoadingSegment {
char str[256]; char str[256];
f32 percentage; f32 percentage;
@ -12,12 +14,19 @@ extern struct LoadingSegment gCurrLoadingSegment;
extern bool gIsThreaded; extern bool gIsThreaded;
#define REFRESH_MUTEX(...) \ #if !defined(WAPI_DXGI) && !defined(WAPI_DUMMY)
if (gIsThreaded) { \ #define LOADING_SCREEN_SUPPORTED
#endif
#ifdef LOADING_SCREEN_SUPPORTED
#define LOADING_SCREEN_MUTEX(...) if (!gCLIOpts.hideLoadingScreen && gIsThreaded) { \
pthread_mutex_lock(&gLoadingThreadMutex); \ pthread_mutex_lock(&gLoadingThreadMutex); \
__VA_ARGS__; \ __VA_ARGS__; \
pthread_mutex_unlock(&gLoadingThreadMutex); \ pthread_mutex_unlock(&gLoadingThreadMutex); \
} \ }
#else
#define LOADING_SCREEN_MUTEX(...)
#endif
extern pthread_t gLoadingThreadId; extern pthread_t gLoadingThreadId;
extern pthread_mutex_t gLoadingThreadMutex; extern pthread_mutex_t gLoadingThreadMutex;

View File

@ -3296,6 +3296,7 @@ char gSmluaConstants[] = ""
"ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n" "ACTION_HOOK_MAX = 2\n"
"MAX_HOOKED_MOD_MENU_ELEMENTS = 256\n"
"MOD_MENU_ELEMENT_BUTTON = 0\n" "MOD_MENU_ELEMENT_BUTTON = 0\n"
"MOD_MENU_ELEMENT_CHECKBOX = 1\n" "MOD_MENU_ELEMENT_CHECKBOX = 1\n"
"MOD_MENU_ELEMENT_SLIDER = 2\n" "MOD_MENU_ELEMENT_SLIDER = 2\n"

View File

@ -201,8 +201,8 @@ static u32 mods_count_directory(char* modsBasePath) {
return pathCount; return pathCount;
} }
static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath) { static void mods_load(struct Mods* mods, char* modsBasePath, UNUSED bool isUserModPath) {
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath)); LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath));
// generate bins // generate bins
dynos_generate_packs(modsBasePath); dynos_generate_packs(modsBasePath);
@ -230,9 +230,9 @@ static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath)
LOG_ERROR("Could not open directory '%s'", modsBasePath); LOG_ERROR("Could not open directory '%s'", modsBasePath);
return; return;
} }
f32 count = (f32) mods_count_directory(modsBasePath); UNUSED f32 count = (f32) mods_count_directory(modsBasePath);
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mods In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath)); LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mods In %s Mod Path:\n\\#808080\\%s", isUserModPath ? "User" : "Local", modsBasePath));
// iterate // iterate
char path[SYS_MAX_PATH] = { 0 }; char path[SYS_MAX_PATH] = { 0 };
@ -241,18 +241,18 @@ static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath)
// sanity check / fill path[] // sanity check / fill path[]
if (!directory_sanity_check(dir, modsBasePath, path)) { continue; } if (!directory_sanity_check(dir, modsBasePath, path)) { continue; }
REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mod:\n\\#808080\\%s/%s", modsBasePath, dir->d_name)); LOADING_SCREEN_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mod:\n\\#808080\\%s/%s", modsBasePath, dir->d_name));
// load the mod // load the mod
if (!mod_load(mods, modsBasePath, dir->d_name)) { if (!mod_load(mods, modsBasePath, dir->d_name)) {
break; break;
} }
REFRESH_MUTEX(gCurrLoadingSegment.percentage = (f32) i / count); LOADING_SCREEN_MUTEX(gCurrLoadingSegment.percentage = (f32) i / count);
} }
closedir(d); closedir(d);
REFRESH_MUTEX(gCurrLoadingSegment.percentage = 1); LOADING_SCREEN_MUTEX(gCurrLoadingSegment.percentage = 1);
} }
void mods_refresh_local(void) { void mods_refresh_local(void) {
@ -306,7 +306,7 @@ void mods_enable(char* relativePath) {
} }
void mods_init(void) { void mods_init(void) {
REFRESH_MUTEX(loading_screen_set_segment_text("Caching Mods")); LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Caching Mods"));
// load mod cache // load mod cache
mod_cache_load(); mod_cache_load();

View File

@ -96,10 +96,6 @@ u8 gLuaVolumeEnv = 127;
static struct AudioAPI *audio_api; static struct AudioAPI *audio_api;
struct GfxWindowManagerAPI *wm_api = &WAPI; struct GfxWindowManagerAPI *wm_api = &WAPI;
#if !defined(WAPI_DXGI) && !defined(WAPI_DUMMY)
#define LOADING_SCREEN_SUPPORTED
#endif
extern void gfx_run(Gfx *commands); extern void gfx_run(Gfx *commands);
extern void thread5_game_loop(void *arg); extern void thread5_game_loop(void *arg);
extern void create_next_audio_buffer(s16 *samples, u32 num_samples); extern void create_next_audio_buffer(s16 *samples, u32 num_samples);
@ -317,7 +313,7 @@ void* main_game_init(void* isThreaded) {
// load language // load language
if (!djui_language_init(configLanguage)) { snprintf(configLanguage, MAX_CONFIG_STRING, "%s", ""); } if (!djui_language_init(configLanguage)) { snprintf(configLanguage, MAX_CONFIG_STRING, "%s", ""); }
REFRESH_MUTEX(loading_screen_set_segment_text("Loading")); LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Loading"));
dynos_gfx_init(); dynos_gfx_init();
enable_queued_dynos_packs(); enable_queued_dynos_packs();
sync_objects_init_system(); sync_objects_init_system();
@ -326,13 +322,13 @@ void* main_game_init(void* isThreaded) {
// check_for_updates(); // check_for_updates();
// } // }
REFRESH_MUTEX(loading_screen_set_segment_text("Loading ROM Assets")); LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Loading ROM Assets"));
rom_assets_load(); rom_assets_load();
smlua_text_utils_init(); smlua_text_utils_init();
mods_init(); mods_init();
enable_queued_mods(); enable_queued_mods();
REFRESH_MUTEX( LOADING_SCREEN_MUTEX(
gCurrLoadingSegment.percentage = 0; gCurrLoadingSegment.percentage = 0;
loading_screen_set_segment_text("Starting Game"); loading_screen_set_segment_text("Starting Game");
); );

View File

@ -115,7 +115,7 @@ void get_version_remote(void) {
} }
void check_for_updates(void) { void check_for_updates(void) {
REFRESH_MUTEX(loading_screen_set_segment_text("Checking For Updates")); LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates"));
get_version_remote(); get_version_remote();
if (sRemoteVersion[0] != '\0' && strcmp(sRemoteVersion, get_version())) { if (sRemoteVersion[0] != '\0' && strcmp(sRemoteVersion, get_version())) {