mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-28 23:13:02 +00:00
Fix loading screen
This commit is contained in:
parent
cc9348c71c
commit
0b66a50a00
1 changed files with 18 additions and 24 deletions
|
@ -28,28 +28,28 @@ bool gIsThreaded = false;
|
||||||
extern Vp D_8032CF00;
|
extern Vp D_8032CF00;
|
||||||
|
|
||||||
static void loading_screen_produce_one_frame(void) {
|
static void loading_screen_produce_one_frame(void) {
|
||||||
// Start frame
|
// start frame
|
||||||
gfx_start_frame();
|
gfx_start_frame();
|
||||||
config_gfx_pool();
|
config_gfx_pool();
|
||||||
init_render_image();
|
init_render_image();
|
||||||
create_dl_ortho_matrix();
|
create_dl_ortho_matrix();
|
||||||
djui_gfx_displaylist_begin();
|
djui_gfx_displaylist_begin();
|
||||||
|
|
||||||
// Fix scaling issues
|
// fix scaling issues
|
||||||
gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));
|
gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));
|
||||||
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
|
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
|
||||||
|
|
||||||
// Clear screen
|
// clear screen
|
||||||
create_dl_translation_matrix(MENU_MTX_PUSH, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 240.f, 0.f);
|
create_dl_translation_matrix(MENU_MTX_PUSH, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 240.f, 0.f);
|
||||||
create_dl_scale_matrix(MENU_MTX_NOPUSH, (GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT) / 130.f, 3.f, 1.f);
|
create_dl_scale_matrix(MENU_MTX_NOPUSH, (GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT) / 130.f, 3.f, 1.f);
|
||||||
gDPSetEnvColor(gDisplayListHead++, 0x00, 0x00, 0x00, 0xFF);
|
gDPSetEnvColor(gDisplayListHead++, 0x00, 0x00, 0x00, 0xFF);
|
||||||
gSPDisplayList(gDisplayListHead++, dl_draw_text_bg_box);
|
gSPDisplayList(gDisplayListHead++, dl_draw_text_bg_box);
|
||||||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||||
|
|
||||||
// Render loading screen elements
|
// render loading screen elements
|
||||||
if (sLoading) { djui_base_render(&sLoading->base); }
|
if (sLoading) { djui_base_render(&sLoading->base); }
|
||||||
|
|
||||||
// Render frame
|
// render frame
|
||||||
djui_gfx_displaylist_end();
|
djui_gfx_displaylist_end();
|
||||||
end_master_display_list();
|
end_master_display_list();
|
||||||
alloc_display_list(0);
|
alloc_display_list(0);
|
||||||
|
@ -67,19 +67,16 @@ static bool loading_screen_on_render(struct DjuiBase* base) {
|
||||||
windowWidth /= scale;
|
windowWidth /= scale;
|
||||||
windowHeight /= scale;
|
windowHeight /= scale;
|
||||||
|
|
||||||
f32 loadingDescY1 = windowHeight * 0.5f - sLoading->loadingDesc->base.height.value * 0.5f;
|
// fill the screen
|
||||||
f32 loadingDescY2 = windowHeight * 0.5f + sLoading->loadingDesc->base.height.value * 0.5f;
|
|
||||||
|
|
||||||
// Fill the screen
|
|
||||||
djui_base_set_size(base, windowWidth, windowHeight);
|
djui_base_set_size(base, windowWidth, windowHeight);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Loading text description
|
// loading text description
|
||||||
char buffer[256] = "";
|
char buffer[256] = "";
|
||||||
u32 length = strlen(gCurrLoadingSegment.str);
|
u32 length = strlen(gCurrLoadingSegment.str);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
if (gCurrLoadingSegment.percentage > 0) {
|
if (gCurrLoadingSegment.percentage > 0) {
|
||||||
snprintf(buffer, 256, "%s\n\\#C8C8C8\\%d%%", gCurrLoadingSegment.str, (u8) floor(gCurrLoadingSegment.percentage * 100));
|
snprintf(buffer, 256, "%s\n\\#c8c8c8\\%d%%", gCurrLoadingSegment.str, (u8)floor(gCurrLoadingSegment.percentage * 100));
|
||||||
} else {
|
} else {
|
||||||
snprintf(buffer, 256, "%s...", gCurrLoadingSegment.str);
|
snprintf(buffer, 256, "%s...", gCurrLoadingSegment.str);
|
||||||
}
|
}
|
||||||
|
@ -93,11 +90,11 @@ static bool loading_screen_on_render(struct DjuiBase* base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
djui_text_set_text(sLoading->loadingDesc, buffer);
|
djui_text_set_text(sLoading->loadingDesc, buffer);
|
||||||
djui_base_set_location(&sLoading->loadingDesc->base, 0, loadingDescY1);
|
djui_base_set_location(&sLoading->loadingDesc->base, 0, windowHeight - 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading bar
|
// loading bar
|
||||||
djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, loadingDescY2 + 64);
|
djui_base_set_location(&sLoading->loadingBar->base, windowWidth / 4, windowHeight - 100);
|
||||||
djui_base_set_visible(&sLoading->loadingBar->base, gCurrLoadingSegment.percentage > 0 && strlen(gCurrLoadingSegment.str) > 0);
|
djui_base_set_visible(&sLoading->loadingBar->base, gCurrLoadingSegment.percentage > 0 && strlen(gCurrLoadingSegment.str) > 0);
|
||||||
|
|
||||||
djui_base_compute(base);
|
djui_base_compute(base);
|
||||||
|
@ -116,40 +113,37 @@ static void loading_screen_destroy(struct DjuiBase* base) {
|
||||||
void render_loading_screen(void) {
|
void render_loading_screen(void) {
|
||||||
struct LoadingScreen* load = malloc(sizeof(struct LoadingScreen));
|
struct LoadingScreen* load = malloc(sizeof(struct LoadingScreen));
|
||||||
struct DjuiBase* base = &load->base;
|
struct DjuiBase* base = &load->base;
|
||||||
f32 nextY = 0;
|
|
||||||
|
|
||||||
djui_base_init(NULL, base, loading_screen_on_render, loading_screen_destroy);
|
djui_base_init(NULL, base, loading_screen_on_render, loading_screen_destroy);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Splash image
|
// splash image
|
||||||
struct DjuiImage* splashImage = djui_image_create(base, texture_coopdx_logo, 2048, 1024, 32);
|
struct DjuiImage* splashImage = djui_image_create(base, texture_coopdx_logo, 2048, 1024, 32);
|
||||||
djui_base_set_size(&splashImage->base, 740.0f, 364.0f);
|
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_alignment(&splashImage->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||||
djui_base_set_location(&splashImage->base, 0, -100);
|
djui_base_set_location(&splashImage->base, 0, -100);
|
||||||
nextY += gDjuiFonts[1]->defaultFontScale * 3.0f;
|
|
||||||
|
|
||||||
load->splashImage = splashImage;
|
load->splashImage = splashImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Current loading stage text
|
// current loading stage text
|
||||||
struct DjuiText *text = djui_text_create(base, "");
|
struct DjuiText *text = djui_text_create(base, "");
|
||||||
djui_base_set_location_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
djui_base_set_location_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||||
djui_base_set_location(&text->base, 0, 0);
|
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_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||||
djui_base_set_size(&text->base, 1.0f, gDjuiFonts[0]->defaultFontScale * 3.0f);
|
djui_base_set_size(&text->base, 1.0f, gDjuiFonts[0]->defaultFontScale * 4.0f);
|
||||||
djui_base_set_color(&text->base, 200, 200, 200, 255);
|
djui_base_set_color(&text->base, 200, 200, 200, 255);
|
||||||
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
djui_text_set_alignment(text, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
|
||||||
djui_text_set_font(text, gDjuiFonts[0]);
|
djui_text_set_font(text, gDjuiFonts[0]);
|
||||||
djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 1);
|
djui_text_set_font_scale(text, gDjuiFonts[0]->defaultFontScale * 1.5f);
|
||||||
|
|
||||||
load->loadingDesc = text;
|
load->loadingDesc = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Loading bar
|
// loading bar
|
||||||
struct DjuiProgressBar *progressBar = djui_progress_bar_create(base, &gCurrLoadingSegment.percentage, 0.0f, 1.0f, false);
|
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_type(&progressBar->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||||
djui_base_set_location(&progressBar->base, 0, 0);
|
djui_base_set_location(&progressBar->base, 0, 0);
|
||||||
|
@ -161,14 +155,14 @@ void render_loading_screen(void) {
|
||||||
|
|
||||||
sLoading = load;
|
sLoading = load;
|
||||||
|
|
||||||
// Loading screen loop
|
// loading screen loop
|
||||||
while (!gGameInited) {
|
while (!gGameInited) {
|
||||||
WAPI.main_loop(loading_screen_produce_one_frame);
|
WAPI.main_loop(loading_screen_produce_one_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_join(gLoadingThreadId, NULL);
|
pthread_join(gLoadingThreadId, NULL);
|
||||||
|
|
||||||
// Reset some things after rendering the loading screen
|
// reset some things after rendering the loading screen
|
||||||
reset_djui();
|
reset_djui();
|
||||||
alloc_display_list_reset();
|
alloc_display_list_reset();
|
||||||
gDisplayListHead = NULL;
|
gDisplayListHead = NULL;
|
||||||
|
|
Loading…
Reference in a new issue