Skip to content

Commit b14f033

Browse files
committed
Adopt Fluent in DiscoHawk, simply moving strings across
1 parent ac27453 commit b14f033

File tree

5 files changed

+150
-47
lines changed

5 files changed

+150
-47
lines changed

src/BizHawk.Client.DiscoHawk/About.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BizHawk.Client.DiscoHawk
77
{
88
public class About : Form
99
{
10-
public About()
10+
public About(MultiMessageContext i18n)
1111
{
1212
SuspendLayout();
1313

@@ -17,12 +17,7 @@ public About()
1717
richTextBox1.ReadOnly = true;
1818
richTextBox1.Size = new(499, 236);
1919
richTextBox1.TabIndex = 1;
20-
richTextBox1.Text = ("DiscoHawk converts bolloxed-up crusty disc images to totally tidy CCD."
21-
+ "\n\nDiscoHawk is part of the BizHawk project ( https://github.com/TASEmulators/BizHawk )."
22-
+ "\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."
23-
+ "\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."
24-
+ "\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.)")
25-
.Replace("\n", Environment.NewLine);
20+
richTextBox1.Text = i18n["discohawkabout-4584-lbl-explainer-label"]!.Replace("\n", Environment.NewLine);
2621
richTextBox1.LinkClicked += (_, clickedArgs) => Util.OpenUrlExternal(clickedArgs.LinkText);
2722

2823
Button button1 = new();
@@ -31,7 +26,7 @@ public About()
3126
button1.Name = "button1";
3227
button1.Size = new(75, 23);
3328
button1.TabIndex = 2;
34-
button1.Text = "OK";
29+
button1.Text = i18n["discohawkabout-9804-btn-dismiss-textstr"];
3530
button1.UseVisualStyleBackColor = true;
3631
button1.Click += (_, _) => Close();
3732

@@ -55,7 +50,7 @@ public About()
5550
FormBorderStyle = FormBorderStyle.FixedDialog;
5651
MinimizeBox = false;
5752
Name = "About";
58-
Text = "About DiscoHawk";
53+
Text = i18n["discohawkabout-2822-windowtitlestatic"];
5954
ResumeLayout(performLayout: false);
6055
PerformLayout();
6156
}

src/BizHawk.Client.DiscoHawk/ComparisonResults.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ComparisonResults : Form
77
{
88
public readonly RichTextBox textBox1;
99

10-
public ComparisonResults()
10+
public ComparisonResults(MultiMessageContext i18n)
1111
{
1212
SuspendLayout();
1313

@@ -19,7 +19,7 @@ public ComparisonResults()
1919
textBox1.ReadOnly = true;
2020
textBox1.Size = new(757, 394);
2121
textBox1.TabIndex = 1;
22-
textBox1.Text = "";
22+
textBox1.Text = string.Empty; // overwritten by caller as part of object initialisation
2323

2424
TabControl tabControl1 = new();
2525
tabControl1.SuspendLayout();
@@ -43,31 +43,31 @@ public ComparisonResults()
4343
tabPage1.Padding = new(all: 3);
4444
tabPage1.Size = new(763, 400);
4545
tabPage1.TabIndex = 0;
46-
tabPage1.Text = "Log";
46+
tabPage1.Text = i18n["discohawkcomparereadout-6110-tab-log-textstr"];
4747
tabPage1.UseVisualStyleBackColor = true;
4848

4949
tabPage2.Location = new(4, 22);
5050
tabPage2.Name = "tabPage2";
5151
tabPage2.Padding = new(all: 3);
5252
tabPage2.Size = new(763, 400);
5353
tabPage2.TabIndex = 1;
54-
tabPage2.Text = "SRC Context";
54+
tabPage2.Text = i18n["discohawkcomparereadout-6110-tab-src-textstr"];
5555
tabPage2.UseVisualStyleBackColor = true;
5656

5757
tabPage3.Location = new(4, 22);
5858
tabPage3.Name = "tabPage3";
5959
tabPage3.Padding = new(all: 3);
6060
tabPage3.Size = new(763, 400);
6161
tabPage3.TabIndex = 2;
62-
tabPage3.Text = "DST Context";
62+
tabPage3.Text = i18n["discohawkcomparereadout-6110-tab-dest-textstr"];
6363
tabPage3.UseVisualStyleBackColor = true;
6464

6565
AutoScaleDimensions = new(6.0f, 13.0f);
6666
AutoScaleMode = AutoScaleMode.Font;
6767
ClientSize = new(771, 426);
6868
Controls.Add(tabControl1);
6969
Name = "ComparisonResults";
70-
Text = "ComparisonResults";
70+
Text = i18n["discohawkcomparereadout-2005-windowtitlestatic"];
7171
tabControl1.ResumeLayout(performLayout: false);
7272
tabPage1.ResumeLayout(performLayout: false);
7373
ResumeLayout(performLayout: false);

src/BizHawk.Client.DiscoHawk/MainDiscoForm.cs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace BizHawk.Client.DiscoHawk
1111
{
1212
public class MainDiscoForm : Form
1313
{
14+
private readonly MultiMessageContext _i18n;
15+
1416
private readonly RadioButton ccdOutputButton;
1517

1618
private readonly RadioButton chdOutputButton;
@@ -26,16 +28,18 @@ public class MainDiscoForm : Form
2628
// An outputted list showing new file name
2729
// Progress bar should show file being converted
2830
// Add disc button, which puts it on the progress cue (converts it)
29-
public MainDiscoForm()
31+
public MainDiscoForm(MultiMessageContext i18n)
3032
{
33+
_i18n = i18n;
34+
3135
SuspendLayout();
3236

3337
Button ExitButton = new();
3438
ExitButton.Location = new(434, 414);
3539
ExitButton.Name = "ExitButton";
3640
ExitButton.Size = new(75, 23);
3741
ExitButton.TabIndex = 0;
38-
ExitButton.Text = "E&xit";
42+
ExitButton.Text = i18n["maindiscoform-4723-btn-exit-textstr"];
3943
ExitButton.UseVisualStyleBackColor = true;
4044
ExitButton.Click += (_, _) => Close();
4145

@@ -56,7 +60,7 @@ public MainDiscoForm()
5660
label1.Name = "label1";
5761
label1.Size = new(166, 47);
5862
label1.TabIndex = 0;
59-
label1.Text = "Drag here to HAWK your disc - dump it out as a clean CCD/CHD";
63+
label1.Text = i18n["maindiscoform-1872-area-hawkdisc-label"];
6064

6165
lblMp3ExtractMagicArea = new();
6266
lblMp3ExtractMagicArea.SuspendLayout();
@@ -75,16 +79,16 @@ public MainDiscoForm()
7579
label2.Name = "label2";
7680
label2.Size = new(163, 39);
7781
label2.TabIndex = 0;
78-
label2.Text = "Drag a disc here to extract the audio tracks to MP3";
82+
label2.Text = i18n["maindiscoform-6011-area-mp3extract-label"];
7983

8084
Button btnAbout = new();
8185
btnAbout.Location = new(353, 414);
8286
btnAbout.Name = "btnAbout";
8387
btnAbout.Size = new(75, 23);
8488
btnAbout.TabIndex = 3;
85-
btnAbout.Text = "&About";
89+
btnAbout.Text = i18n["maindiscoform-5766-btn-about-textstr"];
8690
btnAbout.UseVisualStyleBackColor = true;
87-
btnAbout.Click += (_, _) => new About().ShowDialog();
91+
btnAbout.Click += (_, _) => new About(_i18n).ShowDialog();
8892

8993
RadioButton radioButton1 = new();
9094
radioButton1.AutoSize = true;
@@ -94,7 +98,7 @@ public MainDiscoForm()
9498
radioButton1.Size = new(67, 17);
9599
radioButton1.TabIndex = 4;
96100
radioButton1.TabStop = true;
97-
radioButton1.Text = "BizHawk";
101+
radioButton1.Text = i18n["maindiscoform-4559-radio-engine-hawk-textstr"];
98102
radioButton1.UseVisualStyleBackColor = true;
99103

100104
GroupBox groupBox1 = new();
@@ -112,27 +116,27 @@ public MainDiscoForm()
112116
groupBox1.Size = new(276, 234);
113117
groupBox1.TabIndex = 5;
114118
groupBox1.TabStop = false;
115-
groupBox1.Text = "Disc Reading Engine";
119+
groupBox1.Text = i18n["maindiscoform-7187-group-engine-label"];
116120

117121
label4.Location = new(20, 95);
118122
label4.Name = "label4";
119123
label4.Size = new(216, 43);
120124
label4.TabIndex = 8;
121-
label4.Text = "- Doesn\'t support audio decoding yet\r\n(even though Mednafen proper can do it)\r\n- Loads ISO, CUE, and CCD";
125+
label4.Text = i18n["maindiscoform-7205-radio-engine-mednafen-longdesc-label"];
122126

123127
label3.Location = new(20, 39);
124128
label3.Name = "label3";
125129
label3.Size = new(253, 33);
126130
label3.TabIndex = 7;
127-
label3.Text = "- Uses FFMPEG for audio decoding\r\n- Loads ISO, CUE, CCD, CDI, CHD, MDS, and NRG";
131+
label3.Text = i18n["maindiscoform-4559-radio-engine-hawk-longdesc-label"];
128132

129133
radioButton2.AutoSize = true;
130134
radioButton2.Enabled = false;
131135
radioButton2.Location = new(6, 75);
132136
radioButton2.Name = "radioButton2";
133137
radioButton2.Size = new(73, 17);
134138
radioButton2.TabIndex = 5;
135-
radioButton2.Text = "Mednafen";
139+
radioButton2.Text = i18n["maindiscoform-7205-radio-engine-mednafen-textstr"];
136140
radioButton2.UseVisualStyleBackColor = true;
137141

138142
GroupBox groupBox2 = new();
@@ -147,7 +151,7 @@ public MainDiscoForm()
147151
groupBox2.Size = new(271, 69);
148152
groupBox2.TabIndex = 6;
149153
groupBox2.TabStop = false;
150-
groupBox2.Text = "Output Format";
154+
groupBox2.Text = i18n["maindiscoform-5561-group-hawkoutput-label"];
151155

152156
ccdOutputButton.AutoSize = true;
153157
ccdOutputButton.Checked = true;
@@ -156,7 +160,7 @@ public MainDiscoForm()
156160
ccdOutputButton.Size = new(47, 17);
157161
ccdOutputButton.TabIndex = 5;
158162
ccdOutputButton.TabStop = true;
159-
ccdOutputButton.Text = "CCD";
163+
ccdOutputButton.Text = i18n["maindiscoform-7576-radio-hawkoutput-ccd-textstr"];
160164
ccdOutputButton.UseVisualStyleBackColor = true;
161165

162166
chdOutputButton.AutoSize = true;
@@ -166,7 +170,7 @@ public MainDiscoForm()
166170
chdOutputButton.Size = new(47, 17);
167171
chdOutputButton.TabIndex = 6;
168172
chdOutputButton.TabStop = true;
169-
chdOutputButton.Text = "CHD";
173+
chdOutputButton.Text = i18n["maindiscoform-2884-radio-hawkoutput-chd-textstr"];
170174
chdOutputButton.UseVisualStyleBackColor = true;
171175

172176
Label label6 = new();
@@ -176,15 +180,15 @@ public MainDiscoForm()
176180
label6.Name = "label6";
177181
label6.Size = new(111, 13);
178182
label6.TabIndex = 2;
179-
label6.Text = "Compare Reading To:";
183+
label6.Text = i18n["maindiscoform-4639-group-compare-list-label"];
180184

181185
Label label7 = new();
182186
label7.AutoSize = true;
183187
label7.Location = new(358, 12);
184188
label7.Name = "label7";
185189
label7.Size = new(70, 13);
186190
label7.TabIndex = 10;
187-
label7.Text = "- Operations -";
191+
label7.Text = i18n["maindiscoform-7426-pane-operations-label"];
188192

189193
lvCompareTargets = new();
190194
lvCompareTargets.Columns.Add(new ColumnHeader());
@@ -193,8 +197,8 @@ public MainDiscoForm()
193197
lvCompareTargets.GridLines = true;
194198
lvCompareTargets.HeaderStyle = ColumnHeaderStyle.None;
195199
lvCompareTargets.HideSelection = false;
196-
lvCompareTargets.Items.Add("BizHawk");
197-
lvCompareTargets.Items.Add("Mednafen");
200+
lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-hawk-label"]);
201+
lvCompareTargets.Items.Add(i18n["maindiscoform-5267-compare-mednafen-label"]);
198202
lvCompareTargets.Location = new(9, 340);
199203
lvCompareTargets.Name = "lvCompareTargets";
200204
lvCompareTargets.Size = new(121, 97);
@@ -221,7 +225,7 @@ public MainDiscoForm()
221225
MaximizeBox = false;
222226
MinimizeBox = false;
223227
Name = "MainDiscoForm";
224-
Text = "DiscoHawk";
228+
Text = i18n["maindiscoform-3997-windowtitlestatic"];
225229
Load += (_, _) => lvCompareTargets.Columns[0].Width = lvCompareTargets.ClientSize.Width;
226230
lblMagicDragArea.ResumeLayout(performLayout: false);
227231
lblMp3ExtractMagicArea.ResumeLayout(performLayout: false);
@@ -246,14 +250,14 @@ private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e)
246250
{
247251
var success = DiscoHawkLogic.HawkAndWriteFile(
248252
inputPath: file,
249-
errorCallback: err => MessageBox.Show(err, "Error loading disc"),
253+
errorCallback: err => MessageBox.Show(err, _i18n["discodischawking-6945-errbox-hawk-windowtitlestatic"]),
250254
hawkedFormat: outputFormat);
251255
if (!success) break;
252256
}
253257
}
254258
catch (Exception ex)
255259
{
256-
MessageBox.Show(ex.ToString(), "Error loading disc");
260+
MessageBox.Show(ex.ToString(), _i18n["discodischawking-3654-errbox-misc-windowtitlestatic"]);
257261
throw;
258262
}
259263
finally
@@ -323,9 +327,8 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
323327
{
324328
#if true
325329
MessageBox.Show(
326-
caption: "FFmpeg missing",
327-
text: "This function requires FFmpeg, but it doesn't appear to have been downloaded.\n"
328-
+ "EmuHawk can automatically download it: you just need to set up A/V recording with the FFmpeg writer.");
330+
caption: _i18n["discomp3extract-5715-errbox-noffmpeg-windowtitlestatic"],
331+
text: _i18n["discomp3extract-5715-errbox-noffmpeg-label"]);
329332
return;
330333
#else
331334
using EmuHawk.FFmpegDownloaderForm dialog = new(); // builds fine when <Compile Include/>'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)
343346
{
344347
using var disc = Disc.LoadAutomagic(file);
345348
var (path, filename, _) = file.SplitPathToDirFileAndExt();
346-
static bool? PromptForOverwrite(string mp3Path)
349+
bool? PromptForOverwrite(string mp3Path)
347350
=> MessageBox.Show(
348-
$"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}",
349-
"File to extract already exists",
351+
string.Format(_i18n["discomp3extract-3418-prompt-overwrite-fmtstr"], mp3Path),
352+
_i18n["discomp3extract-3418-prompt-overwrite-windowtitlestatic"],
350353
MessageBoxButtons.YesNoCancel) switch
351354
{
352355
DialogResult.Yes => true,
@@ -358,7 +361,7 @@ private void LblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
358361
}
359362
catch (Exception ex)
360363
{
361-
MessageBox.Show(ex.ToString(), "Error loading disc");
364+
MessageBox.Show(ex.ToString(), _i18n["discomp3extract-7691-errbox-misc-windowtitlestatic"]);
362365
throw;
363366
}
364367
finally

src/BizHawk.Client.DiscoHawk/Program.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,18 @@ private static void Main(string[] args)
122122

123123
if (args.Length == 0)
124124
{
125-
using var dialog = new MainDiscoForm();
125+
MultiMessageContext i18n = new("en");
126+
using MainDiscoForm dialog = new(i18n);
126127
dialog.ShowDialog();
127128
}
128129
else
129130
{
130131
DiscoHawkLogic.RunWithArgs(
131132
args,
132-
results =>
133+
results => // invoked 0..1 times
133134
{
134-
using var cr = new ComparisonResults { textBox1 = { Text = results } };
135+
MultiMessageContext i18n = new("en");
136+
using ComparisonResults cr = new(i18n) { textBox1 = { Text = results } };
135137
cr.ShowDialog();
136138
});
137139
}

0 commit comments

Comments
 (0)