allow manual loading of JSON
This commit is contained in:
parent
d19bef33d2
commit
0fdd51a3ec
@ -50,13 +50,16 @@ namespace EliteBGS.BGS {
|
|||||||
where file.NormalisedTimestamp >= start && file.NormalisedTimestamp <= end
|
where file.NormalisedTimestamp >= start && file.NormalisedTimestamp <= end
|
||||||
select file.Entries
|
select file.Entries
|
||||||
;
|
;
|
||||||
var relevant = from log in entries.SelectMany(array => array)
|
Scan(entries.SelectMany(x => x).ToList());
|
||||||
where IsRelevant(log)
|
}
|
||||||
select log
|
|
||||||
;
|
|
||||||
|
|
||||||
|
public void Scan(List<Entry> entries) {
|
||||||
|
if (entries.Count <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Entry> relevant = entries.Where(x => IsRelevant(x)).ToList();
|
||||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||||
|
|
||||||
Dictionary<string, int> buyCost = new Dictionary<string, int>();
|
Dictionary<string, int> buyCost = new Dictionary<string, int>();
|
||||||
|
|
||||||
string current_system = null;
|
string current_system = null;
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<Reference Include="System.Design" />
|
<Reference Include="System.Design" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Security" />
|
<Reference Include="System.Security" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -90,6 +91,9 @@
|
|||||||
<Compile Include="BGS\FactionKillBonds.cs" />
|
<Compile Include="BGS\FactionKillBonds.cs" />
|
||||||
<Compile Include="EDDB\PopulatedSystems.cs" />
|
<Compile Include="EDDB\PopulatedSystems.cs" />
|
||||||
<Compile Include="EDDB\Stations.cs" />
|
<Compile Include="EDDB\Stations.cs" />
|
||||||
|
<Compile Include="LoadEntriesWindow.xaml.cs">
|
||||||
|
<DependentUpon>LoadEntriesWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Resources.Designer.cs">
|
<Compile Include="Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@ -110,6 +114,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="LoadEntriesWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
22
LoadEntriesWindow.xaml
Normal file
22
LoadEntriesWindow.xaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<Window x:Class="EliteBGS.LoadEntriesWindow"
|
||||||
|
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:EliteBGS"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Load Entries" Height="450" Width="600">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBox x:Name="Lines" AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" Grid.Row="0" Height="Auto" Grid.Column="0" Grid.ColumnSpan="3" VerticalScrollBarVisibility="Visible" />
|
||||||
|
<Button x:Name="Load" Content="Load Entries" Grid.Row="1" Margin="5,5,5,5" Height="Auto" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Load_Click" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
52
LoadEntriesWindow.xaml.cs
Normal file
52
LoadEntriesWindow.xaml.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using EDJournal;
|
||||||
|
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.Shapes;
|
||||||
|
|
||||||
|
namespace EliteBGS {
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for LoadEntriesWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class LoadEntriesWindow : Window {
|
||||||
|
public delegate void EntriesLoadedDelegate(List<Entry> entries);
|
||||||
|
|
||||||
|
public event EntriesLoadedDelegate EntriesLoaded;
|
||||||
|
|
||||||
|
public LoadEntriesWindow() {
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Load_Click(object sender, RoutedEventArgs e) {
|
||||||
|
string lines = Lines.Text.Trim();
|
||||||
|
if (lines.Length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Entry> entries = new List<Entry>();
|
||||||
|
|
||||||
|
foreach (string line in lines.Split('\n')) {
|
||||||
|
Entry entry = Entry.Parse(line);
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries.Count > 0) {
|
||||||
|
EntriesLoaded?.Invoke(entries);
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
|
||||||
|
exception.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
xmlns:local="clr-namespace:EliteBGS"
|
xmlns:local="clr-namespace:EliteBGS"
|
||||||
xmlns:BGS="clr-namespace:EliteBGS.BGS" xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
xmlns:BGS="clr-namespace:EliteBGS.BGS" xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico">
|
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico" Closing="window_Closing">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
@ -49,6 +49,8 @@
|
|||||||
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||||
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||||
|
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">
|
<TreeView x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
|
@ -29,6 +29,8 @@ namespace EliteBGS {
|
|||||||
|
|
||||||
public Report Report => report;
|
public Report Report => report;
|
||||||
|
|
||||||
|
private LoadEntriesWindow loadentries = new LoadEntriesWindow();
|
||||||
|
|
||||||
private static readonly List<IDiscordLogGenerator> logtypes = new List<IDiscordLogGenerator>() {
|
private static readonly List<IDiscordLogGenerator> logtypes = new List<IDiscordLogGenerator>() {
|
||||||
new NonaDiscordLog(),
|
new NonaDiscordLog(),
|
||||||
new GenericDiscordLog(),
|
new GenericDiscordLog(),
|
||||||
@ -43,6 +45,8 @@ namespace EliteBGS {
|
|||||||
/* ignored */
|
/* ignored */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadentries.EntriesLoaded += Loadentries_EntriesLoaded;
|
||||||
|
|
||||||
report.OnLog += Report_OnLog;
|
report.OnLog += Report_OnLog;
|
||||||
|
|
||||||
foreach (IDiscordLogGenerator type in logtypes) {
|
foreach (IDiscordLogGenerator type in logtypes) {
|
||||||
@ -83,6 +87,17 @@ namespace EliteBGS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
||||||
|
try {
|
||||||
|
report.Scan(lines);
|
||||||
|
RefreshObjectives();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
Log("Something went terribly wrong while parsing the E:D player journal.");
|
||||||
|
Log("Please send this to CMDR Hekateh:");
|
||||||
|
Log(exception.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Api_StationsAvailable() {
|
private void Api_StationsAvailable() {
|
||||||
try {
|
try {
|
||||||
stations_db = api.MakeStations();
|
stations_db = api.MakeStations();
|
||||||
@ -321,5 +336,13 @@ namespace EliteBGS {
|
|||||||
string template = LogType.SelectedItem.ToString();
|
string template = LogType.SelectedItem.ToString();
|
||||||
config.Global.LastUsedDiscordTemplate = template;
|
config.Global.LastUsedDiscordTemplate = template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ManuallyParse_Click(object sender, RoutedEventArgs e) {
|
||||||
|
loadentries.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
loadentries.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user