Make some extension methods for doing the icon and text logic for the core statusbar item, makes for some prettier syntax, but also makes it easier to use this logic elsewhere

This commit is contained in:
adelikat 2014-07-29 01:11:57 +00:00
parent 9d72250fa1
commit 4346504e24
3 changed files with 93 additions and 58 deletions

View File

@ -498,6 +498,7 @@
<Compile Include="DisplayManager\SwappableDisplaySurfaceSet.cs" />
<Compile Include="DisplayManager\TextureFrugalizer.cs" />
<Compile Include="Extensions\ControlExtensions.cs" />
<Compile Include="Extensions\CoreExtensions.cs" />
<Compile Include="Extensions\ToolExtensions.cs" />
<Compile Include="GlobalWin.cs" />
<Compile Include="Input\GamePad.cs" Condition=" '$(OS)' == 'Windows_NT' " />

View File

@ -0,0 +1,88 @@
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Emulation.Cores.Atari.Atari7800;
using BizHawk.Emulation.Cores.Nintendo.GBA;
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
using BizHawk.Emulation.Cores.Sega.Saturn;
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
using BizHawk.Emulation.Cores.Sony.PSP;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.CoreExtensions
{
public static class CoreExtensions
{
public static Bitmap Icon(this IEmulator core)
{
var attributes = Global.Emulator.Attributes();
if (!attributes.Ported)
{
return Properties.Resources.CorpHawkSmall;
}
if (Global.Emulator is QuickNES)
{
return Properties.Resources.QuickNes;
}
else if (Global.Emulator is LibsnesCore)
{
return Properties.Resources.bsnes;
}
else if (Global.Emulator is Yabause)
{
return Properties.Resources.yabause;
}
else if (Global.Emulator is Atari7800)
{
return Properties.Resources.emu7800;
}
else if (Global.Emulator is GBA)
{
return Properties.Resources.meteor;
}
else if (Global.Emulator is GPGX)
{
return Properties.Resources.genplus;
}
else if (Global.Emulator is PSP)
{
return Properties.Resources.ppsspp;
}
else if (Global.Emulator is Gameboy)
{
return Properties.Resources.gambatte;
}
else if (Global.Emulator is Snes9x)
{
return Properties.Resources.snes9x;
}
else
{
return null;
}
}
public static string DisplayName(this IEmulator core)
{
var attributes = Global.Emulator.Attributes();
var str = (!attributes.Released ? "(Experimental) " : string.Empty) +
attributes.CoreName;
if (Global.Emulator is LibsnesCore)
{
str += " (" + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile + ")";
}
return str;
}
}
}

View File

@ -18,7 +18,6 @@ using BizHawk.Bizware.BizwareGL;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Emulation.Cores.Atari.Atari2600;
using BizHawk.Emulation.Cores.Atari.Atari7800;
using BizHawk.Emulation.Cores.Calculators;
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
using BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
@ -28,14 +27,12 @@ using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.PCEngine;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
using BizHawk.Emulation.Cores.Sega.Saturn;
using BizHawk.Emulation.Cores.Sony.PSP;
using BizHawk.Emulation.DiscSystem;
using BizHawk.Emulation.Cores.Nintendo.N64;
using BizHawk.Client.EmuHawk.WinFormExtensions;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
using BizHawk.Client.EmuHawk.CoreExtensions;
namespace BizHawk.Client.EmuHawk
{
@ -2450,62 +2447,11 @@ namespace BizHawk.Client.EmuHawk
}
CoreNameStatusBarButton.Visible = true;
CoreAttributes attributes = Global.Emulator.Attributes();
CoreNameStatusBarButton.Text =
(!attributes.Released ? "(Experimental) " : string.Empty) +
attributes.CoreName;
var attributes = Global.Emulator.Attributes();
CoreNameStatusBarButton.Text = Global.Emulator.DisplayName();
CoreNameStatusBarButton.Image = Global.Emulator.Icon();
CoreNameStatusBarButton.ToolTipText = attributes.Ported ? "(ported) " : string.Empty;
if (!attributes.Ported)
{
CoreNameStatusBarButton.Image = Properties.Resources.CorpHawkSmall;
}
else
{
if (Global.Emulator is QuickNES)
{
CoreNameStatusBarButton.Image = Properties.Resources.QuickNes;
}
else if (Global.Emulator is LibsnesCore)
{
CoreNameStatusBarButton.Image = Properties.Resources.bsnes;
CoreNameStatusBarButton.Text += " (" + ((LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings()).Profile + ")";
}
else if (Global.Emulator is Yabause)
{
CoreNameStatusBarButton.Image = Properties.Resources.yabause;
}
else if (Global.Emulator is Atari7800)
{
CoreNameStatusBarButton.Image = Properties.Resources.emu7800;
}
else if (Global.Emulator is GBA)
{
CoreNameStatusBarButton.Image = Properties.Resources.meteor;
}
else if (Global.Emulator is GPGX)
{
CoreNameStatusBarButton.Image = Properties.Resources.genplus;
}
else if (Global.Emulator is PSP)
{
CoreNameStatusBarButton.Image = Properties.Resources.ppsspp;
}
else if (Global.Emulator is Gameboy)
{
CoreNameStatusBarButton.Image = Properties.Resources.gambatte;
}
else if (Global.Emulator is Snes9x)
{
CoreNameStatusBarButton.Image = Properties.Resources.snes9x;
}
else
{
CoreNameStatusBarButton.Image = null;
}
}
}
#endregion