Fix tutorial popup positioning in split-screen viewports

Replace the manual switch-case that computed viewport origin with the shared GetViewportRect/Fit16x9 helpers (from UISplitScreenHelpers.h). This ensures the tutorial popup is positioned and scaled consistently with the rest of the split-screen UI, fitting a 16:9 box inside each viewport and applying safezone offsets correctly.

Also adds missing default:break to safezone switch statements to silence compiler warnings.

Made-with: Cursor
This commit is contained in:
MrTheShy 2026-03-09 12:32:30 +01:00
parent 93f2d7335d
commit 257298eb15

View file

@ -1,6 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "UI.h" #include "UI.h"
#include "UIComponent_TutorialPopup.h" #include "UIComponent_TutorialPopup.h"
#include "UISplitScreenHelpers.h"
#include "..\..\Common\Tutorial\Tutorial.h" #include "..\..\Common\Tutorial\Tutorial.h"
#include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\MultiplayerLocalPlayer.h" #include "..\..\MultiplayerLocalPlayer.h"
@ -474,27 +475,17 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewpo
{ {
if(viewport != C4JRender::VIEWPORT_TYPE_FULLSCREEN) if(viewport != C4JRender::VIEWPORT_TYPE_FULLSCREEN)
{ {
S32 xPos = 0; // Derive the viewport origin and fit a 16:9 box inside it (same as UIScene::render),
S32 yPos = 0; // then apply safezone nudges so the popup stays clear of screen edges.
switch( viewport ) F32 originX, originY, viewW, viewH;
{ GetViewportRect(ui.getScreenWidth(), ui.getScreenHeight(), viewport, originX, originY, viewW, viewH);
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
xPos = static_cast<S32>(ui.getScreenWidth() / 2); S32 fitW, fitH, offsetX, offsetY;
yPos = static_cast<S32>(ui.getScreenHeight() / 2); Fit16x9(viewW, viewH, fitW, fitH, offsetX, offsetY);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT: S32 xPos = static_cast<S32>(originX) + offsetX;
yPos = static_cast<S32>(ui.getScreenHeight() / 2); S32 yPos = static_cast<S32>(originY) + offsetY;
break;
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
xPos = static_cast<S32>(ui.getScreenWidth() / 2);
break;
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos = static_cast<S32>(ui.getScreenWidth() / 2);
yPos = static_cast<S32>(ui.getScreenHeight() / 2);
break;
}
//Adjust for safezone //Adjust for safezone
switch( viewport ) switch( viewport )
{ {
@ -505,6 +496,7 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewpo
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
yPos += getSafeZoneHalfHeight(); yPos += getSafeZoneHalfHeight();
break; break;
default: break;
} }
switch( viewport ) switch( viewport )
{ {
@ -515,10 +507,11 @@ void UIComponent_TutorialPopup::render(S32 width, S32 height, C4JRender::eViewpo
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT: case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
xPos -= getSafeZoneHalfWidth(); xPos -= getSafeZoneHalfWidth();
break; break;
default: break;
} }
ui.setupRenderPosition(xPos, yPos); ui.setupRenderPosition(xPos, yPos);
IggyPlayerSetDisplaySize( getMovie(), width, height ); IggyPlayerSetDisplaySize( getMovie(), fitW, fitH );
IggyPlayerDraw( getMovie() ); IggyPlayerDraw( getMovie() );
} }
else else