summaryrefslogtreecommitdiff
path: root/src/port/Engine.cpp
diff options
context:
space:
mode:
authorKiloku <mateus.sateles@protonmail.com>2025-01-12 20:15:37 -0300
committerLywx <kiritodev01@gmail.com>2025-01-12 20:00:48 -0600
commit913fbfdd14ab296a469d2889a601b94fce51d2de (patch)
tree79c744597b59168cb47958c72de53ae9c5bcaf7b /src/port/Engine.cpp
parent2d538fac86336d5c9d5cc4628f8e6a00583c2c09 (diff)
Allow customizing HUD aspect ratio independently from game aspect ratio
Diffstat (limited to 'src/port/Engine.cpp')
-rw-r--r--src/port/Engine.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index f7797ad5..39a26a8e 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -538,6 +538,14 @@ extern "C" float OTRGetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
}
+extern "C" float OTRGetHUDAspectRatio() {
+ if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0)
+ {
+ return OTRGetAspectRatio();
+ }
+ return ((float)CVarGetInteger("gHUDAspectRatio.X", 1) / (float)CVarGetInteger("gHUDAspectRatio.Y", 1));
+}
+
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * OTRGetAspectRatio() + (v));
}
@@ -555,6 +563,15 @@ extern "C" float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectR
return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : OTRGetAspectRatio()) -
(gfx_native_dimensions.width - v));
}
+
+extern "C" float OTRGetDimensionFromLeftEdgeOverride(float v) {
+ return OTRGetDimensionFromLeftEdgeForcedAspect(v, OTRGetHUDAspectRatio());
+}
+
+extern "C" float OTRGetDimensionFromRightEdgeOverride(float v) {
+ return OTRGetDimensionFromRightEdgeForcedAspect(v, OTRGetHUDAspectRatio());
+}
+
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
return gfx_current_dimensions.width;
@@ -581,6 +598,14 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdgeForcedAspect(float v, float a
return ((int) ceilf(OTRGetDimensionFromRightEdgeForcedAspect(v, aspectRatio)));
}
+extern "C" int16_t OTRGetRectDimensionFromLeftEdgeOverride(float v) {
+ return OTRGetRectDimensionFromLeftEdgeForcedAspect(v, OTRGetHUDAspectRatio());
+}
+
+extern "C" int16_t OTRGetRectDimensionFromRightEdgeOverride(float v) {
+ return OTRGetRectDimensionFromRightEdgeForcedAspect(v, OTRGetHUDAspectRatio());
+}
+
extern "C" int32_t OTRConvertHUDXToScreenX(int32_t v) {
float gameAspectRatio = gfx_current_dimensions.aspect_ratio;
int32_t gameHeight = gfx_current_dimensions.height;