Skip to content

Commit 5c1ef39

Browse files
committed
add CanShowMessageLabel
1 parent b28cfc8 commit 5c1ef39

3 files changed

Lines changed: 74 additions & 27 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.Designer.cs

Lines changed: 26 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.cs

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,53 @@ public FlashpointSecurePlayerGUI() {
8585
oldCPUSimulator = new OldCPUSimulator(ImportStart, ImportStop);
8686
}
8787

88-
private void ShowOutput(string errorLabelText) {
88+
private bool CanShowMessageLabel(string text) {
89+
if (text == null) {
90+
return false;
91+
}
92+
93+
if (text.Contains("\n")) {
94+
return false;
95+
}
96+
97+
canShowMessageLabel.Text = text;
98+
99+
if (canShowMessageLabel.Width > securePlaybackProgressBar.Width) {
100+
return false;
101+
}
102+
return true;
103+
}
104+
105+
private bool ShowOutput(string text) {
89106
ProgressManager.ShowOutput();
90-
errorLabel.Text = errorLabelText;
107+
108+
if (text == null) {
109+
return false;
110+
}
111+
112+
if (CanShowMessageLabel(text)) {
113+
messageLabel.Text = text;
114+
return true;
115+
}
116+
117+
MessageBox.Show(text, Properties.Resources.FlashpointSecurePlayer, MessageBoxButtons.OK, MessageBoxIcon.None);
118+
return false;
91119
}
92120

93-
private void ShowError(string errorLabelText) {
121+
private bool ShowError(string text) {
94122
ProgressManager.ShowError();
95-
errorLabel.Text = errorLabelText;
123+
124+
if (text == null) {
125+
return false;
126+
}
127+
128+
if (CanShowMessageLabel(text)) {
129+
messageLabel.Text = text;
130+
return true;
131+
}
132+
133+
MessageBox.Show(text, Properties.Resources.FlashpointSecurePlayer, MessageBoxButtons.OK, MessageBoxIcon.Error);
134+
return false;
96135
}
97136

98137
private void ShowNoGameSelected() {
@@ -1051,13 +1090,10 @@ private async Task StartSecurePlayback(TemplateElement templateElement) {
10511090

10521091
try {
10531092
await ActivateModificationsAsync(templateElement, delegate (string text) {
1054-
if (text.Contains("\n")) {
1055-
ProgressManager.ShowError();
1056-
MessageBox.Show(text, Properties.Resources.FlashpointSecurePlayer, MessageBoxButtons.OK, MessageBoxIcon.Error);
1093+
if (!ShowError(text)) {
10571094
Application.Exit();
1058-
} else {
1059-
ShowError(text);
10601095
}
1096+
10611097
throw new InvalidModificationException("An error occured while activating the Modification.");
10621098
}).ConfigureAwait(true);
10631099
} catch (InvalidModificationException ex) {
@@ -1301,13 +1337,10 @@ private async void FlashpointSecurePlayer_Shown(object sender, EventArgs e) {
13011337
// ActiveX Import
13021338
try {
13031339
await ImportActiveX(delegate (string text) {
1304-
if (text.Contains("\n")) {
1305-
ProgressManager.ShowError();
1306-
MessageBox.Show(text, Properties.Resources.FlashpointSecurePlayer, MessageBoxButtons.OK, MessageBoxIcon.Error);
1340+
if (!ShowError(text)) {
13071341
Application.Exit();
1308-
} else {
1309-
ShowError(text);
13101342
}
1343+
13111344
throw new ActiveXImportFailedException("An error occured while activating the ActiveX Import.");
13121345
});
13131346
} catch (InvalidModificationException ex) {

FlashpointSecurePlayer/OldCPUSimulator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public void Activate(string templateName, ref ProcessStartInfo softwareProcessSt
198198
}
199199
return;
200200
}
201+
201202
throw new InvalidOldCPUSimulatorException("The Old CPU Simulator in this Mode is not supported.");
202203
}
203204
}

0 commit comments

Comments
 (0)