Use a single-source-of-truth for tools' icons in menus and Tool Box

reverts 733b6c49b
some more `[SpecializedTool]`s have icons now
This commit is contained in:
YoshiRulz 2023-02-08 07:06:58 +10:00
parent 0d02d5c498
commit 8b7cba96bb
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
32 changed files with 244 additions and 76 deletions

View File

@ -102,6 +102,9 @@ namespace BizHawk.Client.EmuHawk
}
}
public static Icon ToolIcon
=> Properties.Resources.Logo;
[ConfigPersist]
private Dictionary<string, CoreInfo> KnownCores { get; set; }
@ -114,7 +117,7 @@ namespace BizHawk.Client.EmuHawk
public CoreFeatureAnalysis()
{
InitializeComponent();
Icon = Properties.Resources.Logo;
Icon = ToolIcon;
KnownCores = new Dictionary<string, CoreInfo>();
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
@ -15,6 +16,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class LogWindow : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.CommandWindow;
// TODO: only show add to game db when this is a Rom details dialog
// Let user decide what type (instead of always adding it as a good dump)
private readonly List<string> _lines = new List<string>();
@ -32,7 +36,7 @@ namespace BizHawk.Client.EmuHawk
public LogWindow()
{
InitializeComponent();
Icon = Properties.Resources.CommandWindow;
Icon = ToolIcon;
AddToGameDbBtn.Image = Properties.Resources.Add;
Closing += (o, e) =>
{

View File

@ -261,34 +261,51 @@ namespace BizHawk.Client.EmuHawk
ProfilesMenuItem.Image = Properties.Resources.Profile;
SaveConfigMenuItem.Image = Properties.Resources.Save;
LoadConfigMenuItem.Image = Properties.Resources.LoadConfig;
ToolBoxMenuItem.Image = Properties.Resources.ToolBox;
RamWatchMenuItem.Image = Properties.Resources.Watch;
RamSearchMenuItem.Image = Properties.Resources.Search;
LuaConsoleMenuItem.Image = Properties.Resources.TextDoc;
TAStudioMenuItem.Image = Properties.Resources.TAStudio;
HexEditorMenuItem.Image = Properties.Resources.Poke;
TraceLoggerMenuItem.Image = Properties.Resources.Pencil;
DebuggerMenuItem.Image = Properties.Resources.Bug;
CodeDataLoggerMenuItem.Image = Properties.Resources.CdLogger;
VirtualPadMenuItem.Image = Properties.Resources.GameController;
BasicBotMenuItem.Image = Properties.Resources.BasicBotBit;
CheatsMenuItem.Image = Properties.Resources.Freeze;
GameSharkConverterMenuItem.Image = Properties.Resources.Shark;
MultiDiskBundlerFileMenuItem.Image = Properties.Resources.SaveConfig;
(ToolBoxMenuItem.Image, /*ToolBoxMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(ToolBox)]
= (/*ToolBox.ToolIcon.ToBitmap()*/Properties.Resources.ToolBox, "Tool Box");
(RamWatchMenuItem.Image, /*RamWatchMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(RamWatch)]
= (/*RamWatch.ToolIcon.ToBitmap()*/Properties.Resources.Watch, "RAM Watch");
(RamSearchMenuItem.Image, /*RamSearchMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(RamSearch)]
= (/*RamSearch.ToolIcon.ToBitmap()*/Properties.Resources.Search, "RAM Search");
(LuaConsoleMenuItem.Image, /*LuaConsoleMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(LuaConsole)]
= (/*LuaConsole.ToolIcon.ToBitmap()*/Properties.Resources.TextDoc, "Lua Console");
(TAStudioMenuItem.Image, /*TAStudioMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(TAStudio)]
= (/*TAStudio.ToolIcon.ToBitmap()*/Properties.Resources.TAStudio, "TAStudio");
(HexEditorMenuItem.Image, /*HexEditorMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(HexEditor)]
= (/*HexEditor.ToolIcon.ToBitmap()*/Properties.Resources.Poke, "Hex Editor");
(TraceLoggerMenuItem.Image, /*TraceLoggerMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(TraceLogger)]
= (/*TraceLogger.ToolIcon.ToBitmap()*/Properties.Resources.Pencil, "Trace Logger");
(DebuggerMenuItem.Image, /*DebuggerMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(GenericDebugger)]
= (/*GenericDebugger.ToolIcon.ToBitmap()*/Properties.Resources.Bug, "Debugger");
(CodeDataLoggerMenuItem.Image, /*CodeDataLoggerMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(CDL)]
= (/*CDL.ToolIcon.ToBitmap()*/Properties.Resources.CdLogger, "Code Data Logger");
(VirtualPadMenuItem.Image, /*VirtualPadMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(VirtualpadTool)]
= (/*VirtualpadTool.ToolIcon.ToBitmap()*/Properties.Resources.GameController, "Virtual Pads");
(BasicBotMenuItem.Image, /*BasicBotMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(BasicBot)]
= (/*BasicBot.ToolIcon.ToBitmap()*/Properties.Resources.BasicBotBit, "Basic Bot");
(CheatsMenuItem.Image, /*CheatsMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(Cheats)]
= (/*Cheats.ToolIcon.ToBitmap()*/Properties.Resources.Freeze, "Cheats");
(GameSharkConverterMenuItem.Image, /*GameSharkConverterMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(GameShark)]
= (/*GameShark.ToolIcon.ToBitmap()*/Properties.Resources.Shark, "Cheat Code Converter");
(MultiDiskBundlerFileMenuItem.Image, /*MultiDiskBundlerFileMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(MultiDiskBundler)]
= (/*MultiDiskBundler.ToolIcon.ToBitmap()*/Properties.Resources.SaveConfig, "Multi-disk Bundler");
NesControllerSettingsMenuItem.Image = Properties.Resources.GameController;
NESGraphicSettingsMenuItem.Image = Properties.Resources.TvIcon;
NESSoundChannelsMenuItem.Image = Properties.Resources.Audio;
KeypadMenuItem.Image = Properties.Resources.Calculator;
(KeypadMenuItem.Image, /*KeypadMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(TI83KeyPad)]
= (/*TI83KeyPad.ToolIcon.ToBitmap()*/Properties.Resources.Calculator, "TI-83 Virtual KeyPad");
PSXControllerSettingsMenuItem.Image = Properties.Resources.GameController;
SNESControllerConfigurationMenuItem.Image = Properties.Resources.GameController;
SnesGfxDebuggerMenuItem.Image = Properties.Resources.Bug;
(SnesGfxDebuggerMenuItem.Image, /*SnesGfxDebuggerMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(SNESGraphicsDebugger)]
= (/*SNESGraphicsDebugger.ToolIcon.ToBitmap()*/Properties.Resources.Bug, "Graphics Debugger");
ColecoControllerSettingsMenuItem.Image = Properties.Resources.GameController;
N64PluginSettingsMenuItem.Image = Properties.Resources.Monitor;
N64ControllerSettingsMenuItem.Image = Properties.Resources.GameController;
IntVControllerSettingsMenuItem.Image = Properties.Resources.GameController;
OnlineHelpMenuItem.Image = Properties.Resources.Help;
ForumsMenuItem.Image = Properties.Resources.TAStudio;
FeaturesMenuItem.Image = Properties.Resources.KitchenSink;
(FeaturesMenuItem.Image, /*FeaturesMenuItem.Text*/_) = ToolManager.IconAndNameCache[typeof(CoreFeatureAnalysis)]
= (/*CoreFeatureAnalysis.ToolIcon.ToBitmap()*/Properties.Resources.KitchenSink, "Core Features");
AboutMenuItem.Image = Properties.Resources.CorpHawkSmall;
DumpStatusButton.Image = Properties.Resources.Blank;
PlayRecordStatusButton.Image = Properties.Resources.Blank;
@ -2147,10 +2164,8 @@ namespace BizHawk.Client.EmuHawk
GenericCoreSubMenu.DropDownItems.Add(new ToolStripSeparator());
foreach (var toolType in specializedTools)
{
ToolStripMenuItem item = new()
{
Text = $"&{toolType.GetCustomAttribute<SpecializedToolAttribute>().DisplayName}",
};
var (icon, name) = Tools.GetIconAndNameFor(toolType);
ToolStripMenuItem item = new() { Image = icon, Text = $"&{name}" };
item.Click += (_, _) => Tools.Load(toolType);
GenericCoreSubMenu.DropDownItems.Add(item);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -19,6 +19,9 @@ namespace BizHawk.Client.EmuHawk
{
private static readonly FilesystemFilterSet BotFilesFSFilterSet = new(new FilesystemFilter("Bot files", new[] { "bot" }));
public static Icon ToolIcon
=> Resources.BasicBot;
private string _currentFileName = "";
private string CurrentFileName
@ -91,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
public BasicBot()
{
InitializeComponent();
Icon = Resources.BasicBot;
Icon = ToolIcon;
NewMenuItem.Image = Resources.NewFile;
OpenMenuItem.Image = Resources.OpenFile;
SaveMenuItem.Image = Resources.SaveAs;

View File

@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
@ -22,6 +23,9 @@ namespace BizHawk.Client.EmuHawk
{
private static readonly FilesystemFilterSet CDLFilesFSFilterSet = new(new FilesystemFilter("Code Data Logger Files", new[] { "cdl" }));
public static Icon ToolIcon
=> Resources.CdLoggerIcon;
private RecentFiles _recentFld = new RecentFiles();
[ConfigPersist]
@ -75,7 +79,7 @@ namespace BizHawk.Client.EmuHawk
tsbLoggingActive.Image = Resources.Placeholder;
tsbViewUpdate.Image = Resources.Placeholder;
tsbExportText.Image = Resources.LoadConfig;
Icon = Resources.CdLoggerIcon;
Icon = ToolIcon;
tsbViewStyle.SelectedIndex = 0;

View File

@ -29,6 +29,9 @@ namespace BizHawk.Client.EmuHawk
private static readonly FilesystemFilterSet CheatsFSFilterSet = new(new FilesystemFilter("Cheat Files", new[] { "cht" }));
public static Icon ToolIcon
=> Resources.FreezeIcon;
private string _sortedColumn;
private bool _sortReverse;
@ -37,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
public Cheats()
{
InitializeComponent();
Icon = Resources.FreezeIcon;
Icon = ToolIcon;
ToggleContextMenuItem.Image = Resources.Refresh;
RemoveContextMenuItem.Image = Resources.Delete;
DisableAllContextMenuItem.Image = Resources.Stop;

View File

@ -14,12 +14,15 @@ namespace BizHawk.Client.EmuHawk
private const string AddressColumnName = "Address";
private const string InstructionColumnName = "Instruction";
public static Icon ToolIcon
=> Properties.Resources.BugIcon;
protected override string WindowTitleStatic => "Debugger";
public GenericDebugger()
{
InitializeComponent();
Icon = Properties.Resources.BugIcon;
Icon = ToolIcon;
Closing += (o, e) => DisengageDebugger();
DisassemblerView.QueryItemText += DisassemblerView_QueryItemText;

View File

@ -13,6 +13,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class GbGpuView : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.GambatteIcon;
[RequiredService]
public IGameboyCommon Gb { get; private set; }
@ -69,7 +72,7 @@ namespace BizHawk.Client.EmuHawk
public GbGpuView()
{
InitializeComponent();
Icon = Properties.Resources.GambatteIcon;
Icon = ToolIcon;
bmpViewBG.ChangeBitmapSize(256, 256);
bmpViewWin.ChangeBitmapSize(256, 256);
bmpViewTiles1.ChangeBitmapSize(128, 192);

View File

@ -16,6 +16,9 @@ namespace BizHawk.Client.EmuHawk
// the bg color
private static readonly uint PaperColor = (uint)Color.AntiqueWhite.ToArgb();
public static Icon ToolIcon
=> Properties.Resources.GambatteIcon;
private readonly ColorMatrix _paperAdjustment;
[RequiredService]
@ -35,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
public GBPrinterView()
{
InitializeComponent();
Icon = Properties.Resources.GambatteIcon;
Icon = ToolIcon;
// adjust the color of the printed output to be more papery
_paperAdjustment = new ColorMatrix

View File

@ -14,6 +14,9 @@ namespace BizHawk.Client.EmuHawk
[SpecializedTool("GPU Viewer")]
public partial class GbaGpuView : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.GbaIcon.Value;
[RequiredService]
private IGBAGPUViewable GBA { get; set; }
@ -34,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
public GbaGpuView()
{
InitializeComponent();
Icon = Properties.Resources.GbaIcon.Value;
Icon = ToolIcon;
// TODO: hook up something
// we do this twice to avoid having to & 0x7fff with every color
int[] tmp = GBColors.GetLut(GBColors.ColorType.vivid);

View File

@ -1,4 +1,5 @@
using System;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
@ -18,6 +19,9 @@ namespace BizHawk.Client.EmuHawk
unsupportedCores: new[] { CoreNames.Snes9X })]
public partial class GameShark : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.SharkIcon;
[RequiredService]
// ReSharper disable once UnusedAutoPropertyAccessor.Local
private IMemoryDomains MemoryDomains { get; set; }
@ -31,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
public GameShark()
{
InitializeComponent();
Icon = Properties.Resources.SharkIcon;
Icon = ToolIcon;
}
private void Go_Click(object sender, EventArgs e)

View File

@ -53,6 +53,9 @@ namespace BizHawk.Client.EmuHawk
private static readonly FilesystemFilterSet TextTablesFSFilterSet = new(new FilesystemFilter("Text Table Files", new[] { "tbl" }));
public static Icon ToolIcon
=> Resources.PokeIcon;
private static FilesystemFilterSet CreateBinaryDumpFSFilterSet(string ext)
=> new(new FilesystemFilter("Binary", new[] { ext }));
@ -148,7 +151,7 @@ namespace BizHawk.Client.EmuHawk
if (OSTailoredCode.IsUnixHost) _fontHeight -= MAGIC_FIX_NUMBER_H;
InitializeComponent();
Icon = Resources.PokeIcon;
Icon = ToolIcon;
SaveMenuItem.Image = Resources.SaveAs;
CopyMenuItem.Image = Resources.Duplicate;
PasteMenuItem.Image = Resources.Paste;

View File

@ -30,6 +30,9 @@ namespace BizHawk.Client.EmuHawk
private static readonly FilesystemFilterSet SessionsFSFilterSet = new FilesystemFilterSet(new FilesystemFilter("Lua Session Files", new[] { "luases" }));
public static Icon ToolIcon
=> Resources.TextDocIcon;
private readonly LuaAutocompleteInstaller _luaAutoInstaller = new LuaAutocompleteInstaller();
private readonly Dictionary<LuaFile, FileSystemWatcher> _watches = new();
@ -117,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
InsertSeparatorToolbarItem.Image = Resources.InsertSeparator;
EraseToolbarItem.Image = Resources.Erase;
RecentScriptsSubMenu.Image = Resources.Recent;
Icon = Resources.TextDocIcon;
Icon = ToolIcon;
Closing += (o, e) =>
{

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
@ -17,6 +18,9 @@ namespace BizHawk.Client.EmuHawk
public static readonly FilesystemFilterSet MacrosFSFilterSet = new FilesystemFilterSet(new FilesystemFilter("Movie Macros", new[] { "bk2m" }));
public static Icon ToolIcon
=> Properties.Resources.TAStudioIcon;
private readonly List<MovieZone> _zones = new List<MovieZone>();
private readonly List<int> _unsavedZones = new List<int>();
private bool _selecting;
@ -34,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
{
_initializing = true;
InitializeComponent();
Icon = Properties.Resources.TAStudioIcon;
Icon = ToolIcon;
}
private void MacroInputTool_Load(object sender, EventArgs e)

View File

@ -20,6 +20,9 @@ namespace BizHawk.Client.EmuHawk
{
private static readonly FilesystemFilterSet BundlesFSFilterSet = new(new FilesystemFilter("XML Files", new[] { "xml" }));
public static Icon ToolIcon
=> Properties.Resources.DualIcon;
private XElement _currentXml;
[RequiredService]
@ -30,7 +33,7 @@ namespace BizHawk.Client.EmuHawk
public MultiDiskBundler()
{
InitializeComponent();
Icon = Properties.Resources.DualIcon;
Icon = ToolIcon;
SystemDropDown.Items.AddRange(new[]
{
VSystemID.Raw.AmstradCPC,

View File

@ -1,4 +1,6 @@
using System;
using System.Drawing;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Common;
@ -7,6 +9,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class BarcodeEntry : ToolFormBase
{
public static Icon ToolIcon
=> Properties.Resources.NesControllerIcon;
[RequiredService]
private DatachBarcode Reader { get; set; }
@ -15,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
public BarcodeEntry()
{
InitializeComponent();
Icon = Properties.Resources.NesControllerIcon;
Icon = ToolIcon;
}
public override void Restart()

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Linq;
@ -22,6 +23,9 @@ namespace BizHawk.Client.EmuHawk
AppendAllFilesEntry = false,
};
public static Icon ToolIcon
=> Properties.Resources.NesControllerIcon;
[RequiredService]
private NES Nes { get; set; }
@ -30,7 +34,7 @@ namespace BizHawk.Client.EmuHawk
public NESMusicRipper()
{
InitializeComponent();
Icon = Properties.Resources.NesControllerIcon;
Icon = ToolIcon;
SyncContents();
}

View File

@ -13,6 +13,10 @@ namespace BizHawk.Client.EmuHawk
{
// TODO:
// Show Scroll Lines + UI Toggle
public static Icon ToolIcon
=> Properties.Resources.NesControllerIcon;
[RequiredService]
private INESPPUViewable _ppu { get; set; }
[RequiredService]
@ -32,7 +36,7 @@ namespace BizHawk.Client.EmuHawk
public NESNameTableViewer()
{
InitializeComponent();
Icon = Properties.Resources.NesControllerIcon;
Icon = ToolIcon;
}
private void NESNameTableViewer_Load(object sender, EventArgs e)

View File

@ -16,6 +16,10 @@ namespace BizHawk.Client.EmuHawk
// Speedups
// Smarter refreshing? only refresh when things of changed, perhaps peek at the ppu to when the pattern table has changed, or sprites have moved
// Maybe 48 individual bitmaps for sprites is faster than the overhead of redrawing all that transparent space
public static Icon ToolIcon
=> Properties.Resources.NesControllerIcon;
private readonly byte[] _ppuBusPrev = new byte[0x3000];
private readonly byte[] _palRamPrev = new byte[0x20];
@ -49,7 +53,7 @@ namespace BizHawk.Client.EmuHawk
public NesPPU()
{
InitializeComponent();
Icon = Properties.Resources.NesControllerIcon;
Icon = ToolIcon;
CalculateFormSize();
}

View File

@ -12,6 +12,9 @@ namespace BizHawk.Client.EmuHawk
[SpecializedTool("BG Viewer")]
public partial class PceBgViewer : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.PceIcon;
[RequiredService]
public IPceGpuView Viewer { get; private set; }
[RequiredService]
@ -32,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
public PceBgViewer()
{
InitializeComponent();
Icon = Properties.Resources.PceIcon;
Icon = ToolIcon;
Activated += (o, e) => Generate();
}

View File

@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
@ -14,6 +15,9 @@ namespace BizHawk.Client.EmuHawk
[SpecializedTool("Sound Debugger")]
public partial class PCESoundDebugger : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.BugIcon;
[RequiredService]
private PCEngine PCE { get; set; }
@ -22,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
public PCESoundDebugger()
{
InitializeComponent();
Icon = Properties.Resources.BugIcon;
Icon = ToolIcon;
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);

View File

@ -12,6 +12,9 @@ namespace BizHawk.Client.EmuHawk
[SpecializedTool("Tile Viewer")]
public partial class PceTileViewer : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.PceIcon;
[RequiredService]
public IPceGpuView Viewer { get; private set; }
@ -26,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
public PceTileViewer()
{
InitializeComponent();
Icon = Properties.Resources.PceIcon;
Icon = ToolIcon;
bmpViewBG.ChangeBitmapSize(512, 256);
bmpViewSP.ChangeBitmapSize(512, 256);
bmpViewBGPal.ChangeBitmapSize(256, 256);

View File

@ -12,6 +12,9 @@ namespace BizHawk.Client.EmuHawk
[SpecializedTool("VDP Viewer")]
public partial class SmsVdpViewer : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.SmsIcon;
[RequiredService]
private ISmsGpuView Vdp { get; set; }
@ -25,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
public SmsVdpViewer()
{
InitializeComponent();
Icon = Properties.Resources.SmsIcon;
Icon = ToolIcon;
bmpViewTiles.ChangeBitmapSize(256, 128);
bmpViewPalette.ChangeBitmapSize(16, 2);

View File

@ -18,6 +18,9 @@ namespace BizHawk.Client.EmuHawk
{
public static readonly FilesystemFilterSet TAStudioProjectsFSFilterSet = new(FilesystemFilter.TAStudioProjects);
public static Icon ToolIcon
=> Resources.TAStudioIcon;
public override bool BlocksInputWhenFocused => IsInMenuLoop;
public new IMainFormForTools MainForm => base.MainForm;
@ -125,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
recentMacrosToolStripMenuItem.Image = Resources.Recent;
TASEditorManualOnlineMenuItem.Image = Resources.Help;
ForumThreadMenuItem.Image = Resources.TAStudio;
Icon = Resources.TAStudioIcon;
Icon = ToolIcon;
_defaultMainSplitDistance = MainVertialSplit.SplitterDistance;
_defaultBranchMarkerSplitDistance = BranchesMarkersSplit.SplitterDistance;

View File

@ -11,6 +11,9 @@ namespace BizHawk.Client.EmuHawk
{
public sealed partial class TI83KeyPad : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Resources.CalculateIcon;
[RequiredService]
// ReSharper disable once UnusedAutoPropertyAccessor.Local
public TI83Common Emu { get; private set; }
@ -20,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
public TI83KeyPad()
{
InitializeComponent();
Icon = Resources.CalculateIcon;
Icon = ToolIcon;
LeftButton.Image = Resources.WhiteTriLeft;
RightButton.Image = Resources.WhiteTriRight;
DownButton.Image = Resources.WhiteTriDown;

View File

@ -14,6 +14,9 @@ namespace BizHawk.Client.EmuHawk
{
private static readonly Lazy<Image> IconMissingIcon = new(() => Properties.Resources.Logo.ToBitmap());
public static Icon ToolIcon
=> Properties.Resources.ToolBoxIcon;
private static readonly Lazy<IReadOnlyCollection<Type>> ToolTypes = new(() => EmuHawk.ReflectionCache.Types
.Where(static t => typeof(IToolForm).IsAssignableFrom(t) && typeof(Form).IsAssignableFrom(t))
.Where(VersionInfo.DeveloperBuild
@ -29,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
public ToolBox()
{
InitializeComponent();
Icon = Properties.Resources.ToolBoxIcon;
Icon = ToolIcon;
}
private void ToolBox_Load(object sender, EventArgs e)
@ -55,33 +58,11 @@ namespace BizHawk.Client.EmuHawk
foreach (var t in ToolTypes.Value)
{
if (!ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) continue;
Icon/*?*/ image_t = null;
if (t.FullName == "BizHawk.Client.EmuHawk.CoreFeatureAnalysis") { image_t = Properties.Resources.Logo; }
if (t.FullName == "BizHawk.Client.EmuHawk.LogWindow") { image_t = Properties.Resources.CommandWindow; }
if (t.FullName == "BizHawk.Client.EmuHawk.LuaConsole") { image_t = Properties.Resources.TextDocIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.MacroInputTool") { image_t = Properties.Resources.TAStudioIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.MultiDiskBundler") { image_t = Properties.Resources.DualIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.VirtualpadTool") { image_t = Properties.Resources.GameControllerIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.BasicBot") { image_t = Properties.Resources.BasicBot; }
if (t.FullName == "BizHawk.Client.EmuHawk.CDL") { image_t = Properties.Resources.CdLoggerIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.Cheats") { image_t = Properties.Resources.BugIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.GenericDebugger") { image_t = Properties.Resources.BugIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.GameShark") { image_t = Properties.Resources.SharkIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.GBPrinterView") { image_t = Properties.Resources.GambatteIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.GbGpuView") { image_t = Properties.Resources.GambatteIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.HexEditor") { image_t = Properties.Resources.FreezeIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.TAStudio") { image_t = Properties.Resources.TAStudioIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.TraceLogger") { image_t = Properties.Resources.PencilIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.RamSearch") { image_t = Properties.Resources.SearchIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.RamWatch") { image_t = Properties.Resources.WatchIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.NESSoundConfig") { image_t = Properties.Resources.NesControllerIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.NESMusicRipper") { image_t = Properties.Resources.NesControllerIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.NesPPU") { image_t = Properties.Resources.MonitorIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.NESNameTableViewer") { image_t = Properties.Resources.MonitorIcon; }
if (t.FullName == "BizHawk.Client.EmuHawk.SmsVdpViewer") { image_t = Properties.Resources.SmsIcon; }
var (icon, name) = Tools.GetIconAndNameFor(t);
ToolStripButton tsb = new() {
DisplayStyle = ToolStripItemDisplayStyle.Image,
Image = image_t?.ToBitmap() ?? IconMissingIcon.Value,
Image = icon ?? IconMissingIcon.Value,
Text = name,
};
tsb.Click += (_, _) => Tools.Load(t);
ToolBoxStrip.Items.Add(tsb);

View File

@ -447,6 +447,7 @@ namespace BizHawk.Client.EmuHawk
/// Determines whether a given IToolForm is already loaded
/// </summary>
/// <typeparam name="T">Type of tool to check</typeparam>
/// <remarks>yo why do we have 4 versions of this, each with slightly different behaviour in edge cases --yoshi</remarks>
public bool IsLoaded<T>() where T : IToolForm
=> _tools.OfType<T>().FirstOrDefault()?.IsActive is true;
@ -482,6 +483,80 @@ namespace BizHawk.Client.EmuHawk
return Load<T>(false);
}
/// <summary>
/// returns the instance of <paramref name="toolType"/>, regardless of whether it's loaded,<br/>
/// but doesn't create and load a new instance if it's not found
/// </summary>
/// <remarks>
/// does not check <paramref name="toolType"/> is a class implementing <see cref="IToolForm"/>;<br/>
/// you may pass any class or interface
/// </remarks>
public IToolForm/*?*/ LazyGet(Type toolType)
=> _tools.Find(t => toolType.IsAssignableFrom(t.GetType()));
internal static readonly IDictionary<Type, (Image/*?*/ Icon, string Name)> IconAndNameCache = new Dictionary<Type, (Image/*?*/ Icon, string Name)>
{
[typeof(LogWindow)] = (LogWindow.ToolIcon.ToBitmap(), "Log Window"), // can't do this lazily, see https://github.com/TASEmulators/BizHawk/issues/2741#issuecomment-1421014589
};
private static PropertyInfo/*?*/ _PInfo_FormBase_WindowTitleStatic = null;
private static PropertyInfo PInfo_FormBase_WindowTitleStatic
=> _PInfo_FormBase_WindowTitleStatic ??= typeof(FormBase).GetProperty("WindowTitleStatic", BindingFlags.NonPublic | BindingFlags.Instance);
private static bool CaptureIconAndName(object tool, Type toolType, ref Image/*?*/ icon, ref string/*?*/ name)
{
if (IconAndNameCache.ContainsKey(toolType)) return true;
Form winform = null;
if (name is null)
{
winform = tool as FormBase;
if (winform is not null)
{
// then `tool is Formbase` and this getter call is safe
name = (string) PInfo_FormBase_WindowTitleStatic.GetValue(tool);
// could do `tool._windowTitleStatic ??= tool.WindowTitleStatic`, but the getter's only being run 1 extra time here anyway so not worth the LOC
}
winform ??= tool as Form;
if (winform is not null)
{
icon = winform.Icon?.ToBitmap();
name ??= winform.Name;
}
}
if (!string.IsNullOrWhiteSpace(name))
{
IconAndNameCache[toolType] = (icon, name);
return true;
}
// else don't cache anything
name = winform?.Text;
return false;
}
private static void CaptureIconAndName(object tool, Type toolType)
{
Image/*?*/ icon = null;
string/*?*/ name = null;
CaptureIconAndName(tool, toolType, ref icon, ref name);
}
public (Image/*?*/ Icon, string Name) GetIconAndNameFor(Type toolType)
{
if (IconAndNameCache.TryGetValue(toolType, out var tuple)) return tuple;
Image/*?*/ icon = null;
var name = toolType.GetCustomAttribute<SpecializedToolAttribute>()?.DisplayName; //TODO codegen ToolIcon and WindowTitleStatic from [Tool] or some new attribute -- Bitmap..ctor(Type, string)
var instance = LazyGet(toolType);
if (instance is not null)
{
if (CaptureIconAndName(instance, toolType, ref icon, ref name)) return (icon, name);
// else fall through
}
return (
icon ?? (toolType.GetProperty("ToolIcon", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) as Icon)?.ToBitmap(),
string.IsNullOrWhiteSpace(name) ? toolType.Name : name);
}
public IEnumerable<Type> AvailableTools => EmuHawk.ReflectionCache.Types
.Where(t => !t.IsInterface && typeof(IToolForm).IsAssignableFrom(t) && IsAvailable(t));
@ -650,7 +725,7 @@ namespace BizHawk.Client.EmuHawk
{
tool = (IToolForm)Activator.CreateInstance(toolType);
}
CaptureIconAndName(tool, toolType);
// Add to our list of tools
_tools.Add(tool);
return tool;
@ -735,6 +810,7 @@ namespace BizHawk.Client.EmuHawk
_tools.Remove(tool);
}
tool = new T();
CaptureIconAndName(tool, typeof(T));
_tools.Add(tool);
return tool;
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
@ -13,6 +14,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class TraceLogger : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.PencilIcon;
private static readonly FilesystemFilterSet LogFilesFSFilterSet = new(
new FilesystemFilter("Log Files", new[] { "log" }),
FilesystemFilter.TextFiles);
@ -70,7 +74,7 @@ namespace BizHawk.Client.EmuHawk
public TraceLogger()
{
InitializeComponent();
Icon = Properties.Resources.PencilIcon;
Icon = ToolIcon;
SaveLogMenuItem.Image = Properties.Resources.SaveAs;
TraceView.QueryItemText += TraceView_QueryItemText;

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
@ -11,6 +12,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class VirtualpadTool : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Properties.Resources.GameControllerIcon;
[RequiredService]
private IEmulator Emulator { get; set; }
@ -47,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
{
StickyPads = true;
InitializeComponent();
Icon = Properties.Resources.GameControllerIcon;
Icon = ToolIcon;
}
private void VirtualpadTool_Load(object sender, EventArgs e)

View File

@ -26,6 +26,9 @@ namespace BizHawk.Client.EmuHawk
private const int MaxDetailedSize = 1024 * 1024; // 1mb, semi-arbitrary decision, sets the size to check for and automatically switch to fast mode for the user
private const int MaxSupportedSize = 1024 * 1024 * 64; // 64mb, semi-arbitrary decision, sets the maximum size RAM Search will support (as it will crash beyond this)
public static Icon ToolIcon
=> Resources.SearchIcon;
// TODO: DoSearch grabs the state of widgets and passes it to the engine before running, so rip out code that is attempting to keep the state up to date through change events
private string _currentFileName = "";
@ -48,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
InitializeComponent();
Icon = Resources.SearchIcon;
Icon = ToolIcon;
SearchMenuItem.Image = Resources.Search;
DoSearchContextMenuItem.Image = Resources.Search;
NewSearchContextMenuItem.Image = Resources.Restart;

View File

@ -18,6 +18,9 @@ namespace BizHawk.Client.EmuHawk
{
public partial class RamWatch : ToolFormBase, IToolFormAutoConfig
{
public static Icon ToolIcon
=> Resources.WatchIcon;
private WatchList _watches;
private string _sortedColumn;
@ -81,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
MoveDownMenuItem.Image = Resources.MoveDown;
MoveTopMenuItem.Image = Resources.MoveTop;
MoveBottomMenuItem.Image = Resources.MoveBottom;
Icon = Resources.WatchIcon;
Icon = ToolIcon;
Settings = new RamWatchSettings();