Skip to content

Commit

Permalink
AutoRun works correctly again (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
DocMoebiuz authored Dec 13, 2023
1 parent 7579acb commit 1da52a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions MobiFlight/ExecutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ public bool ModulesAvailable()

public void Start()
{
if (timer.Enabled) return;

simConnectCache.Start();
xplaneCache.Start();
OnStartActions();
Expand Down
24 changes: 13 additions & 11 deletions UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ private void MainForm_Shown(object sender, EventArgs e)

execManager.OnSimAvailable += ExecManager_OnSimAvailable;
execManager.OnSimUnavailable += ExecManager_OnSimUnavailable;
execManager.OnSimCacheConnectionLost += new EventHandler(fsuipcCache_ConnectionLost);
execManager.OnSimCacheConnected += new EventHandler(fsuipcCache_Connected);
execManager.OnSimCacheConnected += new EventHandler(checkAutoRun);
execManager.OnSimCacheClosed += new EventHandler(fsuipcCache_Closed);
execManager.OnSimCacheConnectionLost += new EventHandler(SimCache_ConnectionLost);
execManager.OnSimCacheConnected += new EventHandler(SimCache_Connected);
execManager.OnSimCacheConnected += new EventHandler(CheckAutoRun);
execManager.OnSimCacheClosed += new EventHandler(SimCache_Closed);
execManager.OnSimAircraftChanged += ExecManager_OnSimAircraftChanged;

// working hypothesis: we don't need this at all.
Expand Down Expand Up @@ -239,8 +239,7 @@ private void MainForm_Shown(object sender, EventArgs e)
#endif
Update();
Refresh();
execManager.AutoConnectStart();


moduleToolStripDropDownButton.DropDownItems.Clear();
moduleToolStripDropDownButton.ToolTipText = i18n._tr("uiMessageNoModuleFound");
}
Expand Down Expand Up @@ -434,6 +433,10 @@ void ExecManager_OnInitialModuleLookupFinished(object sender, EventArgs e)
AppTelemetry.Instance.TrackStart();

InitialLookupFinished = true;

// Now we are done with all initialization stuff
// and now we are ready to look for sims
execManager.AutoConnectStart();
}

private void CheckForHubhopUpdate()
Expand Down Expand Up @@ -843,7 +846,7 @@ private bool RunIsAvailable()
/// <summary>
/// updates the UI with appropriate icon states
/// </summary>
void fsuipcCache_Closed(object sender, EventArgs e)
void SimCache_Closed(object sender, EventArgs e)
{
if (sender.GetType() == typeof(SimConnectCache))
{
Expand Down Expand Up @@ -921,7 +924,7 @@ private void ExecManager_OnSimUnavailable(object sender, EventArgs e)
/// <summary>
/// updates the UI with appropriate icon states
/// </summary>
void fsuipcCache_Connected(object sender, EventArgs e)
void SimCache_Connected(object sender, EventArgs e)
{
// Typically the information in this static object is correct
// only in the case of FSUIPC it might actually be not correct
Expand Down Expand Up @@ -1013,7 +1016,7 @@ void fsuipcCache_Connected(object sender, EventArgs e)
/// <summary>
/// gets triggered as soon as the fsuipc is connected
/// </summary>
void checkAutoRun (object sender, EventArgs e)
void CheckAutoRun (object sender, EventArgs e)
{
if (Properties.Settings.Default.AutoRun || cmdLineParams.AutoRun)
{
Expand All @@ -1028,7 +1031,7 @@ void checkAutoRun (object sender, EventArgs e)
/// <summary>
/// shows message to user and stops execution of timer
/// </summary>
void fsuipcCache_ConnectionLost(object sender, EventArgs e)
void SimCache_ConnectionLost(object sender, EventArgs e)
{
execManager.Stop();

Expand Down Expand Up @@ -1484,7 +1487,6 @@ private void LoadConfig(string fileName, bool merge = false)
AppTelemetry.Instance.TrackSettings();

ConfigLoaded?.Invoke(this, configFile);

}

private void _checkForOrphanedJoysticks(bool showNotNecessaryMessage)
Expand Down

0 comments on commit 1da52a2

Please sign in to comment.