From 3e1680238284190cf548474b85601312f53a8d85 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 9 Aug 2013 02:54:59 +0000 Subject: [PATCH] Start new path config dialog INTERIM only, shows proof of concept of dynamic tab creation --- .../BizHawk.MultiClient.csproj | 9 ++ .../BizHawk.MultiClient_v4.5.csproj | 11 +- BizHawk.MultiClient/Config.cs | 47 ++++--- BizHawk.MultiClient/MainForm.MenuItems.cs | 9 +- .../config/NewPathConfig.Designer.cs | 107 +++++++++++++++ BizHawk.MultiClient/config/NewPathConfig.cs | 124 ++++++++++++++++++ BizHawk.MultiClient/config/NewPathConfig.resx | 120 +++++++++++++++++ 7 files changed, 405 insertions(+), 22 deletions(-) create mode 100644 BizHawk.MultiClient/config/NewPathConfig.Designer.cs create mode 100644 BizHawk.MultiClient/config/NewPathConfig.cs create mode 100644 BizHawk.MultiClient/config/NewPathConfig.resx diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index da38c8e325..d86142c874 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -416,6 +416,12 @@ GenGameGenie.cs + + Form + + + NewPathConfig.cs + Component @@ -675,6 +681,9 @@ GenGameGenie.cs + + NewPathConfig.cs + PCEBGViewer.cs diff --git a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj index 67f1de0f23..09c109a83b 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient_v4.5.csproj @@ -216,6 +216,10 @@ NewHotkeyWindow.cs + + + NewPathConfig.cs + Form @@ -494,7 +498,9 @@ Component - + + Form + LuaRegisteredFunctionsList.cs @@ -627,6 +633,9 @@ NewHotkeyWindow.cs + + NewPathConfig.cs + PathInfo.cs diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index 88092fb0d4..d952352522 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -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 diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index ab5c4120d8..2aa0e82da4 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -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) diff --git a/BizHawk.MultiClient/config/NewPathConfig.Designer.cs b/BizHawk.MultiClient/config/NewPathConfig.Designer.cs new file mode 100644 index 0000000000..b7b3285bcf --- /dev/null +++ b/BizHawk.MultiClient/config/NewPathConfig.Designer.cs @@ -0,0 +1,107 @@ +namespace BizHawk.MultiClient +{ + partial class NewPathConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/config/NewPathConfig.cs b/BizHawk.MultiClient/config/NewPathConfig.cs new file mode 100644 index 0000000000..dd68e3570b --- /dev/null +++ b/BizHawk.MultiClient/config/NewPathConfig.cs @@ -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 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 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() + { + + } + } +} diff --git a/BizHawk.MultiClient/config/NewPathConfig.resx b/BizHawk.MultiClient/config/NewPathConfig.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.MultiClient/config/NewPathConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file