Start new path config dialog INTERIM only, shows proof of concept of dynamic tab creation

This commit is contained in:
adelikat 2013-08-09 02:54:59 +00:00
parent b5dd64ad3b
commit 3e16802382
7 changed files with 405 additions and 22 deletions

View File

@ -416,6 +416,12 @@
<Compile Include="GENtools\GenGameGenie.Designer.cs">
<DependentUpon>GenGameGenie.cs</DependentUpon>
</Compile>
<Compile Include="config\NewPathConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="config\NewPathConfig.Designer.cs">
<DependentUpon>NewPathConfig.cs</DependentUpon>
</Compile>
<Compile Include="PCEtools\PCEBGCanvas.cs">
<SubType>Component</SubType>
</Compile>
@ -675,6 +681,9 @@
<EmbeddedResource Include="GENtools\GenGameGenie.resx">
<DependentUpon>GenGameGenie.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\NewPathConfig.resx">
<DependentUpon>NewPathConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PCEtools\PCEBGViewer.resx">
<DependentUpon>PCEBGViewer.cs</DependentUpon>
</EmbeddedResource>

View File

@ -216,6 +216,10 @@
<Compile Include="config\NewHotkeyWindow.Designer.cs">
<DependentUpon>NewHotkeyWindow.cs</DependentUpon>
</Compile>
<Compile Include="config\NewPathConfig.cs" />
<Compile Include="config\NewPathConfig.Designer.cs">
<DependentUpon>NewPathConfig.cs</DependentUpon>
</Compile>
<Compile Include="config\PathConfig.cs">
<SubType>Form</SubType>
</Compile>
@ -494,7 +498,9 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\LuaDocumentation.cs" />
<Compile Include="tools\LuaRegisteredFunctionsList.cs" />
<Compile Include="tools\LuaRegisteredFunctionsList.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="tools\LuaRegisteredFunctionsList.Designer.cs">
<DependentUpon>LuaRegisteredFunctionsList.cs</DependentUpon>
</Compile>
@ -627,6 +633,9 @@
<EmbeddedResource Include="config\NewHotkeyWindow.resx">
<DependentUpon>NewHotkeyWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\NewPathConfig.resx">
<DependentUpon>NewPathConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\PathInfo.resx">
<DependentUpon>PathInfo.cs</DependentUpon>
</EmbeddedResource>

View File

