n64: stop measuring resolutions array with a magic number

This commit is contained in:
feos 2019-06-17 20:07:22 +03:00
parent e8d64cdbbb
commit ef4cda38d1
1 changed files with 9 additions and 7 deletions

View File

@ -15,6 +15,7 @@ namespace BizHawk.Client.EmuHawk
private N64Settings _s;
private N64SyncSettings _ss;
private static string _customResItemName = "Custom";
private static readonly string[] ValidResolutions =
{
"320 x 240",
@ -31,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
"1920 x 1440",
"2048 x 1536",
"2880 x 2160",
"Custom"
_customResItemName
};
private bool _programmaticallyChangingPluginComboBox = false;
@ -105,7 +106,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveSettings()
{
// Global
if (VideoResolutionComboBox.Text != "Custom")
if (VideoResolutionComboBox.Text != _customResItemName)
{
var videoSettings = VideoResolutionComboBox.SelectedItem.ToString();
var strArr = videoSettings.Split('x');
@ -540,9 +541,10 @@ namespace BizHawk.Client.EmuHawk
{
VideoResolutionComboBox.SelectedIndex = index;
}
else if (PluginComboBox.SelectedIndex != 4)
else if (PluginComboBox.SelectedIndex != 4) // wtf
{
VideoResolutionComboBox.SelectedIndex = 13;
VideoResolutionComboBox.SelectedIndex =
VideoResolutionComboBox.Items.IndexOf(_customResItemName);
ShowCustomVideoResolutionControls();
}
@ -1204,7 +1206,7 @@ namespace BizHawk.Client.EmuHawk
int oldSizeX, oldSizeY;
var oldResolution = VideoResolutionComboBox.SelectedItem.ToString();
if (oldResolution != "Custom")
if (oldResolution != _customResItemName)
{
strArr = oldResolution.Split('x');
oldSizeX = int.Parse(strArr[0].Trim());
@ -1233,7 +1235,7 @@ namespace BizHawk.Client.EmuHawk
int bestFit = -1;
for (int i = 0; i < VideoResolutionComboBox.Items.Count; i++)
{
if ((string)VideoResolutionComboBox.Items[i] != "Custom")
if ((string)VideoResolutionComboBox.Items[i] != _customResItemName)
{
string option = (string)VideoResolutionComboBox.Items[i];
strArr = option.Split('x');
@ -1268,7 +1270,7 @@ namespace BizHawk.Client.EmuHawk
private void VideoResolutionComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (VideoResolutionComboBox.Text == "Custom")
if (VideoResolutionComboBox.Text == _customResItemName)
{
ShowCustomVideoResolutionControls();
}