Skip to content

Commit

Permalink
Update MSFS2020 & XPlane HubHop presets (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
DocMoebiuz authored Jan 21, 2023
1 parent ea7534f commit 67811ba
Show file tree
Hide file tree
Showing 7 changed files with 585 additions and 480 deletions.
18 changes: 18 additions & 0 deletions ProjectMessages/ProjectMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ProjectMessages/ProjectMessages.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ Please manually flash the boards using "upload firmware" and select the correct
<value>Der Wert muss eine gültige Zahl sein.</value>
<comment>The value must be a valid number.</comment>
</data>
<data name="uiMessageHubHopUpdateError" xml:space="preserve">
<value>Update der HubHop Presets war nicht erfolgreich. Bitte checke das Log für weitere Details.</value>
<comment>Error on downloading HubHop presets. Please check the Log for more information.</comment>
</data>
<data name="uiMessageHubHopUpdateSuccessful" xml:space="preserve">
<value>Update der HubHop Presets war erfolgreich.</value>
<comment>HubHop presets download was successful.</comment>
</data>
<data name="uiMessageResetConfirm" xml:space="preserve">
<value>Möchtest Du wirklich die MobiFlight Firmware deinstallieren? Alle Deine Daten werden vom Board gelöscht.</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions ProjectMessages/ProjectMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ Check log for more details.</value>
<data name="uiMessageValidationMustBeNumber" xml:space="preserve">
<value>The value must be a valid number.</value>
</data>
<data name="uiMessageHubHopUpdateError" xml:space="preserve">
<value>Error on downloading HubHop presets. Please check the Log for more information.</value>
</data>
<data name="uiMessageHubHopUpdateSuccessful" xml:space="preserve">
<value>HubHop presets download was successful.</value>
</data>
<data name="uiMessageResetConfirm" xml:space="preserve">
<value>Do you really want to uninstall the MobiFlight firmware? All your data will be removed from the board.</value>
</data>
Expand Down
29 changes: 24 additions & 5 deletions SimConnectMSFS/WasmModuleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ public class WasmModuleUpdater
public const String WasmEventsSimVarsFolder = @".\presets";
public const String WasmEventsSimVarsFileName = @"msfs2020_simvars.cip";

public const String WasmEventHubHHopUrl = @"https://hubhop-api-mgtm.azure-api.net/api/v1/presets?type=json";
public const String WasmEventHubHHopUrl = @"https://hubhop-api-mgtm.azure-api.net/api/v1/msfs2020/presets?type=json";
public const String WasmEventsHubHopFolder = @".\presets";
public const String WasmEventsHubHopFileName = @"msfs2020_hubhop_presets.json";

public const String WasmEventsXplaneHubHHopUrl = @"https://hubhop-api-mgtm.azure-api.net/api/v1/xplane/presets?type=json";
public const String WasmEventsXplaneHubHopFileName = @"xplane_hubhop_presets.json";

public const String WasmModuleName = @"MobiFlightWasmModule.wasm";
public const String WasmModuleNameOld = @"StandaloneModule.wasm";

Expand Down Expand Up @@ -240,23 +243,39 @@ public bool DownloadWasmEvents()
Log.Instance.log("WASM events.txt has been downloaded and installed successfully.", LogSeverity.Debug);

progress.ProgressMessage = "Downloading EventIDs (legacy)";
progress.Current = 25;
progress.Current = 33;
DownloadAndInstallProgress?.Invoke(this, progress);
if (!DownloadSingleFile(new Uri(WasmEventsCipUrl), WasmEventsCipFileName, WasmEventsCipFolder)) return false;
Log.Instance.log("WASM msfs2020_eventids.cip has been downloaded and installed successfully.", LogSeverity.Debug);

progress.ProgressMessage = "Downloading SimVars (legacy)";
progress.Current = 50;
progress.Current = 66;
DownloadAndInstallProgress?.Invoke(this, progress);
if (!DownloadSingleFile(new Uri(WasmEventsSimVarsUrl), WasmEventsSimVarsFileName, WasmEventsSimVarsFolder)) return false;
Log.Instance.log("WASM msfs2020_simvars.cip has been downloaded and installed successfully.", LogSeverity.Debug);

progress.ProgressMessage = "Downloading HubHop Presets";
progress.Current = 75;
progress.ProgressMessage = "Downloading done";
progress.Current = 100;
DownloadAndInstallProgress?.Invoke(this, progress);
return true;
}

