NES Graphics config - hook up sprite, background toggling, and background color selection. Fix up bugs. Also add the files to SVN, since I always forget that the first time!

This commit is contained in:
andres.delikat 2011-06-11 14:40:00 +00:00
parent ef4b30cbd2
commit d70121bc04
3 changed files with 535 additions and 0 deletions

View File

@ -0,0 +1,309 @@
namespace BizHawk.MultiClient
{
partial class NESGraphicsConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.AllowMoreSprites = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.AutoLoadPalette = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.PalettePath = new System.Windows.Forms.TextBox();
this.BrowsePalette = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.ClipLeftAndRightCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.BackgroundColorPanel = new System.Windows.Forms.Panel();
this.DispBackground = new System.Windows.Forms.CheckBox();
this.DispSprites = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.BackGroundColorNumber = new System.Windows.Forms.TextBox();
this.ChangeBGColor = new System.Windows.Forms.Button();
this.BGColorDialog = new System.Windows.Forms.ColorDialog();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(213, 403);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0;
this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(294, 403);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 1;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
//
// AllowMoreSprites
//
this.AllowMoreSprites.AutoSize = true;
this.AllowMoreSprites.Location = new System.Drawing.Point(9, 19);
this.AllowMoreSprites.Name = "AllowMoreSprites";
this.AllowMoreSprites.Size = new System.Drawing.Size(203, 17);
this.AllowMoreSprites.TabIndex = 2;
this.AllowMoreSprites.Text = "Allow more than 8 sprites per scanline";
this.AllowMoreSprites.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.AutoLoadPalette);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.PalettePath);
this.groupBox1.Controls.Add(this.BrowsePalette);
this.groupBox1.Location = new System.Drawing.Point(12, 24);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(352, 110);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Palette Config";
//
// AutoLoadPalette
//
this.AutoLoadPalette.AutoSize = true;
this.AutoLoadPalette.Checked = true;
this.AutoLoadPalette.CheckState = System.Windows.Forms.CheckState.Checked;
this.AutoLoadPalette.Location = new System.Drawing.Point(6, 73);
this.AutoLoadPalette.Name = "AutoLoadPalette";
this.AutoLoadPalette.Size = new System.Drawing.Size(135, 17);
this.AutoLoadPalette.TabIndex = 3;
this.AutoLoadPalette.Text = "Load this file on startup";
this.AutoLoadPalette.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Use palette from file";
//
// PalettePath
//
this.PalettePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PalettePath.Location = new System.Drawing.Point(6, 47);
this.PalettePath.Name = "PalettePath";
this.PalettePath.Size = new System.Drawing.Size(259, 20);
this.PalettePath.TabIndex = 1;
//
// BrowsePalette
//
this.BrowsePalette.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BrowsePalette.Location = new System.Drawing.Point(271, 44);
this.BrowsePalette.Name = "BrowsePalette";
this.BrowsePalette.Size = new System.Drawing.Size(75, 23);
this.BrowsePalette.TabIndex = 0;
this.BrowsePalette.Text = "&Browse...";
this.BrowsePalette.UseVisualStyleBackColor = true;
this.BrowsePalette.Click += new System.EventHandler(this.BrowsePalette_Click);
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.ClipLeftAndRightCheckBox);
this.groupBox2.Controls.Add(this.AllowMoreSprites);
this.groupBox2.Location = new System.Drawing.Point(12, 156);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(352, 81);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
//
// ClipLeftAndRightCheckBox
//
this.ClipLeftAndRightCheckBox.AutoSize = true;
this.ClipLeftAndRightCheckBox.Location = new System.Drawing.Point(9, 42);
this.ClipLeftAndRightCheckBox.Name = "ClipLeftAndRightCheckBox";
this.ClipLeftAndRightCheckBox.Size = new System.Drawing.Size(186, 17);
this.ClipLeftAndRightCheckBox.TabIndex = 3;
this.ClipLeftAndRightCheckBox.Text = "Clip Left and Right Sides (8 pixels)";
this.ClipLeftAndRightCheckBox.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.ChangeBGColor);
this.groupBox3.Controls.Add(this.BackGroundColorNumber);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.groupBox4);
this.groupBox3.Controls.Add(this.DispBackground);
this.groupBox3.Controls.Add(this.DispSprites);
this.groupBox3.Location = new System.Drawing.Point(12, 254);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(352, 128);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Background and Sprites";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.BackgroundColorPanel);
this.groupBox4.Location = new System.Drawing.Point(9, 94);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(28, 28);
this.groupBox4.TabIndex = 2;
this.groupBox4.TabStop = false;
//
// BackgroundColorPanel
//
this.BackgroundColorPanel.Location = new System.Drawing.Point(4, 8);
this.BackgroundColorPanel.Name = "BackgroundColorPanel";
this.BackgroundColorPanel.Size = new System.Drawing.Size(20, 16);
this.BackgroundColorPanel.TabIndex = 0;
//
// DispBackground
//
this.DispBackground.AutoSize = true;
this.DispBackground.Location = new System.Drawing.Point(9, 42);
this.DispBackground.Name = "DispBackground";
this.DispBackground.Size = new System.Drawing.Size(121, 17);
this.DispBackground.TabIndex = 1;
this.DispBackground.Text = "Display Background";
this.DispBackground.UseVisualStyleBackColor = true;
//
// DispSprites
//
this.DispSprites.AutoSize = true;
this.DispSprites.Location = new System.Drawing.Point(9, 19);
this.DispSprites.Name = "DispSprites";
this.DispSprites.Size = new System.Drawing.Size(95, 17);
this.DispSprites.TabIndex = 0;
this.DispSprites.Text = "Display Sprites";
this.DispSprites.UseVisualStyleBackColor = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 79);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(246, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Background color when Backgrounds are disabled";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(43, 102);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(18, 13);
this.label3.TabIndex = 4;
this.label3.Text = "0x";
//
// BackGroundColorNumber
//
this.BackGroundColorNumber.Location = new System.Drawing.Point(62, 100);
this.BackGroundColorNumber.MaxLength = 8;
this.BackGroundColorNumber.Name = "BackGroundColorNumber";
this.BackGroundColorNumber.ReadOnly = true;
this.BackGroundColorNumber.Size = new System.Drawing.Size(59, 20);
this.BackGroundColorNumber.TabIndex = 5;
//
// ChangeBGColor
//
this.ChangeBGColor.Location = new System.Drawing.Point(136, 98);
this.ChangeBGColor.Name = "ChangeBGColor";
this.ChangeBGColor.Size = new System.Drawing.Size(52, 23);
this.ChangeBGColor.TabIndex = 6;
this.ChangeBGColor.Text = "Change";
this.ChangeBGColor.UseVisualStyleBackColor = true;
this.ChangeBGColor.Click += new System.EventHandler(this.ChangeBGColor_Click);
//
// NESGraphicsConfig
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(381, 438);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NESGraphicsConfig";
this.Text = "NES Graphics Settings";
this.Load += new System.EventHandler(this.NESGraphicsConfig_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button OK;
private System.Windows.Forms.Button Cancel;
private System.Windows.Forms.CheckBox AllowMoreSprites;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox PalettePath;
private System.Windows.Forms.Button BrowsePalette;
private System.Windows.Forms.CheckBox AutoLoadPalette;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.CheckBox ClipLeftAndRightCheckBox;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox DispSprites;
private System.Windows.Forms.CheckBox DispBackground;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Panel BackgroundColorPanel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox BackGroundColorNumber;
private System.Windows.Forms.Button ChangeBGColor;
private System.Windows.Forms.ColorDialog BGColorDialog;
}
}

