ZXHawk: Added non-sync setting to change core background color - #1263

This commit is contained in:
Asnivor 2018-08-06 14:51:10 +01:00
parent 92c3264ff7
commit ddbe1b8a84
4 changed files with 135 additions and 6 deletions

View File

@ -35,6 +35,9 @@
this.lblOSDVerbinfo = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.osdMessageVerbositycomboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.buttonChooseBGColor = new System.Windows.Forms.Button();
this.checkBoxShowCoreBrdColor = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// OkBtn
@ -72,7 +75,7 @@
// lblOSDVerbinfo
//
this.lblOSDVerbinfo.Font = new System.Drawing.Font("Lucida Console", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblOSDVerbinfo.Location = new System.Drawing.Point(175, 107);
this.lblOSDVerbinfo.Location = new System.Drawing.Point(175, 117);
this.lblOSDVerbinfo.Name = "lblOSDVerbinfo";
this.lblOSDVerbinfo.Size = new System.Drawing.Size(196, 21);
this.lblOSDVerbinfo.TabIndex = 28;
@ -82,7 +85,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 91);
this.label4.Location = new System.Drawing.Point(12, 101);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(125, 13);
this.label4.TabIndex = 27;
@ -94,12 +97,41 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.osdMessageVerbositycomboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.osdMessageVerbositycomboBox1.FormattingEnabled = true;
this.osdMessageVerbositycomboBox1.Location = new System.Drawing.Point(12, 107);
this.osdMessageVerbositycomboBox1.Location = new System.Drawing.Point(12, 117);
this.osdMessageVerbositycomboBox1.Name = "osdMessageVerbositycomboBox1";
this.osdMessageVerbositycomboBox1.Size = new System.Drawing.Size(157, 21);
this.osdMessageVerbositycomboBox1.TabIndex = 26;
this.osdMessageVerbositycomboBox1.SelectionChangeCommitted += new System.EventHandler(this.OSDComboBox_SelectionChangeCommitted);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(132, 13);
this.label2.TabIndex = 29;
this.label2.Text = "Default Background Color:";
//
// buttonChooseBGColor
//
this.buttonChooseBGColor.Location = new System.Drawing.Point(150, 36);
this.buttonChooseBGColor.Name = "buttonChooseBGColor";
this.buttonChooseBGColor.Size = new System.Drawing.Size(75, 23);
this.buttonChooseBGColor.TabIndex = 30;
this.buttonChooseBGColor.Text = "Select";
this.buttonChooseBGColor.UseVisualStyleBackColor = true;
this.buttonChooseBGColor.Click += new System.EventHandler(this.buttonChooseBGColor_Click);
//
// checkBoxShowCoreBrdColor
//
this.checkBoxShowCoreBrdColor.AutoSize = true;
this.checkBoxShowCoreBrdColor.Location = new System.Drawing.Point(15, 69);
this.checkBoxShowCoreBrdColor.Name = "checkBoxShowCoreBrdColor";
this.checkBoxShowCoreBrdColor.Size = new System.Drawing.Size(223, 17);
this.checkBoxShowCoreBrdColor.TabIndex = 31;
this.checkBoxShowCoreBrdColor.Text = "Use last Core border color for background";
this.checkBoxShowCoreBrdColor.UseVisualStyleBackColor = true;
//
// ZXSpectrumNonSyncSettings
//
this.AcceptButton = this.OkBtn;
@ -107,6 +139,9 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.CancelBtn;
this.ClientSize = new System.Drawing.Size(385, 177);
this.Controls.Add(this.checkBoxShowCoreBrdColor);
this.Controls.Add(this.buttonChooseBGColor);
this.Controls.Add(this.label2);
this.Controls.Add(this.lblOSDVerbinfo);
this.Controls.Add(this.label4);
this.Controls.Add(this.osdMessageVerbositycomboBox1);
@ -131,5 +166,8 @@
private System.Windows.Forms.Label lblOSDVerbinfo;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox osdMessageVerbositycomboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button buttonChooseBGColor;
private System.Windows.Forms.CheckBox checkBoxShowCoreBrdColor;
}
}

View File

