Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/0.5-beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
Finn committed Nov 10, 2017
2 parents ae90518 + fc9bfdf commit b6b5580
Show file tree
Hide file tree
Showing 46 changed files with 1,685 additions and 196 deletions.
50 changes: 28 additions & 22 deletions EliteMFD.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EliteMFD", "EliteMFD\EliteMFD.csproj", "{C9B756A8-9CC7-4034-8B70-7966932C4B0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9B756A8-9CC7-4034-8B70-7966932C4B0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9B756A8-9CC7-4034-8B70-7966932C4B0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9B756A8-9CC7-4034-8B70-7966932C4B0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9B756A8-9CC7-4034-8B70-7966932C4B0C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EliteMFD", "EliteMFD\EliteMFD.csproj", "{43D3540C-49AD-496A-B4A3-CF219EE36FEB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Debug|x64.ActiveCfg = Debug|x64
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Debug|x64.Build.0 = Debug|x64
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Release|Any CPU.Build.0 = Release|Any CPU
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Release|x64.ActiveCfg = Release|x64
{43D3540C-49AD-496A-B4A3-CF219EE36FEB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions EliteMFD/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="EliteMFD.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EliteMFD"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions EliteMFD/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace EliteMFD
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Binary file added EliteMFD/DirectOutputCSharpWrapper.dll
Binary file not shown.
116 changes: 116 additions & 0 deletions EliteMFD/Elite Dangerous/Journal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace EliteMFD.EliteDangerous
{
class Journal
{
protected JournalReader journalReader;
protected FileSystemWatcher fswatcher;

protected DirectoryInfo journalPath;
protected FileInfo journalFile;

protected Action<JournalEntry> callback;

[DllImport("shell32.dll")]
static extern int SHGetKnownFolderPath(
[MarshalAs(UnmanagedType.LPStruct)] Guid rfid,
uint dwFlags,
IntPtr hToken,
out IntPtr pszPath // API uses CoTaskMemAlloc
);

private static Guid folderSavedGames = new Guid("4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4"); //Guid of the SavedGames folder

public Journal(Action<JournalEntry> callback)
{
journalPath = GetJournalPath();

SetupFsWatcher();

// Use most recent file as journal until a new one is created
journalFile = journalPath.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
journalReader = new JournalReader(journalFile, LineRead);

this.callback = callback;
}

/// <summary>
/// Finds the Elite Dangerous journal path
/// </summary>
/// <returns>Journal file location</returns>
private static DirectoryInfo GetJournalPath()
{
if (Environment.OSVersion.Version.Major < 6) throw new NotSupportedException();

IntPtr pszPath = IntPtr.Zero;

if (SHGetKnownFolderPath(folderSavedGames, 0, IntPtr.Zero, out pszPath) == 0)
{
string path = Marshal.PtrToStringUni(pszPath);
Marshal.FreeCoTaskMem(pszPath);
return new DirectoryInfo(Path.Combine(path, "Frontier Developments", "Elite Dangerous"));
}

return null;
}

/// <summary>
/// Sets up the fswatcher to monitor the journal files location and watch for new files and changes
/// </summary>
private void SetupFsWatcher()
{
fswatcher = new FileSystemWatcher();
fswatcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.Size;
fswatcher.Path = journalPath.FullName;
fswatcher.EnableRaisingEvents = true;
fswatcher.Filter = "Journal.*.log";
fswatcher.Created += JournalCreated;
}

/// <summary>
/// Removes existing journalreader and creates a new one on the new file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void JournalCreated(object sender, FileSystemEventArgs e)
{
if (journalReader != null)
{
journalReader.Dispose();
journalReader = null;
}

journalFile = new FileInfo(e.FullPath);

journalReader = new JournalReader(journalFile, LineRead);
}

/// <summary>
/// Creates a journalreader on the changed file if no journalreader exists
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void JournalChanged(object sender, FileSystemEventArgs e)
{
if (journalReader == null)
{
journalFile = new FileInfo(e.FullPath);

journalReader = new JournalReader(journalFile, LineRead);
}
}

/// <summary>
/// Callback function called when a line is read to pass the line to the journalparser
/// </summary>
/// <param name="line">Line to be parsed</param>
private void LineRead(string line)
{
callback(JournalParser.ParseLine(line));
}
}
}
16 changes: 16 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/BountyEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class BountyEntry : JournalEntry
{
#region parameters
public long TotalReward { get; set; }
#endregion

public BountyEntry(JObject entry) : base(entry)
{
TotalReward = entry.Value<long>("TotalReward");
}
}
}
20 changes: 20 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/CommitCrimeEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class CommitCrimeEntry : JournalEntry
{
#region parameters
public string CrimeType { get; set; }
public long? Fine { get; set; }
public long? Bounty { get; set; }
#endregion

public CommitCrimeEntry(JObject entry) : base(entry)
{
CrimeType = entry.Value<string>("CrimeType");
Fine = entry.Value<long?>("Fine");
Bounty = entry.Value<long?>("Bounty");
}
}
}
16 changes: 16 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/DockedEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class DockedEntry : StationInfo
{
#region parameters
public bool CockpitBreach { get; set; }
#endregion

public DockedEntry(JObject entry) : base(entry)
{
CockpitBreach = entry.Value<bool>("CockpitBreach");
}
}
}
16 changes: 16 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/DockingDeniedEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class DockingDeniedEntry : StationInfo
{
#region parameters
public string Reason { get; set; }
#endregion

public DockingDeniedEntry(JObject entry) : base(entry)
{
Reason = entry.Value<string>("Reason");
}
}
}
16 changes: 16 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/DockingGrantedEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class DockingGrantedEntry : StationInfo
{
#region parameters
public int LandingPad { get; set; }
#endregion

public DockingGrantedEntry(JObject entry) : base(entry)
{
LandingPad = entry.Value<int>("LandingPad");
}
}
}
23 changes: 23 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/FSDJumpEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Vector3D;
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class FSDJumpEntry : SystemInfo
{
#region parameters
public double JumpDist { get; set; }
public double FuelUsed { get; set; }
public double FuelLevel { get; set; }
public bool BoostUsed { get; set; }
#endregion

public FSDJumpEntry(JObject entry) : base(entry)
{
JumpDist = entry.Value<double>("JumpDist");
FuelUsed = entry.Value<double>("FuelUsed");
FuelLevel = entry.Value<double>("FuelLevel");
BoostUsed = entry.Value<bool>("BoostUsed");
}
}
}
18 changes: 18 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/FuelScoopEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class FuelScoopEntry : JournalEntry
{
#region parameters
public double Scooped { get; set; }
public double Total { get; set; }
#endregion

public FuelScoopEntry(JObject entry) : base(entry)
{
Scooped = entry.Value<double>("Scooped");
Total = entry.Value<double>("Total");
}
}
}
20 changes: 20 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/HullDamageEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class HullDamageEntry : JournalEntry
{
#region parameters
public double Health { get; set; }
public bool PlayerPilot { get; set; }
public bool Fighter { get; set; }
#endregion

public HullDamageEntry(JObject entry) : base(entry)
{
Health = entry.Value<double>("Health");
PlayerPilot = entry.Value<bool>("PlayerPilot");
Fighter = entry.Value<bool>("Fighter");
}
}
}
16 changes: 16 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/JetConeBoostEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class JetConeBoostEntry : JournalEntry
{
#region parameters
public double BoostValue { get; set; }
#endregion

public JetConeBoostEntry(JObject entry) : base(entry)
{
BoostValue = entry.Value<double>("BoostValue");
}
}
}
19 changes: 19 additions & 0 deletions EliteMFD/Elite Dangerous/JournalEntries/JournalEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Newtonsoft.Json.Linq;

namespace EliteMFD.EliteDangerous
{
class JournalEntry
{
#region parameters
public DateTime Timestamp { get; set; }
public string Event { get; set; }
#endregion

public JournalEntry(JObject entry)
{
Timestamp = DateTime.Parse(entry.Value<string>("timestamp"));
Event = entry.Value<string>("event");
}
}
}
Loading

0 comments on commit b6b5580

Please sign in to comment.