@ -156,6 +156,33 @@ namespace BizHawk.MultiClient
public string LogPath = ".";
public string FirmwaresPath = Path.Combine(".", "Firmware");
public PathEntryCollection PathEntries = new PathEntryCollection()
{
new PathEntry() { System = "Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 0 },
new PathEntry() { System = "Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 1 },
new PathEntry() { System = "Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 2 },
new PathEntry() { System = "Global", Type = "Watch (.wch)", Path = ".", Ordinal = 3 },
new PathEntry() { System = "Global", Type = "A/V Dumps", Path = ".", Ordinal = 4 },
new PathEntry() { System = "Global", Type = "Debug Logs", Path = ".", Ordinal = 5 },
new PathEntry() { System = "Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 6 },
new PathEntry() { System = "Global", Type = "Base ROM", Path = ".", Ordinal = 6 },
new PathEntry() { System = "NES", Type = "Base", Path = Path.Combine(".", "NES"), Ordinal = 0 },
new PathEntry() { System = "NES", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry() { System = "NES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry() { System = "NES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry() { System = "NES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry() { System = "NES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry() { System = "NES", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 },
new PathEntry() { System = "SNES", Type = "Base", Path= Path.Combine(".", "SNES"), Ordinal = 0 },
new PathEntry() { System = "SNES", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry() { System = "SNES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry() { System = "SNES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry() { System = "SNES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry() { System = "SNES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
};
//BIOS Paths
public string FilenamePCEBios = "[BIOS] Super CD-ROM System (Japan) (v3.0).pce";
public string FilenameFDSBios = "disksys.rom";
@ -590,26 +617,6 @@ namespace BizHawk.MultiClient
public int TI83KeyPadWndy = -1;
public bool TI83ToolTips = true;
public PathEntryCollection PathEntries = new PathEntryCollection()
{
new PathEntry() { System = "Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 0 },
new PathEntry() { System = "Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 1 },
new PathEntry() { System = "Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 2 },
new PathEntry() { System = "Global", Type = "Watch (.wch)", Path = ".", Ordinal = 3 },
new PathEntry() { System = "Global", Type = "A/V Dumps", Path = ".", Ordinal = 4 },
new PathEntry() { System = "Global", Type = "Debug Logs", Path = ".", Ordinal = 5 },
new PathEntry() { System = "Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 6 },
new PathEntry() { System = "Global", Type = "Base ROM", Path = ".", Ordinal = 6 },
new PathEntry() { System = "NES", Type = "Base", Path = ".", Ordinal = 0 },
new PathEntry() { System = "NES", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry() { System = "NES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry() { System = "NES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry() { System = "NES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry() { System = "NES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry() { System = "NES", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }
};
public BindingCollection HotkeyBindings = new BindingCollection()
{
//General

View File

@ -700,7 +700,14 @@ namespace BizHawk.MultiClient
private void pathsToolStripMenuItem_Click(object sender, EventArgs e)
{
new PathConfig().ShowDialog();
if (INTERIM)
{
new NewPathConfig().ShowDialog();
}
else
{
new PathConfig().ShowDialog();
}
}
private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -0,0 +1,107 @@
namespace BizHawk.MultiClient
{
partial class NewPathConfig
{
/// <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.PathTabControl = new System.Windows.Forms.TabControl();
this.SaveBtn = new System.Windows.Forms.Button();
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(431, 435);
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.Location = new System.Drawing.Point(512, 435);
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;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// PathTabControl
//
this.PathTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PathTabControl.Location = new System.Drawing.Point(12, 84);
this.PathTabControl.Name = "PathTabControl";
this.PathTabControl.SelectedIndex = 0;
this.PathTabControl.Size = new System.Drawing.Size(575, 345);
this.PathTabControl.TabIndex = 2;
//
// SaveBtn
//
this.SaveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SaveBtn.Location = new System.Drawing.Point(12, 435);
this.SaveBtn.Name = "SaveBtn";
this.SaveBtn.Size = new System.Drawing.Size(75, 23);
this.SaveBtn.TabIndex = 3;
this.SaveBtn.Text = "&Save";
this.SaveBtn.UseVisualStyleBackColor = true;
this.SaveBtn.Click += new System.EventHandler(this.SaveBtn_Click);
//
// NewPathConfig
//
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(599, 470);
this.Controls.Add(this.SaveBtn);
this.Controls.Add(this.PathTabControl);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Name = "NewPathConfig";
this.ShowIcon = false;
this.Text = "Path Configuration";
this.Load += new System.EventHandler(this.NewPathConfig_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button OK;
private System.Windows.Forms.Button Cancel;
private System.Windows.Forms.TabControl PathTabControl;
private System.Windows.Forms.Button SaveBtn;
}
}

View File

@ -0,0 +1,124 @@
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;
namespace BizHawk.MultiClient
{
public partial class NewPathConfig : Form
{
public NewPathConfig()
{
InitializeComponent();
}
private void NewPathConfig_Load(object sender, EventArgs e)
{
LoadSettings();
}
private void OK_Click(object sender, EventArgs e)
{
SaveSettings();
Global.OSD.AddMessage("Path settings saved");
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Path config aborted");
Close();
}
private void SaveBtn_Click(object sender, EventArgs e)
{
SaveSettings();
}
private void LoadSettings()
{
//Separate by system
List<string> systems = Global.Config.PathEntries.Select(x => x.System).Distinct().ToList();
systems.Sort();
//TODO: put Global first
//TODO: fix anchoring
//TODO: fix logic of when to pass in the system (global and base do not want this)
foreach(string tab in systems)
{
TabPage t = new TabPage()
{
Text = tab,
};
List<PathEntry> paths = Global.Config.PathEntries.Where(x => x.System == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();
int _x = 6;
int _y = 14;
int textbox_width = 150;
int padding = 10;
int button_width = 26;
foreach(var path in paths)
{
TextBox box = new TextBox()
{
Text = path.Path,
Location = new Point(_x, _y),
Width = textbox_width,
//Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Button btn = new Button()
{
Text = "",
Image = BizHawk.MultiClient.Properties.Resources.OpenFile,
Location = new Point(_x + textbox_width + padding, _y - 1),
Width = button_width,
//Anchor = AnchorStyles.Top | AnchorStyles.Right,
};
btn.Click += new System.EventHandler(delegate {
BrowseFolder(box, path.Type, path.System);
});
Label label = new Label()
{
Text = path.Type,
Location = new Point(_x + textbox_width + (padding * 2) + button_width, _y + 4),
//Anchor = AnchorStyles.Top | AnchorStyles.Right,
};
t.Controls.Add(box);
t.Controls.Add(btn);
t.Controls.Add(label);
_y += 30;
}
PathTabControl.TabPages.Add(t);
}
}
private void BrowseFolder(TextBox box, string _Name, string System)
{
FolderBrowserDialog f = new FolderBrowserDialog
{
Description = "Set the directory for " + _Name,
SelectedPath = PathManager.MakeAbsolutePath(box.Text, System)
};
DialogResult result = f.ShowDialog();
if (result == DialogResult.OK)
{
box.Text = f.SelectedPath;
}
}
private void SaveSettings()
{
}
}
}

View File

@ -0,0 +1,120 @@
<?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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>