mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-22 16:30:23 +00:00
Tweak loading screen visuals, indicate which mod is being loaded
This commit is contained in:
parent
c5a3a6cf32
commit
d6b3f3660d
2 changed files with 32 additions and 36 deletions
|
@ -15,7 +15,6 @@ struct LoadingSegment gCurrLoadingSegment = { "", 0 };
|
|||
struct LoadingScreen {
|
||||
struct DjuiBase base;
|
||||
struct DjuiImage* splashImage;
|
||||
struct DjuiText* loadingText;
|
||||
struct DjuiText* loadingDesc;
|
||||
struct DjuiProgressBar *loadingBar;
|
||||
};
|
||||
|
@ -68,38 +67,37 @@ static bool loading_screen_on_render(struct DjuiBase* base) {
|
|||
windowWidth /= scale;
|
||||
windowHeight /= scale;
|
||||
|
||||
f32 loadingDescY1 = windowHeight * 0.5f - sLoading->loadingDesc->base.height.value * 0.5f;
|
||||
f32 loadingDescY2 = windowHeight * 0.5f + sLoading->loadingDesc->base.height.value * 0.5f;
|
||||
|
||||
// Fill the screen
|
||||
djui_base_set_size(base, windowWidth, windowHeight);
|
||||
|
||||
{
|
||||
// Loading... text
|
||||
char* loadingStr = "Loading";
|
||||
char tmp[20] = "";
|
||||
switch ((u8) floor(clock_elapsed()) % 3) {
|
||||
case 0: snprintf(tmp, 20, "%s...", loadingStr); break;
|
||||
case 1: snprintf(tmp, 20, "%s.", loadingStr); break;
|
||||
default: snprintf(tmp, 20, "%s..", loadingStr); break;
|
||||
}
|
||||
djui_text_set_text(sLoading->loadingText, tmp);
|
||||
djui_base_set_visible(&sLoading->loadingText->base, sLoading->loadingText->base.y.value + 50 < sLoading->loadingDesc->base.y.value);
|
||||
}
|
||||
|
||||
{
|
||||
// Loading text description
|
||||
char buffer[256] = "";
|
||||
if (strlen(gCurrLoadingSegment.str) > 0) {
|
||||
u32 length = strlen(gCurrLoadingSegment.str);
|
||||
if (length > 0) {
|
||||
if (gCurrLoadingSegment.percentage > 0) {
|
||||
snprintf(buffer, 256, "%s... %d%%", gCurrLoadingSegment.str, (u8) floor(gCurrLoadingSegment.percentage * 100));
|
||||
snprintf(buffer, 256, "%s\n\\#C8C8C8\\%d%%", gCurrLoadingSegment.str, (u8) floor(gCurrLoadingSegment.percentage * 100));
|
||||
} else {
|
||||
snprintf(buffer, 256, "%s...", gCurrLoadingSegment.str);
|
||||
}
|
||||
|
||||
// swap around the backslashes
|
||||
bool inColor = false;
|
||||
for (u32 i = 0; i < length; i++) {
|
||||
if (buffer[i] == '\\' && buffer[MIN(i+1,length)] == '#') { inColor = true; }
|
||||
if (buffer[i] == '\\' && !inColor) { buffer[i] = '/'; }
|
||||
if (buffer[i] == '\\' && inColor && buffer[MIN(i+1,length)] != '#') { inColor = false; }
|
||||
}
|
||||
}
|
||||
djui_text_set_text(sLoading->loadingDesc, buffer);
|
||||
djui_base_set_location(&sLoading->loadingDesc->base, 0, windowHeight - 250);
|
||||
djui_base_set_location(&sLoading->loadingDesc->base, 0, loadingDescY1);
|
||||
}
|
||||
|
||||
// Loading bar
|
||||
djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, windowHeight - 100);
|
||||
djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, loadingDescY2 + 64);
|
||||
djui_base_set_visible(&sLoading->loadingBar->base, gCurrLoadingSegment.percentage > 0 && strlen(gCurrLoadingSegment.str) > 0);
|
||||
|
||||
djui_base_compute(base);
|
||||
|
@ -118,6 +116,7 @@ static void loading_screen_destroy(struct DjuiBase* base) {
|
|||
void render_loading_screen(void) {
|
||||
struct LoadingScreen* load = malloc(sizeof(struct LoadingScreen));
|
||||
struct DjuiBase* base = &load->base;
|
||||
f32 nextY = 0;
|
||||
|
||||
djui_base_init(NULL, base, loading_screen_on_render, loading_screen_destroy);
|
||||
|
||||
|
@ -127,33 +126,24 @@ void render_loading_screen(void) {
|
|||
djui_base_set_size(&splashImage->base, 740.0f, 364.0f);
|
||||
djui_base_set_alignment(&splashImage->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_location(&splashImage->base, 0, -100);
|
||||
nextY += gDjuiFonts[1]->defaultFontScale * 3.0f;
|
||||
|
||||
load->splashImage = splashImage;
|
||||
}
|
||||
|
||||
{
|
||||
// "Loading..." text
|
||||
struct DjuiText *text = djui_text_create(base, "");
|
||||
djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&text->base, 1.0f, 32 * 4);
|
||||
djui_base_set_color(&text->base, 200, 200, 200, 255);
|
||||
djui_base_set_location(&text->base, 0, 800);
|
||||
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_font(text, gDjuiFonts[0]);
|
||||
djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 2);
|
||||
|
||||
load->loadingText = text;
|
||||
}
|
||||
|
||||
{
|
||||
// Current loading stage text
|
||||
struct DjuiText *text = djui_text_create(base, "");
|
||||
djui_base_set_location_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(&text->base, 0, 0);
|
||||
nextY += gDjuiFonts[0]->defaultFontScale * 3.0f;
|
||||
|
||||
djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&text->base, 1.0f, 32 * 4);
|
||||
djui_base_set_size(&text->base, 1.0f, gDjuiFonts[0]->defaultFontScale * 3.0f);
|
||||
djui_base_set_color(&text->base, 200, 200, 200, 255);
|
||||
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||
djui_text_set_font(text, gDjuiFonts[0]);
|
||||
djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 1.5f);
|
||||
djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 1);
|
||||
|
||||
load->loadingDesc = text;
|
||||
}
|
||||
|
@ -161,6 +151,8 @@ void render_loading_screen(void) {
|
|||
{
|
||||
// Loading bar
|
||||
struct DjuiProgressBar *progressBar = djui_progress_bar_create(base, &gCurrLoadingSegment.percentage, 0.0f, 1.0f, false);
|
||||
djui_base_set_location_type(&progressBar->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(&progressBar->base, 0, 0);
|
||||
djui_base_set_visible(&progressBar->base, false);
|
||||
progressBar->base.width.value = 0.5;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ static u32 mods_count_directory(char* modsBasePath) {
|
|||
}
|
||||
|
||||
static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath) {
|
||||
if (gIsThreaded) { REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs In %s Path", isUserModPath ? "User" : "Local")); }
|
||||
if (gIsThreaded) { REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Generating DynOS Packs in %s mod path:\n\\#808080\\%s", isUserModPath ? "user" : "local", modsBasePath)); }
|
||||
|
||||
// generate bins
|
||||
dynos_generate_packs(modsBasePath);
|
||||
|
@ -186,7 +186,8 @@ static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath)
|
|||
return;
|
||||
}
|
||||
f32 count = (f32) mods_count_directory(modsBasePath);
|
||||
if (gIsThreaded) { REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading Mods In %s Mod Path", isUserModPath ? "User" : "Local")); }
|
||||
|
||||
if (gIsThreaded) { REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading mods in %s mod path:\n\\#808080\\%s", isUserModPath ? "user" : "local", modsBasePath)); }
|
||||
|
||||
// iterate
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
|
@ -195,10 +196,13 @@ static void mods_load(struct Mods* mods, char* modsBasePath, bool isUserModPath)
|
|||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, modsBasePath, path)) { continue; }
|
||||
|
||||
if (gIsThreaded) { REFRESH_MUTEX(snprintf(gCurrLoadingSegment.str, 256, "Loading mod:\n\\#808080\\%s/%s", modsBasePath, dir->d_name)); }
|
||||
|
||||
// load the mod
|
||||
if (!mod_load(mods, modsBasePath, dir->d_name)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (gIsThreaded) { REFRESH_MUTEX(gCurrLoadingSegment.percentage = (f32) i / count); }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue