Refactor window scale menu, add 6x through 9x (squashed PR #3872)

resolves #3826
This commit is contained in:
SkiHatDuckie 2024-03-19 19:48:15 -04:00 committed by GitHub
parent 3f92764bde
commit 328d36d0ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 121 deletions

View File

@ -123,12 +123,6 @@ namespace BizHawk.Client.EmuHawk
this.LoadedCoreNameMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.LoadedCoreNameMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.ViewSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.ViewSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WindowSizeSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.WindowSizeSubMenu = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.x1MenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.x2MenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.x3MenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.x4MenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.x5MenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.mzMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.SwitchToFullscreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.SwitchToFullscreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.toolStripSeparator2 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx(); this.toolStripSeparator2 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
this.DisplayFPSMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.DisplayFPSMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
@ -983,46 +977,9 @@ namespace BizHawk.Client.EmuHawk
// //
// WindowSizeSubMenu // WindowSizeSubMenu
// //
this.WindowSizeSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.x1MenuItem,
this.x2MenuItem,
this.x3MenuItem,
this.x4MenuItem,
this.x5MenuItem,
this.mzMenuItem});
this.WindowSizeSubMenu.Text = "&Window Size"; this.WindowSizeSubMenu.Text = "&Window Size";
this.WindowSizeSubMenu.DropDownOpened += new System.EventHandler(this.WindowSizeSubMenu_DropDownOpened); this.WindowSizeSubMenu.DropDownOpened += new System.EventHandler(this.WindowSizeSubMenu_DropDownOpened);
// //
// x1MenuItem
//
this.x1MenuItem.Text = "&1x";
this.x1MenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// x2MenuItem
//
this.x2MenuItem.Text = "&2x";
this.x2MenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// x3MenuItem
//
this.x3MenuItem.Text = "&3x";
this.x3MenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// x4MenuItem
//
this.x4MenuItem.Text = "&4x";
this.x4MenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// x5MenuItem
//
this.x5MenuItem.Text = "&5x";
this.x5MenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// mzMenuItem
//
this.mzMenuItem.Text = "1&0x";
this.mzMenuItem.Click += new System.EventHandler(this.WindowSize_Click);
//
// SwitchToFullscreenMenuItem // SwitchToFullscreenMenuItem
// //
this.SwitchToFullscreenMenuItem.Text = "Switch to Fullscreen"; this.SwitchToFullscreenMenuItem.Text = "Switch to Fullscreen";
@ -2524,12 +2481,6 @@ namespace BizHawk.Client.EmuHawk
private BizHawk.WinForms.Controls.ToolStripMenuItemEx SaveNamedStateMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx SaveNamedStateMenuItem;
private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator7; private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator7;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx LoadNamedStateMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx LoadNamedStateMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx x1MenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx x2MenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx x3MenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx x4MenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx x5MenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx mzMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MovieSubMenu; private BizHawk.WinForms.Controls.ToolStripMenuItemEx MovieSubMenu;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx RecentMovieSubMenu; private BizHawk.WinForms.Controls.ToolStripMenuItemEx RecentMovieSubMenu;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx RecordMovieMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx RecordMovieMenuItem;

View File

@ -692,45 +692,15 @@ namespace BizHawk.Client.EmuHawk
private void WindowSizeSubMenu_DropDownOpened(object sender, EventArgs e) private void WindowSizeSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
x1MenuItem.Checked = foreach (ToolStripMenuItem item in WindowSizeSubMenu.DropDownItems)
x2MenuItem.Checked =
x3MenuItem.Checked =
x4MenuItem.Checked =
x5MenuItem.Checked =
mzMenuItem.Checked = false;
switch (Config.TargetZoomFactors[Emulator.SystemId])
{ {
case 1: item.Checked = Config.TargetZoomFactors[Emulator.SystemId] == (int) item.Tag;
x1MenuItem.Checked = true;
break;
case 2:
x2MenuItem.Checked = true;
break;
case 3:
x3MenuItem.Checked = true;
break;
case 4:
x4MenuItem.Checked = true;
break;
case 5:
x5MenuItem.Checked = true;
break;
case 10:
mzMenuItem.Checked = true;
break;
} }
} }
private void WindowSize_Click(object sender, EventArgs e) private void WindowSize_Click(object sender, EventArgs e)
{ {
if (sender == x1MenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 1; Config.TargetZoomFactors[Emulator.SystemId] = (int) ((ToolStripMenuItem) sender).Tag;
if (sender == x2MenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 2;
if (sender == x3MenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 3;
if (sender == x4MenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 4;
if (sender == x5MenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 5;
if (sender == mzMenuItem) Config.TargetZoomFactors[Emulator.SystemId] = 10;
FrameBufferResized(); FrameBufferResized();
} }

View File

@ -62,9 +62,29 @@ namespace BizHawk.Client.EmuHawk
AppendAllFilesEntry = false, AppendAllFilesEntry = false,
}; };
private const int WINDOW_SCALE_MAX = 10;
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
UpdateWindowTitle(); UpdateWindowTitle();
ToolStripItem[] CreateWindowSizeFactorSubmenus()
{
var items = new ToolStripItem[WINDOW_SCALE_MAX];
for (int i = 1; i <= WINDOW_SCALE_MAX; i++)
{
long quotient = Math.DivRem(i, 10, out long remainder);
var temp = new ToolStripMenuItemEx
{
Tag = i,
Text = $"{(quotient > 0 ? quotient : "")}&{remainder}x"
};
temp.Click += this.WindowSize_Click;
items[i - 1] = temp;
}
return items;
}
WindowSizeSubMenu.DropDownItems.AddRange(CreateWindowSizeFactorSubmenus());
foreach (var (groupLabel, appliesTo, coreNames) in Config.CorePickerUIData.Select(static tuple => (GroupLabel: tuple.AppliesTo[0], tuple.AppliesTo, tuple.CoreNames)) foreach (var (groupLabel, appliesTo, coreNames) in Config.CorePickerUIData.Select(static tuple => (GroupLabel: tuple.AppliesTo[0], tuple.AppliesTo, tuple.CoreNames))
.OrderBy(static tuple => tuple.GroupLabel)) .OrderBy(static tuple => tuple.GroupLabel))
@ -2733,54 +2753,20 @@ namespace BizHawk.Client.EmuHawk
private void IncreaseWindowSize() private void IncreaseWindowSize()
{ {
switch (Config.TargetZoomFactors[Emulator.SystemId]) if (Config.TargetZoomFactors[Emulator.SystemId] < WINDOW_SCALE_MAX)
{ {
case 1: Config.TargetZoomFactors[Emulator.SystemId]++;
Config.TargetZoomFactors[Emulator.SystemId] = 2;
break;
case 2:
Config.TargetZoomFactors[Emulator.SystemId] = 3;
break;
case 3:
Config.TargetZoomFactors[Emulator.SystemId] = 4;
break;
case 4:
Config.TargetZoomFactors[Emulator.SystemId] = 5;
break;
case 5:
Config.TargetZoomFactors[Emulator.SystemId] = 10;
break;
case 10:
return;
} }
AddOnScreenMessage($"Screensize set to {Config.TargetZoomFactors[Emulator.SystemId]}x"); AddOnScreenMessage($"Screensize set to {Config.TargetZoomFactors[Emulator.SystemId]}x");
FrameBufferResized(); FrameBufferResized();
} }
private void DecreaseWindowSize() private void DecreaseWindowSize()
{ {
switch (Config.TargetZoomFactors[Emulator.SystemId]) if (Config.TargetZoomFactors[Emulator.SystemId] > 1)
{ {
case 1: Config.TargetZoomFactors[Emulator.SystemId]--;
return;
case 2:
Config.TargetZoomFactors[Emulator.SystemId] = 1;
break;
case 3:
Config.TargetZoomFactors[Emulator.SystemId] = 2;
break;
case 4:
Config.TargetZoomFactors[Emulator.SystemId] = 3;
break;
case 5:
Config.TargetZoomFactors[Emulator.SystemId] = 4;
break;
case 10:
Config.TargetZoomFactors[Emulator.SystemId] = 5;
return;
} }
AddOnScreenMessage($"Screensize set to {Config.TargetZoomFactors[Emulator.SystemId]}x"); AddOnScreenMessage($"Screensize set to {Config.TargetZoomFactors[Emulator.SystemId]}x");
FrameBufferResized(); FrameBufferResized();
} }