Skip to content

Commit b0b59c8

Browse files
authored
fix: pick second-largest resolution that matches resolution, or is 16:9 and is smaller than the current display in both directions (AscensionGameDev#2106)
1 parent 81d666c commit b0b59c8

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Intersect.Client/MonoGame/Graphics/MonoRenderer.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class MonoRenderer : GameRenderer
8989

9090
private bool mSpriteBatchBegan;
9191

92-
private List<string> mValidVideoModes;
92+
private List<string>? _validVideoModes;
9393

9494
private GameTexture? mWhiteTexture;
9595

@@ -766,17 +766,17 @@ public Resolution[] GetAllowedResolutions()
766766

767767
public override List<string> GetValidVideoModes()
768768
{
769-
if (mValidVideoModes != null)
769+
if (_validVideoModes != null)
770770
{
771-
return mValidVideoModes;
771+
return _validVideoModes;
772772
}
773773

774-
mValidVideoModes = new List<string>();
774+
_validVideoModes = new List<string>();
775775

776776
var allowedResolutions = GetAllowedResolutions();
777777

778-
var displayWidth = mGraphicsDevice?.DisplayMode?.Width;
779-
var displayHeight = mGraphicsDevice?.DisplayMode?.Height;
778+
var displayWidth = mGraphicsDevice.DisplayMode?.Width;
779+
var displayHeight = mGraphicsDevice.DisplayMode?.Height;
780780

781781
foreach (var resolution in allowedResolutions)
782782
{
@@ -790,10 +790,10 @@ public override List<string> GetValidVideoModes()
790790
continue;
791791
}
792792

793-
mValidVideoModes.Add(resolution.ToString());
793+
_validVideoModes.Add(resolution.ToString());
794794
}
795795

796-
return mValidVideoModes;
796+
return _validVideoModes;
797797
}
798798

799799
public override FloatRect GetView()
@@ -818,8 +818,20 @@ public override void Init()
818818
var allowedResolutions = GetAllowedResolutions();
819819
var currentDisplayMode = mGraphicsDevice.Adapter.CurrentDisplayMode;
820820
var defaultResolution = allowedResolutions.LastOrDefault(
821-
allowedResolution => allowedResolution.X < currentDisplayMode.Width && allowedResolution.Y < currentDisplayMode.Height
821+
allowedResolution => currentDisplayMode.Width != allowedResolution.X &&
822+
currentDisplayMode.Width ==
823+
allowedResolution.X * currentDisplayMode.Height / allowedResolution.Y
822824
);
825+
826+
if (defaultResolution == default)
827+
{
828+
defaultResolution = allowedResolutions.LastOrDefault(
829+
allowedResolution => allowedResolution.X * 9 / 16 == allowedResolution.Y &&
830+
allowedResolution.X < currentDisplayMode.Width &&
831+
allowedResolution.Y < currentDisplayMode.Height
832+
);
833+
}
834+
823835
if (defaultResolution != default)
824836
{
825837
database.TargetResolution = allowedResolutions.IndexOf(defaultResolution);

0 commit comments

Comments
 (0)