diff --git a/BizHawk.Client.EmuHawk/config/PathConfig.Designer.cs b/BizHawk.Client.EmuHawk/config/PathConfig.Designer.cs index fc098b402a..e9122a643d 100644 --- a/BizHawk.Client.EmuHawk/config/PathConfig.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/PathConfig.Designer.cs @@ -28,163 +28,165 @@ /// 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.label1 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.RecentForROMs = new System.Windows.Forms.CheckBox(); - this.BasePathBox = new System.Windows.Forms.TextBox(); - this.BrowseBase = new System.Windows.Forms.Button(); - this.BaseDescription = new System.Windows.Forms.Label(); - this.DefaultsBtn = 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(471, 411); - 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(552, 411); - 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) + 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.label1 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.RecentForROMs = new System.Windows.Forms.CheckBox(); + this.BasePathBox = new System.Windows.Forms.TextBox(); + this.BrowseBase = new System.Windows.Forms.Button(); + this.BaseDescription = new System.Windows.Forms.Label(); + this.DefaultsBtn = 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(471, 411); + 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(552, 411); + 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.Multiline = true; - this.PathTabControl.Name = "PathTabControl"; - this.PathTabControl.SelectedIndex = 0; - this.PathTabControl.Size = new System.Drawing.Size(615, 321); - 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, 411); - 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); - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(527, 52); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(97, 13); - this.label1.TabIndex = 210; - this.label1.Text = "Special Commands"; - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Help; - this.button1.Location = new System.Drawing.Point(496, 47); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(26, 23); - this.button1.TabIndex = 209; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // RecentForROMs - // - this.RecentForROMs.AutoSize = true; - this.RecentForROMs.Location = new System.Drawing.Point(12, 51); - this.RecentForROMs.Name = "RecentForROMs"; - this.RecentForROMs.Size = new System.Drawing.Size(184, 17); - this.RecentForROMs.TabIndex = 207; - this.RecentForROMs.Text = "Always use recent path for ROMs"; - this.RecentForROMs.UseVisualStyleBackColor = true; - this.RecentForROMs.CheckedChanged += new System.EventHandler(this.RecentForROMs_CheckedChanged); - // - // BasePathBox - // - this.BasePathBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.PathTabControl.Location = new System.Drawing.Point(12, 84); + this.PathTabControl.Multiline = true; + this.PathTabControl.Name = "PathTabControl"; + this.PathTabControl.SelectedIndex = 0; + this.PathTabControl.Size = new System.Drawing.Size(615, 321); + this.PathTabControl.TabIndex = 2; + this.PathTabControl.SelectedIndexChanged += new System.EventHandler(this.PathTabControl_SelectedIndexChanged); + // + // 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, 411); + 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); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(527, 52); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(97, 13); + this.label1.TabIndex = 210; + this.label1.Text = "Special Commands"; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Help; + this.button1.Location = new System.Drawing.Point(496, 47); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(26, 23); + this.button1.TabIndex = 209; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // RecentForROMs + // + this.RecentForROMs.AutoSize = true; + this.RecentForROMs.Location = new System.Drawing.Point(12, 51); + this.RecentForROMs.Name = "RecentForROMs"; + this.RecentForROMs.Size = new System.Drawing.Size(184, 17); + this.RecentForROMs.TabIndex = 207; + this.RecentForROMs.Text = "Always use recent path for ROMs"; + this.RecentForROMs.UseVisualStyleBackColor = true; + this.RecentForROMs.CheckedChanged += new System.EventHandler(this.RecentForROMs_CheckedChanged); + // + // BasePathBox + // + this.BasePathBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.BasePathBox.Location = new System.Drawing.Point(12, 15); - this.BasePathBox.Name = "BasePathBox"; - this.BasePathBox.Size = new System.Drawing.Size(510, 20); - this.BasePathBox.TabIndex = 205; - // - // BrowseBase - // - this.BrowseBase.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.BrowseBase.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile; - this.BrowseBase.Location = new System.Drawing.Point(530, 14); - this.BrowseBase.Name = "BrowseBase"; - this.BrowseBase.Size = new System.Drawing.Size(26, 23); - this.BrowseBase.TabIndex = 206; - this.BrowseBase.UseVisualStyleBackColor = true; - this.BrowseBase.Click += new System.EventHandler(this.BrowseBase_Click); - // - // BaseDescription - // - this.BaseDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.BaseDescription.AutoSize = true; - this.BaseDescription.Location = new System.Drawing.Point(563, 19); - this.BaseDescription.Name = "BaseDescription"; - this.BaseDescription.Size = new System.Drawing.Size(64, 13); - this.BaseDescription.TabIndex = 208; - this.BaseDescription.Text = "Global Base"; - // - // DefaultsBtn - // - this.DefaultsBtn.Location = new System.Drawing.Point(93, 411); - this.DefaultsBtn.Name = "DefaultsBtn"; - this.DefaultsBtn.Size = new System.Drawing.Size(75, 23); - this.DefaultsBtn.TabIndex = 211; - this.DefaultsBtn.Text = "&Defaults"; - this.DefaultsBtn.UseVisualStyleBackColor = true; - this.DefaultsBtn.Click += new System.EventHandler(this.DefaultsBtn_Click); - // - // PathConfig - // - 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(639, 446); - this.Controls.Add(this.DefaultsBtn); - this.Controls.Add(this.label1); - this.Controls.Add(this.button1); - this.Controls.Add(this.RecentForROMs); - this.Controls.Add(this.BasePathBox); - this.Controls.Add(this.BrowseBase); - this.Controls.Add(this.BaseDescription); - this.Controls.Add(this.SaveBtn); - this.Controls.Add(this.PathTabControl); - this.Controls.Add(this.Cancel); - this.Controls.Add(this.OK); - this.MinimumSize = new System.Drawing.Size(360, 250); - this.Name = "PathConfig"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Path Configuration"; - this.Load += new System.EventHandler(this.NewPathConfig_Load); - this.ResumeLayout(false); - this.PerformLayout(); + this.BasePathBox.Location = new System.Drawing.Point(12, 15); + this.BasePathBox.Name = "BasePathBox"; + this.BasePathBox.Size = new System.Drawing.Size(510, 20); + this.BasePathBox.TabIndex = 205; + // + // BrowseBase + // + this.BrowseBase.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.BrowseBase.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile; + this.BrowseBase.Location = new System.Drawing.Point(530, 14); + this.BrowseBase.Name = "BrowseBase"; + this.BrowseBase.Size = new System.Drawing.Size(26, 23); + this.BrowseBase.TabIndex = 206; + this.BrowseBase.UseVisualStyleBackColor = true; + this.BrowseBase.Click += new System.EventHandler(this.BrowseBase_Click); + // + // BaseDescription + // + this.BaseDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.BaseDescription.AutoSize = true; + this.BaseDescription.Location = new System.Drawing.Point(563, 19); + this.BaseDescription.Name = "BaseDescription"; + this.BaseDescription.Size = new System.Drawing.Size(64, 13); + this.BaseDescription.TabIndex = 208; + this.BaseDescription.Text = "Global Base"; + // + // DefaultsBtn + // + this.DefaultsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.DefaultsBtn.Location = new System.Drawing.Point(93, 411); + this.DefaultsBtn.Name = "DefaultsBtn"; + this.DefaultsBtn.Size = new System.Drawing.Size(75, 23); + this.DefaultsBtn.TabIndex = 211; + this.DefaultsBtn.Text = "&Defaults"; + this.DefaultsBtn.UseVisualStyleBackColor = true; + this.DefaultsBtn.Click += new System.EventHandler(this.DefaultsBtn_Click); + // + // PathConfig + // + 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(639, 446); + this.Controls.Add(this.DefaultsBtn); + this.Controls.Add(this.label1); + this.Controls.Add(this.button1); + this.Controls.Add(this.RecentForROMs); + this.Controls.Add(this.BasePathBox); + this.Controls.Add(this.BrowseBase); + this.Controls.Add(this.BaseDescription); + this.Controls.Add(this.SaveBtn); + this.Controls.Add(this.PathTabControl); + this.Controls.Add(this.Cancel); + this.Controls.Add(this.OK); + this.MinimumSize = new System.Drawing.Size(360, 250); + this.Name = "PathConfig"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Path Configuration"; + this.Load += new System.EventHandler(this.NewPathConfig_Load); + this.ResumeLayout(false); + this.PerformLayout(); } diff --git a/BizHawk.Client.EmuHawk/config/PathConfig.cs b/BizHawk.Client.EmuHawk/config/PathConfig.cs index fc7760150b..e8f8da1ef5 100644 --- a/BizHawk.Client.EmuHawk/config/PathConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PathConfig.cs @@ -75,7 +75,10 @@ namespace BizHawk.Client.EmuHawk { RecentForROMs.Checked = Global.Config.UseRecentForROMs; BasePathBox.Text = Global.Config.PathEntries.GlobalBase; - DoTabs(Global.Config.PathEntries.Paths); + + StartTabPages(); + //DoTabs(Global.Config.PathEntries.Paths); + SetDefaultFocusedTab(); DoRomToggle(); } @@ -99,6 +102,111 @@ namespace BizHawk.Client.EmuHawk } } + private void StartTabPages() + { + PathTabControl.TabPages.Clear(); + //Separate by system + List systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList(); + systems.Sort(); + foreach (string systemDisplayName in systems) + { + PathTabControl.TabPages.Add(new TabPage + { + Text = systemDisplayName, + Name = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System + }); + } + } + + private void DoTabPage(TabPage tabPage) + { + const int xpos = 6; + int textboxWidth = tabPage.Width - 150; + const int padding = 5; + const int buttonWidth = 26; + int widgetOffset = textboxWidth + 15; + const int rowHeight = 30; + List paths = Global.Config.PathEntries.Where(x => x.System == tabPage.Name).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList(); + + int ypos = 14; + + foreach (var path in paths) + { + TextBox box = new TextBox + { + Text = path.Path, + Location = new Point(xpos, ypos), + Width = textboxWidth, + Name = path.Type, + Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, + MinimumSize = new Size(26, 23), + AutoCompleteMode = AutoCompleteMode.SuggestAppend, + AutoCompleteCustomSource = AutoCompleteOptions, + AutoCompleteSource = AutoCompleteSource.CustomSource, + }; + + Button btn = new Button + { + Text = String.Empty, + Image = Properties.Resources.OpenFile, + Location = new Point(widgetOffset, ypos - 1), + Width = buttonWidth, + Name = path.Type, + Anchor = AnchorStyles.Top | AnchorStyles.Right, + }; + + TextBox tempBox = box; + string tempPath = path.Type; + string tempSystem = path.System; + btn.Click += delegate + { + BrowseFolder(tempBox, tempPath, tempSystem); + }; + + Label label = new Label + { + Text = path.Type, + Location = new Point(widgetOffset + buttonWidth + padding, ypos + 4), + Width = 100, + Name = path.Type, + Anchor = AnchorStyles.Top | AnchorStyles.Right, + }; + + tabPage.Controls.Add(label); + tabPage.Controls.Add(btn); + tabPage.Controls.Add(box); + + ypos += rowHeight; + } + + string sys = tabPage.Name; + if (tabPage.Name == "PCE") //Hack + { + sys = "PCECD"; + } + + bool hasFirmwares = FirmwaresConfig.SystemGroupNames.Any(x => x.Key == sys); + + if (hasFirmwares) + { + Button firmwareButton = new Button + { + Name = sys, + Text = "&Firmware", + Location = new Point(xpos, ypos), + Width = 75, + }; + firmwareButton.Click += delegate + { + FirmwaresConfig f = new FirmwaresConfig { TargetSystem = sys }; + f.ShowDialog(); + }; + + tabPage.Controls.Add(firmwareButton); + } + } + + //TODO: this is only used by the defaults button, refactor since it is now redundant code (will have to force the rebuilding of all tabpages, currently they only build as necessar private void DoTabs(List pathCollection) { PathTabControl.SuspendLayout(); @@ -319,5 +427,14 @@ namespace BizHawk.Client.EmuHawk { DoTabs(PathEntryCollection.DefaultValues); } + + private void PathTabControl_SelectedIndexChanged(object sender, EventArgs e) + { + var tabPage = (sender as TabControl).SelectedTab; + if (tabPage.Controls.Count == 0) + { + DoTabPage((sender as TabControl).SelectedTab); + } + } } }