public bool DownloadHubHopPresets()
{
ProgressUpdateEvent progress = new ProgressUpdateEvent();

progress.ProgressMessage = "Downloading HubHop Presets (MSFS2020)";
progress.Current = 33;
DownloadAndInstallProgress?.Invoke(this, progress);
if (!DownloadSingleFile(new Uri(WasmEventHubHHopUrl), WasmEventsHubHopFileName, WasmEventsHubHopFolder)) return false;
Log.Instance.log($"WASM {WasmEventsHubHopFileName} has been downloaded and installed successfully.", LogSeverity.Info);

progress.ProgressMessage = "Downloading HubHop Presets (XPlane)";
progress.Current = 66;
DownloadAndInstallProgress?.Invoke(this, progress);
if (!DownloadSingleFile(new Uri(WasmEventsXplaneHubHHopUrl), WasmEventsXplaneHubHopFileName, WasmEventsHubHopFolder)) return false;
Log.Instance.log($"WASM {WasmEventsXplaneHubHopFileName} has been downloaded and installed successfully.", LogSeverity.Info);

progress.ProgressMessage = "Downloading done";
progress.Current = 100;
DownloadAndInstallProgress?.Invoke(this, progress);
Expand Down
48 changes: 33 additions & 15 deletions UI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 41 additions & 2 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,8 +1697,6 @@ private void downloadLatestEventsToolStripMenuItem_Click(object sender, EventArg

if (updater.InstallWasmEvents())
{
Msfs2020HubhopPresetListSingleton.Instance.Clear();
XplaneHubhopPresetListSingleton.Instance.Clear();
progressForm.DialogResult = DialogResult.OK;
}
else
Expand Down Expand Up @@ -1727,6 +1725,47 @@ private void downloadLatestEventsToolStripMenuItem_Click(object sender, EventArg
progressForm.Dispose();
}

private void downloadHubHopPresetsToolStripMenuItem_Click(object sender, EventArgs e)
{
WasmModuleUpdater updater = new WasmModuleUpdater();
ProgressForm progressForm = new ProgressForm();
Control MainForm = this;

updater.DownloadAndInstallProgress += progressForm.OnProgressUpdated;
var t = new Task(() => {
if (updater.DownloadHubHopPresets())
{
Msfs2020HubhopPresetListSingleton.Instance.Clear();
XplaneHubhopPresetListSingleton.Instance.Clear();
progressForm.DialogResult = DialogResult.OK;
}
else
{
progressForm.DialogResult = DialogResult.No;
Log.Instance.log(i18n._tr("uiMessageHubHopUpdateError"), LogSeverity.Error);
}
}
);

t.Start();
if (progressForm.ShowDialog() == DialogResult.OK)
{
TimeoutMessageDialog.Show(
i18n._tr("uiMessageHubHopUpdateSuccessful"),
i18n._tr("uiMessageWasmUpdater"),
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
TimeoutMessageDialog.Show(
i18n._tr("uiMessageWasmEventsInstallationError"),
i18n._tr("uiMessageWasmUpdater"),
MessageBoxButtons.OK, MessageBoxIcon.Error);
};

progressForm.Dispose();
}

private void openDiscordServer_Click(object sender, EventArgs e)
{
Process.Start("https://discord.gg/U28QeEJpBV");
Expand Down
Loading

0 comments on commit 67811ba

Please sign in to comment.