From b3fc9ce7ad63ccce8d7a488352615b95e504f820 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 26 Jul 2025 13:12:14 +1000 Subject: [PATCH 1/8] Inline Designer files in DiscoHawk --- .../About.Designer.cs | 93 ------ src/BizHawk.Client.DiscoHawk/About.cs | 60 +++- src/BizHawk.Client.DiscoHawk/About.resx | 131 -------- .../ComparisonResults.Designer.cs | 119 ------- .../ComparisonResults.cs | 78 ++++- .../ComparisonResults.resx | 120 ------- .../MainDiscoForm.Designer.cs | 292 ------------------ src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs | 242 ++++++++++++++- .../MainDiscoForm.resx | 120 ------- 9 files changed, 372 insertions(+), 883 deletions(-) delete mode 100644 src/BizHawk.Client.DiscoHawk/About.Designer.cs delete mode 100644 src/BizHawk.Client.DiscoHawk/About.resx delete mode 100644 src/BizHawk.Client.DiscoHawk/ComparisonResults.Designer.cs delete mode 100644 src/BizHawk.Client.DiscoHawk/ComparisonResults.resx delete mode 100644 src/BizHawk.Client.DiscoHawk/MainDiscoForm.Designer.cs delete mode 100644 src/BizHawk.Client.DiscoHawk/MainDiscoForm.resx diff --git a/src/BizHawk.Client.DiscoHawk/About.Designer.cs b/src/BizHawk.Client.DiscoHawk/About.Designer.cs deleted file mode 100644 index c33456f21e1..00000000000 --- a/src/BizHawk.Client.DiscoHawk/About.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace BizHawk.Client.DiscoHawk -{ - partial class About - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About)); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.lblVersion = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // richTextBox1 - // - this.richTextBox1.Location = new System.Drawing.Point(12, 12); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.ReadOnly = true; - this.richTextBox1.Size = new System.Drawing.Size(499, 236); - this.richTextBox1.TabIndex = 1; - this.richTextBox1.Text = resources.GetString("richTextBox1.Text"); - this.richTextBox1.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBox1_LinkClicked); - // - // button1 - // - this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button1.Location = new System.Drawing.Point(436, 254); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 2; - this.button1.Text = "OK"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // lblVersion - // - this.lblVersion.AutoSize = true; - this.lblVersion.Location = new System.Drawing.Point(12, 259); - this.lblVersion.Name = "lblVersion"; - this.lblVersion.Size = new System.Drawing.Size(79, 13); - this.lblVersion.TabIndex = 3; - this.lblVersion.Text = "version number"; - // - // About - // - this.AcceptButton = this.button1; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.button1; - this.ClientSize = new System.Drawing.Size(525, 282); - this.ControlBox = false; - this.Controls.Add(this.lblVersion); - this.Controls.Add(this.button1); - this.Controls.Add(this.richTextBox1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MinimizeBox = false; - this.Name = "About"; - this.Text = "About DiscoHawk"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.RichTextBox richTextBox1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label lblVersion; - } -} \ No newline at end of file diff --git a/src/BizHawk.Client.DiscoHawk/About.cs b/src/BizHawk.Client.DiscoHawk/About.cs index 16fcf8d3b31..8fede89222a 100644 --- a/src/BizHawk.Client.DiscoHawk/About.cs +++ b/src/BizHawk.Client.DiscoHawk/About.cs @@ -1,15 +1,69 @@ +using System.Reflection; using System.Windows.Forms; using BizHawk.Common; namespace BizHawk.Client.DiscoHawk { - public partial class About : Form + public class About : Form { + private readonly Button button1; + + private readonly Label lblVersion; + + private readonly RichTextBox richTextBox1; + public About() { - InitializeComponent(); - lblVersion.Text = $"v{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"; + richTextBox1 = new(); + button1 = new(); + lblVersion = new(); + SuspendLayout(); + + richTextBox1.Location = new(12, 12); + richTextBox1.Name = "richTextBox1"; + richTextBox1.ReadOnly = true; + richTextBox1.Size = new(499, 236); + richTextBox1.TabIndex = 1; + richTextBox1.Text = ("DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD." + + "\n\nDiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk )." + + "\n\nBizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments." + + "\n\nTo use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked." + + "\n\nThis is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.)") + .Replace("\n", Environment.NewLine); + richTextBox1.LinkClicked += richTextBox1_LinkClicked; + + button1.DialogResult = DialogResult.Cancel; + button1.Location = new(436, 254); + button1.Name = "button1"; + button1.Size = new(75, 23); + button1.TabIndex = 2; + button1.Text = "OK"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + + lblVersion.AutoSize = true; + lblVersion.Location = new(12, 259); + lblVersion.Name = "lblVersion"; + lblVersion.Size = new(79, 13); + lblVersion.TabIndex = 3; + lblVersion.Text = $"v{Assembly.GetExecutingAssembly().GetName().Version}"; + + AcceptButton = button1; + AutoScaleDimensions = new(6.0f, 13.0f); + AutoScaleMode = AutoScaleMode.Font; + CancelButton = button1; + ClientSize = new(525, 282); + ControlBox = false; + Controls.Add(lblVersion); + Controls.Add(button1); + Controls.Add(richTextBox1); + FormBorderStyle = FormBorderStyle.FixedDialog; + MinimizeBox = false; + Name = "About"; + Text = "About DiscoHawk"; + ResumeLayout(performLayout: false); + PerformLayout(); } private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) diff --git a/src/BizHawk.Client.DiscoHawk/About.resx b/src/BizHawk.Client.DiscoHawk/About.resx deleted file mode 100644 index df0c33f24c8..00000000000 --- a/src/BizHawk.Client.DiscoHawk/About.resx +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD. - -DiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk ). - -BizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments. - -To use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked. - -This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.) - - \ No newline at end of file diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.Designer.cs b/src/BizHawk.Client.DiscoHawk/ComparisonResults.Designer.cs deleted file mode 100644 index df1b7b78097..00000000000 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.Designer.cs +++ /dev/null @@ -1,119 +0,0 @@ -namespace BizHawk.Client.DiscoHawk -{ - partial class ComparisonResults - { - /// - /// 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.textBox1 = new System.Windows.Forms.RichTextBox(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.tabPage3 = new System.Windows.Forms.TabPage(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(3, 3); - this.textBox1.Name = "textBox1"; - this.textBox1.ReadOnly = true; - this.textBox1.Size = new System.Drawing.Size(757, 394); - this.textBox1.TabIndex = 1; - this.textBox1.Text = ""; - // - // tabControl1 - // - this.tabControl1.Controls.Add(this.tabPage1); - this.tabControl1.Controls.Add(this.tabPage2); - this.tabControl1.Controls.Add(this.tabPage3); - this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(771, 426); - this.tabControl1.TabIndex = 2; - // - // tabPage1 - // - this.tabPage1.Controls.Add(this.textBox1); - 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(763, 400); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "Log"; - this.tabPage1.UseVisualStyleBackColor = true; - // - // tabPage2 - // - 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(763, 400); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "SRC Context"; - this.tabPage2.UseVisualStyleBackColor = true; - // - // tabPage3 - // - this.tabPage3.Location = new System.Drawing.Point(4, 22); - this.tabPage3.Name = "tabPage3"; - this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(763, 400); - this.tabPage3.TabIndex = 2; - this.tabPage3.Text = "DST Context"; - this.tabPage3.UseVisualStyleBackColor = true; - // - // ComparisonResults - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(771, 426); - this.Controls.Add(this.tabControl1); - this.Name = "ComparisonResults"; - this.Text = "ComparisonResults"; - this.tabControl1.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - public System.Windows.Forms.RichTextBox textBox1; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.TabPage tabPage3; - - - - } -} \ No newline at end of file diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs index 5e64950a669..93763e3b1a9 100644 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs +++ b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs @@ -1,12 +1,84 @@ -using System.Windows.Forms; +using System.Drawing; +using System.Windows.Forms; namespace BizHawk.Client.DiscoHawk { - public partial class ComparisonResults : Form + public class ComparisonResults : Form { + private readonly TabControl tabControl1; + + private readonly TabPage tabPage1; + + private readonly TabPage tabPage2; + + private readonly TabPage tabPage3; + + public readonly RichTextBox textBox1; + public ComparisonResults() { - InitializeComponent(); + textBox1 = new(); + tabControl1 = new(); + tabPage1 = new(); + tabPage2 = new(); + tabPage3 = new(); + tabControl1.SuspendLayout(); + tabPage1.SuspendLayout(); + SuspendLayout(); + + textBox1.Dock = DockStyle.Fill; + textBox1.Font = new("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + textBox1.Location = new(3, 3); + textBox1.Name = "textBox1"; + textBox1.ReadOnly = true; + textBox1.Size = new(757, 394); + textBox1.TabIndex = 1; + textBox1.Text = ""; + + tabControl1.Controls.Add(tabPage1); + tabControl1.Controls.Add(tabPage2); + tabControl1.Controls.Add(tabPage3); + tabControl1.Dock = DockStyle.Fill; + tabControl1.Location = new(0, 0); + tabControl1.Name = "tabControl1"; + tabControl1.SelectedIndex = 0; + tabControl1.Size = new(771, 426); + tabControl1.TabIndex = 2; + + tabPage1.Controls.Add(textBox1); + tabPage1.Location = new(4, 22); + tabPage1.Name = "tabPage1"; + tabPage1.Padding = new(all: 3); + tabPage1.Size = new(763, 400); + tabPage1.TabIndex = 0; + tabPage1.Text = "Log"; + tabPage1.UseVisualStyleBackColor = true; + + tabPage2.Location = new(4, 22); + tabPage2.Name = "tabPage2"; + tabPage2.Padding = new(all: 3); + tabPage2.Size = new(763, 400); + tabPage2.TabIndex = 1; + tabPage2.Text = "SRC Context"; + tabPage2.UseVisualStyleBackColor = true; + + tabPage3.Location = new(4, 22); + tabPage3.Name = "tabPage3"; + tabPage3.Padding = new(all: 3); + tabPage3.Size = new(763, 400); + tabPage3.TabIndex = 2; + tabPage3.Text = "DST Context"; + tabPage3.UseVisualStyleBackColor = true; + + AutoScaleDimensions = new(6.0f, 13.0f); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new(771, 426); + Controls.Add(tabControl1); + Name = "ComparisonResults"; + Text = "ComparisonResults"; + tabControl1.ResumeLayout(performLayout: false); + tabPage1.ResumeLayout(performLayout: false); + ResumeLayout(performLayout: false); } } } diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.resx b/src/BizHawk.Client.DiscoHawk/ComparisonResults.resx deleted file mode 100644 index 29dcb1b3a35..00000000000 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.Designer.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.Designer.cs deleted file mode 100644 index 1bf3a131365..00000000000 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.Designer.cs +++ /dev/null @@ -1,292 +0,0 @@ -namespace BizHawk.Client.DiscoHawk -{ - partial class MainDiscoForm - { - /// - /// 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() - { - System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("BizHawk"); - System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Mednafen"); - this.ExitButton = new System.Windows.Forms.Button(); - this.lblMagicDragArea = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.lblMp3ExtractMagicArea = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.btnAbout = new System.Windows.Forms.Button(); - this.radioButton1 = new System.Windows.Forms.RadioButton(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.radioButton2 = new System.Windows.Forms.RadioButton(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.ccdOutputButton = new System.Windows.Forms.RadioButton(); - this.chdOutputButton = new System.Windows.Forms.RadioButton(); - this.label6 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.lvCompareTargets = new System.Windows.Forms.ListView(); - this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); - this.lblMagicDragArea.SuspendLayout(); - this.lblMp3ExtractMagicArea.SuspendLayout(); - this.groupBox1.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // ExitButton - // - this.ExitButton.Location = new System.Drawing.Point(434, 414); - this.ExitButton.Name = "ExitButton"; - this.ExitButton.Size = new System.Drawing.Size(75, 23); - this.ExitButton.TabIndex = 0; - this.ExitButton.Text = "E&xit"; - this.ExitButton.UseVisualStyleBackColor = true; - this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click); - // - // lblMagicDragArea - // - this.lblMagicDragArea.AllowDrop = true; - this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.lblMagicDragArea.Controls.Add(this.label1); - this.lblMagicDragArea.Location = new System.Drawing.Point(290, 31); - this.lblMagicDragArea.Name = "lblMagicDragArea"; - this.lblMagicDragArea.Size = new System.Drawing.Size(223, 109); - this.lblMagicDragArea.TabIndex = 1; - this.lblMagicDragArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.lblMagicDragArea_DragDrop); - this.lblMagicDragArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.LblMagicDragArea_DragEnter); - // - // label1 - // - this.label1.Location = new System.Drawing.Point(17, 25); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(166, 47); - this.label1.TabIndex = 0; - this.label1.Text = "Drag here to HAWK your disc - dump it out as a clean CCD/CHD"; - // - // lblMp3ExtractMagicArea - // - this.lblMp3ExtractMagicArea.AllowDrop = true; - this.lblMp3ExtractMagicArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.lblMp3ExtractMagicArea.Controls.Add(this.label2); - this.lblMp3ExtractMagicArea.Location = new System.Drawing.Point(290, 146); - this.lblMp3ExtractMagicArea.Name = "lblMp3ExtractMagicArea"; - this.lblMp3ExtractMagicArea.Size = new System.Drawing.Size(223, 100); - this.lblMp3ExtractMagicArea.TabIndex = 2; - this.lblMp3ExtractMagicArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.LblMp3ExtractMagicArea_DragDrop); - this.lblMp3ExtractMagicArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.LblMagicDragArea_DragEnter); - // - // label2 - // - this.label2.Location = new System.Drawing.Point(20, 25); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(163, 39); - this.label2.TabIndex = 0; - this.label2.Text = "Drag a disc here to extract the audio tracks to MP3"; - // - // btnAbout - // - this.btnAbout.Location = new System.Drawing.Point(353, 414); - this.btnAbout.Name = "btnAbout"; - this.btnAbout.Size = new System.Drawing.Size(75, 23); - this.btnAbout.TabIndex = 3; - this.btnAbout.Text = "&About"; - this.btnAbout.UseVisualStyleBackColor = true; - this.btnAbout.Click += new System.EventHandler(this.BtnAbout_Click); - // - // radioButton1 - // - this.radioButton1.AutoSize = true; - this.radioButton1.Checked = true; - this.radioButton1.Location = new System.Drawing.Point(6, 19); - this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(67, 17); - this.radioButton1.TabIndex = 4; - this.radioButton1.TabStop = true; - this.radioButton1.Text = "BizHawk"; - this.radioButton1.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.radioButton2); - this.groupBox1.Controls.Add(this.radioButton1); - this.groupBox1.Enabled = true; - this.groupBox1.Location = new System.Drawing.Point(9, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(276, 234); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Disc Reading Engine"; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(20, 95); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(216, 43); - this.label4.TabIndex = 8; - this.label4.Text = "- Doesn\'t support audio decoding yet\r\n(even though Mednafen proper can do it)\r\n- " + "Loads ISO, CUE, and CCD"; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(20, 39); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(253, 33); - this.label3.TabIndex = 7; - this.label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG"; - // - // radioButton2 - // - this.radioButton2.AutoSize = true; - this.radioButton2.Enabled = false; - this.radioButton2.Location = new System.Drawing.Point(6, 75); - this.radioButton2.Name = "radioButton2"; - this.radioButton2.Size = new System.Drawing.Size(73, 17); - this.radioButton2.TabIndex = 5; - this.radioButton2.Text = "Mednafen"; - this.radioButton2.UseVisualStyleBackColor = true; - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.ccdOutputButton); - this.groupBox2.Controls.Add(this.chdOutputButton); - this.groupBox2.Enabled = true; - this.groupBox2.Location = new System.Drawing.Point(9, 252); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(271, 69); - this.groupBox2.TabIndex = 6; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Output Format"; - // - // ccdOutputButton - // - this.ccdOutputButton.AutoSize = true; - this.ccdOutputButton.Checked = true; - this.ccdOutputButton.Location = new System.Drawing.Point(12, 19); - this.ccdOutputButton.Name = "ccdOutputButton"; - this.ccdOutputButton.Size = new System.Drawing.Size(47, 17); - this.ccdOutputButton.TabIndex = 5; - this.ccdOutputButton.TabStop = true; - this.ccdOutputButton.Text = "CCD"; - this.ccdOutputButton.UseVisualStyleBackColor = true; - // - // chdOutputButton - // - this.chdOutputButton.AutoSize = true; - this.chdOutputButton.Checked = false; - this.chdOutputButton.Location = new System.Drawing.Point(65, 19); - this.chdOutputButton.Name = "chdOutputButton"; - this.chdOutputButton.Size = new System.Drawing.Size(47, 17); - this.chdOutputButton.TabIndex = 6; - this.chdOutputButton.TabStop = true; - this.chdOutputButton.Text = "CHD"; - this.chdOutputButton.UseVisualStyleBackColor = true; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Enabled = false; - this.label6.Location = new System.Drawing.Point(9, 324); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(111, 13); - this.label6.TabIndex = 2; - this.label6.Text = "Compare Reading To:"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(358, 12); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(70, 13); - this.label7.TabIndex = 10; - this.label7.Text = "- Operations -"; - // - // lvCompareTargets - // - this.lvCompareTargets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1 }); - this.lvCompareTargets.Enabled = false; - this.lvCompareTargets.FullRowSelect = true; - this.lvCompareTargets.GridLines = true; - this.lvCompareTargets.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.lvCompareTargets.HideSelection = false; - this.lvCompareTargets.Items.AddRange(new System.Windows.Forms.ListViewItem[] { listViewItem1, listViewItem2 }); - this.lvCompareTargets.Location = new System.Drawing.Point(9, 340); - this.lvCompareTargets.Name = "lvCompareTargets"; - this.lvCompareTargets.Size = new System.Drawing.Size(121, 97); - this.lvCompareTargets.TabIndex = 11; - this.lvCompareTargets.UseCompatibleStateImageBehavior = false; - this.lvCompareTargets.View = System.Windows.Forms.View.Details; - // - // MainDiscoForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(521, 449); - this.Controls.Add(this.lvCompareTargets); - this.Controls.Add(this.label6); - this.Controls.Add(this.label7); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.btnAbout); - this.Controls.Add(this.lblMp3ExtractMagicArea); - this.Controls.Add(this.lblMagicDragArea); - this.Controls.Add(this.ExitButton); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MainDiscoForm"; - this.Text = "DiscoHawk"; - this.Load += new System.EventHandler(this.MainDiscoForm_Load); - this.lblMagicDragArea.ResumeLayout(false); - this.lblMp3ExtractMagicArea.ResumeLayout(false); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - } - - #endregion - - private System.Windows.Forms.Button ExitButton; - private System.Windows.Forms.Panel lblMagicDragArea; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Panel lblMp3ExtractMagicArea; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button btnAbout; - private System.Windows.Forms.RadioButton radioButton1; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.RadioButton radioButton2; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.RadioButton ccdOutputButton; - private System.Windows.Forms.RadioButton chdOutputButton; - private System.Windows.Forms.ListView lvCompareTargets; - private System.Windows.Forms.ColumnHeader columnHeader1; - } -} \ No newline at end of file diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index 1e5e0924dcc..04d58e1125b 100644 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -9,8 +9,44 @@ namespace BizHawk.Client.DiscoHawk { - public partial class MainDiscoForm : Form + public class MainDiscoForm : Form { + private readonly Button btnAbout; + + private readonly RadioButton ccdOutputButton; + + private readonly RadioButton chdOutputButton; + + private readonly ColumnHeader columnHeader1; + + private readonly Button ExitButton; + + private readonly GroupBox groupBox1; + + private readonly GroupBox groupBox2; + + private readonly Label label1; + + private readonly Label label2; + + private readonly Label label3; + + private readonly Label label4; + + private readonly Label label6; + + private readonly Label label7; + + private readonly Panel lblMagicDragArea; + + private readonly Panel lblMp3ExtractMagicArea; + + private readonly ListView lvCompareTargets; + + private readonly RadioButton radioButton1; + + private readonly RadioButton radioButton2; + // Release TODO: // An input (queue) list // An outputted list showing new file name @@ -18,10 +54,212 @@ public partial class MainDiscoForm : Form // Add disc button, which puts it on the progress cue (converts it) public MainDiscoForm() { - InitializeComponent(); + ListViewItem listViewItem1 = new("BizHawk"); + ListViewItem listViewItem2 = new("Mednafen"); + ExitButton = new(); + lblMagicDragArea = new(); + label1 = new(); + lblMp3ExtractMagicArea = new(); + label2 = new(); + btnAbout = new(); + radioButton1 = new(); + groupBox1 = new(); + label4 = new(); + label3 = new(); + radioButton2 = new(); + groupBox2 = new(); + ccdOutputButton = new(); + chdOutputButton = new(); + label6 = new(); + label7 = new(); + lvCompareTargets = new(); + columnHeader1 = new(); + lblMagicDragArea.SuspendLayout(); + lblMp3ExtractMagicArea.SuspendLayout(); + groupBox1.SuspendLayout(); + groupBox2.SuspendLayout(); + SuspendLayout(); + + ExitButton.Location = new(434, 414); + ExitButton.Name = "ExitButton"; + ExitButton.Size = new(75, 23); + ExitButton.TabIndex = 0; + ExitButton.Text = "E&xit"; + ExitButton.UseVisualStyleBackColor = true; + ExitButton.Click += ExitButton_Click; + + lblMagicDragArea.AllowDrop = true; + lblMagicDragArea.BorderStyle = BorderStyle.Fixed3D; + lblMagicDragArea.Controls.Add(label1); + lblMagicDragArea.Location = new(290, 31); + lblMagicDragArea.Name = "lblMagicDragArea"; + lblMagicDragArea.Size = new(223, 109); + lblMagicDragArea.TabIndex = 1; + lblMagicDragArea.DragDrop += lblMagicDragArea_DragDrop; + lblMagicDragArea.DragEnter += LblMagicDragArea_DragEnter; + + label1.Location = new(17, 25); + label1.Name = "label1"; + label1.Size = new(166, 47); + label1.TabIndex = 0; + label1.Text = "Drag here to HAWK your disc - dump it out as a clean CCD/CHD"; + + lblMp3ExtractMagicArea.AllowDrop = true; + lblMp3ExtractMagicArea.BorderStyle = BorderStyle.Fixed3D; + lblMp3ExtractMagicArea.Controls.Add(label2); + lblMp3ExtractMagicArea.Location = new(290, 146); + lblMp3ExtractMagicArea.Name = "lblMp3ExtractMagicArea"; + lblMp3ExtractMagicArea.Size = new(223, 100); + lblMp3ExtractMagicArea.TabIndex = 2; + lblMp3ExtractMagicArea.DragDrop += LblMp3ExtractMagicArea_DragDrop; + lblMp3ExtractMagicArea.DragEnter += LblMagicDragArea_DragEnter; + + label2.Location = new(20, 25); + label2.Name = "label2"; + label2.Size = new(163, 39); + label2.TabIndex = 0; + label2.Text = "Drag a disc here to extract the audio tracks to MP3"; + + btnAbout.Location = new(353, 414); + btnAbout.Name = "btnAbout"; + btnAbout.Size = new(75, 23); + btnAbout.TabIndex = 3; + btnAbout.Text = "&About"; + btnAbout.UseVisualStyleBackColor = true; + btnAbout.Click += BtnAbout_Click; + + radioButton1.AutoSize = true; + radioButton1.Checked = true; + radioButton1.Location = new(6, 19); + radioButton1.Name = "radioButton1"; + radioButton1.Size = new(67, 17); + radioButton1.TabIndex = 4; + radioButton1.TabStop = true; + radioButton1.Text = "BizHawk"; + radioButton1.UseVisualStyleBackColor = true; + + groupBox1.Controls.Add(label4); + groupBox1.Controls.Add(label3); + groupBox1.Controls.Add(radioButton2); + groupBox1.Controls.Add(radioButton1); + groupBox1.Enabled = true; + groupBox1.Location = new(9, 12); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new(276, 234); + groupBox1.TabIndex = 5; + groupBox1.TabStop = false; + groupBox1.Text = "Disc Reading Engine"; + + label4.Location = new(20, 95); + label4.Name = "label4"; + label4.Size = new(216, 43); + label4.TabIndex = 8; + label4.Text = "- Doesn\'t support audio decoding yet\r\n(even though Mednafen proper can do it)\r\n- Loads ISO, CUE, and CCD"; + + label3.Location = new(20, 39); + label3.Name = "label3"; + label3.Size = new(253, 33); + label3.TabIndex = 7; + label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG"; + + radioButton2.AutoSize = true; + radioButton2.Enabled = false; + radioButton2.Location = new(6, 75); + radioButton2.Name = "radioButton2"; + radioButton2.Size = new(73, 17); + radioButton2.TabIndex = 5; + radioButton2.Text = "Mednafen"; + radioButton2.UseVisualStyleBackColor = true; + + groupBox2.Controls.Add(ccdOutputButton); + groupBox2.Controls.Add(chdOutputButton); + groupBox2.Enabled = true; + groupBox2.Location = new(9, 252); + groupBox2.Name = "groupBox2"; + groupBox2.Size = new(271, 69); + groupBox2.TabIndex = 6; + groupBox2.TabStop = false; + groupBox2.Text = "Output Format"; + + ccdOutputButton.AutoSize = true; + ccdOutputButton.Checked = true; + ccdOutputButton.Location = new(12, 19); + ccdOutputButton.Name = "ccdOutputButton"; + ccdOutputButton.Size = new(47, 17); + ccdOutputButton.TabIndex = 5; + ccdOutputButton.TabStop = true; + ccdOutputButton.Text = "CCD"; + ccdOutputButton.UseVisualStyleBackColor = true; + + chdOutputButton.AutoSize = true; + chdOutputButton.Checked = false; + chdOutputButton.Location = new(65, 19); + chdOutputButton.Name = "chdOutputButton"; + chdOutputButton.Size = new(47, 17); + chdOutputButton.TabIndex = 6; + chdOutputButton.TabStop = true; + chdOutputButton.Text = "CHD"; + chdOutputButton.UseVisualStyleBackColor = true; + + label6.AutoSize = true; + label6.Enabled = false; + label6.Location = new(9, 324); + label6.Name = "label6"; + label6.Size = new(111, 13); + label6.TabIndex = 2; + label6.Text = "Compare Reading To:"; + + label7.AutoSize = true; + label7.Location = new(358, 12); + label7.Name = "label7"; + label7.Size = new(70, 13); + label7.TabIndex = 10; + label7.Text = "- Operations -"; + + lvCompareTargets.Columns.Add(columnHeader1); + lvCompareTargets.Enabled = false; + lvCompareTargets.FullRowSelect = true; + lvCompareTargets.GridLines = true; + lvCompareTargets.HeaderStyle = ColumnHeaderStyle.None; + lvCompareTargets.HideSelection = false; + lvCompareTargets.Items.Add(listViewItem1); + lvCompareTargets.Items.Add(listViewItem2); + lvCompareTargets.Location = new(9, 340); + lvCompareTargets.Name = "lvCompareTargets"; + lvCompareTargets.Size = new(121, 97); + lvCompareTargets.TabIndex = 11; + lvCompareTargets.UseCompatibleStateImageBehavior = false; + lvCompareTargets.View = View.Details; + + AutoScaleDimensions = new(6.0f, 13.0f); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new(521, 449); + Controls.Add(lvCompareTargets); + Controls.Add(label6); + Controls.Add(label7); + Controls.Add(groupBox2); + Controls.Add(groupBox1); + Controls.Add(btnAbout); + Controls.Add(lblMp3ExtractMagicArea); + Controls.Add(lblMagicDragArea); + Controls.Add(ExitButton); + FormBorderStyle = FormBorderStyle.FixedDialog; var icoStream = typeof(MainDiscoForm).Assembly.GetManifestResourceStream("BizHawk.Client.DiscoHawk.discohawk.ico"); if (icoStream != null) Icon = new Icon(icoStream); else Console.WriteLine("couldn't load .ico EmbeddedResource?"); + MaximizeBox = false; + MinimizeBox = false; + Name = "MainDiscoForm"; + Text = "DiscoHawk"; + Load += MainDiscoForm_Load; + lblMagicDragArea.ResumeLayout(performLayout: false); + lblMp3ExtractMagicArea.ResumeLayout(performLayout: false); + groupBox1.ResumeLayout(performLayout: false); + groupBox1.PerformLayout(); + groupBox2.ResumeLayout(performLayout: false); + groupBox2.PerformLayout(); + ResumeLayout(performLayout: false); + PerformLayout(); } private void MainDiscoForm_Load(object sender, EventArgs e) diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.resx b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.resx deleted file mode 100644 index 29dcb1b3a35..00000000000 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 From 0dc08f721c85d1a403494a0a944bbebc33646005 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 26 Jul 2025 14:29:24 +1000 Subject: [PATCH 2/8] Inline some fields and event handlers in DiscoHawk --- src/BizHawk.Client.DiscoHawk/About.cs | 26 +---- .../ComparisonResults.cs | 22 ++--- src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs | 98 +++++-------------- 3 files changed, 39 insertions(+), 107 deletions(-) diff --git a/src/BizHawk.Client.DiscoHawk/About.cs b/src/BizHawk.Client.DiscoHawk/About.cs index 8fede89222a..8b5a8c4e6e6 100644 --- a/src/BizHawk.Client.DiscoHawk/About.cs +++ b/src/BizHawk.Client.DiscoHawk/About.cs @@ -7,19 +7,11 @@ namespace BizHawk.Client.DiscoHawk { public class About : Form { - private readonly Button button1; - - private readonly Label lblVersion; - - private readonly RichTextBox richTextBox1; - public About() { - richTextBox1 = new(); - button1 = new(); - lblVersion = new(); SuspendLayout(); + RichTextBox richTextBox1 = new(); richTextBox1.Location = new(12, 12); richTextBox1.Name = "richTextBox1"; richTextBox1.ReadOnly = true; @@ -31,8 +23,9 @@ public About() + "\n\nTo use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked." + "\n\nThis is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.)") .Replace("\n", Environment.NewLine); - richTextBox1.LinkClicked += richTextBox1_LinkClicked; + richTextBox1.LinkClicked += (_, clickedArgs) => Util.OpenUrlExternal(clickedArgs.LinkText); + Button button1 = new(); button1.DialogResult = DialogResult.Cancel; button1.Location = new(436, 254); button1.Name = "button1"; @@ -40,8 +33,9 @@ public About() button1.TabIndex = 2; button1.Text = "OK"; button1.UseVisualStyleBackColor = true; - button1.Click += button1_Click; + button1.Click += (_, _) => Close(); + Label lblVersion = new(); lblVersion.AutoSize = true; lblVersion.Location = new(12, 259); lblVersion.Name = "lblVersion"; @@ -65,15 +59,5 @@ public About() ResumeLayout(performLayout: false); PerformLayout(); } - - private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) - { - Util.OpenUrlExternal(e.LinkText); - } - - private void button1_Click(object sender, EventArgs e) - { - Close(); - } } } diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs index 93763e3b1a9..6e9891beebf 100644 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs +++ b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs @@ -5,27 +5,13 @@ namespace BizHawk.Client.DiscoHawk { public class ComparisonResults : Form { - private readonly TabControl tabControl1; - - private readonly TabPage tabPage1; - - private readonly TabPage tabPage2; - - private readonly TabPage tabPage3; - public readonly RichTextBox textBox1; public ComparisonResults() { - textBox1 = new(); - tabControl1 = new(); - tabPage1 = new(); - tabPage2 = new(); - tabPage3 = new(); - tabControl1.SuspendLayout(); - tabPage1.SuspendLayout(); SuspendLayout(); + textBox1 = new(); textBox1.Dock = DockStyle.Fill; textBox1.Font = new("Courier New", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); textBox1.Location = new(3, 3); @@ -35,6 +21,11 @@ public ComparisonResults() textBox1.TabIndex = 1; textBox1.Text = ""; + TabControl tabControl1 = new(); + tabControl1.SuspendLayout(); + TabPage tabPage1 = new(); + TabPage tabPage2 = new(); + TabPage tabPage3 = new(); tabControl1.Controls.Add(tabPage1); tabControl1.Controls.Add(tabPage2); tabControl1.Controls.Add(tabPage3); @@ -45,6 +36,7 @@ public ComparisonResults() tabControl1.Size = new(771, 426); tabControl1.TabIndex = 2; + tabPage1.SuspendLayout(); tabPage1.Controls.Add(textBox1); tabPage1.Location = new(4, 22); tabPage1.Name = "tabPage1"; diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index 04d58e1125b..c1109c78862 100644 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -11,42 +11,16 @@ namespace BizHawk.Client.DiscoHawk { public class MainDiscoForm : Form { - private readonly Button btnAbout; - private readonly RadioButton ccdOutputButton; private readonly RadioButton chdOutputButton; - private readonly ColumnHeader columnHeader1; - - private readonly Button ExitButton; - - private readonly GroupBox groupBox1; - - private readonly GroupBox groupBox2; - - private readonly Label label1; - - private readonly Label label2; - - private readonly Label label3; - - private readonly Label label4; - - private readonly Label label6; - - private readonly Label label7; - private readonly Panel lblMagicDragArea; private readonly Panel lblMp3ExtractMagicArea; private readonly ListView lvCompareTargets; - private readonly RadioButton radioButton1; - - private readonly RadioButton radioButton2; - // Release TODO: // An input (queue) list // An outputted list showing new file name @@ -54,40 +28,20 @@ public class MainDiscoForm : Form // Add disc button, which puts it on the progress cue (converts it) public MainDiscoForm() { - ListViewItem listViewItem1 = new("BizHawk"); - ListViewItem listViewItem2 = new("Mednafen"); - ExitButton = new(); - lblMagicDragArea = new(); - label1 = new(); - lblMp3ExtractMagicArea = new(); - label2 = new(); - btnAbout = new(); - radioButton1 = new(); - groupBox1 = new(); - label4 = new(); - label3 = new(); - radioButton2 = new(); - groupBox2 = new(); - ccdOutputButton = new(); - chdOutputButton = new(); - label6 = new(); - label7 = new(); - lvCompareTargets = new(); - columnHeader1 = new(); - lblMagicDragArea.SuspendLayout(); - lblMp3ExtractMagicArea.SuspendLayout(); - groupBox1.SuspendLayout(); - groupBox2.SuspendLayout(); SuspendLayout(); + Button ExitButton = new(); ExitButton.Location = new(434, 414); ExitButton.Name = "ExitButton"; ExitButton.Size = new(75, 23); ExitButton.TabIndex = 0; ExitButton.Text = "E&xit"; ExitButton.UseVisualStyleBackColor = true; - ExitButton.Click += ExitButton_Click; + ExitButton.Click += (_, _) => Close(); + lblMagicDragArea = new(); + lblMagicDragArea.SuspendLayout(); + Label label1 = new(); lblMagicDragArea.AllowDrop = true; lblMagicDragArea.BorderStyle = BorderStyle.Fixed3D; lblMagicDragArea.Controls.Add(label1); @@ -104,6 +58,9 @@ public MainDiscoForm() label1.TabIndex = 0; label1.Text = "Drag here to HAWK your disc - dump it out as a clean CCD/CHD"; + lblMp3ExtractMagicArea = new(); + lblMp3ExtractMagicArea.SuspendLayout(); + Label label2 = new(); lblMp3ExtractMagicArea.AllowDrop = true; lblMp3ExtractMagicArea.BorderStyle = BorderStyle.Fixed3D; lblMp3ExtractMagicArea.Controls.Add(label2); @@ -120,14 +77,16 @@ public MainDiscoForm() label2.TabIndex = 0; label2.Text = "Drag a disc here to extract the audio tracks to MP3"; + Button btnAbout = new(); btnAbout.Location = new(353, 414); btnAbout.Name = "btnAbout"; btnAbout.Size = new(75, 23); btnAbout.TabIndex = 3; btnAbout.Text = "&About"; btnAbout.UseVisualStyleBackColor = true; - btnAbout.Click += BtnAbout_Click; + btnAbout.Click += (_, _) => new About().ShowDialog(); + RadioButton radioButton1 = new(); radioButton1.AutoSize = true; radioButton1.Checked = true; radioButton1.Location = new(6, 19); @@ -138,6 +97,11 @@ public MainDiscoForm() radioButton1.Text = "BizHawk"; radioButton1.UseVisualStyleBackColor = true; + GroupBox groupBox1 = new(); + groupBox1.SuspendLayout(); + Label label4 = new(); + Label label3 = new(); + RadioButton radioButton2 = new(); groupBox1.Controls.Add(label4); groupBox1.Controls.Add(label3); groupBox1.Controls.Add(radioButton2); @@ -171,6 +135,10 @@ public MainDiscoForm() radioButton2.Text = "Mednafen"; radioButton2.UseVisualStyleBackColor = true; + GroupBox groupBox2 = new(); + groupBox2.SuspendLayout(); + ccdOutputButton = new(); + chdOutputButton = new(); groupBox2.Controls.Add(ccdOutputButton); groupBox2.Controls.Add(chdOutputButton); groupBox2.Enabled = true; @@ -201,6 +169,7 @@ public MainDiscoForm() chdOutputButton.Text = "CHD"; chdOutputButton.UseVisualStyleBackColor = true; + Label label6 = new(); label6.AutoSize = true; label6.Enabled = false; label6.Location = new(9, 324); @@ -209,6 +178,7 @@ public MainDiscoForm() label6.TabIndex = 2; label6.Text = "Compare Reading To:"; + Label label7 = new(); label7.AutoSize = true; label7.Location = new(358, 12); label7.Name = "label7"; @@ -216,14 +186,15 @@ public MainDiscoForm() label7.TabIndex = 10; label7.Text = "- Operations -"; - lvCompareTargets.Columns.Add(columnHeader1); + lvCompareTargets = new(); + lvCompareTargets.Columns.Add(new ColumnHeader()); lvCompareTargets.Enabled = false; lvCompareTargets.FullRowSelect = true; lvCompareTargets.GridLines = true; lvCompareTargets.HeaderStyle = ColumnHeaderStyle.None; lvCompareTargets.HideSelection = false; - lvCompareTargets.Items.Add(listViewItem1); - lvCompareTargets.Items.Add(listViewItem2); + lvCompareTargets.Items.Add("BizHawk"); + lvCompareTargets.Items.Add("Mednafen"); lvCompareTargets.Location = new(9, 340); lvCompareTargets.Name = "lvCompareTargets"; lvCompareTargets.Size = new(121, 97); @@ -251,7 +222,7 @@ public MainDiscoForm() MinimizeBox = false; Name = "MainDiscoForm"; Text = "DiscoHawk"; - Load += MainDiscoForm_Load; + Load += (_, _) => lvCompareTargets.Columns[0].Width = lvCompareTargets.ClientSize.Width; lblMagicDragArea.ResumeLayout(performLayout: false); lblMp3ExtractMagicArea.ResumeLayout(performLayout: false); groupBox1.ResumeLayout(performLayout: false); @@ -262,16 +233,6 @@ public MainDiscoForm() PerformLayout(); } - private void MainDiscoForm_Load(object sender, EventArgs e) - { - lvCompareTargets.Columns[0].Width = lvCompareTargets.ClientSize.Width; - } - - private void ExitButton_Click(object sender, EventArgs e) - { - Close(); - } - private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) { lblMagicDragArea.AllowDrop = false; @@ -406,10 +367,5 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) Cursor = Cursors.Default; } } - - private void BtnAbout_Click(object sender, EventArgs e) - { - new About().ShowDialog(); - } } } From ac2745347876b3605d0c8edf72e4b1c7a1046732 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 26 Jul 2025 12:52:33 +1000 Subject: [PATCH 3/8] Add Fluent.Net sample to DiscoHawk --- Directory.Packages.props | 1 + .../BizHawk.Client.DiscoHawk.csproj | 2 + src/BizHawk.Client.DiscoHawk/Program.cs | 2 + src/BizHawk.Client.DiscoHawk/Sample.cs | 101 ++++++++++++++++++ src/BizHawk.Client.DiscoHawk/locale/en.ftl | 24 +++++ src/BizHawk.Client.DiscoHawk/locale/it.ftl | 23 ++++ src/BizHawk.Client.DiscoHawk/locale/pl.ftl | 29 +++++ 7 files changed, 182 insertions(+) create mode 100644 src/BizHawk.Client.DiscoHawk/Sample.cs create mode 100644 src/BizHawk.Client.DiscoHawk/locale/en.ftl create mode 100644 src/BizHawk.Client.DiscoHawk/locale/it.ftl create mode 100644 src/BizHawk.Client.DiscoHawk/locale/pl.ftl diff --git a/Directory.Packages.props b/Directory.Packages.props index dbc519b8ba4..ca5d2f1f68d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,7 @@ + diff --git a/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj b/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj index a3331e1bde0..961aa30ba14 100755 --- a/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj +++ b/src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj @@ -10,9 +10,11 @@ true + + diff --git a/src/BizHawk.Client.DiscoHawk/Program.cs b/src/BizHawk.Client.DiscoHawk/Program.cs index f85d66f0a75..a1892e4c0b3 100644 --- a/src/BizHawk.Client.DiscoHawk/Program.cs +++ b/src/BizHawk.Client.DiscoHawk/Program.cs @@ -114,6 +114,8 @@ private static void Main(string[] args) } } + Sample.RunAll(); // testing Fluent.Net + // Do something for visuals, I guess Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/src/BizHawk.Client.DiscoHawk/Sample.cs b/src/BizHawk.Client.DiscoHawk/Sample.cs new file mode 100644 index 00000000000..219d07be4e2 --- /dev/null +++ b/src/BizHawk.Client.DiscoHawk/Sample.cs @@ -0,0 +1,101 @@ +#nullable enable + +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; + +using Fluent.Net; + +namespace BizHawk.Client.DiscoHawk +{ + public sealed class ArgsDict : Dictionary + { + public ArgsDict(int? tabCount = null) + { + Add(nameof(tabCount), tabCount); + } + } + + public readonly struct MultiMessageContext + { + private static IReadOnlyList ReadEmbeddedAndConcat(string lang, MessageContext[] overlays) + { + MessageContext mc = new(lang, new() { UseIsolating = false }); + Stream embeddedStream; + try + { + embeddedStream = ReflectionCache.EmbeddedResourceStream($"locale.{lang}.ftl"); + } + catch (ArgumentException e) + { + Console.WriteLine(e); + return overlays; + } + using StreamReader sr = new(embeddedStream); + var errors = mc.AddMessages(sr); + foreach (var error in errors) Console.WriteLine(error); + return [ ..overlays, mc ]; + } + + private readonly IReadOnlyList _contexts; + + public readonly CultureInfo Culture; + + public MultiMessageContext(IReadOnlyList contexts) + { + _contexts = contexts; + Culture = new(_contexts.FirstOrDefault()?.Locales?.First()); + } + + public MultiMessageContext(string lang, params MessageContext[] overlays) + : this(ReadEmbeddedAndConcat(lang, overlays)) {} + + public string? this[string id] + => GetString(id); + + public string? GetString( + string id, + IDictionary? args = null, + ICollection? errors = null) + { + foreach (var context in _contexts) + { + var msg = context.GetMessage(id); + if (msg is not null) return context.Format(msg, args, errors); + } + return null; + } + } + + public static class Sample + { + public static void RunAll() + { + static void RunTest(string lang) + { + MultiMessageContext translator = new(lang); + Console.WriteLine($"\n{lang}:"); + Console.WriteLine($"tabs-close-button = {translator.GetString("tabs-close-button")}"); + Console.WriteLine( + "tabs-close-tooltip ($tabCount = 1) = " + + translator.GetString("tabs-close-tooltip", new ArgsDict(tabCount: 1))); + Console.WriteLine( + "tabs-close-tooltip ($tabCount = 2) = " + + translator.GetString("tabs-close-tooltip", new ArgsDict(tabCount: 2))); + Console.WriteLine( + "tabs-close-warning ($tabCount = 1) = " + + translator.GetString("tabs-close-warning", new ArgsDict(tabCount: 1))); + Console.WriteLine( + "tabs-close-warning ($tabCount = 2) = " + + translator.GetString("tabs-close-warning", new ArgsDict(tabCount: 2))); + Console.WriteLine($"sync-dialog-title = {translator.GetString("sync-dialog-title")}"); + Console.WriteLine($"sync-headline-title = {translator.GetString("sync-headline-title")}"); + Console.WriteLine($"sync-signedout-title = {translator.GetString("sync-signedout-title")}"); + } + RunTest("en"); + RunTest("it"); + RunTest("pl"); + } + } +} diff --git a/src/BizHawk.Client.DiscoHawk/locale/en.ftl b/src/BizHawk.Client.DiscoHawk/locale/en.ftl new file mode 100644 index 00000000000..f1600fe9360 --- /dev/null +++ b/src/BizHawk.Client.DiscoHawk/locale/en.ftl @@ -0,0 +1,24 @@ +## Closing tabs + +tabs-close-button = Close +tabs-close-tooltip = {$tabCount -> + [one] Close {$tabCount} tab + *[other] Close {$tabCount} tabs +} +tabs-close-warning = + You are about to close {$tabCount} tabs. + Are you sure you want to continue? + +## Syncing + +-sync-brand-name = Firefox Account + +sync-dialog-title = {-sync-brand-name} +sync-headline-title = + {-sync-brand-name}: The best way to bring + your data always with you +sync-signedout-title = + Connect with your {-sync-brand-name} + +## Datetime +date-is = The date is 'DATETIME($dt, weekday: "short", month: "short", year: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric")'. diff --git a/src/BizHawk.Client.DiscoHawk/locale/it.ftl b/src/BizHawk.Client.DiscoHawk/locale/it.ftl new file mode 100644 index 00000000000..9281d708fdb --- /dev/null +++ b/src/BizHawk.Client.DiscoHawk/locale/it.ftl @@ -0,0 +1,23 @@ +## Closing tabs + +tabs-close-button = Chiudi +tabs-close-tooltip = {$tabCount -> + [one] Chiudi {$tabCount} scheda + *[other] Chiudi {$tabCount} schede +} +tabs-close-warning = + Verranno chiuse {$tabCount} schede. Proseguire? + +## Syncing + +-sync-brand-name = {$first -> + *[uppercase] Account Firefox + [lowercase] account Firefox +} + +sync-dialog-title = {-sync-brand-name} +sync-headline-title = + {-sync-brand-name}: il modo migliore + per avere i tuoi dati sempre con te +sync-signedout-title = + Connetti il tuo {-sync-brand-name[lowercase]} diff --git a/src/BizHawk.Client.DiscoHawk/locale/pl.ftl b/src/BizHawk.Client.DiscoHawk/locale/pl.ftl new file mode 100644 index 00000000000..9048f6b08a4 --- /dev/null +++ b/src/BizHawk.Client.DiscoHawk/locale/pl.ftl @@ -0,0 +1,29 @@ +## Closing tabs + +tabs-close-button = Zamknij +tabs-close-tooltip = {$tabCount -> + [one] Zamknij kartę + [few] Zamknij {$tabCount} karty + *[many] Zamknij { $tabCount } kart +} +tabs-close-warning = {$tabCount -> + [few] Zostaną zamknięte {$tabCount} karty. + Czy chcesz kontynuować? + *[many] Zostanie zamkniętych {$tabCount} kart. + Czy chcesz kontynuować? +} + +## Syncing + +-sync-brand-name = {$case -> + *[nominative] Konto Firefox + [genitive] Konta Firefox + [accusative] Kontem Firefox +} + +sync-dialog-title = {-sync-brand-name} +sync-headline-title = + {-sync-brand-name}: Najlepszy sposób na to, + aby mieć swoje dane zawsze przy sobie +sync-signedout-title = + Zaloguj do {-sync-brand-name[genitive]} From b14f0333b51051c333a062d22d4d4858289b5407 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 28 Jul 2025 00:45:11 +1000 Subject: [PATCH 4/8] Adopt Fluent in DiscoHawk, simply moving strings across --- src/BizHawk.Client.DiscoHawk/About.cs | 13 +-- .../ComparisonResults.cs | 12 +- src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs | 59 +++++----- src/BizHawk.Client.DiscoHawk/Program.cs | 8 +- src/BizHawk.Client.DiscoHawk/locale/en.ftl | 105 +++++++++++++++++- 5 files changed, 150 insertions(+), 47 deletions(-) diff --git a/src/BizHawk.Client.DiscoHawk/About.cs b/src/BizHawk.Client.DiscoHawk/About.cs index 8b5a8c4e6e6..c8d4594a42c 100644 --- a/src/BizHawk.Client.DiscoHawk/About.cs +++ b/src/BizHawk.Client.DiscoHawk/About.cs @@ -7,7 +7,7 @@ namespace BizHawk.Client.DiscoHawk { public class About : Form { - public About() + public About(MultiMessageContext i18n) { SuspendLayout(); @@ -17,12 +17,7 @@ public About() richTextBox1.ReadOnly = true; richTextBox1.Size = new(499, 236); richTextBox1.TabIndex = 1; - richTextBox1.Text = ("DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD." - + "\n\nDiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk )." - + "\n\nBizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments." - + "\n\nTo use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked." - + "\n\nThis is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.)") - .Replace("\n", Environment.NewLine); + richTextBox1.Text = i18n["discohawkabout-4584-lbl-explainer-label"]!.Replace("\n", Environment.NewLine); richTextBox1.LinkClicked += (_, clickedArgs) => Util.OpenUrlExternal(clickedArgs.LinkText); Button button1 = new(); @@ -31,7 +26,7 @@ public About() button1.Name = "button1"; button1.Size = new(75, 23); button1.TabIndex = 2; - button1.Text = "OK"; + button1.Text = i18n["discohawkabout-9804-btn-dismiss-textstr"]; button1.UseVisualStyleBackColor = true; button1.Click += (_, _) => Close(); @@ -55,7 +50,7 @@ public About() FormBorderStyle = FormBorderStyle.FixedDialog; MinimizeBox = false; Name = "About"; - Text = "About DiscoHawk"; + Text = i18n["discohawkabout-2822-windowtitlestatic"]; ResumeLayout(performLayout: false); PerformLayout(); } diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs index 6e9891beebf..bdaac89e33c 100644 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs +++ b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs @@ -7,7 +7,7 @@ public class ComparisonResults : Form { public readonly RichTextBox textBox1; - public ComparisonResults() + public ComparisonResults(MultiMessageContext i18n) { SuspendLayout(); @@ -19,7 +19,7 @@ public ComparisonResults() textBox1.ReadOnly = true; textBox1.Size = new(757, 394); textBox1.TabIndex = 1; - textBox1.Text = ""; + textBox1.Text = string.Empty; // overwritten by caller as part of object initialisation TabControl tabControl1 = new(); tabControl1.SuspendLayout(); @@ -43,7 +43,7 @@ public ComparisonResults() tabPage1.Padding = new(all: 3); tabPage1.Size = new(763, 400); tabPage1.TabIndex = 0; - tabPage1.Text = "Log"; + tabPage1.Text = i18n["discohawkcomparereadout-6110-tab-log-textstr"]; tabPage1.UseVisualStyleBackColor = true; tabPage2.Location = new(4, 22); @@ -51,7 +51,7 @@ public ComparisonResults() tabPage2.Padding = new(all: 3); tabPage2.Size = new(763, 400); tabPage2.TabIndex = 1; - tabPage2.Text = "SRC Context"; + tabPage2.Text = i18n["discohawkcomparereadout-6110-tab-src-textstr"]; tabPage2.UseVisualStyleBackColor = true; tabPage3.Location = new(4, 22); @@ -59,7 +59,7 @@ public ComparisonResults() tabPage3.Padding = new(all: 3); tabPage3.Size = new(763, 400); tabPage3.TabIndex = 2; - tabPage3.Text = "DST Context"; + tabPage3.Text = i18n["discohawkcomparereadout-6110-tab-dest-textstr"]; tabPage3.UseVisualStyleBackColor = true; AutoScaleDimensions = new(6.0f, 13.0f); @@ -67,7 +67,7 @@ public ComparisonResults() ClientSize = new(771, 426); Controls.Add(tabControl1); Name = "ComparisonResults"; - Text = "ComparisonResults"; + Text = i18n["discohawkcomparereadout-2005-windowtitlestatic"]; tabControl1.ResumeLayout(performLayout: false); tabPage1.ResumeLayout(performLayout: false); ResumeLayout(performLayout: false); diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index c1109c78862..a12a9fc2543 100644 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -11,6 +11,8 @@ namespace BizHawk.Client.DiscoHawk { public class MainDiscoForm : Form { + private readonly MultiMessageContext _i18n; + private readonly RadioButton ccdOutputButton; private readonly RadioButton chdOutputButton; @@ -26,8 +28,10 @@ public class MainDiscoForm : Form // An outputted list showing new file name // Progress bar should show file being converted // Add disc button, which puts it on the progress cue (converts it) - public MainDiscoForm() + public MainDiscoForm(MultiMessageContext i18n) { + _i18n = i18n; + SuspendLayout(); Button ExitButton = new(); @@ -35,7 +39,7 @@ public MainDiscoForm() ExitButton.Name = "ExitButton"; ExitButton.Size = new(75, 23); ExitButton.TabIndex = 0; - ExitButton.Text = "E&xit"; + ExitButton.Text = i18n["maindiscoform-4723-btn-exit-textstr"]; ExitButton.UseVisualStyleBackColor = true; ExitButton.Click += (_, _) => Close(); @@ -56,7 +60,7 @@ public MainDiscoForm() label1.Name = "label1"; label1.Size = new(166, 47); label1.TabIndex = 0; - label1.Text = "Drag here to HAWK your disc - dump it out as a clean CCD/CHD"; + label1.Text = i18n["maindiscoform-1872-area-hawkdisc-label"]; lblMp3ExtractMagicArea = new(); lblMp3ExtractMagicArea.SuspendLayout(); @@ -75,16 +79,16 @@ public MainDiscoForm() label2.Name = "label2"; label2.Size = new(163, 39); label2.TabIndex = 0; - label2.Text = "Drag a disc here to extract the audio tracks to MP3"; + label2.Text = i18n["maindiscoform-6011-area-mp3extract-label"]; Button btnAbout = new(); btnAbout.Location = new(353, 414); btnAbout.Name = "btnAbout"; btnAbout.Size = new(75, 23); btnAbout.TabIndex = 3; - btnAbout.Text = "&About"; + btnAbout.Text = i18n["maindiscoform-5766-btn-about-textstr"]; btnAbout.UseVisualStyleBackColor = true; - btnAbout.Click += (_, _) => new About().ShowDialog(); + btnAbout.Click += (_, _) => new About(_i18n).ShowDialog(); RadioButton radioButton1 = new(); radioButton1.AutoSize = true; @@ -94,7 +98,7 @@ public MainDiscoForm() radioButton1.Size = new(67, 17); radioButton1.TabIndex = 4; radioButton1.TabStop = true; - radioButton1.Text = "BizHawk"; + radioButton1.Text = i18n["maindiscoform-4559-radio-engine-hawk-textstr"]; radioButton1.UseVisualStyleBackColor = true; GroupBox groupBox1 = new(); @@ -112,19 +116,19 @@ public MainDiscoForm() groupBox1.Size = new(276, 234); groupBox1.TabIndex = 5; groupBox1.TabStop = false; - groupBox1.Text = "Disc Reading Engine"; + groupBox1.Text = i18n["maindiscoform-7187-group-engine-label"]; label4.Location = new(20, 95); label4.Name = "label4"; label4.Size = new(216, 43); label4.TabIndex = 8; - label4.Text = "- Doesn\'t support audio decoding yet\r\n(even though Mednafen proper can do it)\r\n- Loads ISO, CUE, and CCD"; + label4.Text = i18n["maindiscoform-7205-radio-engine-mednafen-longdesc-label"]; label3.Location = new(20, 39); label3.Name = "label3"; label3.Size = new(253, 33); label3.TabIndex = 7; - label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG"; + label3.Text = i18n["maindiscoform-4559-radio-engine-hawk-longdesc-label"]; radioButton2.AutoSize = true; radioButton2.Enabled = false; @@ -132,7 +136,7 @@ public MainDiscoForm() radioButton2.Name = "radioButton2"; radioButton2.Size = new(73, 17); radioButton2.TabIndex = 5; - radioButton2.Text = "Mednafen"; + radioButton2.Text = i18n["maindiscoform-7205-radio-engine-mednafen-textstr"]; radioButton2.UseVisualStyleBackColor = true; GroupBox groupBox2 = new(); @@ -147,7 +151,7 @@ public MainDiscoForm() groupBox2.Size = new(271, 69); groupBox2.TabIndex = 6; groupBox2.TabStop = false; - groupBox2.Text = "Output Format"; + groupBox2.Text = i18n["maindiscoform-5561-group-hawkoutput-label"]; ccdOutputButton.AutoSize = true; ccdOutputButton.Checked = true; @@ -156,7 +160,7 @@ public MainDiscoForm() ccdOutputButton.Size = new(47, 17); ccdOutputButton.TabIndex = 5; ccdOutputButton.TabStop = true; - ccdOutputButton.Text = "CCD"; + ccdOutputButton.Text = i18n["maindiscoform-7576-radio-hawkoutput-ccd-textstr"]; ccdOutputButton.UseVisualStyleBackColor = true; chdOutputButton.AutoSize = true; @@ -166,7 +170,7 @@ public MainDiscoForm() chdOutputButton.Size = new(47, 17); chdOutputButton.TabIndex = 6; chdOutputButton.TabStop = true; - chdOutputButton.Text = "CHD"; + chdOutputButton.Text = i18n["maindiscoform-2884-radio-hawkoutput-chd-textstr"]; chdOutputButton.UseVisualStyleBackColor = true; Label label6 = new(); @@ -176,7 +180,7 @@ public MainDiscoForm() label6.Name = "label6"; label6.Size = new(111, 13); label6.TabIndex = 2; - label6.Text = "Compare Reading To:"; + label6.Text = i18n["maindiscoform-4639-group-compare-list-label"]; Label label7 = new(); label7.AutoSize = true; @@ -184,7 +188,7 @@ public MainDiscoForm() label7.Name = "label7"; label7.Size = new(70, 13); label7.TabIndex = 10; - label7.Text = "- Operations -"; + label7.Text = i18n["maindiscoform-7426-pane-operations-label"]; lvCompareTargets = new(); lvCompareTargets.Columns.Add(new ColumnHeader()); @@ -193,8 +197,8 @@ public MainDiscoForm() lvCompareTargets.GridLines = true; lvCompareTargets.HeaderStyle = ColumnHeaderStyle.None; lvCompareTargets.HideSelection = false; - lvCompareTargets.Items.Add("BizHawk"); - lvCompareTargets.Items.Add("Mednafen"); + lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-hawk-label"]); + lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-mednafen-label"]); lvCompareTargets.Location = new(9, 340); lvCompareTargets.Name = "lvCompareTargets"; lvCompareTargets.Size = new(121, 97); @@ -221,7 +225,7 @@ public MainDiscoForm() MaximizeBox = false; MinimizeBox = false; Name = "MainDiscoForm"; - Text = "DiscoHawk"; + Text = i18n["maindiscoform-3997-windowtitlestatic"]; Load += (_, _) => lvCompareTargets.Columns[0].Width = lvCompareTargets.ClientSize.Width; lblMagicDragArea.ResumeLayout(performLayout: false); lblMp3ExtractMagicArea.ResumeLayout(performLayout: false); @@ -246,14 +250,14 @@ private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) { var success = DiscoHawkLogic.HawkAndWriteFile( inputPath: file, - errorCallback: err => MessageBox.Show(err, "Error loading disc"), + errorCallback: err => MessageBox.Show(err, _i18n["discodischawking-6945-errbox-hawk-windowtitlestatic"]), hawkedFormat: outputFormat); if (!success) break; } } catch (Exception ex) { - MessageBox.Show(ex.ToString(), "Error loading disc"); + MessageBox.Show(ex.ToString(), _i18n["discodischawking-3654-errbox-misc-windowtitlestatic"]); throw; } finally @@ -323,9 +327,8 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) { #if true MessageBox.Show( - caption: "FFmpeg missing", - text: "This function requires FFmpeg, but it doesn't appear to have been downloaded.\n" - + "EmuHawk can automatically download it: you just need to set up A/V recording with the FFmpeg writer."); + caption: _i18n["discomp3extract-5715-errbox-noffmpeg-windowtitlestatic"], + text: _i18n["discomp3extract-5715-errbox-noffmpeg-label"]); return; #else using EmuHawk.FFmpegDownloaderForm dialog = new(); // builds fine when 'd, but the .resx won't load even if it's also included @@ -343,10 +346,10 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) { using var disc = Disc.LoadAutomagic(file); var (path, filename, _) = file.SplitPathToDirFileAndExt(); - static bool? PromptForOverwrite(string mp3Path) + bool? PromptForOverwrite(string mp3Path) => MessageBox.Show( - $"Do you want to overwrite existing files? Choosing \"No\" will simply skip those. You could also \"Cancel\" the extraction entirely.\n\ncaused by file: {mp3Path}", - "File to extract already exists", + string.Format(_i18n["discomp3extract-3418-prompt-overwrite-fmtstr"], mp3Path), + _i18n["discomp3extract-3418-prompt-overwrite-windowtitlestatic"], MessageBoxButtons.YesNoCancel) switch { DialogResult.Yes => true, @@ -358,7 +361,7 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.ToString(), "Error loading disc"); + MessageBox.Show(ex.ToString(), _i18n["discomp3extract-7691-errbox-misc-windowtitlestatic"]); throw; } finally diff --git a/src/BizHawk.Client.DiscoHawk/Program.cs b/src/BizHawk.Client.DiscoHawk/Program.cs index a1892e4c0b3..96864809b7e 100644 --- a/src/BizHawk.Client.DiscoHawk/Program.cs +++ b/src/BizHawk.Client.DiscoHawk/Program.cs @@ -122,16 +122,18 @@ private static void Main(string[] args) if (args.Length == 0) { - using var dialog = new MainDiscoForm(); + MultiMessageContext i18n = new("en"); + using MainDiscoForm dialog = new(i18n); dialog.ShowDialog(); } else { DiscoHawkLogic.RunWithArgs( args, - results => + results => // invoked 0..1 times { - using var cr = new ComparisonResults { textBox1 = { Text = results } }; + MultiMessageContext i18n = new("en"); + using ComparisonResults cr = new(i18n) { textBox1 = { Text = results } }; cr.ShowDialog(); }); } diff --git a/src/BizHawk.Client.DiscoHawk/locale/en.ftl b/src/BizHawk.Client.DiscoHawk/locale/en.ftl index f1600fe9360..d2d8ef9d1f8 100644 --- a/src/BizHawk.Client.DiscoHawk/locale/en.ftl +++ b/src/BizHawk.Client.DiscoHawk/locale/en.ftl @@ -1,4 +1,107 @@ -## Closing tabs +### DiscoHawk strings + + + +## CLI COMPARE readout dialog + +discohawkcomparereadout-6110-tab-dest-textstr = DST Context +discohawkcomparereadout-6110-tab-log-textstr = Log +discohawkcomparereadout-6110-tab-src-textstr = SRC Context + +discohawkcomparereadout-2005-windowtitlestatic = ComparisonResults + + + +## main window + +maindiscoform-1872-area-hawkdisc-label = Drag here to HAWK your disc - dump it out as a clean CCD/CHD + +maindiscoform-6011-area-mp3extract-label = Drag a disc here to extract the audio tracks to MP3 + +maindiscoform-5766-btn-about-textstr = &About + +maindiscoform-4723-btn-exit-textstr = E&xit + +maindiscoform-5267-compare-hawk-label = BizHawk + +maindiscoform-5267-compare-mednafen-label = Mednafen + +maindiscoform-4639-group-compare-list-label = Compare Reading To: + +maindiscoform-7187-group-engine-label = Disc Reading Engine + +maindiscoform-5561-group-hawkoutput-label = Output Format + +maindiscoform-4559-radio-engine-hawk-textstr = BizHawk +maindiscoform-4559-radio-engine-hawk-longdesc-label = + - Uses FFMPEG for audio decoding + - Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG + +maindiscoform-7205-radio-engine-mednafen-textstr = Mednafen +maindiscoform-7205-radio-engine-mednafen-longdesc-label = + - Doesn't support audio decoding yet + (even though Mednafen proper can do it) + - Loads ISO, CUE, and CCD + +maindiscoform-7576-radio-hawkoutput-ccd-textstr = CCD + +maindiscoform-2884-radio-hawkoutput-chd-textstr = CHD + +maindiscoform-7426-pane-operations-label = - Operations - + +maindiscoform-3997-windowtitlestatic = DiscoHawk + + + +## "Hawk disc" dialogs + +discodischawking-6945-errbox-hawk-windowtitlestatic = Error loading disc + +discodischawking-3654-errbox-misc-windowtitlestatic = Error loading disc + + + +## mp3 extract dialogs + +discomp3extract-7691-errbox-misc-windowtitlestatic = Error loading disc + +discomp3extract-5715-errbox-noffmpeg-label = + This function requires FFmpeg, but it doesn't appear to have been downloaded. + EmuHawk can automatically download it: you just need to set up A/V recording with the FFmpeg writer. +discomp3extract-5715-errbox-noffmpeg-windowtitlestatic = FFmpeg missing + +discomp3extract-3418-prompt-overwrite-fmtstr = + Do you want to overwrite existing files? Choosing "No" will simply skip those. You could also "Cancel" the extraction entirely. + + caused by file: {"{0}"} +discomp3extract-3418-prompt-overwrite-windowtitlestatic = File to extract already exists + + + +## About window + +discohawkabout-9804-btn-dismiss-textstr = OK + +discohawkabout-4584-lbl-explainer-label = + DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD. + + DiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk ). + + BizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments. + + To use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked. + + This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.) + +discohawkabout-2822-windowtitlestatic = About DiscoHawk + + + +### strings for the Fluent sample + + + +## Closing tabs tabs-close-button = Close tabs-close-tooltip = {$tabCount -> From 1d7928077b631329900952a36439964ce6c68d03 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 28 Jul 2025 03:12:21 +1000 Subject: [PATCH 5/8] Use more idiomatic Fluent syntax --- src/BizHawk.Client.DiscoHawk/About.cs | 4 +- .../ComparisonResults.cs | 6 +- src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs | 59 ++++++------ src/BizHawk.Client.DiscoHawk/Sample.cs | 70 +++++++++++++- src/BizHawk.Client.DiscoHawk/locale/en.ftl | 91 +++++++++++-------- 5 files changed, 155 insertions(+), 75 deletions(-) diff --git a/src/BizHawk.Client.DiscoHawk/About.cs b/src/BizHawk.Client.DiscoHawk/About.cs index c8d4594a42c..c2a852990ae 100644 --- a/src/BizHawk.Client.DiscoHawk/About.cs +++ b/src/BizHawk.Client.DiscoHawk/About.cs @@ -17,7 +17,7 @@ public About(MultiMessageContext i18n) richTextBox1.ReadOnly = true; richTextBox1.Size = new(499, 236); richTextBox1.TabIndex = 1; - richTextBox1.Text = i18n["discohawkabout-4584-lbl-explainer-label"]!.Replace("\n", Environment.NewLine); + richTextBox1.Text = i18n["discohawkabout-4584-lbl-explainer"]!.Replace("\n", Environment.NewLine); richTextBox1.LinkClicked += (_, clickedArgs) => Util.OpenUrlExternal(clickedArgs.LinkText); Button button1 = new(); @@ -26,7 +26,7 @@ public About(MultiMessageContext i18n) button1.Name = "button1"; button1.Size = new(75, 23); button1.TabIndex = 2; - button1.Text = i18n["discohawkabout-9804-btn-dismiss-textstr"]; + button1.Text = i18n.GetWithMnemonic("discohawkabout-9804-btn-dismiss"); button1.UseVisualStyleBackColor = true; button1.Click += (_, _) => Close(); diff --git a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs index bdaac89e33c..e88e7a09176 100644 --- a/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs +++ b/src/BizHawk.Client.DiscoHawk/ComparisonResults.cs @@ -43,7 +43,7 @@ public ComparisonResults(MultiMessageContext i18n) tabPage1.Padding = new(all: 3); tabPage1.Size = new(763, 400); tabPage1.TabIndex = 0; - tabPage1.Text = i18n["discohawkcomparereadout-6110-tab-log-textstr"]; + tabPage1.Text = i18n.GetWithMnemonic("discohawkcomparereadout-6110-tab-log"); tabPage1.UseVisualStyleBackColor = true; tabPage2.Location = new(4, 22); @@ -51,7 +51,7 @@ public ComparisonResults(MultiMessageContext i18n) tabPage2.Padding = new(all: 3); tabPage2.Size = new(763, 400); tabPage2.TabIndex = 1; - tabPage2.Text = i18n["discohawkcomparereadout-6110-tab-src-textstr"]; + tabPage2.Text = i18n.GetWithMnemonic("discohawkcomparereadout-6110-tab-src"); tabPage2.UseVisualStyleBackColor = true; tabPage3.Location = new(4, 22); @@ -59,7 +59,7 @@ public ComparisonResults(MultiMessageContext i18n) tabPage3.Padding = new(all: 3); tabPage3.Size = new(763, 400); tabPage3.TabIndex = 2; - tabPage3.Text = i18n["discohawkcomparereadout-6110-tab-dest-textstr"]; + tabPage3.Text = i18n.GetWithMnemonic("discohawkcomparereadout-6110-tab-dest"); tabPage3.UseVisualStyleBackColor = true; AutoScaleDimensions = new(6.0f, 13.0f); diff --git a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index a12a9fc2543..b79323614d0 100644 --- a/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -39,7 +39,7 @@ public MainDiscoForm(MultiMessageContext i18n) ExitButton.Name = "ExitButton"; ExitButton.Size = new(75, 23); ExitButton.TabIndex = 0; - ExitButton.Text = i18n["maindiscoform-4723-btn-exit-textstr"]; + ExitButton.Text = i18n.GetWithMnemonic("maindiscoform-4723-btn-exit"); ExitButton.UseVisualStyleBackColor = true; ExitButton.Click += (_, _) => Close(); @@ -60,7 +60,7 @@ public MainDiscoForm(MultiMessageContext i18n) label1.Name = "label1"; label1.Size = new(166, 47); label1.TabIndex = 0; - label1.Text = i18n["maindiscoform-1872-area-hawkdisc-label"]; + label1.Text = i18n["maindiscoform-1872-area-hawkdisc"]; lblMp3ExtractMagicArea = new(); lblMp3ExtractMagicArea.SuspendLayout(); @@ -79,14 +79,14 @@ public MainDiscoForm(MultiMessageContext i18n) label2.Name = "label2"; label2.Size = new(163, 39); label2.TabIndex = 0; - label2.Text = i18n["maindiscoform-6011-area-mp3extract-label"]; + label2.Text = i18n["maindiscoform-6011-area-mp3extract"]; Button btnAbout = new(); btnAbout.Location = new(353, 414); btnAbout.Name = "btnAbout"; btnAbout.Size = new(75, 23); btnAbout.TabIndex = 3; - btnAbout.Text = i18n["maindiscoform-5766-btn-about-textstr"]; + btnAbout.Text = i18n.GetWithMnemonic("maindiscoform-5766-btn-about"); btnAbout.UseVisualStyleBackColor = true; btnAbout.Click += (_, _) => new About(_i18n).ShowDialog(); @@ -98,7 +98,7 @@ public MainDiscoForm(MultiMessageContext i18n) radioButton1.Size = new(67, 17); radioButton1.TabIndex = 4; radioButton1.TabStop = true; - radioButton1.Text = i18n["maindiscoform-4559-radio-engine-hawk-textstr"]; + radioButton1.Text = i18n.GetWithMnemonic("maindiscoform-4559-radio-engine-hawk"); radioButton1.UseVisualStyleBackColor = true; GroupBox groupBox1 = new(); @@ -116,19 +116,19 @@ public MainDiscoForm(MultiMessageContext i18n) groupBox1.Size = new(276, 234); groupBox1.TabIndex = 5; groupBox1.TabStop = false; - groupBox1.Text = i18n["maindiscoform-7187-group-engine-label"]; + groupBox1.Text = i18n["maindiscoform-7187-group-engine"]; label4.Location = new(20, 95); label4.Name = "label4"; label4.Size = new(216, 43); label4.TabIndex = 8; - label4.Text = i18n["maindiscoform-7205-radio-engine-mednafen-longdesc-label"]; + label4.Text = i18n["maindiscoform-7205-radio-engine-mednafen-longdesc"]; label3.Location = new(20, 39); label3.Name = "label3"; label3.Size = new(253, 33); label3.TabIndex = 7; - label3.Text = i18n["maindiscoform-4559-radio-engine-hawk-longdesc-label"]; + label3.Text = i18n["maindiscoform-4559-radio-engine-hawk-longdesc"]; radioButton2.AutoSize = true; radioButton2.Enabled = false; @@ -136,7 +136,7 @@ public MainDiscoForm(MultiMessageContext i18n) radioButton2.Name = "radioButton2"; radioButton2.Size = new(73, 17); radioButton2.TabIndex = 5; - radioButton2.Text = i18n["maindiscoform-7205-radio-engine-mednafen-textstr"]; + radioButton2.Text = i18n.GetWithMnemonic("maindiscoform-7205-radio-engine-mednafen"); radioButton2.UseVisualStyleBackColor = true; GroupBox groupBox2 = new(); @@ -151,7 +151,7 @@ public MainDiscoForm(MultiMessageContext i18n) groupBox2.Size = new(271, 69); groupBox2.TabIndex = 6; groupBox2.TabStop = false; - groupBox2.Text = i18n["maindiscoform-5561-group-hawkoutput-label"]; + groupBox2.Text = i18n["maindiscoform-5561-group-hawkoutput"]; ccdOutputButton.AutoSize = true; ccdOutputButton.Checked = true; @@ -160,7 +160,7 @@ public MainDiscoForm(MultiMessageContext i18n) ccdOutputButton.Size = new(47, 17); ccdOutputButton.TabIndex = 5; ccdOutputButton.TabStop = true; - ccdOutputButton.Text = i18n["maindiscoform-7576-radio-hawkoutput-ccd-textstr"]; + ccdOutputButton.Text = i18n.GetWithMnemonic("maindiscoform-7576-radio-hawkoutput-ccd"); ccdOutputButton.UseVisualStyleBackColor = true; chdOutputButton.AutoSize = true; @@ -170,7 +170,7 @@ public MainDiscoForm(MultiMessageContext i18n) chdOutputButton.Size = new(47, 17); chdOutputButton.TabIndex = 6; chdOutputButton.TabStop = true; - chdOutputButton.Text = i18n["maindiscoform-2884-radio-hawkoutput-chd-textstr"]; + chdOutputButton.Text = i18n.GetWithMnemonic("maindiscoform-2884-radio-hawkoutput-chd"); chdOutputButton.UseVisualStyleBackColor = true; Label label6 = new(); @@ -180,7 +180,7 @@ public MainDiscoForm(MultiMessageContext i18n) label6.Name = "label6"; label6.Size = new(111, 13); label6.TabIndex = 2; - label6.Text = i18n["maindiscoform-4639-group-compare-list-label"]; + label6.Text = i18n["maindiscoform-4639-group-compare-list"]; Label label7 = new(); label7.AutoSize = true; @@ -188,7 +188,7 @@ public MainDiscoForm(MultiMessageContext i18n) label7.Name = "label7"; label7.Size = new(70, 13); label7.TabIndex = 10; - label7.Text = i18n["maindiscoform-7426-pane-operations-label"]; + label7.Text = i18n["maindiscoform-7426-pane-operations"]; lvCompareTargets = new(); lvCompareTargets.Columns.Add(new ColumnHeader()); @@ -197,8 +197,8 @@ public MainDiscoForm(MultiMessageContext i18n) lvCompareTargets.GridLines = true; lvCompareTargets.HeaderStyle = ColumnHeaderStyle.None; lvCompareTargets.HideSelection = false; - lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-hawk-label"]); - lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-mednafen-label"]); + lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-hawk"]); + lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-mednafen"]); lvCompareTargets.Location = new(9, 340); lvCompareTargets.Name = "lvCompareTargets"; lvCompareTargets.Size = new(121, 97); @@ -250,14 +250,18 @@ private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) { var success = DiscoHawkLogic.HawkAndWriteFile( inputPath: file, - errorCallback: err => MessageBox.Show(err, _i18n["discodischawking-6945-errbox-hawk-windowtitlestatic"]), + errorCallback: err => MessageBox.Show( + caption: _i18n.GetDialogText("discodischawking-6945-errbox-hawk").Caption, + text: err), hawkedFormat: outputFormat); if (!success) break; } } catch (Exception ex) { - MessageBox.Show(ex.ToString(), _i18n["discodischawking-3654-errbox-misc-windowtitlestatic"]); + MessageBox.Show( + caption: _i18n.GetDialogText("discodischawking-3654-errbox-misc").Caption, + text: ex.ToString()); throw; } finally @@ -326,9 +330,8 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) if (!FFmpegService.QueryServiceAvailable()) { #if true - MessageBox.Show( - caption: _i18n["discomp3extract-5715-errbox-noffmpeg-windowtitlestatic"], - text: _i18n["discomp3extract-5715-errbox-noffmpeg-label"]); + var (caption, text) = _i18n.GetDialogText("discomp3extract-5715-errbox-noffmpeg"); + MessageBox.Show(caption: caption, text: text); return; #else using EmuHawk.FFmpegDownloaderForm dialog = new(); // builds fine when 'd, but the .resx won't load even if it's also included @@ -347,21 +350,25 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e) using var disc = Disc.LoadAutomagic(file); var (path, filename, _) = file.SplitPathToDirFileAndExt(); bool? PromptForOverwrite(string mp3Path) - => MessageBox.Show( - string.Format(_i18n["discomp3extract-3418-prompt-overwrite-fmtstr"], mp3Path), - _i18n["discomp3extract-3418-prompt-overwrite-windowtitlestatic"], - MessageBoxButtons.YesNoCancel) switch + { + var (caption, text) = _i18n.GetDialogText( + "discomp3extract-3418-prompt-overwrite", + new ArgsDict(filePath: mp3Path)); + return MessageBox.Show(caption: caption, text: text, buttons: MessageBoxButtons.YesNoCancel) switch { DialogResult.Yes => true, DialogResult.No => false, _ => null, }; + } AudioExtractor.Extract(disc, path, filename, PromptForOverwrite); } } catch (Exception ex) { - MessageBox.Show(ex.ToString(), _i18n["discomp3extract-7691-errbox-misc-windowtitlestatic"]); + MessageBox.Show( + caption: _i18n.GetDialogText("discomp3extract-7691-errbox-misc").Caption, + text: ex.ToString()); throw; } finally diff --git a/src/BizHawk.Client.DiscoHawk/Sample.cs b/src/BizHawk.Client.DiscoHawk/Sample.cs index 219d07be4e2..b98ff13396b 100644 --- a/src/BizHawk.Client.DiscoHawk/Sample.cs +++ b/src/BizHawk.Client.DiscoHawk/Sample.cs @@ -5,14 +5,19 @@ using System.IO; using System.Linq; +using BizHawk.Common.CollectionExtensions; +using BizHawk.Common.StringExtensions; + using Fluent.Net; +using Fluent.Net.RuntimeAst; namespace BizHawk.Client.DiscoHawk { public sealed class ArgsDict : Dictionary { - public ArgsDict(int? tabCount = null) + public ArgsDict(string? filePath = null, int? tabCount = null) { + Add(nameof(filePath), filePath); Add(nameof(tabCount), tabCount); } } @@ -54,17 +59,72 @@ public MultiMessageContext(string lang, params MessageContext[] overlays) public string? this[string id] => GetString(id); + public (string? Caption, string Text) GetDialogText( + string id, + IDictionary? args = null, + ICollection? errors = null) + => GetNode(id) is (var msg, var fromCtx) + ? (msg.Attributes.TryGetValue("windowtitle", out var caption) + ? fromCtx.Format(caption, args, errors) + : null, + fromCtx.Format(msg, args, errors)) + : (null, string.Empty); + + private (Message Message, MessageContext FromContext)? GetNode(string id) + => _contexts.Select(ctx => (Message: ctx.GetMessage(id), FromContext: ctx)) + .FirstOrNull(static tuple => tuple.Message is not null); + public string? GetString( + string id, + IDictionary? args = null, + ICollection? errors = null) + => GetNode(id) is (var msg, var fromCtx) ? fromCtx.Format(msg, args, errors) : null; + + public string? GetWithMnemonic( string id, IDictionary? args = null, ICollection? errors = null) { - foreach (var context in _contexts) + const string ATTR_NAME_CHAR = "mnemonic"; + const string ATTR_NAME_INDEX = "mnemonicindex"; + const string ERR_PFX = $"[i18n {nameof(GetWithMnemonic)}]"; + const string ERR_FMT_STR_MNEMONIC_CHAR_ABSENT = $"{ERR_PFX} the char {{0}}.{ATTR_NAME_CHAR} isn't present in the string (wrong case?)"; + const string ERR_FMT_STR_MNEMONIC_CHAR_ISNT = $"{ERR_PFX} {{0}}.{ATTR_NAME_CHAR} is not a single char"; + const string ERR_FMT_STR_MNEMONIC_INDEX_ISNT = $"{ERR_PFX} failed to parse {{0}}.{ATTR_NAME_INDEX} as int"; + const string ERR_FMT_STR_MNEMONIC_INDEX_MISMATCH = $"{ERR_PFX} {{0}}.{ATTR_NAME_INDEX} points to '{{1}}', which doesn't match .{ATTR_NAME_CHAR} (case-sensitive)"; + const string ERR_FMT_STR_MNEMONIC_INDEX_OOR = $"{ERR_PFX} {{0}}.{ATTR_NAME_INDEX} out of range 0..<{{1}}"; + if (GetNode(id) is not (var msg, var fromCtx)) return null; + string? GetAttr(string attrID) + => msg.Attributes?.TryGetValue(attrID, out var mn) is true ? fromCtx.Format(mn, args, errors) : null; + var strWithoutMn = fromCtx.Format(msg, args, errors); + string? Fail(string msgFmtStr, object? extraArg = null) + { + Console.WriteLine(string.Format(msgFmtStr, id, extraArg)); + return strWithoutMn; + } + //TODO make the char searches case-insensitive? + if (GetAttr(ATTR_NAME_INDEX) is string iAmpStr) + { + // "index" is in `char`s, not graphemes... but I think that's fine, since the mnemonic feature probably only works with Latin/ext anyway --yoshi + if (!int.TryParse(iAmpStr, out var iAmp)) return Fail(ERR_FMT_STR_MNEMONIC_INDEX_ISNT); + if (iAmp < 0 || strWithoutMn.Length <= iAmp) return Fail(ERR_FMT_STR_MNEMONIC_INDEX_OOR, strWithoutMn.Length); + if (GetAttr(ATTR_NAME_CHAR) is string mnChar1) + { + if (mnChar1.Length is not 1) return Fail(ERR_FMT_STR_MNEMONIC_CHAR_ISNT); + var mnChar2 = mnChar1[0]; + if (strWithoutMn[iAmp] != mnChar2) return Fail(ERR_FMT_STR_MNEMONIC_INDEX_MISMATCH, mnChar2); + } +// if (strWithoutMn.Contains('&')) Fail(); //TODO do this? + return strWithoutMn.Insert(iAmp, "&"); + } + if (GetAttr(ATTR_NAME_CHAR) is string mnChar) { - var msg = context.GetMessage(id); - if (msg is not null) return context.Format(msg, args, errors); + if (mnChar.Length is not 1) return Fail(ERR_FMT_STR_MNEMONIC_CHAR_ISNT); +// if (strWithoutMn.Contains('&')) Fail(); //TODO do this? + var strWithMn = strWithoutMn.InsertBefore(mnChar[0], "&", out var found); + return found ? strWithMn : Fail(ERR_FMT_STR_MNEMONIC_CHAR_ABSENT); } - return null; + return strWithoutMn; } } diff --git a/src/BizHawk.Client.DiscoHawk/locale/en.ftl b/src/BizHawk.Client.DiscoHawk/locale/en.ftl index d2d8ef9d1f8..b3f93099b3f 100644 --- a/src/BizHawk.Client.DiscoHawk/locale/en.ftl +++ b/src/BizHawk.Client.DiscoHawk/locale/en.ftl @@ -1,12 +1,20 @@ ### DiscoHawk strings +### SSoT for some terms + +-tm-bizhawk = BizHawk +-tm-discohawk = DiscoHawk +-tm-emuhawk = EmuHawk +-tm-ffmpeg = FFmpeg +-tm-mednafen = Mednafen + ## CLI COMPARE readout dialog -discohawkcomparereadout-6110-tab-dest-textstr = DST Context -discohawkcomparereadout-6110-tab-log-textstr = Log -discohawkcomparereadout-6110-tab-src-textstr = SRC Context +discohawkcomparereadout-6110-tab-dest = DST Context +discohawkcomparereadout-6110-tab-log = Log +discohawkcomparereadout-6110-tab-src = SRC Context discohawkcomparereadout-2005-windowtitlestatic = ComparisonResults @@ -14,86 +22,91 @@ discohawkcomparereadout-2005-windowtitlestatic = ComparisonResults ## main window -maindiscoform-1872-area-hawkdisc-label = Drag here to HAWK your disc - dump it out as a clean CCD/CHD +maindiscoform-1872-area-hawkdisc = Drag here to HAWK your disc - dump it out as a clean CCD/CHD -maindiscoform-6011-area-mp3extract-label = Drag a disc here to extract the audio tracks to MP3 +maindiscoform-6011-area-mp3extract = Drag a disc here to extract the audio tracks to MP3 -maindiscoform-5766-btn-about-textstr = &About +maindiscoform-5766-btn-about = About + .mnemonic = A -maindiscoform-4723-btn-exit-textstr = E&xit +maindiscoform-4723-btn-exit = Exit + .mnemonic = x -maindiscoform-5267-compare-hawk-label = BizHawk +maindiscoform-5267-compare-hawk = {-tm-bizhawk} -maindiscoform-5267-compare-mednafen-label = Mednafen +maindiscoform-5267-compare-mednafen = {-tm-mednafen} -maindiscoform-4639-group-compare-list-label = Compare Reading To: +maindiscoform-4639-group-compare-list = Compare Reading To: -maindiscoform-7187-group-engine-label = Disc Reading Engine +maindiscoform-7187-group-engine = Disc Reading Engine -maindiscoform-5561-group-hawkoutput-label = Output Format +maindiscoform-5561-group-hawkoutput = Output Format -maindiscoform-4559-radio-engine-hawk-textstr = BizHawk -maindiscoform-4559-radio-engine-hawk-longdesc-label = +maindiscoform-4559-radio-engine-hawk = {-tm-bizhawk} +maindiscoform-4559-radio-engine-hawk-longdesc = - Uses FFMPEG for audio decoding - Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG -maindiscoform-7205-radio-engine-mednafen-textstr = Mednafen -maindiscoform-7205-radio-engine-mednafen-longdesc-label = +maindiscoform-7205-radio-engine-mednafen = {-tm-mednafen} +maindiscoform-7205-radio-engine-mednafen-longdesc = - Doesn't support audio decoding yet - (even though Mednafen proper can do it) + (even though {-tm-mednafen} proper can do it) - Loads ISO, CUE, and CCD -maindiscoform-7576-radio-hawkoutput-ccd-textstr = CCD +maindiscoform-7576-radio-hawkoutput-ccd = CCD -maindiscoform-2884-radio-hawkoutput-chd-textstr = CHD +maindiscoform-2884-radio-hawkoutput-chd = CHD -maindiscoform-7426-pane-operations-label = - Operations - +maindiscoform-7426-pane-operations = - Operations - -maindiscoform-3997-windowtitlestatic = DiscoHawk +maindiscoform-3997-windowtitlestatic = {-tm-discohawk} ## "Hawk disc" dialogs -discodischawking-6945-errbox-hawk-windowtitlestatic = Error loading disc +discodischawking-6945-errbox-hawk = + .windowtitle = Error loading disc -discodischawking-3654-errbox-misc-windowtitlestatic = Error loading disc +discodischawking-3654-errbox-misc = + .windowtitle = Error loading disc ## mp3 extract dialogs -discomp3extract-7691-errbox-misc-windowtitlestatic = Error loading disc +discomp3extract-7691-errbox-misc = + .windowtitle = Error loading disc -discomp3extract-5715-errbox-noffmpeg-label = - This function requires FFmpeg, but it doesn't appear to have been downloaded. - EmuHawk can automatically download it: you just need to set up A/V recording with the FFmpeg writer. -discomp3extract-5715-errbox-noffmpeg-windowtitlestatic = FFmpeg missing +discomp3extract-5715-errbox-noffmpeg = + This function requires {-tm-ffmpeg}, but it doesn't appear to have been downloaded. + {-tm-emuhawk} can automatically download it: you just need to set up A/V recording with the {-tm-ffmpeg} writer. + .windowtitle = {-tm-ffmpeg} missing -discomp3extract-3418-prompt-overwrite-fmtstr = +discomp3extract-3418-prompt-overwrite = Do you want to overwrite existing files? Choosing "No" will simply skip those. You could also "Cancel" the extraction entirely. - caused by file: {"{0}"} -discomp3extract-3418-prompt-overwrite-windowtitlestatic = File to extract already exists + caused by file: {$filePath} + .windowtitle = File to extract already exists ## About window -discohawkabout-9804-btn-dismiss-textstr = OK +discohawkabout-9804-btn-dismiss = OK -discohawkabout-4584-lbl-explainer-label = - DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD. +discohawkabout-4584-lbl-explainer = + {-tm-discohawk} converts bolloxed-up crusty disc images to totally tidy CCD. - DiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk ). + {-tm-discohawk} is part of the {-tm-bizhawk} project ( https://github.com/TASEmulators/BizHawk ). - BizHawk is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments. + {-tm-bizhawk} is a .net-based multi-system emulator brought to you by some of the rerecording emulator principals. We wrote our own cue parsing/generating code to be able to handle any kind of junk we threw at it. Instead of trapping it in the emulator, we liberated it in the form of this tool, to be useful in other environments. - To use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. DiscoHawk will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked. + To use, drag a disc (.cue, .iso, .ccd, .cdi, .mds, .nrg) into the top area. {-tm-discohawk} will dump a newly cleaned up CCD file set to the same directory as the original disc image, and call it _hawked. - This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash DiscoHawk or that cause DiscoHawk to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.) + This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash {-tm-discohawk} or that cause {-tm-discohawk} to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.) -discohawkabout-2822-windowtitlestatic = About DiscoHawk +discohawkabout-2822-windowtitlestatic = About {-tm-discohawk} From 169e798e8c22daac54c985e2fadb12aa0b39d776 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 28 Jul 2025 04:27:11 +1000 Subject: [PATCH 6/8] Remove Fluent sample --- .../{Sample.cs => MultiMessageContext.cs} | 34 +------------------ src/BizHawk.Client.DiscoHawk/Program.cs | 2 -- src/BizHawk.Client.DiscoHawk/locale/en.ftl | 31 ----------------- src/BizHawk.Client.DiscoHawk/locale/it.ftl | 23 ------------- src/BizHawk.Client.DiscoHawk/locale/pl.ftl | 29 ---------------- 5 files changed, 1 insertion(+), 118 deletions(-) rename src/BizHawk.Client.DiscoHawk/{Sample.cs => MultiMessageContext.cs} (76%) delete mode 100644 src/BizHawk.Client.DiscoHawk/locale/it.ftl delete mode 100644 src/BizHawk.Client.DiscoHawk/locale/pl.ftl diff --git a/src/BizHawk.Client.DiscoHawk/Sample.cs b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs similarity index 76% rename from src/BizHawk.Client.DiscoHawk/Sample.cs rename to src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs index b98ff13396b..e2002c13365 100644 --- a/src/BizHawk.Client.DiscoHawk/Sample.cs +++ b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs @@ -15,10 +15,9 @@ namespace BizHawk.Client.DiscoHawk { public sealed class ArgsDict : Dictionary { - public ArgsDict(string? filePath = null, int? tabCount = null) + public ArgsDict(string? filePath = null) { Add(nameof(filePath), filePath); - Add(nameof(tabCount), tabCount); } } @@ -127,35 +126,4 @@ public string? this[string id] return strWithoutMn; } } - - public static class Sample - { - public static void RunAll() - { - static void RunTest(string lang) - { - MultiMessageContext translator = new(lang); - Console.WriteLine($"\n{lang}:"); - Console.WriteLine($"tabs-close-button = {translator.GetString("tabs-close-button")}"); - Console.WriteLine( - "tabs-close-tooltip ($tabCount = 1) = " - + translator.GetString("tabs-close-tooltip", new ArgsDict(tabCount: 1))); - Console.WriteLine( - "tabs-close-tooltip ($tabCount = 2) = " - + translator.GetString("tabs-close-tooltip", new ArgsDict(tabCount: 2))); - Console.WriteLine( - "tabs-close-warning ($tabCount = 1) = " - + translator.GetString("tabs-close-warning", new ArgsDict(tabCount: 1))); - Console.WriteLine( - "tabs-close-warning ($tabCount = 2) = " - + translator.GetString("tabs-close-warning", new ArgsDict(tabCount: 2))); - Console.WriteLine($"sync-dialog-title = {translator.GetString("sync-dialog-title")}"); - Console.WriteLine($"sync-headline-title = {translator.GetString("sync-headline-title")}"); - Console.WriteLine($"sync-signedout-title = {translator.GetString("sync-signedout-title")}"); - } - RunTest("en"); - RunTest("it"); - RunTest("pl"); - } - } } diff --git a/src/BizHawk.Client.DiscoHawk/Program.cs b/src/BizHawk.Client.DiscoHawk/Program.cs index 96864809b7e..c23dbcc8d0e 100644 --- a/src/BizHawk.Client.DiscoHawk/Program.cs +++ b/src/BizHawk.Client.DiscoHawk/Program.cs @@ -114,8 +114,6 @@ private static void Main(string[] args) } } - Sample.RunAll(); // testing Fluent.Net - // Do something for visuals, I guess Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/src/BizHawk.Client.DiscoHawk/locale/en.ftl b/src/BizHawk.Client.DiscoHawk/locale/en.ftl index b3f93099b3f..118e5f5a7bb 100644 --- a/src/BizHawk.Client.DiscoHawk/locale/en.ftl +++ b/src/BizHawk.Client.DiscoHawk/locale/en.ftl @@ -107,34 +107,3 @@ discohawkabout-4584-lbl-explainer = This is beta software. You are invited to report problems to our bug tracker or IRC. Problems consist of: crusty disc images that crash {-tm-discohawk} or that cause {-tm-discohawk} to produce a _hawked.ccd which fails to serve your particular purposes (which we will need to be informed of, in case we are outputting wrongly.) discohawkabout-2822-windowtitlestatic = About {-tm-discohawk} - - - -### strings for the Fluent sample - - - -## Closing tabs - -tabs-close-button = Close -tabs-close-tooltip = {$tabCount -> - [one] Close {$tabCount} tab - *[other] Close {$tabCount} tabs -} -tabs-close-warning = - You are about to close {$tabCount} tabs. - Are you sure you want to continue? - -## Syncing - --sync-brand-name = Firefox Account - -sync-dialog-title = {-sync-brand-name} -sync-headline-title = - {-sync-brand-name}: The best way to bring - your data always with you -sync-signedout-title = - Connect with your {-sync-brand-name} - -## Datetime -date-is = The date is 'DATETIME($dt, weekday: "short", month: "short", year: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric")'. diff --git a/src/BizHawk.Client.DiscoHawk/locale/it.ftl b/src/BizHawk.Client.DiscoHawk/locale/it.ftl deleted file mode 100644 index 9281d708fdb..00000000000 --- a/src/BizHawk.Client.DiscoHawk/locale/it.ftl +++ /dev/null @@ -1,23 +0,0 @@ -## Closing tabs - -tabs-close-button = Chiudi -tabs-close-tooltip = {$tabCount -> - [one] Chiudi {$tabCount} scheda - *[other] Chiudi {$tabCount} schede -} -tabs-close-warning = - Verranno chiuse {$tabCount} schede. Proseguire? - -## Syncing - --sync-brand-name = {$first -> - *[uppercase] Account Firefox - [lowercase] account Firefox -} - -sync-dialog-title = {-sync-brand-name} -sync-headline-title = - {-sync-brand-name}: il modo migliore - per avere i tuoi dati sempre con te -sync-signedout-title = - Connetti il tuo {-sync-brand-name[lowercase]} diff --git a/src/BizHawk.Client.DiscoHawk/locale/pl.ftl b/src/BizHawk.Client.DiscoHawk/locale/pl.ftl deleted file mode 100644 index 9048f6b08a4..00000000000 --- a/src/BizHawk.Client.DiscoHawk/locale/pl.ftl +++ /dev/null @@ -1,29 +0,0 @@ -## Closing tabs - -tabs-close-button = Zamknij -tabs-close-tooltip = {$tabCount -> - [one] Zamknij kartę - [few] Zamknij {$tabCount} karty - *[many] Zamknij { $tabCount } kart -} -tabs-close-warning = {$tabCount -> - [few] Zostaną zamknięte {$tabCount} karty. - Czy chcesz kontynuować? - *[many] Zostanie zamkniętych {$tabCount} kart. - Czy chcesz kontynuować? -} - -## Syncing - --sync-brand-name = {$case -> - *[nominative] Konto Firefox - [genitive] Konta Firefox - [accusative] Kontem Firefox -} - -sync-dialog-title = {-sync-brand-name} -sync-headline-title = - {-sync-brand-name}: Najlepszy sposób na to, - aby mieć swoje dane zawsze przy sobie -sync-signedout-title = - Zaloguj do {-sync-brand-name[genitive]} From 6f1fced9397495cb5671f9abc3b48a649a450220 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 28 Jul 2025 04:37:35 +1000 Subject: [PATCH 7/8] Add `MultiMessageContext` init using global CultureInfo --- .../MultiMessageContext.cs | 26 +++++++++++++++++-- src/BizHawk.Client.DiscoHawk/Program.cs | 4 +-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs index e2002c13365..5394ce3828c 100644 --- a/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs +++ b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs @@ -23,6 +23,12 @@ public ArgsDict(string? filePath = null) public readonly struct MultiMessageContext { + public static MultiMessageContext ForCurrentCulture() + { + MultiMessageContext mmc = new(CultureInfo.CurrentUICulture.IetfLanguageTag); + return mmc.Culture is null ? new("en") : mmc; + } + private static IReadOnlyList ReadEmbeddedAndConcat(string lang, MessageContext[] overlays) { MessageContext mc = new(lang, new() { UseIsolating = false }); @@ -44,12 +50,28 @@ private static IReadOnlyList ReadEmbeddedAndConcat(string lang, private readonly IReadOnlyList _contexts; - public readonly CultureInfo Culture; + public readonly CultureInfo? Culture; public MultiMessageContext(IReadOnlyList contexts) { _contexts = contexts; - Culture = new(_contexts.FirstOrDefault()?.Locales?.First()); + var langcode = _contexts.FirstOrDefault()?.Locales?.First(); + if (langcode is null) return; + try + { + Culture = new(langcode); + } + catch (Exception) + { + try + { + Culture = new(langcode.SubstringBefore('-')); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } } public MultiMessageContext(string lang, params MessageContext[] overlays) diff --git a/src/BizHawk.Client.DiscoHawk/Program.cs b/src/BizHawk.Client.DiscoHawk/Program.cs index c23dbcc8d0e..6824227a641 100644 --- a/src/BizHawk.Client.DiscoHawk/Program.cs +++ b/src/BizHawk.Client.DiscoHawk/Program.cs @@ -120,7 +120,7 @@ private static void Main(string[] args) if (args.Length == 0) { - MultiMessageContext i18n = new("en"); + var i18n = MultiMessageContext.ForCurrentCulture(); using MainDiscoForm dialog = new(i18n); dialog.ShowDialog(); } @@ -130,7 +130,7 @@ private static void Main(string[] args) args, results => // invoked 0..1 times { - MultiMessageContext i18n = new("en"); + var i18n = MultiMessageContext.ForCurrentCulture(); using ComparisonResults cr = new(i18n) { textBox1 = { Text = results } }; cr.ShowDialog(); }); From 0d671f680224cf7a3df7fc1912be7f9f27347686 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 28 Jul 2025 04:51:12 +1000 Subject: [PATCH 8/8] Don't print stacktrace when MultiMessageContext correctly falls back --- .../MultiMessageContext.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs index 5394ce3828c..b0435a500ce 100644 --- a/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs +++ b/src/BizHawk.Client.DiscoHawk/MultiMessageContext.cs @@ -25,11 +25,17 @@ public readonly struct MultiMessageContext { public static MultiMessageContext ForCurrentCulture() { - MultiMessageContext mmc = new(CultureInfo.CurrentUICulture.IetfLanguageTag); - return mmc.Culture is null ? new("en") : mmc; + MultiMessageContext mmc = new(CultureInfo.CurrentUICulture.IetfLanguageTag, out var streamException); + if (streamException is null && mmc.Culture is not null) return mmc; + MultiMessageContext mmc1 = new("en", out var streamException1); + if (streamException1 is not null) Console.WriteLine(streamException1); + return mmc1; } - private static IReadOnlyList ReadEmbeddedAndConcat(string lang, MessageContext[] overlays) + private static IReadOnlyList ReadEmbeddedAndConcat( + string lang, + MessageContext[] overlays, + out Exception? streamException) { MessageContext mc = new(lang, new() { UseIsolating = false }); Stream embeddedStream; @@ -39,12 +45,13 @@ private static IReadOnlyList ReadEmbeddedAndConcat(string lang, } catch (ArgumentException e) { - Console.WriteLine(e); + streamException = e; return overlays; } using StreamReader sr = new(embeddedStream); var errors = mc.AddMessages(sr); foreach (var error in errors) Console.WriteLine(error); + streamException = null; return [ ..overlays, mc ]; } @@ -74,8 +81,8 @@ public MultiMessageContext(IReadOnlyList contexts) } } - public MultiMessageContext(string lang, params MessageContext[] overlays) - : this(ReadEmbeddedAndConcat(lang, overlays)) {} + public MultiMessageContext(string lang, out Exception? streamException, params MessageContext[] overlays) + : this(ReadEmbeddedAndConcat(lang, overlays, out streamException)) {} public string? this[string id] => GetString(id);