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 all 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
8 changes: 6 additions & 2 deletions CargoMonitor/EddiCargoMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\EddiApp.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
<Name>EddiApp</Name>
</ProjectReference>
<ProjectReference Include="..\Events\EddiEvents.csproj">
<Project>{2BB41C51-9BE0-49C9-91FD-C4E444994ECE}</Project>
Expand Down
8 changes: 6 additions & 2 deletions CrimeMonitor/EddiCrimeMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\EddiApp.csproj">
<Project>{ec7ba042-a370-447f-8c3e-241358cebcbb}</Project>
<Name>Eddi</Name>
<Name>EddiApp</Name>
</ProjectReference>
<ProjectReference Include="..\Events\EddiEvents.csproj">
<Project>{2bb41c51-9be0-49c9-91fd-c4e444994ece}</Project>
Expand Down
8 changes: 4 additions & 4 deletions EDDI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilities", "Utilities\Util
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EddiJournalMonitor", "JournalMonitor\EddiJournalMonitor.csproj", "{72B6F41D-0107-4D3A-8603-C3EDDA1C5243}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eddi", "EDDI\Eddi.csproj", "{EC7BA042-A370-447F-8C3E-241358CEBCBB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EddiApp", "EDDI\EddiApp.csproj", "{EC7BA042-A370-447F-8C3E-241358CEBCBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EddiEvents", "Events\EddiEvents.csproj", "{2BB41C51-9BE0-49C9-91FD-C4E444994ECE}"
EndProject
Expand Down Expand Up @@ -238,9 +238,9 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
RESX_TaskErrorCategory = Message
RESX_AutoCreateNewLanguageFiles = True
RESX_ShowErrorsInErrorList = False
SolutionGuid = {28C2EDB6-0FA0-409F-987C-7A24F542D0CF}
RESX_ShowErrorsInErrorList = False
RESX_AutoCreateNewLanguageFiles = True
RESX_TaskErrorCategory = Message
EndGlobalSection
EndGlobal
10 changes: 5 additions & 5 deletions EDDI/Eddi.csproj → EDDI/EddiApp.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
148 changes: 148 additions & 0 deletions EDDI/MainWindowResponder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using EddiCore;
using EddiDataDefinitions;
using EddiEvents;
using System.Collections.Generic;
using System.Linq;
using System.Windows;

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;
}
}
}
8 changes: 6 additions & 2 deletions EDDNResponder/EddiEddnResponder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@
<Project>{C5F48807-921B-456D-A9E4-A0282E5E8CF1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\EddiApp.csproj">
<Project>{ec7ba042-a370-447f-8c3e-241358cebcbb}</Project>
<Name>Eddi</Name>
<Name>EddiApp</Name>
</ProjectReference>
<ProjectReference Include="..\Events\EddiEvents.csproj">
<Project>{2BB41C51-9BE0-49C9-91FD-C4E444994ECE}</Project>
Expand Down
8 changes: 6 additions & 2 deletions EDDPMonitor/EddiEddpMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@
<Project>{c5f48807-921b-456d-a9e4-a0282e5e8cf1}</Project>
<Name>EddiDataProviderService</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\EddiApp.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
<Name>EddiApp</Name>
</ProjectReference>
<ProjectReference Include="..\Events\EddiEvents.csproj">
<Project>{2bb41c51-9be0-49c9-91fd-c4e444994ece}</Project>
Expand Down
8 changes: 6 additions & 2 deletions EDSMResponder/EddiEdsmResponder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EDDI\Eddi.csproj">
<ProjectReference Include="..\EddiCore\EddiCore.csproj">
<Project>{28dc25d7-4dfd-4a77-b4ff-b9badb711ecb}</Project>
<Name>EddiCore</Name>
</ProjectReference>
<ProjectReference Include="..\EDDI\EddiApp.csproj">
<Project>{EC7BA042-A370-447F-8C3E-241358CEBCBB}</Project>
<Name>Eddi</Name>
<Name>EddiApp</Name>
</ProjectReference>
<ProjectReference Include="..\DataDefinitions\EddiDataDefinitions.csproj">
<Project>{0C845B02-E283-43D8-91A7-205AD3397371}</Project>
Expand Down
Loading