Scale 2D coordinates to backbuffer resolution. (#124)

* Starting with backbuffer scaling refactor.

* CSD & primitive 2Ds refactored.

* More refactoring.

* Fix primitive 2D, and on screen 3D items.

* Fix right side offset scaling.

* Fix Inspire letterbox.

* Fix offset scaling in world map.

* Fix custom menus.

* Remove debugging code.
This commit is contained in:
Skyth (Asilkan)
2025-01-18 23:56:47 +03:00
committed by GitHub
parent 1cf12fa97f
commit 40a8bf557b
10 changed files with 189 additions and 211 deletions
+14 -14
View File
@@ -161,14 +161,14 @@ static void DrawScanlineBars()
if (g_aspectRatio >= WIDE_ASPECT_RATIO)
optionsX = g_aspectRatioOffsetX;
else
optionsX = (1.0f - g_narrowOffsetScale) * -20.0f;
optionsX = (1.0f - g_aspectRatioNarrowScale) * g_aspectRatioScale * -20.0f;
// Options text
DrawTextWithOutline
(
g_dfsogeistdFont,
Scale(48.0f),
{ Scale(optionsX + 122.0f), Scale(56.0f) },
{ optionsX + Scale(122.0f), Scale(56.0f) },
IM_COL32(255, 190, 33, 255),
Localise("Options_Header_Name").c_str(),
4,
@@ -322,7 +322,7 @@ static bool DrawCategories()
constexpr float WIDE_PADDING_GRID_COUNT = 3.0f;
float gridSize = Scale(GRID_SIZE);
float textPadding = gridSize * Lerp(NARROW_PADDING_GRID_COUNT, WIDE_PADDING_GRID_COUNT, g_narrowOffsetScale);
float textPadding = gridSize * Lerp(NARROW_PADDING_GRID_COUNT, WIDE_PADDING_GRID_COUNT, g_aspectRatioNarrowScale);
float tabPadding = gridSize;
float size = Scale(32.0f);
@@ -468,7 +468,7 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
constexpr float OPTION_WIDE_GRID_COUNT = 54.0f;
auto gridSize = Scale(GRID_SIZE);
auto optionWidth = gridSize * floor(Lerp(OPTION_NARROW_GRID_COUNT, OPTION_WIDE_GRID_COUNT, g_narrowOffsetScale));
auto optionWidth = gridSize * floor(Lerp(OPTION_NARROW_GRID_COUNT, OPTION_WIDE_GRID_COUNT, g_aspectRatioNarrowScale));
auto optionHeight = gridSize * 5.5f;
auto optionPadding = gridSize * 0.5f;
auto valueWidth = Scale(192.0f);
@@ -1220,23 +1220,23 @@ void OptionsMenu::Draw()
DrawScanlineBars();
float settingsGridCount = floor(Lerp(SETTINGS_NARROW_GRID_COUNT, SETTINGS_WIDE_GRID_COUNT, g_narrowOffsetScale));
float paddingGridCount = Lerp(PADDING_NARROW_GRID_COUNT, PADDING_WIDE_GRID_COUNT, g_narrowOffsetScale);
float infoGridCount = floor(Lerp(INFO_NARROW_GRID_COUNT, INFO_WIDE_GRID_COUNT, g_narrowOffsetScale));
float settingsGridCount = floor(Lerp(SETTINGS_NARROW_GRID_COUNT, SETTINGS_WIDE_GRID_COUNT, g_aspectRatioNarrowScale));
float paddingGridCount = Lerp(PADDING_NARROW_GRID_COUNT, PADDING_WIDE_GRID_COUNT, g_aspectRatioNarrowScale);
float infoGridCount = floor(Lerp(INFO_NARROW_GRID_COUNT, INFO_WIDE_GRID_COUNT, g_aspectRatioNarrowScale));
float totalGridCount = settingsGridCount + paddingGridCount + infoGridCount;
float offsetX = g_aspectRatioOffsetX + (1280.0f - ((GRID_SIZE * totalGridCount) - 1)) / 2.0f;
float minY = Scale(g_aspectRatioOffsetY + CONTAINER_POS_Y);
float maxY = Scale(g_aspectRatioOffsetY + (720.0f - CONTAINER_POS_Y + 1.0f));
float offsetX = (1280.0f - ((GRID_SIZE * totalGridCount) - 1)) / 2.0f;
float minY = g_aspectRatioOffsetY + Scale(CONTAINER_POS_Y);
float maxY = g_aspectRatioOffsetY + Scale((720.0f - CONTAINER_POS_Y + 1.0f));
DrawSettingsPanel(
{ Scale(offsetX), minY },
{ Scale(offsetX + settingsGridCount * GRID_SIZE), maxY }
{ g_aspectRatioOffsetX + Scale(offsetX), minY },
{ g_aspectRatioOffsetX + Scale(offsetX + settingsGridCount * GRID_SIZE), maxY }
);
DrawInfoPanel(
{ Scale(offsetX + (settingsGridCount + paddingGridCount) * GRID_SIZE), minY },
{ Scale(offsetX + totalGridCount * GRID_SIZE), maxY }
{ g_aspectRatioOffsetX + Scale(offsetX + (settingsGridCount + paddingGridCount) * GRID_SIZE), minY },
{ g_aspectRatioOffsetX + Scale(offsetX + totalGridCount * GRID_SIZE), maxY }
);
if (g_isStage)