Skip to content

Commit 198741a

Browse files
committed
Cleanup PatchForm, add deprecation warning
1 parent d5fe30c commit 198741a

File tree

1 file changed

+13
-59
lines changed

1 file changed

+13
-59
lines changed

Refresher/UI/PatchForm.cs

Lines changed: 13 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public abstract class PatchForm<TPatcher> : RefresherForm where TPatcher : class
3131

3232
private bool _usedAutoDiscover = false;
3333

34-
protected PatchForm(string subtitle) : base(subtitle, new Size(700, -1), false)
34+
protected PatchForm(string subtitle) : base(subtitle + " [LEGACY PATCHER!]", new Size(700, -1), false)
3535
{
36+
MessageBox.Show("This legacy patch method is deprecated and might be removed in a future release.\n\n" +
37+
"Please use the other patchers, or let us know if this is necessary for you.", "Deprecation Warning", MessageBoxType.Warning);
38+
3639
this._messages = new ListBox { Height = 200 };
3740
this._patchButton = new Button(this.Patch) { Text = "Patch!", Enabled = false };
3841

@@ -45,38 +48,37 @@ protected void InitializePatcher()
4548
TableLayout formPanel = this.FormPanel;
4649
formPanel.Spacing = new Size(5, 5);
4750
formPanel.Padding = new Padding(0, 0, 0, 10);
48-
49-
StackLayout layout;
5051

5152
this.Content = new Splitter
5253
{
5354
Orientation = Orientation.Vertical,
5455
Panel1 = formPanel,
5556

5657
// ReSharper disable once RedundantExplicitParamsArrayCreation
57-
Panel2 = layout = new StackLayout(new StackLayoutItem[]
58-
{
58+
Panel2 = new StackLayout([
5959
this._messages,
60-
new Button(this.Guide) { Text = "View guide" },
6160
new Button(this.InvokeAutoDiscover) { Text = "AutoDiscover" },
6261
this._patchButton,
63-
})
62+
new Label
63+
{
64+
Text = "This is a legacy patcher. Support will not be provided.",
65+
TextAlignment = TextAlignment.Center,
66+
TextColor = Colors.Orange,
67+
},
68+
])
6469
{
6570
Padding = new Padding(0, 10, 0, 0),
6671
Spacing = 5,
6772
HorizontalContentAlignment = HorizontalAlignment.Stretch,
6873
VerticalContentAlignment = VerticalAlignment.Bottom,
6974
},
7075
};
71-
72-
foreach (Button button in this.AddExtraButtons())
73-
layout.Items.Add(button);
7476

7577
this.UrlField.TextChanged += this.Reverify;
7678
this.UrlField.PlaceholderText = "http://localhost:10061/lbp";
7779
}
7880

79-
protected static TableRow AddField<TControl>(string labelText, out TControl control, Button? button = null, int forceHeight = -1) where TControl : Control, new()
81+
protected static TableRow AddField<TControl>(string labelText, out TControl control) where TControl : Control, new()
8082
{
8183
if (!string.IsNullOrWhiteSpace(labelText)) labelText += ':';
8284

@@ -87,16 +89,6 @@ protected void InitializePatcher()
8789
};
8890

8991
control = new TControl();
90-
if (forceHeight != -1) control.Height = forceHeight;
91-
92-
if (button != null)
93-
{
94-
DynamicLayout buttonLayout = new();
95-
buttonLayout.AddRow(button, control);
96-
buttonLayout.Spacing = new Size(5, 0);
97-
98-
return new TableRow(label, buttonLayout);
99-
}
10092

10193
return new TableRow(label, control);
10294
}
@@ -106,40 +98,6 @@ public virtual void CompletePatch(object? sender, EventArgs e)
10698
// Not necessary for some patchers maybe
10799
}
108100

109-
public virtual IEnumerable<Button> AddExtraButtons()
110-
{
111-
return Array.Empty<Button>();
112-
}
113-
114-
public virtual void Guide(object? sender, EventArgs e)
115-
{
116-
MessageBox.Show("No guide exists for this patch method yet, so stay tuned!", MessageBoxType.Warning);
117-
}
118-
119-
protected void OpenUrl(string url)
120-
{
121-
try
122-
{
123-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
124-
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
125-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
126-
Process.Start("xdg-open", url);
127-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
128-
Process.Start("open", url);
129-
else
130-
throw new PlatformNotSupportedException("Cannot open a URL on this platform.");
131-
}
132-
catch (Exception e)
133-
{
134-
State.Logger.LogError(OSIntegration, e.ToString());
135-
MessageBox.Show("We couldn't open your browser due to an error.\n" +
136-
$"You can use this link instead: {url}\n\n" +
137-
$"Exception details: {e.GetType().Name} {e.Message}",
138-
MessageBoxType.Error);
139-
}
140-
// based off of https://stackoverflow.com/a/43232486
141-
}
142-
143101
private void InvokeAutoDiscover(object? sender, EventArgs arg)
144102
{
145103
string url = this.UrlField.Text;
@@ -257,8 +215,6 @@ private void Patch(object? sender, EventArgs e)
257215
if (!this._patchButton.Enabled) return; // shouldn't happen ever but just in-case
258216
if (this.Patcher == null) return;
259217

260-
this.BeforePatch(sender, e);
261-
262218
if (!this._usedAutoDiscover)
263219
{
264220
DialogResult result = MessageBox.Show("You didn't use AutoDiscover. Would you like to try to run it now?", MessageBoxButtons.YesNoCancel, MessageBoxType.Question);
@@ -285,8 +241,6 @@ private void Patch(object? sender, EventArgs e)
285241

286242
this.CompletePatch(sender, e);
287243
}
288-
289-
protected virtual void BeforePatch(object? sender, EventArgs e) {}
290244

291245
protected void FailVerify(string reason, Exception? e = null, bool clear = true)
292246
{

0 commit comments

Comments
 (0)