Skip to content

Commit

Permalink
Update events for beta 5.
Browse files Browse the repository at this point in the history
Add event data to VoiceAttack.
  • Loading branch information
mcdee committed Oct 5, 2016
1 parent 689a8e3 commit 2300c8c
Show file tree
Hide file tree
Showing 40 changed files with 525 additions and 157 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -210,3 +210,6 @@ FakesAssemblies/
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# Inno Setup output
Output/
5 changes: 5 additions & 0 deletions CompanionAppService/CompanionAppService.cs
Expand Up @@ -282,6 +282,11 @@ public Profile Profile()
{
var reader = new StreamReader(stream, encoding);
string data = reader.ReadToEnd();
if (data == null || data.Trim() == "")
{
Logging.Warn("No data returned, returning null profile");
return null;
}
Logging.Debug("Data is " + data);
cachedProfile = ProfileFromJson(data);
if (cachedProfile != null)
Expand Down
1 change: 1 addition & 0 deletions DataDefinitions/Material.cs
Expand Up @@ -90,6 +90,7 @@ public static Material FromEDName(string from)
if (result == null)
{
Logging.Report("Unknown material ED name " + from);
result = new Material(from, "Unknown", "Unknown", Rarity.Unknown);
}
return result;
}
Expand Down
1 change: 1 addition & 0 deletions DataDefinitions/Rarity.cs
Expand Up @@ -29,6 +29,7 @@ private Rarity(string edname, int level, string name)
RARITIES.Add(this);
}

