Add project files.
This commit is contained in:
parent
ac7029146f
commit
5d3af78a69
6
App.config
Normal file
6
App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
9
App.xaml
Normal file
9
App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="NonaBGSApplication"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:NonaBGS"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
18
App.xaml.cs
Normal file
18
App.xaml.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class NonaBGSApplication : Application
|
||||
{
|
||||
}
|
||||
}
|
38
BGS/Cartographics.cs
Normal file
38
BGS/Cartographics.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class Cartographics : LogEntry {
|
||||
public Cartographics(MultiSellExplorationDataEntry e, string current_system, string current_station) {
|
||||
this.Entries.Add(e);
|
||||
this.System = current_system;
|
||||
this.Station = current_station;
|
||||
}
|
||||
|
||||
public int TotalSum {
|
||||
get {
|
||||
return (from entry in Entries
|
||||
where entry.Is(Events.MultiSellExplorationData)
|
||||
select (entry as MultiSellExplorationDataEntry).TotalEarnings)
|
||||
.Sum()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.AppendFormat("Sold {0} CR worth of Cartographics Data", TotalSum);
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cartographics only help the controlling faction.
|
||||
/// </summary>
|
||||
public override bool OnlyControllingFaction => true;
|
||||
}
|
||||
}
|
11
BGS/CombatZone.cs
Normal file
11
BGS/CombatZone.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class CombatZone {
|
||||
private int level;
|
||||
}
|
||||
}
|
11
BGS/DiscordLogGenerator.cs
Normal file
11
BGS/DiscordLogGenerator.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public interface IDiscordLogGenerator {
|
||||
string GenerateDiscordLog(Report report);
|
||||
}
|
||||
}
|
24
BGS/LogEntry.cs
Normal file
24
BGS/LogEntry.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class LogEntry {
|
||||
private List<Entry> entries = new List<Entry>();
|
||||
|
||||
public List<Entry> Entries => entries;
|
||||
public string Station { get; set; }
|
||||
public string System { get; set; }
|
||||
public string Faction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this entry only benefits the controlling faction or not, default: no
|
||||
/// </summary>
|
||||
public virtual bool OnlyControllingFaction {
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
42
BGS/MissionCompleted.cs
Normal file
42
BGS/MissionCompleted.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class MissionCompleted : LogEntry {
|
||||
public MissionCompleted(MissionCompletedEntry e, string system, string station) {
|
||||
this.Entries.Add(e);
|
||||
this.Faction = e.JSON.GetValue("Faction").ToString();
|
||||
this.System = system;
|
||||
this.Station = station;
|
||||
}
|
||||
|
||||
public string MissionName {
|
||||
get { return (Entries[0] as MissionCompletedEntry).HumanReadableName; }
|
||||
}
|
||||
|
||||
public string Influence {
|
||||
get { return (Entries[0] as MissionCompletedEntry).GetInfluenceForFaction(Faction); }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
if (Entries.Count <= 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var entry = Entries[0] as MissionCompletedEntry;
|
||||
var influence = entry.GetInfluenceForFaction(Faction);
|
||||
|
||||
builder.AppendFormat("{0}", entry.HumanReadableName);
|
||||
if (influence != "") {
|
||||
builder.AppendFormat(", Influence: {0}", influence);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
158
BGS/NonaDiscordLog.cs
Normal file
158
BGS/NonaDiscordLog.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class NonaDiscordLog : IDiscordLogGenerator {
|
||||
private string FormatDate() {
|
||||
StringBuilder date = new StringBuilder();
|
||||
DateTime today = DateTime.Now;
|
||||
string suffix;
|
||||
|
||||
if (today.Day == 1 || today.Day == 21 || today.Day == 31) {
|
||||
suffix = "st";
|
||||
} else if (today.Day == 2 || today.Day == 22) {
|
||||
suffix = "nd";
|
||||
} else {
|
||||
suffix = "th";
|
||||
}
|
||||
|
||||
date.AppendFormat("{0} {1}{2}, {3}",
|
||||
today.ToString("MMMM"), today.Day, suffix,
|
||||
today.Year + EliteDangerous.YearOffset
|
||||
);
|
||||
|
||||
return date.ToString();
|
||||
}
|
||||
|
||||
private string BuildCartoGraphics(Objective objective) {
|
||||
var total = from entries in objective.LogEntries
|
||||
where entries.GetType() == typeof(Cartographics)
|
||||
select entries
|
||||
;
|
||||
var pages = total.Count();
|
||||
var sum = total.Sum(x => (x as Cartographics).TotalSum);
|
||||
|
||||
if (pages <= 0 || sum <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return string.Format("Sold {0} page(s) worth of universal cartographics\n" +
|
||||
"(Total value: {1} CR)\n", pages, sum);
|
||||
}
|
||||
|
||||
private string BuildMicroResourcesSold(Objective objective) {
|
||||
var total = from entries in objective.LogEntries
|
||||
where entries.GetType() == typeof(SellMicroResources)
|
||||
select entries
|
||||
;
|
||||
var sum = total.Sum(x => (x as SellMicroResources).TotalSum);
|
||||
|
||||
if (sum <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return string.Format("Sold {0} CR worth of Micro Resources\n", sum);
|
||||
}
|
||||
|
||||
private string BuildVouchers(Objective objective) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var missions = from entries in objective.LogEntries
|
||||
where entries.GetType() == typeof(Vouchers)
|
||||
select entries
|
||||
;
|
||||
|
||||
if (missions == null || missions.Count() <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (var mission in missions) {
|
||||
var m = mission as Vouchers;
|
||||
builder.AppendFormat("Handed in {0} vouchers for {1}\n", m.Type, m.Faction);
|
||||
builder.AppendFormat("(Total value: {0} CR)\n", m.TotalSum);
|
||||
builder.AppendFormat("\n");
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private string BuildMissionList(Objective objective) {
|
||||
Dictionary<string, Dictionary<string, int>> collated = new Dictionary<string, Dictionary<string, int>>();
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
var missions = from entries in objective.LogEntries
|
||||
where entries.GetType() == typeof(MissionCompleted)
|
||||
select entries
|
||||
;
|
||||
|
||||
if (missions == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
foreach (MissionCompleted m in missions) {
|
||||
if (!collated.ContainsKey(m.MissionName)) {
|
||||
collated[m.MissionName] = new Dictionary<string, int>();
|
||||
}
|
||||
if (!collated[m.MissionName].ContainsKey(m.Influence)) {
|
||||
collated[m.MissionName][m.Influence] = 0;
|
||||
}
|
||||
|
||||
++collated[m.MissionName][m.Influence];
|
||||
}
|
||||
|
||||
foreach (var mission in collated) {
|
||||
if (objective.Faction != null) {
|
||||
output.AppendFormat("{0} for {1}\n", mission.Key, objective.Faction);
|
||||
} else {
|
||||
output.AppendFormat("{0}\n", mission.Key);
|
||||
}
|
||||
output.Append("(");
|
||||
foreach (var influence in mission.Value.OrderBy(x => x.Key.Length)) {
|
||||
output.AppendFormat("Inf{0} x{1}, ", influence.Key, influence.Value);
|
||||
}
|
||||
output.Remove(output.Length - 2, 2); // remove last ", "
|
||||
output.Append(")\n\n");
|
||||
}
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
|
||||
public string GenerateDiscordLog(Report report) {
|
||||
StringBuilder log = new StringBuilder();
|
||||
|
||||
log.AppendFormat(":clock2: `Date:` {0}\n", FormatDate());
|
||||
foreach (var objective in report.Objectives) {
|
||||
if (objective.LogEntries.Count <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
log.AppendFormat(":globe_with_meridians: `Location:` {0}\n", objective.ToShortString());
|
||||
log.Append(":clipboard: `Conducted:`\n");
|
||||
log.Append("```\n");
|
||||
|
||||
StringBuilder entries = new StringBuilder();
|
||||
|
||||
var missions = BuildMissionList(objective);
|
||||
entries.Append(missions);
|
||||
|
||||
var vouchers = BuildVouchers(objective);
|
||||
entries.Append(vouchers);
|
||||
|
||||
var carto = BuildCartoGraphics(objective);
|
||||
entries.Append(carto);
|
||||
|
||||
var micro = BuildMicroResourcesSold(objective);
|
||||
entries.Append(micro);
|
||||
|
||||
log.Append(entries.ToString().Trim());
|
||||
log.Append("\n```\n");
|
||||
}
|
||||
|
||||
return log.ToString();
|
||||
}
|
||||
}
|
||||
}
|
103
BGS/Objective.cs
Normal file
103
BGS/Objective.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class Objective {
|
||||
private string system;
|
||||
private string station;
|
||||
private string faction;
|
||||
|
||||
private List<LogEntry> entries = new List<LogEntry>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<LogEntry> LogEntries {
|
||||
get => entries;
|
||||
set => entries = value;
|
||||
}
|
||||
|
||||
public int Matches(LogEntry e) {
|
||||
int match_count = 0;
|
||||
|
||||
if (e.OnlyControllingFaction) {
|
||||
if (Faction == null || (e.Faction != Faction)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.System != null && system != null &&
|
||||
e.System == system) {
|
||||
++match_count;
|
||||
}
|
||||
|
||||
if (e.Station != null && station != null &&
|
||||
e.Station == station) {
|
||||
++match_count;
|
||||
}
|
||||
|
||||
if (e.Faction != null && faction != null &&
|
||||
e.Faction == faction) {
|
||||
++match_count;
|
||||
}
|
||||
|
||||
return match_count;
|
||||
}
|
||||
|
||||
public int CompareTo(Objective other) {
|
||||
return (other.System == System &&
|
||||
other.Station == Station &&
|
||||
other.Faction == Faction) ? 0 : -1;
|
||||
}
|
||||
|
||||
public bool IsValid => System != null && Faction != null;
|
||||
|
||||
public string System {
|
||||
get { return system; }
|
||||
set { system = value; }
|
||||
}
|
||||
|
||||
public string Station {
|
||||
get { return station; }
|
||||
set { station = value; }
|
||||
}
|
||||
|
||||
public string Faction {
|
||||
get { return faction; }
|
||||
set { faction = value; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
if (system != null && system.Length > 0) {
|
||||
str.AppendFormat("System: {0}", system);
|
||||
}
|
||||
if (station != null && station.Length > 0) {
|
||||
if (str.Length > 0) {
|
||||
str.Append(", ");
|
||||
}
|
||||
str.AppendFormat("Station: {0}", station);
|
||||
}
|
||||
if (faction != null && faction.Length > 0) {
|
||||
if (str.Length > 0) {
|
||||
str.Append(", ");
|
||||
}
|
||||
str.AppendFormat("Faction: {0}", faction);
|
||||
}
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
public string ToShortString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
if (system != null && system.Length > 0) {
|
||||
str.AppendFormat("{0}", system);
|
||||
}
|
||||
if (station != null && station.Length > 0) {
|
||||
if (str.Length > 0) {
|
||||
str.Append(", ");
|
||||
}
|
||||
str.AppendFormat("{0}", station);
|
||||
}
|
||||
return str.ToString();
|
||||
}
|
||||
}
|
||||
}
|
121
BGS/Report.cs
Normal file
121
BGS/Report.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class Report {
|
||||
private List<Objective> objectives = new List<Objective>();
|
||||
|
||||
public delegate void OnLogDelegate(string log);
|
||||
|
||||
public event OnLogDelegate OnLog;
|
||||
|
||||
public List<Objective> Objectives {
|
||||
get { return objectives; }
|
||||
set { objectives = value; }
|
||||
}
|
||||
|
||||
public bool AddObjective(Objective objective) {
|
||||
var found = objectives.Find(x => x == objective);
|
||||
bool added = false;
|
||||
|
||||
if (found == null) {
|
||||
objectives.Add(objective);
|
||||
added = true;
|
||||
}
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
private bool IsRelevant(Entry e) {
|
||||
return e.Is(Events.MissionCompleted) ||
|
||||
e.Is(Events.Docked) ||
|
||||
e.Is(Events.FSDJump) ||
|
||||
e.Is(Events.MultiSellExplorationData) ||
|
||||
e.Is(Events.SellMicroResources) ||
|
||||
e.Is(Events.RedeemVoucher)
|
||||
;
|
||||
}
|
||||
|
||||
public void Scan(PlayerJournal journal, DateTime start, DateTime end) {
|
||||
var entries = from file in journal.Files
|
||||
where file.NormalisedTimestamp >= start && file.NormalisedTimestamp <= end
|
||||
select file.Entries
|
||||
;
|
||||
var relevant = from log in entries.SelectMany(array => array)
|
||||
where IsRelevant(log)
|
||||
select log
|
||||
;
|
||||
|
||||
string current_system = null;
|
||||
string current_station = null;
|
||||
string controlling_faction = null;
|
||||
|
||||
this.objectives.ForEach(x => x.LogEntries.Clear());
|
||||
|
||||
foreach (var e in relevant) {
|
||||
LogEntry entry = null;
|
||||
|
||||
if (e.Is(Events.Docked)) {
|
||||
/* gleem the current station from this message
|
||||
*/
|
||||
current_station = (e as DockedEntry).StationName;
|
||||
} else if (e.Is(Events.FSDJump)) {
|
||||
current_system = (e as FSDJumpEntry).StarSystem;
|
||||
controlling_faction = (e as FSDJumpEntry).SystemFaction;
|
||||
} else if (e.Is(Events.MissionCompleted)) {
|
||||
var completed = e as MissionCompletedEntry;
|
||||
entry = new MissionCompleted(completed, current_system, current_station);
|
||||
if (completed.HumanReadableNameWasGenerated) {
|
||||
OnLog?.Invoke("Human readable name for mission \"" +
|
||||
completed.Name +
|
||||
"\" was generated, please report this.");
|
||||
}
|
||||
} else if (e.Is(Events.MultiSellExplorationData)) {
|
||||
entry = new Cartographics(e as MultiSellExplorationDataEntry, current_system, current_station);
|
||||
entry.Faction = controlling_faction;
|
||||
} else if (e.Is(Events.RedeemVoucher)) {
|
||||
entry = new Vouchers();
|
||||
entry.Entries.Add(e);
|
||||
entry.System = current_system;
|
||||
entry.Station = current_station;
|
||||
entry.Faction = controlling_faction;
|
||||
} else if (e.Is(Events.SellMicroResources)) {
|
||||
entry = new SellMicroResources(current_system, current_station);
|
||||
entry.Entries.Add(e);
|
||||
}
|
||||
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var matches = objectives
|
||||
.Where(x => x.Matches(entry) > 0)
|
||||
.OrderBy(x => x.Matches(entry))
|
||||
;
|
||||
if (matches == null || matches.Count() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var objective = matches
|
||||
.OrderBy(x => x.Matches(entry))
|
||||
.Reverse()
|
||||
.First()
|
||||
;
|
||||
|
||||
if (objective != null) {
|
||||
objective.LogEntries.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Scan(PlayerJournal journal) {
|
||||
Scan(journal, DateTime.Now, DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
28
BGS/SellMicroResources.cs
Normal file
28
BGS/SellMicroResources.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class SellMicroResources : LogEntry {
|
||||
public SellMicroResources(string system, string station) {
|
||||
System = system;
|
||||
Station = Station;
|
||||
}
|
||||
|
||||
public int TotalSum {
|
||||
get {
|
||||
return Entries
|
||||
.Where(x => x.GetType() == typeof(SellMicroResourcesEntry))
|
||||
.Sum(x => (x as SellMicroResourcesEntry).Price)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Sell Micro Resources: {0} CR", TotalSum);
|
||||
}
|
||||
}
|
||||
}
|
44
BGS/Vouchers.cs
Normal file
44
BGS/Vouchers.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NonaBGS.Journal;
|
||||
|
||||
namespace NonaBGS.BGS {
|
||||
public class Vouchers : LogEntry {
|
||||
|
||||
public int TotalSum {
|
||||
get {
|
||||
return Entries
|
||||
.Where(x => x.GetType() == typeof(RedeemVoucherEntry))
|
||||
.Sum(x => (x as RedeemVoucherEntry).Amount)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public string Type {
|
||||
get {
|
||||
string v = Entries
|
||||
.Where(x => x.GetType() == typeof(RedeemVoucherEntry))
|
||||
.GroupBy(x => (x as RedeemVoucherEntry).Type)
|
||||
.Select(x => x.Key)
|
||||
.First();
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.AppendFormat("{0} Vouchers: {1} CR", TotalSum, Type);
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vouchers only help the controlling faction
|
||||
/// </summary>
|
||||
public override bool OnlyControllingFaction => true;
|
||||
}
|
||||
}
|
13
Journal/DockedEntry.cs
Normal file
13
Journal/DockedEntry.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class DockedEntry : Entry {
|
||||
public string StationName {
|
||||
get { return JSON.GetValue("StationName").ToString(); }
|
||||
}
|
||||
}
|
||||
}
|
15
Journal/EliteDangerous.cs
Normal file
15
Journal/EliteDangerous.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class EliteDangerous {
|
||||
/// <summary>
|
||||
/// The ingame universe is 1286 years in the future. This is needed to convert dates
|
||||
/// and times to ingame dates and times
|
||||
/// </summary>
|
||||
public static readonly int YearOffset = 1286;
|
||||
}
|
||||
}
|
88
Journal/Entry.cs
Normal file
88
Journal/Entry.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
/// <summary>
|
||||
/// Base class for a single entry within the player journal. If no specific sub class is available
|
||||
/// this class gives basic information, such as EventType or date when it happened. It also allows
|
||||
/// base classes access to the underlying JSON object. Base classes should be named after the event
|
||||
/// type that they map + Entry. So "FSDJump" event is handled by FSDJumpEntry.
|
||||
/// </summary>
|
||||
public class Entry {
|
||||
private static readonly Dictionary<string, Type> classes = new Dictionary<string, Type> {
|
||||
{ Events.Docked, typeof(DockedEntry) },
|
||||
{ Events.FSDJump, typeof(FSDJumpEntry) },
|
||||
{ Events.MissionCompleted, typeof(MissionCompletedEntry) },
|
||||
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
|
||||
{ Events.MarketSell, typeof(MarketSellEntry) },
|
||||
{ Events.SellMicroResources, typeof(SellMicroResourcesEntry) },
|
||||
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
|
||||
};
|
||||
|
||||
private string eventtype = null;
|
||||
private string datetime = null;
|
||||
private DateTime timestamp;
|
||||
|
||||
private string jsonstr = null;
|
||||
protected JObject json = null;
|
||||
|
||||
public Entry() {
|
||||
}
|
||||
|
||||
public static Entry Parse(string journalline) {
|
||||
var json = JObject.Parse(journalline);
|
||||
return Parse(json);
|
||||
}
|
||||
|
||||
public static Entry Parse(JObject json) {
|
||||
string event_name = json.GetValue("event").ToString();
|
||||
|
||||
classes.TryGetValue(event_name, out Type classhandler);
|
||||
if (classhandler == null) {
|
||||
classhandler = typeof(Entry);
|
||||
}
|
||||
|
||||
var obj = (Entry)Activator.CreateInstance(classhandler);
|
||||
obj.InternalInitialise(json);
|
||||
obj.Initialise();
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void InternalInitialise(JObject jobject) {
|
||||
this.json = jobject;
|
||||
this.jsonstr = json.ToString(formatting: Formatting.None);
|
||||
|
||||
this.eventtype = json.GetValue("event").ToString();
|
||||
this.datetime = json.GetValue("timestamp").ToString();
|
||||
this.timestamp = DateTime.Parse(this.datetime);
|
||||
}
|
||||
|
||||
protected virtual void Initialise() {
|
||||
}
|
||||
|
||||
public bool Is(string eventtype) {
|
||||
if (eventtype == null || this.eventtype == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return String.Equals(this.eventtype, eventtype, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public string Event {
|
||||
get { return eventtype; }
|
||||
}
|
||||
|
||||
public DateTime Timestamp {
|
||||
get { return timestamp; }
|
||||
}
|
||||
|
||||
public JObject JSON {
|
||||
get { return this.json; }
|
||||
}
|
||||
}
|
||||
}
|
17
Journal/Events.cs
Normal file
17
Journal/Events.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class Events {
|
||||
public static readonly string MissionCompleted = "MissionCompleted";
|
||||
public static readonly string Docked = "Docked";
|
||||
public static readonly string FSDJump = "FSDJump";
|
||||
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
|
||||
public static readonly string MarketSell = "MarketSell";
|
||||
public static readonly string SellMicroResources = "SellMicroResources";
|
||||
public static readonly string RedeemVoucher = "RedeemVoucher";
|
||||
}
|
||||
}
|
23
Journal/FSDJumpEntry.cs
Normal file
23
Journal/FSDJumpEntry.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class FSDJumpEntry : Entry {
|
||||
private string starsystem = null;
|
||||
private string systemfaction = null;
|
||||
protected override void Initialise() {
|
||||
starsystem = JSON.Value<string>("StarSystem");
|
||||
var faction = JSON.Value<JObject>("SystemFaction");
|
||||
if (faction != null) {
|
||||
systemfaction = faction.Value<string>("Name");
|
||||
}
|
||||
}
|
||||
public string StarSystem => starsystem;
|
||||
|
||||
public string SystemFaction => systemfaction;
|
||||
}
|
||||
}
|
11
Journal/JournalException.cs
Normal file
11
Journal/JournalException.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class JournalException : Exception {
|
||||
public JournalException(string message) : base(message) {
|
||||
}
|
||||
}
|
||||
}
|
112
Journal/JournalFile.cs
Normal file
112
Journal/JournalFile.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace NonaBGS.Journal
|
||||
{
|
||||
public class JournalFile : IComparable<JournalFile>
|
||||
{
|
||||
private string fullpath = null;
|
||||
private string part = null;
|
||||
private int intpart = 0;
|
||||
private DateTime datetime;
|
||||
private DateTime normalised;
|
||||
private List<Entry> entries = new List<Entry>();
|
||||
|
||||
private static Regex fileregex = new Regex("Journal\\.(\\d+)\\.(\\d+)\\.log");
|
||||
private static string iso8601 = "yyyyMMddTHHmmss";
|
||||
private static string iso8601_notime = "yyyyMMdd";
|
||||
|
||||
private void SetFilename(string path) {
|
||||
string filename = Path.GetFileName(path);
|
||||
if (!File.Exists(path) || filename == null) {
|
||||
throw new JournalException(string.Format("Invalid journal file: {0}", filename));
|
||||
}
|
||||
|
||||
var matches = fileregex.Matches(filename);
|
||||
if (matches.Count < 1) {
|
||||
throw new JournalException(string.Format("Invalid journal file: {0}", filename));
|
||||
}
|
||||
|
||||
this.fullpath = path;
|
||||
this.part = matches[0].Groups[2].ToString();
|
||||
this.intpart = int.Parse(part);
|
||||
// The ISO is not quite correct on journal filenames, so build
|
||||
// a proper ISO 8601 date time stamp out of it.
|
||||
var date = new StringBuilder();
|
||||
date.Append("20"); // Add the missing century in front.
|
||||
date.Append(matches[0].Groups[1].ToString());
|
||||
date.Insert(8, "T"); // Add the "T" separating date and time
|
||||
this.datetime = DateTime.ParseExact(date.ToString(), iso8601, CultureInfo.InvariantCulture);
|
||||
this.normalised = DateTime.Parse(this.datetime.ToShortDateString());
|
||||
}
|
||||
|
||||
public int CompareTo(JournalFile other) {
|
||||
if (datetime == null || other.datetime == null) {
|
||||
return 0;
|
||||
}
|
||||
var comp = DateTime.Compare(datetime, other.datetime);
|
||||
if (comp == 0) {
|
||||
/* If we have the exact same datetime we compare by parts.
|
||||
*/
|
||||
return intpart - other.intpart;
|
||||
} else {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
public JournalFile(string path) {
|
||||
SetFilename(path);
|
||||
}
|
||||
|
||||
public DateTime Timestamp {
|
||||
get { return datetime; }
|
||||
}
|
||||
|
||||
public DateTime NormalisedTimestamp {
|
||||
get { return normalised; }
|
||||
}
|
||||
|
||||
public int Part {
|
||||
get { return intpart; }
|
||||
}
|
||||
|
||||
public IEnumerable<Entry> Entries {
|
||||
get {
|
||||
if (entries == null || entries.Count == 0) {
|
||||
try {
|
||||
LoadEntries();
|
||||
} catch (IOException) {
|
||||
entries = new List<Entry>();
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadEntries() {
|
||||
List<string> lines = new List<string>();
|
||||
|
||||
/* This needs to be done this way, otherwise, if the game is still running the journal files cannot
|
||||
* be accessed. And it is very much convenient to generate logs while the game is still running.
|
||||
*/
|
||||
using (var fs = new FileStream(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
|
||||
using (var sr = new StreamReader(fs, Encoding.UTF8)) {
|
||||
string line = null;
|
||||
while ((line = sr.ReadLine()) != null) {
|
||||
lines.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entries.Clear();
|
||||
foreach(var line in lines) {
|
||||
Entry entry = Entry.Parse(line);
|
||||
entries.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
Journal/MarketSellEntry.cs
Normal file
17
Journal/MarketSellEntry.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class MarketSellEntry : Entry {
|
||||
private int totalsale = 0;
|
||||
|
||||
protected override void Initialise() {
|
||||
totalsale = JSON.Value<int>("TotalSale");
|
||||
}
|
||||
|
||||
public int TotalSale => totalsale;
|
||||
}
|
||||
}
|
146
Journal/MissionCompletedEntry.cs
Normal file
146
Journal/MissionCompletedEntry.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class MissionCompletedEntry : Entry {
|
||||
private Dictionary<string, string> influences = new Dictionary<string, string>();
|
||||
private string readable_name = null;
|
||||
private bool readable_name_generated = false;
|
||||
private string name = null;
|
||||
private string commodity = null;
|
||||
private int count = 0;
|
||||
private int donated = 0;
|
||||
|
||||
private readonly Dictionary<string, string> humanreadable = new Dictionary<string, string> {
|
||||
{ "Mission_AltruismCredits_name", "Donate Credits" },
|
||||
{ "Mission_Collect_name", "Collect" },
|
||||
{ "Mission_Courier_Elections_name", "Courier (Elections)" },
|
||||
{ "Mission_Courier_name", "Courier" },
|
||||
{ "Mission_Courier_RankEmp_name", "Courier (Empire)" },
|
||||
{ "Mission_Delivery_Boom_name", "Delivery (Boom)" },
|
||||
{ "Mission_Delivery_Retreat_name", "Delivery (Retreat)" },
|
||||
{ "Mission_Delivery_name", "Delivery" },
|
||||
{ "Mission_Delivery_Agriculture_name", "Delivery (Agriculture)" },
|
||||
{ "Mission_HackMegaship_name", "Hack Megaship" },
|
||||
{ "Mission_MassacreWing_name", "Massacre (Wing)" },
|
||||
{ "Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught" },
|
||||
{ "Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore" },
|
||||
{ "Mission_OnFoot_Reboot_MB_name", "On Foot Reboot" },
|
||||
{ "Mission_Rescue_Planet_name", "Planet Rescue" },
|
||||
{ "Mission_Salvage_name", "Salvage" },
|
||||
{ "MISSION_Salvage_Illegal_name", "Salvage (Illegal)" },
|
||||
{ "MISSION_Salvage_Retreat_name", "Salvage (Retreat)" },
|
||||
{ "MISSION_Salvage_Expansion_name", "Salvage (Expansion)" },
|
||||
{ "Mission_Salvage_RankEmp_name", "Salvage (Imperial Navy)" },
|
||||
{ "MISSION_Scan_name", "Scan" },
|
||||
};
|
||||
|
||||
protected override void Initialise() {
|
||||
MakeHumanReadableName();
|
||||
name = JSON.Value<string>("Name");
|
||||
if (JSON.ContainsKey("Commodity_Localised")) {
|
||||
commodity = JSON.Value<string>("Commodity_Localised");
|
||||
}
|
||||
if (JSON.ContainsKey("Count")) {
|
||||
count = JSON.Value<int>("Count");
|
||||
}
|
||||
if (JSON.ContainsKey("Donated")) {
|
||||
donated = JSON.Value<int>("Donated");
|
||||
}
|
||||
}
|
||||
|
||||
public string Name => name;
|
||||
public string Commodity => commodity;
|
||||
public int Count => count;
|
||||
|
||||
private void MakeHumanReadableName() {
|
||||
if (readable_name != null && readable_name.Length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
if (humanreadable.ContainsKey(Name)) {
|
||||
builder = new StringBuilder(humanreadable[Name]);
|
||||
readable_name_generated = false;
|
||||
} else {
|
||||
builder = new StringBuilder(Name);
|
||||
builder.Replace("Mission_", "");
|
||||
builder.Replace("_name", "");
|
||||
builder.Replace("_MB", "");
|
||||
builder.Replace('_', ' ');
|
||||
builder.Replace("Illegal", " (Illegal)");
|
||||
builder.Replace("OnFoot", "On Foot");
|
||||
builder.Replace(" BS", "");
|
||||
builder.Replace("HackMegaship", "Hack Megaship");
|
||||
builder.Replace("Boom", "");
|
||||
builder.Replace("RebootRestore", "Reboot/Restore");
|
||||
builder.Replace("CivilLiberty", "");
|
||||
readable_name_generated = true;
|
||||
}
|
||||
|
||||
if (count > 0 && commodity != null) {
|
||||
builder.AppendFormat(" ({0} {1})", count, commodity);
|
||||
}
|
||||
|
||||
if (donated > 0) {
|
||||
builder.AppendFormat(" ({0} CR)", donated);
|
||||
}
|
||||
|
||||
readable_name = builder.ToString().Trim();
|
||||
}
|
||||
|
||||
public string HumanReadableName {
|
||||
get {
|
||||
MakeHumanReadableName();
|
||||
return readable_name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HumanReadableNameWasGenerated {
|
||||
get {
|
||||
MakeHumanReadableName();
|
||||
return readable_name_generated;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetInfluenceForFaction(string faction) {
|
||||
if (influences.ContainsKey(faction)) {
|
||||
return influences[faction];
|
||||
}
|
||||
|
||||
var effects = JSON.Value<JArray>("FactionEffects");
|
||||
foreach (var effect in effects.Children<JObject>()) {
|
||||
if (effect.GetValue("Faction").ToString() != faction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var influence = effect.Value<JArray>("Influence");
|
||||
if (influence == null || influence.Count == 0) {
|
||||
// No influence reward, happens on courier missions sometimes.
|
||||
// There is always one point of rep, even if the mission won't state it
|
||||
influences.Add(faction, "+");
|
||||
}
|
||||
|
||||
foreach (var infl in influence.Children<JObject>()) {
|
||||
infl.TryGetValue("Influence", out JToken result);
|
||||
if (result != null && result.Type == JTokenType.String) {
|
||||
influences.Add(faction, result.ToString());
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
17
Journal/MultiSellExplorationDataEntry.cs
Normal file
17
Journal/MultiSellExplorationDataEntry.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class MultiSellExplorationDataEntry : Entry {
|
||||
private int totalearnings = 0;
|
||||
|
||||
protected override void Initialise() {
|
||||
totalearnings = JSON.Value<int>("TotalEarnings");
|
||||
}
|
||||
|
||||
public int TotalEarnings => totalearnings;
|
||||
}
|
||||
}
|
56
Journal/PlayerJournal.cs
Normal file
56
Journal/PlayerJournal.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class PlayerJournal {
|
||||
public static string DefaultPath = "%UserProfile%\\Saved Games\\Frontier Developments\\Elite Dangerous";
|
||||
|
||||
private List<JournalFile> journalfiles = new List<JournalFile>();
|
||||
private string basepath = null;
|
||||
|
||||
public PlayerJournal() {
|
||||
Initialise(DefaultPath);
|
||||
}
|
||||
|
||||
public PlayerJournal(string path) {
|
||||
Initialise(path);
|
||||
}
|
||||
|
||||
private void Initialise(string path) {
|
||||
basepath = Environment.ExpandEnvironmentVariables(path);
|
||||
}
|
||||
|
||||
public List<JournalFile> Files {
|
||||
get { return journalfiles; }
|
||||
}
|
||||
|
||||
public void Open() {
|
||||
if (!Directory.Exists(basepath)) {
|
||||
throw new JournalException("Invalid base path, path could not be found");
|
||||
}
|
||||
this.ScanFiles();
|
||||
}
|
||||
|
||||
public void ScanFiles() {
|
||||
var files = Directory.EnumerateFiles(basepath);
|
||||
|
||||
journalfiles.Clear();
|
||||
|
||||
foreach (var file in files) {
|
||||
string full = Path.Combine(basepath, file);
|
||||
try {
|
||||
JournalFile journalfile = new JournalFile(full);
|
||||
journalfiles.Add(journalfile);
|
||||
} catch (JournalException) {
|
||||
/* invalid journal file, or one of the other json files in there */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
journalfiles.Sort();
|
||||
}
|
||||
}
|
||||
}
|
19
Journal/RedeemVoucherEntry.cs
Normal file
19
Journal/RedeemVoucherEntry.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class RedeemVoucherEntry : Entry {
|
||||
private int amount = 0;
|
||||
private string type = null;
|
||||
protected override void Initialise() {
|
||||
amount = JSON.Value<int>("Amount");
|
||||
type = JSON.Value<string>("Type");
|
||||
}
|
||||
|
||||
public int Amount => amount;
|
||||
public string Type => type;
|
||||
}
|
||||
}
|
17
Journal/SellMicroResourcesEntry.cs
Normal file
17
Journal/SellMicroResourcesEntry.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Journal {
|
||||
public class SellMicroResourcesEntry : Entry {
|
||||
private int price;
|
||||
|
||||
protected override void Initialise() {
|
||||
price = JSON.Value<int>("Price");
|
||||
}
|
||||
|
||||
public int Price => price;
|
||||
}
|
||||
}
|
122
MainWindow.xaml
Normal file
122
MainWindow.xaml
Normal file
@ -0,0 +1,122 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:NonaBGS"
|
||||
xmlns:BGS="clr-namespace:NonaBGS.BGS" xmlns:Util="clr-namespace:NonaBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="NonaBGS.MainWindow"
|
||||
mc:Ignorable="d"
|
||||
Title="Nova Navy BGS Helper" Height="513.8" Width="885.658">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl>
|
||||
<TabItem Header="Current Objectives">
|
||||
<Grid Background="#FFE5E5E5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToolBar VerticalAlignment="Top" Grid.Row="0" Width="Auto" Grid.ColumnSpan="3" Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Left">
|
||||
<Label Content="System:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="system" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,0,0,3.286" MinWidth="120" VerticalContentAlignment="Center"/>
|
||||
<Label Content="Station:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="station" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120"/>
|
||||
<Label Content="Faction:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="faction" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120"/>
|
||||
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
||||
<Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/>
|
||||
</ToolBar>
|
||||
<ToolBar VerticalAlignment="Top" Grid.Row="1" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
|
||||
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>
|
||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||
<Label Content="From:" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</ToolBar>
|
||||
<TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Discord Report">
|
||||
<Grid Background="#FFE5E5E5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto">
|
||||
<Button x:Name="GenerateDiscord" Content="Genereate Discord Report" VerticalAlignment="Center" Margin="0,0,0,4.857" Click="GenerateDiscord_Click" Height="26"/>
|
||||
</ToolBar>
|
||||
<TextBox x:Name="DiscordLog" Height="Auto" Margin="0,0,-0.285,-0.429" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.Row="1" Grid.ColumnSpan="2"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Settings" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="53.7142857142857">
|
||||
<Grid Background="#FFE5E5E5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Header="Location of Player Journal" Height="Auto" Grid.Row="0" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="3" Margin="0,0,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="Location on disk for the player journal. There is usually no need to change this setting." Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.08,0.496"/>
|
||||
<TextBox x:Name="journallocation" Text="" Grid.Row="1" Grid.Column="0" Margin="5,0,5,10" TextWrapping="Wrap" />
|
||||
<Button x:Name="browsejournallocation" Content="Browse" Grid.Row="1" Grid.Column="1" Margin="0,0,0,0" Width="Auto" VerticalAlignment="Top" HorizontalAlignment="Left" Click="browsejournallocation_Click"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Online Services" Height="Auto" Margin="0,5,0,0" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="26*"/>
|
||||
<ColumnDefinition Width="285*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox x:Name="useeddb" Content="Use eddb station and system data for autocompletion" HorizontalAlignment="Left" Margin="0,10,0,10" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Click="useeddb_Click"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Event Log" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top">
|
||||
<Grid Background="#FFE5E5E5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox x:Name="log" Height="Auto" Margin="0,0,0,0" TextWrapping="Wrap" FontFamily="Courier New"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
192
MainWindow.xaml.cs
Normal file
192
MainWindow.xaml.cs
Normal file
@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Ookii.Dialogs.Wpf;
|
||||
|
||||
using NonaBGS.Journal;
|
||||
using NonaBGS.BGS;
|
||||
using NonaBGS.Util;
|
||||
|
||||
namespace NonaBGS {
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window {
|
||||
private PlayerJournal journal = null;
|
||||
private Report report = new Report();
|
||||
private Config config = new Config();
|
||||
private EDDB eddb = null;
|
||||
|
||||
public Config Config => config;
|
||||
|
||||
public Report Report => report;
|
||||
|
||||
public MainWindow() {
|
||||
InitializeComponent();
|
||||
|
||||
try {
|
||||
config.LoadGlobal();
|
||||
} catch (Exception) {
|
||||
/* ignored */
|
||||
}
|
||||
|
||||
report.OnLog += Report_OnLog;
|
||||
|
||||
eddb = new EDDB(config.ConfigPath);
|
||||
journal = new PlayerJournal(config.Global.JournalLocation);
|
||||
|
||||
// Set both to now
|
||||
startdate.SelectedDate = DateTime.Now;
|
||||
enddate.SelectedDate = DateTime.Now;
|
||||
journallocation.Text = Config.Global.JournalLocation;
|
||||
useeddb.IsChecked = Config.Global.UseEDDB;
|
||||
|
||||
try {
|
||||
config.LoadObjectives(Report);
|
||||
RefreshObjectives();
|
||||
|
||||
SyncDatabases();
|
||||
} catch (Exception) {
|
||||
/* ignored */
|
||||
}
|
||||
}
|
||||
|
||||
private void Report_OnLog(string message) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.Append(DateTime.Now.ToString());
|
||||
builder.Append(": ");
|
||||
builder.Append(message);
|
||||
builder.Append("\n");
|
||||
|
||||
log.AppendText(builder.ToString());
|
||||
}
|
||||
|
||||
private void SyncDatabases() {
|
||||
if (!config.Global.UseEDDB) {
|
||||
return;
|
||||
}
|
||||
|
||||
eddb.Download();
|
||||
}
|
||||
|
||||
private void RefreshObjectives() {
|
||||
entries.Items.Clear();
|
||||
|
||||
if (report.Objectives == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var obj in report.Objectives) {
|
||||
var item_objective = new TreeViewItem {
|
||||
Header = obj.ToString(),
|
||||
Tag = obj
|
||||
};
|
||||
|
||||
foreach (var log in obj.LogEntries) {
|
||||
var log_objective = new TreeViewItem {
|
||||
Header = log.ToString(),
|
||||
Tag = log
|
||||
};
|
||||
item_objective.Items.Add(log_objective);
|
||||
}
|
||||
|
||||
item_objective.IsExpanded = true;
|
||||
entries.Items.Add(item_objective);
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseJournal_Click(object sender, RoutedEventArgs e) {
|
||||
journal.Open(); // Load all files
|
||||
|
||||
var start = startdate.SelectedDate ?? DateTime.Now;
|
||||
var end = startdate.SelectedDate ?? DateTime.Now;
|
||||
|
||||
report.Scan(journal, start, end);
|
||||
|
||||
RefreshObjectives();
|
||||
}
|
||||
|
||||
private void AddFilter_Click(object sender, RoutedEventArgs e) {
|
||||
Objective objective = new Objective {
|
||||
System = system.Text,
|
||||
Faction = faction.Text,
|
||||
Station = station.Text
|
||||
};
|
||||
|
||||
if (!objective.IsValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (report.AddObjective(objective)) {
|
||||
RefreshObjectives();
|
||||
config.SaveObjectives(Report);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateDiscord_Click(object sender, RoutedEventArgs e) {
|
||||
NonaDiscordLog discord = new NonaDiscordLog();
|
||||
string report = discord.GenerateDiscordLog(Report);
|
||||
|
||||
DiscordLog.Text = report;
|
||||
}
|
||||
|
||||
private void RemoveCurrentObjective() {
|
||||
if (entries.SelectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeViewItem item = entries.SelectedItem as TreeViewItem;
|
||||
var obj = item.Tag;
|
||||
bool removed = false;
|
||||
|
||||
if (obj.GetType() == typeof(Objective)) {
|
||||
removed = report.Objectives.Remove(obj as Objective);
|
||||
} else if (obj.GetType() == typeof(LogEntry) ||
|
||||
obj.GetType().IsSubclassOf(typeof(LogEntry))) {
|
||||
var parent = (item.Parent as TreeViewItem).Tag as Objective;
|
||||
removed = parent.LogEntries.Remove(obj as LogEntry);
|
||||
}
|
||||
|
||||
if (removed) {
|
||||
RefreshObjectives();
|
||||
config.SaveObjectives(Report);
|
||||
}
|
||||
}
|
||||
|
||||
private void entries_KeyUp(object sender, KeyEventArgs e) {
|
||||
if (e.Key == Key.Delete) {
|
||||
RemoveCurrentObjective();
|
||||
}
|
||||
}
|
||||
|
||||
private void browsejournallocation_Click(object sender, RoutedEventArgs e) {
|
||||
var dialog = new VistaFolderBrowserDialog();
|
||||
|
||||
if ((bool)!dialog.ShowDialog()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Config.Global.JournalLocation = dialog.SelectedPath;
|
||||
journallocation.Text = Config.Global.JournalLocation;
|
||||
journal = new PlayerJournal(config.Global.JournalLocation);
|
||||
}
|
||||
|
||||
private void useeddb_Click(object sender, RoutedEventArgs e) {
|
||||
Config.Global.UseEDDB = (bool)useeddb.IsChecked;
|
||||
SyncDatabases();
|
||||
}
|
||||
}
|
||||
}
|
55
Properties/AssemblyInfo.cs
Normal file
55
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("nonabgs")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("nonabgs")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
Properties/Resources.Designer.cs
generated
Normal file
63
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NonaBGS.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NonaBGS.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
Properties/Resources.resx
Normal file
117
Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
Properties/Settings.Designer.cs
generated
Normal file
26
Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NonaBGS.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
Properties/Settings.settings
Normal file
7
Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
43
Util/AppConfig.cs
Normal file
43
Util/AppConfig.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NonaBGS.Util {
|
||||
public class AppConfig : INotifyPropertyChanged {
|
||||
private static readonly string default_journal_location = "%UserProfile%\\Saved Games\\Frontier Developments\\Elite Dangerous";
|
||||
private string journal_location = default_journal_location;
|
||||
private bool useeddb = false;
|
||||
|
||||
public string DefaultJournalLocation => default_journal_location;
|
||||
|
||||
public bool UseEDDB {
|
||||
get => useeddb;
|
||||
set {
|
||||
useeddb = value;
|
||||
FirePropertyChanged("UseEDDB");
|
||||
}
|
||||
}
|
||||
|
||||
public string JournalLocation {
|
||||
get {
|
||||
if (journal_location == null) {
|
||||
return DefaultJournalLocation;
|
||||
}
|
||||
return journal_location;
|
||||
}
|
||||
set {
|
||||
journal_location = value;
|
||||
FirePropertyChanged("JournalLocation");
|
||||
}
|
||||
}
|
||||
|
||||
private void FirePropertyChanged(string property) {
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
85
Util/Config.cs
Normal file
85
Util/Config.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using NonaBGS.BGS;
|
||||
|
||||
namespace NonaBGS.Util {
|
||||
public class Config {
|
||||
private string config_folder = null;
|
||||
private string objectives_file = null;
|
||||
private string config_file = null;
|
||||
|
||||
private AppConfig global_config = new AppConfig();
|
||||
|
||||
public Config() {
|
||||
DetermineConfigFolder();
|
||||
global_config.PropertyChanged += Global_config_PropertyChanged;
|
||||
}
|
||||
|
||||
private void Global_config_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
|
||||
try {
|
||||
SaveGlobal();
|
||||
} catch (Exception) {
|
||||
/* ignored */
|
||||
}
|
||||
}
|
||||
|
||||
public string ConfigPath => config_folder;
|
||||
|
||||
public AppConfig Global => global_config;
|
||||
|
||||
private void DetermineConfigFolder() {
|
||||
string folder = Environment.ExpandEnvironmentVariables("%appdata%\\NonaBGS");
|
||||
|
||||
if (!Directory.Exists(folder)) {
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
config_folder = folder;
|
||||
|
||||
objectives_file = Path.Combine(config_folder, "objectives.json");
|
||||
config_file = Path.Combine(config_folder, "config.json");
|
||||
}
|
||||
|
||||
public void SaveGlobal() {
|
||||
var serializer = JsonSerializer.CreateDefault();
|
||||
using (var file = new StreamWriter(File.OpenWrite(config_file), Encoding.UTF8)) {
|
||||
var stream = new JsonTextWriter(file);
|
||||
serializer.Serialize(stream, global_config);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadGlobal() {
|
||||
var serializer = JsonSerializer.CreateDefault();
|
||||
using (var file = new StreamReader(File.OpenRead(config_file), Encoding.UTF8)) {
|
||||
var stream = new JsonTextReader(file);
|
||||
var app = serializer.Deserialize<AppConfig>(stream);
|
||||
|
||||
if (app != null) {
|
||||
this.global_config = app;
|
||||
global_config.PropertyChanged += Global_config_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveObjectives(Report report) {
|
||||
var serializer = JsonSerializer.CreateDefault();
|
||||
using (var file = new StreamWriter(File.OpenWrite(objectives_file), Encoding.UTF8)) {
|
||||
var stream = new JsonTextWriter(file);
|
||||
serializer.Serialize(stream, report.Objectives);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadObjectives(Report report) {
|
||||
var serializer = JsonSerializer.CreateDefault();
|
||||
using (var file = new StreamReader(File.OpenRead(objectives_file), Encoding.UTF8)) {
|
||||
var stream = new JsonTextReader(file);
|
||||
var objectives = serializer.Deserialize<List<Objective>>(stream);
|
||||
|
||||
report.Objectives = objectives;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
Util/EDDB.cs
Normal file
48
Util/EDDB.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
namespace NonaBGS.Util {
|
||||
public class EDDB {
|
||||
private static readonly string EDDB_SYSTEMS_ARCHIVE = "https://eddb.io/archive/v6/systems_populated.json";
|
||||
private string cache_folder = null;
|
||||
private WebClient client = new WebClient();
|
||||
|
||||
private string systems_file = null;
|
||||
|
||||
public string SystemsFile => systems_file;
|
||||
|
||||
public string Cache {
|
||||
get => cache_folder;
|
||||
set => cache_folder = value;
|
||||
}
|
||||
|
||||
public EDDB(string cache_folder) {
|
||||
this.cache_folder = cache_folder;
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public void Initialise() {
|
||||
client.DownloadDataCompleted += Client_DownloadDataCompleted;
|
||||
}
|
||||
|
||||
private void DownloadFile(string url) {
|
||||
Uri uri = new Uri(url);
|
||||
string name = Path.GetFileName(uri.AbsolutePath);
|
||||
systems_file = Path.Combine(this.cache_folder, name);
|
||||
|
||||
client.DownloadFileAsync(new Uri(EDDB_SYSTEMS_ARCHIVE), systems_file);
|
||||
}
|
||||
|
||||
public void Download() {
|
||||
DownloadFile(EDDB_SYSTEMS_ARCHIVE);
|
||||
}
|
||||
|
||||
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
|
||||
}
|
||||
}
|
||||
}
|
140
nonabgs.csproj
Normal file
140
nonabgs.csproj
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{73BFB315-C808-40E7-8D69-B651F875880C}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>NonaBGS</RootNamespace>
|
||||
<AssemblyName>nonabgs</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>NonaBGSApplication</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ookii.Dialogs.Wpf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=66aa232afad40158, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Ookii.Dialogs.Wpf.3.1.0\lib\net45\Ookii.Dialogs.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="BGS\DiscordLogGenerator.cs" />
|
||||
<Compile Include="BGS\NonaDiscordLog.cs" />
|
||||
<Compile Include="BGS\SellMicroResources.cs" />
|
||||
<Compile Include="Journal\EliteDangerous.cs" />
|
||||
<Compile Include="Journal\MarketSellEntry.cs" />
|
||||
<Compile Include="Journal\MultiSellExplorationDataEntry.cs" />
|
||||
<Compile Include="Journal\RedeemVoucherEntry.cs" />
|
||||
<Compile Include="Journal\SellMicroResourcesEntry.cs" />
|
||||
<Compile Include="Util\AppConfig.cs" />
|
||||
<Compile Include="Util\Config.cs" />
|
||||
<Compile Include="Util\EDDB.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BGS\Report.cs" />
|
||||
<Compile Include="BGS\Vouchers.cs" />
|
||||
<Compile Include="BGS\Cartographics.cs" />
|
||||
<Compile Include="BGS\CombatZone.cs" />
|
||||
<Compile Include="BGS\LogEntry.cs" />
|
||||
<Compile Include="BGS\MissionCompleted.cs" />
|
||||
<Compile Include="Journal\DockedEntry.cs" />
|
||||
<Compile Include="Journal\Entry.cs" />
|
||||
<Compile Include="BGS\Objective.cs" />
|
||||
<Compile Include="Journal\Events.cs" />
|
||||
<Compile Include="Journal\FSDJumpEntry.cs" />
|
||||
<Compile Include="Journal\JournalException.cs" />
|
||||
<Compile Include="Journal\JournalFile.cs" />
|
||||
<Compile Include="Journal\MissionCompletedEntry.cs" />
|
||||
<Compile Include="Journal\PlayerJournal.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="UI\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
25
nonabgs.sln
Normal file
25
nonabgs.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31205.134
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nonabgs", "nonabgs.csproj", "{73BFB315-C808-40E7-8D69-B651F875880C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{73BFB315-C808-40E7-8D69-B651F875880C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{73BFB315-C808-40E7-8D69-B651F875880C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{73BFB315-C808-40E7-8D69-B651F875880C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{73BFB315-C808-40E7-8D69-B651F875880C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {40F4B1BD-FC53-485B-9AEE-3357B375CED2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
5
packages.config
Normal file
5
packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="Ookii.Dialogs.Wpf" version="3.1.0" targetFramework="net472" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user