@ -11,6 +11,7 @@ namespace BizHawk.Client.EmuHawk
public partial class ZXSpectrumNonSyncSettings : Form
{
private ZXSpectrum.ZXSpectrumSettings _settings;
private int bgColor;
public ZXSpectrumNonSyncSettings()
{
@ -21,7 +22,11 @@ namespace BizHawk.Client.EmuHawk
{
_settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone();
bgColor = _settings.BackgroundColor;
SetBtnColor();
checkBoxShowCoreBrdColor.Checked = _settings.UseCoreBorderForBackground;
// OSD Message Verbosity
var osdTypes = Enum.GetNames(typeof(ZXSpectrum.OSDVerbosity));
@ -33,14 +38,25 @@ namespace BizHawk.Client.EmuHawk
UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()));
}
private void SetBtnColor()
{
var c = System.Drawing.Color.FromArgb(bgColor);
buttonChooseBGColor.ForeColor = c;
buttonChooseBGColor.BackColor = c;
}
private void OkBtn_Click(object sender, EventArgs e)
{
bool changed =
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString();
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() ||
_settings.BackgroundColor != bgColor ||
_settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked;
if (changed)
{
_settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString());
_settings.BackgroundColor = bgColor;
_settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked;
GlobalWin.MainForm.PutCoreSettings(_settings);
@ -82,5 +98,63 @@ namespace BizHawk.Client.EmuHawk
ComboBox cb = sender as ComboBox;
UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString()));
}
private void buttonChooseBGColor_Click(object sender, EventArgs e)
{
var currColor = _settings.BackgroundColor;
System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor);
ColorDialog cd = new ColorDialog();
System.Drawing.Color[] colors = new System.Drawing.Color[]
{
System.Drawing.Color.FromArgb(0x00, 0x00, 0x00),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7),
System.Drawing.Color.FromArgb(0xD7, 0x00, 0xD7),
System.Drawing.Color.FromArgb(0x00, 0xD7, 0x00),
System.Drawing.Color.FromArgb(0x00, 0xD7, 0xD7),
System.Drawing.Color.FromArgb(0xD7, 0xD7, 0x00),
System.Drawing.Color.FromArgb(0xD7, 0xD7, 0xD7),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0x00, 0x00, 0x00),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0xFF, 0x00, 0x00),
System.Drawing.Color.FromArgb(0xFF, 0x00, 0xFF),
System.Drawing.Color.FromArgb(0x00, 0xFF, 0x00),
System.Drawing.Color.FromArgb(0x00, 0xFF, 0xFF),
System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x00),
System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF),
};
cd.CustomColors = new int[]
{
System.Drawing.ColorTranslator.ToOle(colors[0]),
System.Drawing.ColorTranslator.ToOle(colors[1]),
System.Drawing.ColorTranslator.ToOle(colors[2]),
System.Drawing.ColorTranslator.ToOle(colors[3]),
System.Drawing.ColorTranslator.ToOle(colors[4]),
System.Drawing.ColorTranslator.ToOle(colors[5]),
System.Drawing.ColorTranslator.ToOle(colors[6]),
System.Drawing.ColorTranslator.ToOle(colors[7]),
System.Drawing.ColorTranslator.ToOle(colors[8]),
System.Drawing.ColorTranslator.ToOle(colors[9]),
System.Drawing.ColorTranslator.ToOle(colors[10]),
System.Drawing.ColorTranslator.ToOle(colors[11]),
System.Drawing.ColorTranslator.ToOle(colors[12]),
System.Drawing.ColorTranslator.ToOle(colors[13]),
System.Drawing.ColorTranslator.ToOle(colors[14]),
System.Drawing.ColorTranslator.ToOle(colors[15]),
};
cd.Color = c;
if (cd.ShowDialog() == DialogResult.OK)
{
var color = cd.Color;
var col = color.ToArgb();
bgColor = col;
SetBtnColor();
}
}
}
}

View File

@ -827,7 +827,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public int BackgroundColor
{
get { return ULAPalette[7]; } //ULAPalette[borderColour]; }
get
{
var settings = _machine.Spectrum.GetSettings();
var color = settings.BackgroundColor;
if (!settings.UseCoreBorderForBackground)
return color;
else
return ULAPalette[fetchBorder];
}
}
public int VirtualWidth

View File

@ -80,6 +80,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
[DefaultValue(75)]
public int AYVolume { get; set; }
[DisplayName("Default Background Color")]
[Description("The default BG color")]
[DefaultValue(0)]
public int BackgroundColor { get; set; }
[DisplayName("Use Core Border Color")]
[Description("The core renders the background color from the last detected generated border color")]
[DefaultValue(false)]
public bool UseCoreBorderForBackground { get; set; }
public ZXSpectrumSettings Clone()
{