Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDDI split #1996

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CargoMonitor/EddiCargoMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
Expand Down
4 changes: 4 additions & 0 deletions CrimeMonitor/EddiCrimeMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<Project>{ec7ba042-a370-447f-8c3e-241358cebcbb}</Project>
<Name>Eddi</Name>
Expand Down
10 changes: 5 additions & 5 deletions EDDI/Eddi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EddiUpgrader.cs" />
<Compile Include="MainWindowResponder.cs" />
<Compile Include="Settings.cs" />
<Compile Include="StarSystemComboBox.cs" />
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="EDDI.cs" />
<Compile Include="EliteConfiguration.cs" />
<Compile Include="EDDIMonitor.cs" />
<Compile Include="EDDIResponder.cs" />
<Page Include="ChangeLog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -156,7 +153,6 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="EDDIConfiguration.cs" />
<Compile Include="ChangeLog.xaml.cs">
<DependentUpon>ChangeLog.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -243,6 +239,10 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EddiInaraService\EddiInaraService.csproj">
<Project>{19AB6841-AA93-4D23-BE6D-4CB6883CDF62}</Project>
<Name>EddiInaraService</Name>
Expand Down
23 changes: 22 additions & 1 deletion EDDI/EddiUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Utilities;

Expand Down Expand Up @@ -105,7 +106,7 @@ public static void Upgrade()
else
{
// Inno setup will attempt to restart this application so register it
EDDI.NativeMethods.RegisterApplicationRestart(null, EDDI.RestartFlags.NONE);
RegisterApplicationRestart(null, RestartFlags.NONE);

Logging.Info("Downloaded update to " + updateFile);
Logging.Info("Path is " + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Expand All @@ -123,5 +124,25 @@ public static void Upgrade()
Logging.Error("Upgrade failed", ex);
}
}

// Required to restart app after upgrade
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern uint RegisterApplicationRestart(string pwzCommandLine, RestartFlags dwFlags);

// Flags for upgrade
[Flags]
private enum RestartFlags
{
NONE = 0,
RESTART_CYCLICAL = 1,
RESTART_NOTIFY_SOLUTION = 2,
RESTART_NOTIFY_FAULT = 4,
RESTART_NO_CRASH = 8,
RESTART_NO_HANG = 16,
RESTART_NO_PATCH = 32,
RESTART_NO_REBOOT = 64
}

}

}
2 changes: 1 addition & 1 deletion EDDI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ private void setStatusInfo()
{
upgradeButton.Visibility = Visibility.Collapsed;
var capiState = CompanionAppService.Instance.CurrentState;
if (!EDDI.running)
if (!EDDI.IsRunning)
{
statusText.Text = Properties.EddiResources.safe_mode;
}
Expand Down
151 changes: 151 additions & 0 deletions EDDI/MainWindowResponder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using EddiCore;
using EddiDataDefinitions;
using EddiEvents;

namespace Eddi
{
public class MainWindowResponder: EDDIResponder
{
private MainWindow _mainWindow = null;

private MainWindow MainWindow
{
get
{
if (_mainWindow == null)
{
if (Application.Current?.MainWindow != null)
{
_mainWindow = ((MainWindow) Application.Current.MainWindow);
}
}

return _mainWindow;
}
}

public string ResponderName() => "MainWindow";

public string LocalizedResponderName() => "MainWindow";

public string ResponderDescription() => "Main Window Description";

public bool Start() => true;

public void Stop() { }

public void Reload() { }
public System.Windows.Controls.UserControl ConfigurationTabItem() => null;

public void Handle(Event theEvent)
{
if (MainWindow == null)
return;

switch (theEvent)
{
case SquadronStatusEvent squadronStatus:
eventSquadronStatus(squadronStatus);
break;
case SquadronRankEvent squadronRank:
eventSquadronRank(squadronRank);
break;
case CarrierJumpedEvent carrierJumped:
updateSquadronFactionDropDown(carrierJumped.factions);
break;
case LocationEvent location:
updateSquadronFactionDropDown(location.factions);
break;
case JumpedEvent jumped:
updateSquadronFactionDropDown(jumped.factions);
break;
default:
break;
}
}

private void updateSquadronFactionDropDown(IEnumerable<Faction> factions)
{
//Update the squadron faction
var configuration = EDDIConfiguration.FromFile();
MainWindow.squadronFactionDropDown.SelectedItem = configuration.SquadronFaction;

// Update system, allegiance, & power when in squadron home system
var currentSystem = EDDI.Instance.CurrentStarSystem;

var squadronFaction = factions.FirstOrDefault(f =>
(bool)f.presences.
FirstOrDefault(p => p.systemName == currentSystem.systemname)?.squadronhomesystem || f.squadronfaction);

if (squadronFaction != null)
{
MainWindow.squadronSystemDropDown.Text = currentSystem.systemname;
MainWindow.ConfigureSquadronFactionOptions(configuration);
}

// Update the squadron power, if changed
var power = Power.FromName(currentSystem?.power);
if (power == null || power == configuration.SquadronPower)
{
return;
}

MainWindow.squadronPowerDropDown.SelectedItem = power.localizedName;
MainWindow.ConfigureSquadronPowerOptions(configuration);
}

//private void updateSquadronFactionDropDown()
//{
// EDDIConfiguration configuration = EDDIConfiguration.FromFile();
// MainWindow.squadronFactionDropDown.SelectedItem = configuration.SquadronFaction;

// var currentSystem = EDDI.Instance.CurrentStarSystem;

// // Check if current system is inhabited by or HQ for squadron faction
// var squadronFaction = factions.FirstOrDefault(f =>
// (bool)f.presences.
// FirstOrDefault(p => p.systemName == currentSystem.systemname)?.squadronhomesystem || f.squadronfaction);
// if (squadronFaction != null)
// {
// MainWindow.squadronFactionDropDown.SelectedItem = squadronFaction.name;
// }
//}

private void eventSquadronStatus(SquadronStatusEvent theEvent)
{
var configuration = EDDIConfiguration.FromFile();
switch (theEvent.status)
{
case "created":
MainWindow.eddiSquadronNameText.Text = theEvent.name;
MainWindow.squadronRankDropDown.SelectedItem = configuration.SquadronRank.localizedName;
configuration = MainWindow.resetSquadronRank(configuration);
break;
case "joined":
MainWindow.eddiSquadronNameText.Text = theEvent.name;
break;
case "disbanded":
case "kicked":
case "left":
MainWindow.eddiSquadronNameText.Text = string.Empty;
MainWindow.eddiSquadronIDText.Text = string.Empty;
configuration = MainWindow.resetSquadronRank(configuration);
break;
}
}

private void eventSquadronRank(SquadronRankEvent theEvent)
{
var rank = SquadronRank.FromRank(theEvent.newrank + 1);

MainWindow.eddiSquadronNameText.Text = theEvent.name;
MainWindow.squadronRankDropDown.SelectedItem = rank.localizedName;
}
}
}
4 changes: 4 additions & 0 deletions EDDNResponder/EddiEddnResponder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
<Project>{C5F48807-921B-456D-A9E4-A0282E5E8CF1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<Project>{ec7ba042-a370-447f-8c3e-241358cebcbb}</Project>
<Name>Eddi</Name>
Expand Down
4 changes: 4 additions & 0 deletions EDDPMonitor/EddiEddpMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
Expand Down
4 changes: 4 additions & 0 deletions EDSMResponder/EddiEdsmResponder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
Expand Down
Loading