public static readonly Rarity Unknown = new Rarity("unknown", 0, "Unknown");
public static readonly Rarity VeryCommon= new Rarity("verycommon", 1, "Very common");
public static readonly Rarity Common = new Rarity("common", 2, "Common");
public static readonly Rarity Standard = new Rarity("standard", 3, "Standard");
Expand Down
Binary file modified EDDI.ico
Binary file not shown.
1 change: 1 addition & 0 deletions EDDI.sln
Expand Up @@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ChangeLog.md = ChangeLog.md
Contributors.md = Contributors.md
images\Directory.jpg = images\Directory.jpg
EDDI.ico = EDDI.ico
Installer.iss = Installer.iss
LICENSE.md = LICENSE.md
images\MainOptions.jpg = images\MainOptions.jpg
Expand Down
174 changes: 112 additions & 62 deletions EDDI/EDDI.cs
Expand Up @@ -31,6 +31,8 @@ public class EDDI
{
private static EDDI instance;

private static bool started;

static EDDI()
{
// Set up our app directory
Expand All @@ -41,7 +43,6 @@ static EDDI()
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
}


private static readonly object instanceLock = new object();
public static EDDI Instance
{
Expand Down Expand Up @@ -92,19 +93,14 @@ protected virtual void OnEvent(Event theEvent)
public StarSystem CurrentStarSystem { get; private set; }
public StarSystem LastStarSystem { get; private set; }

public EDDIConfiguration configuration { get; private set; }

public static readonly string ENVIRONMENT_SUPERCRUISE = "Supercruise";
public static readonly string ENVIRONMENT_NORMAL_SPACE = "Normal space";

private EDDI()
{
try
{
Logging.Info(Constants.EDDI_NAME + " " + Constants.EDDI_VERSION + " starting");

// Set up the EDDI configuration
configuration = EDDIConfiguration.FromFile();
EDDIConfiguration configuration = EDDIConfiguration.FromFile();
Logging.Verbose = configuration.Debug;
if (configuration.HomeSystem != null && configuration.HomeSystem.Trim().Length > 0)
{
Expand Down Expand Up @@ -184,7 +180,7 @@ private EDDI()
}

// We always start in normal space
Environment = ENVIRONMENT_NORMAL_SPACE;
Environment = Constants.ENVIRONMENT_NORMAL_SPACE;

// Set up monitors and responders
monitors = findMonitors();
Expand Down Expand Up @@ -215,72 +211,122 @@ private EDDI()

public void Start()
{
EDDIConfiguration configuration = EDDIConfiguration.FromFile();

foreach (EDDIMonitor monitor in monitors)
if (!started)
{
bool enabled;
if (!configuration.Plugins.TryGetValue(monitor.MonitorName(), out enabled))
{
// No information; default to enabled
enabled = true;
}
EDDIConfiguration configuration = EDDIConfiguration.FromFile();

if (!enabled)
foreach (EDDIMonitor monitor in monitors)
{
Logging.Debug(monitor.MonitorName() + " is disabled; not starting");
}
else
{
Thread monitorThread = new Thread(() => monitor.Start());
monitorThread.IsBackground = true;
monitorThread.Name = monitor.MonitorName();
Logging.Info("Starting " + monitor.MonitorName());
monitorThread.Start();
}
}
bool enabled;
if (!configuration.Plugins.TryGetValue(monitor.MonitorName(), out enabled))
{
// No information; default to enabled
enabled = true;
}

foreach (EDDIResponder responder in responders)
{
bool enabled;
if (!configuration.Plugins.TryGetValue(responder.ResponderName(), out enabled))
{
// No information; default to enabled
enabled = true;
if (!enabled)
{
Logging.Debug(monitor.MonitorName() + " is disabled; not starting");
}
else
{
Thread monitorThread = new Thread(() => monitor.Start());
monitorThread.IsBackground = true;
monitorThread.Name = monitor.MonitorName();
Logging.Info("Starting " + monitor.MonitorName());
monitorThread.Start();
}
}

if (!enabled)
{
Logging.Debug(responder.ResponderName() + " is disabled; not starting");
}
else
foreach (EDDIResponder responder in responders)
{
bool responderStarted = responder.Start();
if (responderStarted)
bool enabled;
if (!configuration.Plugins.TryGetValue(responder.ResponderName(), out enabled))
{
// No information; default to enabled
enabled = true;
}

if (!enabled)
{
EventHandler += new OnEventHandler(responder.Handle);
Logging.Info("Started " + responder.ResponderName());
Logging.Debug(responder.ResponderName() + " is disabled; not starting");
}
else
{
Logging.Warn("Failed to start " + responder.ResponderName());
bool responderStarted = responder.Start();
if (responderStarted)
{
EventHandler += new OnEventHandler(responder.Handle);
Logging.Info("Started " + responder.ResponderName());
}
else
{
Logging.Warn("Failed to start " + responder.ResponderName());
}
}
}
started = true;
}
}

public void Stop()
{
if (started)
{
foreach (EDDIResponder responder in responders)
{
responder.Stop();
}
foreach (EDDIMonitor monitor in monitors)
{
monitor.Stop();
}
}

Logging.Info(Constants.EDDI_NAME + " " + Constants.EDDI_VERSION + " stopped");

started = false;
}

/// <summary>
/// Reload all monitors and responders
/// </summary>
public void Reload()
{
foreach (EDDIResponder responder in responders)
{
responder.Stop();
responder.Reload();
}
foreach (EDDIMonitor monitor in monitors)
{
monitor.Stop();
monitor.Reload();
}

Logging.Info(Constants.EDDI_NAME + " " + Constants.EDDI_VERSION + " shutting down");
Logging.Info(Constants.EDDI_NAME + " " + Constants.EDDI_VERSION + " stopped");
}

/// <summary>
/// Reload a specific monitor or responder
/// </summary>
public void Reload(string name)
{
foreach (EDDIResponder responder in responders)
{
if (responder.ResponderName() == name)
{
responder.Reload();
return;
}
}
foreach (EDDIMonitor monitor in monitors)
{
if (monitor.MonitorName() == name)
{
monitor.Reload();
}
}

Logging.Info(Constants.EDDI_NAME + " " + Constants.EDDI_VERSION + " stopped");
}

public void eventHandler(Event journalEvent)
Expand Down Expand Up @@ -399,7 +445,7 @@ private bool eventJumping(JumpingEvent theEvent)
CurrentStarSystem.lastvisit = DateTime.Now;
StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem);
// After jump we are always in supercruise
Environment = ENVIRONMENT_SUPERCRUISE;
Environment = Constants.ENVIRONMENT_SUPERCRUISE;
setCommanderTitle();
}
return passEvent;
Expand All @@ -423,28 +469,32 @@ private bool eventJumped(JumpedEvent theEvent)
{
passEvent = true;
updateCurrentSystem(theEvent.system);
if (CurrentStarSystem.x == null)
{
// Star system is missing co-ordinates to take them from the event
CurrentStarSystem.x = theEvent.x;
CurrentStarSystem.y = theEvent.y;
CurrentStarSystem.z = theEvent.z;
}

// The information in the event is more up-to-date than the information we obtain from external sources, so update it here
CurrentStarSystem.x = theEvent.x;
CurrentStarSystem.y = theEvent.y;
CurrentStarSystem.z = theEvent.z;
CurrentStarSystem.allegiance = theEvent.allegiance;
CurrentStarSystem.faction = theEvent.faction;
CurrentStarSystem.primaryeconomy = theEvent.economy;
CurrentStarSystem.government = theEvent.government;
CurrentStarSystem.security = theEvent.security;

CurrentStarSystem.visits++;
CurrentStarSystem.lastvisit = DateTime.Now;
StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem);
// After jump we are always in supercruise
Environment = ENVIRONMENT_SUPERCRUISE;
Environment = Constants.ENVIRONMENT_SUPERCRUISE;
setCommanderTitle();
}
return passEvent;
}

