Add an edit dialog for TAStudio palette (resolves #2119)

This commit is contained in:
YoshiRulz 2021-11-19 03:54:37 +10:00
parent 90c489beed
commit e23a2df7e0
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 117 additions and 0 deletions

View File

@ -129,6 +129,7 @@ namespace BizHawk.Client.EmuHawk
this.toolStripSeparator12 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
this.hideWasLagFramesToolStripMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.iconsToolStripMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.ColorSettingsMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.DenoteStatesWithIconsToolStripMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.DenoteStatesWithBGColorToolStripMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.DenoteMarkersWithIconsToolStripMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
@ -700,6 +701,7 @@ namespace BizHawk.Client.EmuHawk
this.RotateMenuItem,
this.HideLagFramesSubMenu,
this.iconsToolStripMenuItem,
this.ColorSettingsMenuItem,
this.toolStripSeparator23,
this.followCursorToolStripMenuItem,
this.toolStripSeparator25,
@ -769,6 +771,11 @@ namespace BizHawk.Client.EmuHawk
this.iconsToolStripMenuItem.Text = "Icons";
this.iconsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.IconsMenuItem_DropDownOpened);
//
// ColorSettingsMenuItem
//
this.ColorSettingsMenuItem.Text = "Edit TAStudio Colors...";
this.ColorSettingsMenuItem.Click += new System.EventHandler(this.ColorSettingsMenuItem_Click);
//
// DenoteStatesWithIconsToolStripMenuItem
//
this.DenoteStatesWithIconsToolStripMenuItem.CheckOnClick = true;
@ -1358,6 +1365,7 @@ namespace BizHawk.Client.EmuHawk
private System.Windows.Forms.SplitContainer MainVertialSplit;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx StartANewProjectFromSaveRamMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx iconsToolStripMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx ColorSettingsMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx DenoteStatesWithIconsToolStripMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx DenoteStatesWithBGColorToolStripMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx DenoteMarkersWithIconsToolStripMenuItem;

View File

@ -1190,6 +1190,9 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog();
}
private void ColorSettingsMenuItem_Click(object sender, EventArgs e)
=> this.ShowDialogAsChild(new TAStudioColorSettingsForm(Palette, p => Settings.Palette = p));
private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e)
{
var inputPrompt = new InputPrompt

View File

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.WinForms.Controls;
namespace BizHawk.Client.EmuHawk
{
public sealed class TAStudioColorSettingsForm : Form
{
/// <remarks>TODO better labels</remarks>
public TAStudioColorSettingsForm(TAStudioPalette initPalette, Action<TAStudioPalette> save)
{
Dictionary<string, Color> colours = new();
void Init(TAStudioPalette fromPalette)
{
// colours["currentFrame_FrameCol"] = fromPalette.CurrentFrame_FrameCol;
colours["currentFrame_InputLog"] = fromPalette.CurrentFrame_InputLog;
colours["greenZone_FrameCol"] = fromPalette.GreenZone_FrameCol;
colours["greenZone_InputLog"] = fromPalette.GreenZone_InputLog;
colours["greenZone_InputLog_Stated"] = fromPalette.GreenZone_InputLog_Stated;
colours["greenZone_InputLog_Invalidated"] = fromPalette.GreenZone_InputLog_Invalidated;
colours["lagZone_FrameCol"] = fromPalette.LagZone_FrameCol;
colours["lagZone_InputLog"] = fromPalette.LagZone_InputLog;
colours["lagZone_InputLog_Stated"] = fromPalette.LagZone_InputLog_Stated;
colours["lagZone_InputLog_Invalidated"] = fromPalette.LagZone_InputLog_Invalidated;
colours["marker_FrameCol"] = fromPalette.Marker_FrameCol;
colours["analogEdit_Col"] = fromPalette.AnalogEdit_Col;
}
Init(initPalette);
ColorDialog picker = new() { FullOpen = true };
Size panelSize = new(20, 20);
SingleRowFLP Row(string key, string labelText) // can't use ref here because those aren't captured in closures :(
{
Panel panel = new() { BackColor = colours[key], BorderStyle = BorderStyle.FixedSingle, Size = panelSize, Tag = key };
panel.Click += (_, _) =>
{
picker.Color = colours[key];
if (picker.ShowDialog().IsOk()) panel.BackColor = colours[key] = picker.Color;
};
return new() { Controls = { panel, new LabelEx { Text = labelText } } };
}
SingleColumnFLP flpPanels = new()
{
Controls =
{
// Row("currentFrame_FrameCol", "CurrentFrame: FrameCol"),
Row("currentFrame_InputLog", "CurrentFrame: InputLog"),
Row("greenZone_FrameCol", "GreenZone: FrameCol"),
Row("greenZone_InputLog", "GreenZone InputLog: Normal"),
Row("greenZone_InputLog_Stated", "GreenZone InputLog: Stated"),
Row("greenZone_InputLog_Invalidated", "GreenZone InputLog: Invalidated"),
Row("lagZone_FrameCol", "LagZone: FrameCol"),
Row("lagZone_InputLog", "LagZone InputLog: Normal"),
Row("lagZone_InputLog_Stated", "LagZone InputLog: Stated"),
Row("lagZone_InputLog_Invalidated", "LagZone InputLog: Invalidated"),
Row("marker_FrameCol", "Marker: FrameCol"),
Row("analogEdit_Col", "AnalogEdit: Col"),
},
};
Size btnSize = new(75, 23);
SzButtonEx btnOK = new() { Size = btnSize, Text = "OK" };
btnOK.Click += (_, _) =>
{
save(new(
// currentFrame_FrameCol: colours["currentFrame_FrameCol"],
currentFrame_InputLog: colours["currentFrame_InputLog"],
greenZone_FrameCol: colours["greenZone_FrameCol"],
greenZone_InputLog: colours["greenZone_InputLog"],
greenZone_InputLog_Stated: colours["greenZone_InputLog_Stated"],
greenZone_InputLog_Invalidated: colours["greenZone_InputLog_Invalidated"],
lagZone_FrameCol: colours["lagZone_FrameCol"],
lagZone_InputLog: colours["lagZone_InputLog"],
lagZone_InputLog_Stated: colours["lagZone_InputLog_Stated"],
lagZone_InputLog_Invalidated: colours["lagZone_InputLog_Invalidated"],
marker_FrameCol: colours["marker_FrameCol"],
analogEdit_Col: colours["analogEdit_Col"]));
Close();
};
SzButtonEx btnCancel = new() { Size = btnSize, Text = "Cancel" };
btnCancel.Click += (_, _) => Close();
SzButtonEx btnDefaults = new() { Size = btnSize, Text = "Defaults" };
btnDefaults.Click += (_, _) =>
{
Init(TAStudioPalette.Default);
foreach (var panel in flpPanels.Controls.Cast<SingleRowFLP>().Select(flp => (Panel)flp.Controls[0]))
{
panel.BackColor = colours[(string) panel.Tag];
}
};
SingleRowFLP flpButtons = new() { Controls = { btnOK, btnCancel, btnDefaults } };
((FlowLayoutPanel) flpButtons).FlowDirection = FlowDirection.RightToLeft; // why did I disable this
SuspendLayout();
BackColor = Color.White;
ClientSize = new(240, 320);
Text = "Edit TAStudio Colors";
Controls.Add(new SingleColumnFLP { Controls = { flpButtons, flpPanels } });
ResumeLayout();
}
}
}