NES config - Fix crash when palette path is null, hook up NES palette path config in path config dialog, dialog fix ups

This commit is contained in:
andres.delikat 2011-06-11 16:22:48 +00:00
parent f052b0bd71
commit f52c4610e8
6 changed files with 2255 additions and 2196 deletions

View File

@ -29,6 +29,7 @@
public string PathNESSaveRAM = ".\\SaveRAM";
public string PathNESScreenshots = ".\\Screenshots";
public string PathNESCheats = ".\\Cheats";
public string PathNESPalette = ".\\Palettes";
public string BaseSMS = ".\\SMS";
public string PathSMSROMs = ".";

View File

@ -764,7 +764,7 @@ namespace BizHawk.MultiClient
{
NES nes = new NES();
nextEmulator = nes;
if (Global.Config.NESAutoLoadPalette && HawkFile.ExistsAt(Global.Config.NESPaletteFile))
if (Global.Config.NESAutoLoadPalette && Global.Config.NESPaletteFile.Length > 0 && HawkFile.ExistsAt(Global.Config.NESPaletteFile))
{
nes.SetPalette(NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(Global.Config.NESPaletteFile)));
}

View File

@ -39,14 +39,14 @@
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.ClipLeftAndRightCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.ChangeBGColor = new System.Windows.Forms.Button();
this.BackGroundColorNumber = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
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();
@ -60,7 +60,7 @@
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.TabIndex = 40;
this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click);
@ -72,7 +72,7 @@
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.TabIndex = 45;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
//
@ -82,7 +82,7 @@
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.TabIndex = 15;
this.AllowMoreSprites.Text = "Allow more than 8 sprites per scanline";
this.AllowMoreSprites.UseVisualStyleBackColor = true;
//
@ -109,7 +109,7 @@
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.TabIndex = 10;
this.AutoLoadPalette.Text = "Load this file on startup";
this.AutoLoadPalette.UseVisualStyleBackColor = true;
//
@ -137,7 +137,7 @@
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.TabIndex = 5;
this.BrowsePalette.Text = "&Browse...";
this.BrowsePalette.UseVisualStyleBackColor = true;
this.BrowsePalette.Click += new System.EventHandler(this.BrowsePalette_Click);
@ -160,7 +160,7 @@
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.TabIndex = 20;
this.ClipLeftAndRightCheckBox.Text = "Clip Left and Right Sides (8 pixels)";
this.ClipLeftAndRightCheckBox.UseVisualStyleBackColor = true;
//
@ -182,6 +182,43 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Background and Sprites";
//
// 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 = 35;
this.ChangeBGColor.Text = "Change";
this.ChangeBGColor.UseVisualStyleBackColor = true;
this.ChangeBGColor.Click += new System.EventHandler(this.ChangeBGColor_Click);
//
// 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;
//
// 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";
//
// 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";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.BackgroundColorPanel);
@ -201,60 +238,27 @@
// DispBackground
//
this.DispBackground.AutoSize = true;
this.DispBackground.Checked = true;
this.DispBackground.CheckState = System.Windows.Forms.CheckState.Checked;
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.TabIndex = 30;
this.DispBackground.Text = "Display Background";
this.DispBackground.UseVisualStyleBackColor = true;
//
// DispSprites
//
this.DispSprites.AutoSize = true;
this.DispSprites.Checked = true;
this.DispSprites.CheckState = System.Windows.Forms.CheckState.Checked;
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.TabIndex = 25;
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;
@ -270,6 +274,7 @@
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NESGraphicsConfig";
this.ShowIcon = false;
this.Text = "NES Graphics Settings";
this.Load += new System.EventHandler(this.NESGraphicsConfig_Load);
this.groupBox1.ResumeLayout(false);

View File

@ -14,9 +14,6 @@ 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
@ -24,7 +21,6 @@ namespace BizHawk.MultiClient
//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
@ -53,7 +49,7 @@ namespace BizHawk.MultiClient
private void BrowsePalette_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.GetPlatformBase("NES");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESPalette, "NES");
ofd.Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*";
ofd.RestoreDirectory = true;
@ -65,6 +61,8 @@ namespace BizHawk.MultiClient
}
private void OK_Click(object sender, EventArgs e)
{
if (PalettePath.Text.Length > 0)
{
string path = PathManager.MakeAbsolutePath(PalettePath.Text, "NES");
palette = new HawkFile(PalettePath.Text);
@ -77,12 +75,20 @@ namespace BizHawk.MultiClient
nes.SetPalette(NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)));
Global.RenderPanel.AddMessage("Palette file loaded: " + palette.Name);
}
}
}
else
{
Global.Config.NESPaletteFile = "";
nes.SetPalette(NES.Palettes.FCEUX_Standard);
Global.RenderPanel.AddMessage("Standard Palette set");
}
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();
}

View File