private bool eventEnteredSupercruise(EnteredSupercruiseEvent theEvent)
{
if (Environment == null || Environment != ENVIRONMENT_SUPERCRUISE)
if (Environment == null || Environment != Constants.ENVIRONMENT_SUPERCRUISE)
{
Environment = ENVIRONMENT_SUPERCRUISE;
Environment = Constants.ENVIRONMENT_SUPERCRUISE;
updateCurrentSystem(theEvent.system);
return true;
}
Expand All @@ -453,9 +503,9 @@ private bool eventEnteredSupercruise(EnteredSupercruiseEvent theEvent)

private bool eventEnteredNormalSpace(EnteredNormalSpaceEvent theEvent)
{
if (Environment == null || Environment != ENVIRONMENT_NORMAL_SPACE)
if (Environment == null || Environment != Constants.ENVIRONMENT_NORMAL_SPACE)
{
Environment = ENVIRONMENT_NORMAL_SPACE;
Environment = Constants.ENVIRONMENT_NORMAL_SPACE;
updateCurrentSystem(theEvent.system);
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions EDDI/EDDIMonitor.cs
Expand Up @@ -32,6 +32,11 @@ public interface EDDIMonitor
/// </summary>
void Stop();

/// <summary>
/// Called when this monitor needs to reload its configuration
/// </summary>
void Reload();

UserControl ConfigurationTabItem();
}
}
1 change: 1 addition & 0 deletions EDDI/MainWindow.xaml
Expand Up @@ -31,6 +31,7 @@
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" Margin="10" Text="The second group obtain event information. These are the tabs that end in 'monitor'. They obtain events from different places, and require minimal configuration but need to be completed before they will work." VerticalAlignment="Top"/>
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" Margin="10" Text="The third group respond to events. These are the tabs that end in 'responder'. These come with varying degrees of configuration, but will work out of the box." VerticalAlignment="Top"/>
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" Margin="10" Text="Monitors and responders can be enabled individually, although it is recommended that to begin with you leave them all enabled. Once you are comfortable with how EDDI works you can start to alter its behaviour." VerticalAlignment="Top"/>
<TextBlock DockPanel.Dock="Bottom" TextWrapping="Wrap" Margin="10" FontSize="18" Text="Please note that if you are using EDDI with VoiceAttack then you should not have this window running at the same time as VoiceAttack. Carry out your configuration work here, then shut this down and start VoiceAttack." VerticalAlignment="Center" TextAlignment="Center"/>
</DockPanel>
</TabItem>
<TabItem Header="Commander Details">
Expand Down

0 comments on commit 2300c8c

Please sign in to comment.