From 08e2b49e8834ed98631f7dd93e5801a8a0bd3794 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 12:43:45 +0200 Subject: [PATCH 1/6] Fixed viewport calculations of the character selection UIs from multiplayer. --- src/game/menu.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/game/menu.c b/src/game/menu.c index 26c839f0a..f36bfec72 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -2262,7 +2262,21 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype) gdl = func0f0d49c8(gdl); gSPMatrix(gdl++, osVirtualToPhysical(camGetPerspectiveMtxL()), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } else { - f32 aspect = (f32) (g_MenuScissorX2 - g_MenuScissorX1) / (f32) (g_MenuScissorY2 - g_MenuScissorY1); +#ifdef PLATFORM_N64 + s32 x1 = g_MenuScissorX1; + s32 x2 = g_MenuScissorX2; +#else + s32 halfScreenWidth = SCREEN_WIDTH_LO >> 1; + f32 scale = SCREEN_ASPECT / videoGetAspect(); + f32 width = (g_MenuScissorX2 - g_MenuScissorX1) * scale; + f32 center = (g_MenuScissorX1 + g_MenuScissorX2) * 0.5f; + center = ((center - halfScreenWidth) * scale) + halfScreenWidth; + + s32 x1 = (s32)(center - width * 0.5f); + s32 x2 = (s32)(center + width * 0.5f); +#endif + + f32 aspect = (f32) (x2 - x1) / (f32) (g_MenuScissorY2 - g_MenuScissorY1); static u32 znear = 10; static u32 zfar = 300; @@ -2272,8 +2286,8 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype) gdl = func0f0d49c8(gdl); - viSetViewPosition(g_MenuScissorX1 * g_ScaleX, g_MenuScissorY1); - viSetFovAspectAndSize(g_Vars.currentplayer->fovy, aspect, (g_MenuScissorX2 - g_MenuScissorX1) * g_ScaleX, g_MenuScissorY2 - g_MenuScissorY1); + viSetViewPosition(x1 * g_ScaleX, g_MenuScissorY1); + viSetFovAspectAndSize(g_Vars.currentplayer->fovy, aspect, (x2 - x1) * g_ScaleX, g_MenuScissorY2 - g_MenuScissorY1); gdl = vi0000af00(gdl, var800a2048[g_MpPlayerNum]); gdl = vi0000aca4(gdl, znear, zfar); From f855dc32f178b5d238eda62a68c669b557816df8 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 13:17:43 +0200 Subject: [PATCH 2/6] Apply a small offset to the arrows in character selection so they don't get cut off by the scissor. --- src/game/menuitem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game/menuitem.c b/src/game/menuitem.c index f06218f30..5cb385059 100644 --- a/src/game/menuitem.c +++ b/src/game/menuitem.c @@ -2607,11 +2607,17 @@ Gfx *menuitemCarouselRender(Gfx *gdl, struct menurendercontext *context) colour = colourBlend(colourBlend(colour, 0x000000ff, 127), colour1, weight); } +#ifdef PLATFORM_N64 + s16 chevronOffset = 0; +#else + s16 chevronOffset = 3; +#endif + // Left arrow - gdl = menugfxDrawCarouselChevron(gdl, context->x, context->y + context->height / 2, 8, 1, -1, colour); + gdl = menugfxDrawCarouselChevron(gdl, context->x + chevronOffset, context->y + context->height / 2, 8, 1, -1, colour); // Right arrow - gdl = menugfxDrawCarouselChevron(gdl, context->x + context->width, context->y + context->height / 2, 8, 3, -1, colour); + gdl = menugfxDrawCarouselChevron(gdl, context->x + context->width - chevronOffset, context->y + context->height / 2, 8, 3, -1, colour); // This part of the function is unused because param2 is always zero. // Setting it to 0x7b causes a crash. From d36c55d048302ce8a7e314b6778fb6ad1f3c6086 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 14:04:02 +0200 Subject: [PATCH 3/6] - Fixed model position in device training menu. --- src/game/trainingmenus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index 430d0db6b..02dedb602 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -1924,6 +1924,11 @@ MenuDialogHandlerResult dtTrainingDetailsMenuDialog(s32 operation, struct menudi } #endif +#ifndef PLATFORM_N64 + g_Menus[g_MpPlayerNum].menumodel.newposx *= ((f32)SCREEN_WIDTH_LO / (f32)SCREEN_HEIGHT_LO) / videoGetAspect(); + g_Menus[g_MpPlayerNum].menumodel.curposx = g_Menus[g_MpPlayerNum].menumodel.newposx; +#endif + g_Menus[g_MpPlayerNum].menumodel.newscale /= 2.5f; } break; From 2844930a21b76b05088d0fb6ec9f22f73ab7d8e5 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 14:10:43 +0200 Subject: [PATCH 4/6] Recalculate model position in device training menu every tick, so it adjusts when resizing the window. --- src/game/trainingmenus.c | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index 02dedb602..d6ea27bf9 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -1888,6 +1888,7 @@ MenuDialogHandlerResult dtTrainingDetailsMenuDialog(s32 operation, struct menudi g_Menus[g_MpPlayerNum].training.weaponnum = weaponnum; func0f105948(weaponnum); +#ifdef PLATFORM_N64 #if VERSION == VERSION_PAL_FINAL if (g_ViRes == VIRES_HI) { if (optionsGetScreenRatio() == SCREENRATIO_16_9) { @@ -1923,6 +1924,7 @@ MenuDialogHandlerResult dtTrainingDetailsMenuDialog(s32 operation, struct menudi g_Menus[g_MpPlayerNum].menumodel.curposx = 90; } #endif +#endif #ifndef PLATFORM_N64 g_Menus[g_MpPlayerNum].menumodel.newposx *= ((f32)SCREEN_WIDTH_LO / (f32)SCREEN_HEIGHT_LO) / videoGetAspect(); @@ -1935,6 +1937,47 @@ MenuDialogHandlerResult dtTrainingDetailsMenuDialog(s32 operation, struct menudi case MENUOP_CLOSE: break; case MENUOP_TICK: +#ifndef PLATFORM_N64 +#if VERSION == VERSION_PAL_FINAL + if (g_ViRes == VIRES_HI) { + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + g_Menus[g_MpPlayerNum].menumodel.newposx = 84; + g_Menus[g_MpPlayerNum].menumodel.curposx = 84; + } else { + g_Menus[g_MpPlayerNum].menumodel.newposx = 104; + g_Menus[g_MpPlayerNum].menumodel.curposx = 104; + } + } else { + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + g_Menus[g_MpPlayerNum].menumodel.newposx = 64; + g_Menus[g_MpPlayerNum].menumodel.curposx = 64; + } else { + g_Menus[g_MpPlayerNum].menumodel.newposx = 84; + g_Menus[g_MpPlayerNum].menumodel.curposx = 84; + } + } +#elif VERSION == VERSION_PAL_BETA + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + g_Menus[g_MpPlayerNum].menumodel.newposx = 64; + g_Menus[g_MpPlayerNum].menumodel.curposx = 64; + } else { + g_Menus[g_MpPlayerNum].menumodel.newposx = 84; + g_Menus[g_MpPlayerNum].menumodel.curposx = 84; + } +#else + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + g_Menus[g_MpPlayerNum].menumodel.newposx = 70; + g_Menus[g_MpPlayerNum].menumodel.curposx = 70; + } else { + g_Menus[g_MpPlayerNum].menumodel.newposx = 90; + g_Menus[g_MpPlayerNum].menumodel.curposx = 90; + } +#endif + + g_Menus[g_MpPlayerNum].menumodel.newposx *= ((f32)SCREEN_WIDTH_LO / (f32)SCREEN_HEIGHT_LO) / videoGetAspect(); + g_Menus[g_MpPlayerNum].menumodel.curposx = g_Menus[g_MpPlayerNum].menumodel.newposx; +#endif + if (g_Menus[g_MpPlayerNum].curdialog && g_Menus[g_MpPlayerNum].curdialog->definition == dialogdef) { if (dtGetWeaponByDeviceIndex(dtGetIndexBySlot(g_DtSlot)) == WEAPON_DISGUISE41) { g_Menus[g_MpPlayerNum].menumodel.newanimnum = ANIM_006A; From f0fe7f41f1c2d3b60e7f17ee62f01a23b74a1247 Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 14:13:17 +0200 Subject: [PATCH 5/6] Forgot to remove something from previous commit. --- src/game/trainingmenus.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index d6ea27bf9..d183e3b2f 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -1926,11 +1926,6 @@ MenuDialogHandlerResult dtTrainingDetailsMenuDialog(s32 operation, struct menudi #endif #endif -#ifndef PLATFORM_N64 - g_Menus[g_MpPlayerNum].menumodel.newposx *= ((f32)SCREEN_WIDTH_LO / (f32)SCREEN_HEIGHT_LO) / videoGetAspect(); - g_Menus[g_MpPlayerNum].menumodel.curposx = g_Menus[g_MpPlayerNum].menumodel.newposx; -#endif - g_Menus[g_MpPlayerNum].menumodel.newscale /= 2.5f; } break; From 48c294fc247e8286a15e1f70b98465f9f9b809dc Mon Sep 17 00:00:00 2001 From: MaikelChan Date: Tue, 6 Aug 2024 14:21:36 +0200 Subject: [PATCH 6/6] Recalculate model position in character profile menu every tick, so it adjusts when resizing the window. --- src/game/trainingmenus.c | 63 +++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index d183e3b2f..4729e17c3 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -1535,19 +1535,7 @@ MenuDialogHandlerResult ciCharacterProfileMenuDialog(s32 operation, struct menud f32 y; f32 scale; - switch (operation) { - case MENUOP_OPEN: - if (bodynum == BODY_DRCAROLL) { - scale = 0.7f; - g_Menus[g_MpPlayerNum].menumodel.zoom = -1; - } else { - g_Menus[g_MpPlayerNum].menumodel.zoom = 30; - scale = 1.0f; - } - - g_Menus[g_MpPlayerNum].menumodel.zoomtimer60 = TICKS(120); - g_Menus[g_MpPlayerNum].menumodel.removingpiece = false; - +#ifndef PLATFORM_N64 #if VERSION == VERSION_PAL_FINAL if (g_ViRes != VIRES_HI) { x = -117; @@ -1574,6 +1562,50 @@ MenuDialogHandlerResult ciCharacterProfileMenuDialog(s32 operation, struct menud if (optionsGetScreenRatio() == SCREENRATIO_16_9) { x = -100; } +#endif +#endif + + switch (operation) { + case MENUOP_OPEN: + if (bodynum == BODY_DRCAROLL) { + scale = 0.7f; + g_Menus[g_MpPlayerNum].menumodel.zoom = -1; + } else { + g_Menus[g_MpPlayerNum].menumodel.zoom = 30; + scale = 1.0f; + } + + g_Menus[g_MpPlayerNum].menumodel.zoomtimer60 = TICKS(120); + g_Menus[g_MpPlayerNum].menumodel.removingpiece = false; + +#ifdef PLATFORM_N64 +#if VERSION == VERSION_PAL_FINAL + if (g_ViRes != VIRES_HI) { + x = -117; + + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + x = -87; + } + } else { + x = -177; + + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + x = -127; + } + } +#elif VERSION == VERSION_PAL_BETA + x = -117; + + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + x = -87; + } +#else + x = -130; + + if (optionsGetScreenRatio() == SCREENRATIO_16_9) { + x = -100; + } +#endif #endif y = -15; @@ -1603,6 +1635,11 @@ MenuDialogHandlerResult ciCharacterProfileMenuDialog(s32 operation, struct menud case MENUOP_CLOSE: break; case MENUOP_TICK: +#ifndef PLATFORM_N64 + x = (float)x * ((f32)SCREEN_WIDTH_LO / (f32)SCREEN_HEIGHT_LO) / videoGetAspect(); + g_Menus[g_MpPlayerNum].menumodel.newposx = x; +#endif + if (bodynum == BODY_DRCAROLL) { static struct modelpartvisibility vis[] = { { MODELPART_DRCAROLL_0001, false },