View File

@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using BizHawk.Emulation.Consoles.Nintendo;
namespace BizHawk.MultiClient
{
public partial class NESGraphicsConfig : Form
{
//TODO:
//Add restriction on for load event for nes
//Add restriction on Main form menu item for nes
//Add palette config in NES path config
//Hook up allow > 8 scan lines
//Hook up Clip L+R Sides
//Hook up Disp Background
//Hook up Disp Sprites
//Hook up BG color
//Allow selection of palette file from archive
//Hotkeys for BG & Sprite display toggle
//allow null in box
//select all on enter event for palette config
//NTSC fileter settings? Hue, Tint (This should probably be a multiclient thing, not a nes specific thing?)
//Color panel isn't loading color on load
HawkFile palette = null;
NES nes;
public NESGraphicsConfig()
{
InitializeComponent();
}
private void NESGraphicsConfig_Load(object sender, EventArgs e)
{
nes = Global.Emulator as NES;
AllowMoreSprites.Checked = Global.Config.NESAllowMoreThanEightSprites;
ClipLeftAndRightCheckBox.Checked = Global.Config.NESClipLeftAndRight;
AutoLoadPalette.Checked = Global.Config.NESAutoLoadPalette;
PalettePath.Text = Global.Config.NESPaletteFile;
DispSprites.Checked = Global.Config.NESDispSprites;
DispBackground.Checked = Global.Config.NESDispBackground;
BGColorDialog.Color = Color.FromArgb(Global.Config.NESBackgroundColor);
SetColorBox();
}
private void BrowsePalette_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.GetPlatformBase("NES");
ofd.Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*";
ofd.RestoreDirectory = true;
var result = ofd.ShowDialog();
if (result != DialogResult.OK)
return;
PalettePath.Text = ofd.FileName;
}
private void OK_Click(object sender, EventArgs e)
{
string path = PathManager.MakeAbsolutePath(PalettePath.Text, "NES");
palette = new HawkFile(PalettePath.Text);
if (palette != null && palette.Exists)
{
if (Global.Config.NESPaletteFile != palette.Name)
{
Global.Config.NESPaletteFile = palette.Name;
nes.SetPalette(NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)));
Global.RenderPanel.AddMessage("Palette file loaded: " + palette.Name);
}
Global.Config.NESAllowMoreThanEightSprites = AllowMoreSprites.Checked;
Global.Config.NESClipLeftAndRight = ClipLeftAndRightCheckBox.Checked;
Global.Config.NESAutoLoadPalette = AutoLoadPalette.Checked;
Global.Config.NESDispSprites = DispSprites.Checked;
Global.Config.NESDispBackground = DispBackground.Checked;
}
this.Close();
}
private void SetColorBox()
{
int color = BGColorDialog.Color.ToArgb();
BackGroundColorNumber.Text = String.Format("{0:X8}", color);
BackgroundColorPanel.BackColor = BGColorDialog.Color;
}
private void ChangeBGColor_Click(object sender, EventArgs e)
{
if (BGColorDialog.ShowDialog() == DialogResult.OK)
SetColorBox();
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="BGColorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>