@ -201,6 +201,9 @@
this.BaseDescription = new System.Windows.Forms.Label();
this.RecentForROMs = new System.Windows.Forms.CheckBox();
this.SaveButton = new System.Windows.Forms.Button();
this.NESPaletteBox = new System.Windows.Forms.TextBox();
this.NESBrowsePalette = new System.Windows.Forms.Button();
this.NESPaletteDescription = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
@ -621,6 +624,9 @@
//
// tabPage1
//
this.tabPage1.Controls.Add(this.NESPaletteDescription);
this.tabPage1.Controls.Add(this.NESBrowsePalette);
this.tabPage1.Controls.Add(this.NESPaletteBox);
this.tabPage1.Controls.Add(this.NESCheatsDescription);
this.tabPage1.Controls.Add(this.NESBrowseCheats);
this.tabPage1.Controls.Add(this.NESCheatsBox);
@ -642,7 +648,7 @@
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(435, 251);
this.tabPage1.Size = new System.Drawing.Size(452, 251);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "NES";
this.tabPage1.UseVisualStyleBackColor = true;
@ -731,7 +737,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(435, 251);
this.tabPage2.Size = new System.Drawing.Size(452, 251);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "SMS";
this.tabPage2.UseVisualStyleBackColor = true;
@ -818,7 +824,7 @@
this.tabPage9.Controls.Add(this.SGROMsBrowse);
this.tabPage9.Location = new System.Drawing.Point(4, 22);
this.tabPage9.Name = "tabPage9";
this.tabPage9.Size = new System.Drawing.Size(435, 251);
this.tabPage9.Size = new System.Drawing.Size(452, 251);
this.tabPage9.TabIndex = 8;
this.tabPage9.Text = "SG-1000";
this.tabPage9.UseVisualStyleBackColor = true;
@ -1026,7 +1032,7 @@
this.tabPage8.Controls.Add(this.GGSaveRAMBox);
this.tabPage8.Location = new System.Drawing.Point(4, 22);
this.tabPage8.Name = "tabPage8";
this.tabPage8.Size = new System.Drawing.Size(435, 251);
this.tabPage8.Size = new System.Drawing.Size(452, 251);
this.tabPage8.TabIndex = 7;
this.tabPage8.Text = "G. Gear";
this.tabPage8.UseVisualStyleBackColor = true;
@ -1233,7 +1239,7 @@
this.tabPage3.Controls.Add(this.GenesisROMsBox);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(435, 251);
this.tabPage3.Size = new System.Drawing.Size(452, 251);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Genesis";
this.tabPage3.UseVisualStyleBackColor = true;
@ -1440,7 +1446,7 @@
this.tabPage4.Controls.Add(this.PCESaveRAMBox);
this.tabPage4.Location = new System.Drawing.Point(4, 22);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(435, 251);
this.tabPage4.Size = new System.Drawing.Size(452, 251);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "PC Engine";
this.tabPage4.UseVisualStyleBackColor = true;
@ -1650,7 +1656,7 @@
this.tabPage5.Controls.Add(this.GBSaveRAMBox);
this.tabPage5.Location = new System.Drawing.Point(4, 22);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Size = new System.Drawing.Size(435, 251);
this.tabPage5.Size = new System.Drawing.Size(452, 251);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "Gameboy";
this.tabPage5.UseVisualStyleBackColor = true;
@ -2116,6 +2122,37 @@
this.SaveButton.UseVisualStyleBackColor = true;
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
//
// NESPaletteBox
//
this.NESPaletteBox.AcceptsTab = true;
this.NESPaletteBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.NESPaletteBox.Location = new System.Drawing.Point(13, 209);
this.NESPaletteBox.Name = "NESPaletteBox";
this.NESPaletteBox.Size = new System.Drawing.Size(280, 20);
this.NESPaletteBox.TabIndex = 24;
//
// NESBrowsePalette
//
this.NESBrowsePalette.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NESBrowsePalette.Location = new System.Drawing.Point(299, 208);
this.NESBrowsePalette.Name = "NESBrowsePalette";
this.NESBrowsePalette.Size = new System.Drawing.Size(54, 23);
this.NESBrowsePalette.TabIndex = 25;
this.NESBrowsePalette.Text = "Browse";
this.NESBrowsePalette.UseVisualStyleBackColor = true;
this.NESBrowsePalette.Click += new System.EventHandler(this.NESBrowsePalette_Click);
//
// NESPaletteDescription
//
this.NESPaletteDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NESPaletteDescription.AutoSize = true;
this.NESPaletteDescription.Location = new System.Drawing.Point(360, 212);
this.NESPaletteDescription.Name = "NESPaletteDescription";
this.NESPaletteDescription.Size = new System.Drawing.Size(40, 13);
this.NESPaletteDescription.TabIndex = 26;
this.NESPaletteDescription.Text = "Palette";
//
// PathConfig
//
this.AcceptButton = this.OK;
@ -2334,5 +2371,8 @@
private System.Windows.Forms.Label SGROMsDescription;
private System.Windows.Forms.TextBox SGSaveRAMBox;
private System.Windows.Forms.Button SGROMsBrowse;
private System.Windows.Forms.Label NESPaletteDescription;
private System.Windows.Forms.Button NESBrowsePalette;
private System.Windows.Forms.TextBox NESPaletteBox;
}
}

View File

@ -54,6 +54,7 @@ namespace BizHawk.MultiClient
NESSaveRAMBox.Text = Global.Config.PathNESSaveRAM;
NESScreenshotsBox.Text = Global.Config.PathNESScreenshots;
NESCheatsBox.Text = Global.Config.PathNESCheats;
NESPaletteBox.Text = Global.Config.PathNESPalette;
Sega8BaseBox.Text = Global.Config.BaseSMS;
Sega8ROMsBox.Text = Global.Config.PathSMSROMs;
@ -121,6 +122,7 @@ namespace BizHawk.MultiClient
Global.Config.PathNESSaveRAM = NESSaveRAMBox.Text;
Global.Config.PathNESScreenshots = NESScreenshotsBox.Text;
Global.Config.PathNESCheats = NESCheatsBox.Text;
Global.Config.PathNESPalette = NESPaletteBox.Text;
Global.Config.BaseSMS = Sega8BaseBox.Text;
Global.Config.PathSMSROMs = Sega8ROMsBox.Text;
@ -537,5 +539,10 @@ namespace BizHawk.MultiClient
{
BrowseFolder(SGCheatsBox, SGCheatsDescription.Text, "SG");
}
private void NESBrowsePalette_Click(object sender, EventArgs e)
{
BrowseFolder(NESPaletteBox, NESPaletteDescription.Text, "NES");
}
}
}