Compare commits
3 Commits
431c83fc23
...
60949ef475
Author | SHA1 | Date | |
---|---|---|---|
60949ef475 | |||
1cde35c234 | |||
f88047718a |
@ -1,8 +1,12 @@
|
|||||||
# EliteBGS changelog
|
# EliteBGS changelog
|
||||||
|
|
||||||
## 0.1.x on XX.06.2022
|
## 0.1.3 on 07.06.2022
|
||||||
|
|
||||||
* Fixed a bug where entries in non-rated journal files were not properly picked up.
|
* Fixed a bug where entries in non-rated journal files were not properly picked up.
|
||||||
|
* Remove EDDB database usage. This feature could block the tool if it failed to convert
|
||||||
|
the JSON to something more usable, downloads took forever, and the tool itself could
|
||||||
|
run out of memory loading and converting JSON from EDDB. With automatic objective
|
||||||
|
detection this tool is no longer really needed.
|
||||||
|
|
||||||
## 0.1.2 on 06.04.2022
|
## 0.1.2 on 06.04.2022
|
||||||
|
|
||||||
|
180
EDDB/API.cs
180
EDDB/API.cs
@ -1,180 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace EliteBGS.EDDB {
|
|
||||||
public class API {
|
|
||||||
private static readonly string EDDB_SYSTEMS_ARCHIVE = "https://eddb.io/archive/v6/systems_populated.json";
|
|
||||||
private static readonly string EDDB_STATIONS_ARCHIVE = "https://eddb.io/archive/v6/stations.json";
|
|
||||||
|
|
||||||
private string cache_folder = null;
|
|
||||||
|
|
||||||
private string systems_file = null;
|
|
||||||
private string stations_file = null;
|
|
||||||
private string stations_file_short = null;
|
|
||||||
|
|
||||||
public delegate void DatabaseAvailableDelegate();
|
|
||||||
public delegate void DatabaseUpdateProgressDelegate();
|
|
||||||
|
|
||||||
public event DatabaseAvailableDelegate SystemsAvailable;
|
|
||||||
public event DatabaseAvailableDelegate StationsAvailable;
|
|
||||||
|
|
||||||
public event DatabaseUpdateProgressDelegate DatabaseUpdateProgress;
|
|
||||||
public event DatabaseUpdateProgressDelegate DatabaseUpdateFinished;
|
|
||||||
|
|
||||||
public string SystemsFile => systems_file;
|
|
||||||
public string StationsFile => stations_file;
|
|
||||||
public string StationsFileShort => stations_file_short;
|
|
||||||
|
|
||||||
public string Cache {
|
|
||||||
get => cache_folder;
|
|
||||||
set => cache_folder = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public API(string cache_folder) {
|
|
||||||
Initialise(cache_folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Initialise(string cache_folder) {
|
|
||||||
this.cache_folder = cache_folder;
|
|
||||||
systems_file = Path.Combine(this.cache_folder, "systems_populated.json");
|
|
||||||
stations_file = Path.Combine(this.cache_folder, "stations.json");
|
|
||||||
stations_file_short = Path.Combine(this.cache_folder, "stations_short.json");
|
|
||||||
|
|
||||||
this.StationsAvailable += API_StationsAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void API_StationsAvailable() {
|
|
||||||
TranslateStations();
|
|
||||||
DatabaseUpdateFinished?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DownloadFile(string url, string file, DatabaseAvailableDelegate notifier) {
|
|
||||||
WebClient client = new WebClient();
|
|
||||||
client.DownloadFileCompleted += Client_DownloadFileCompleted;
|
|
||||||
client.DownloadProgressChanged += Client_DownloadProgressChanged;
|
|
||||||
client.DownloadFileAsync(new Uri(url), file, notifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) {
|
|
||||||
DatabaseUpdateProgress?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) {
|
|
||||||
DatabaseAvailableDelegate notifier = e.UserState as DatabaseAvailableDelegate;
|
|
||||||
notifier?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TranslateStations() {
|
|
||||||
if (!HaveStationsFile) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var short_time = File.GetLastWriteTimeUtc(StationsFileShort);
|
|
||||||
var long_time = File.GetLastWriteTimeUtc(StationsFile);
|
|
||||||
|
|
||||||
if (HaveStationsFileShort && long_time <= short_time) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<int, List<string>> systems = new Dictionary<int, List<string>>();
|
|
||||||
|
|
||||||
using (var str = new StreamReader(StationsFile)) {
|
|
||||||
using (var reader = new JsonTextReader(str)) {
|
|
||||||
JArray obj = (JArray)JToken.ReadFrom(reader);
|
|
||||||
|
|
||||||
foreach (JObject child in obj.Children<JObject>()) {
|
|
||||||
int system_id = child.Value<int>("system_id");
|
|
||||||
string name = child.Value<string>("name");
|
|
||||||
|
|
||||||
if (!systems.ContainsKey(system_id)) {
|
|
||||||
systems.Add(system_id, new List<string>());
|
|
||||||
}
|
|
||||||
|
|
||||||
DatabaseUpdateProgress?.Invoke();
|
|
||||||
|
|
||||||
systems[system_id].Add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JObject short_stations = new JObject();
|
|
||||||
|
|
||||||
foreach(int ids in systems.Keys) {
|
|
||||||
JArray station_names = new JArray();
|
|
||||||
foreach(string system in systems[ids]) {
|
|
||||||
station_names.Add(system);
|
|
||||||
}
|
|
||||||
short_stations.Add(ids.ToString(), station_names);
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var outstr = new StreamWriter(stations_file_short)) {
|
|
||||||
using (var jwriter = new JsonTextWriter(outstr)) {
|
|
||||||
short_stations.WriteTo(jwriter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckDatabases() {
|
|
||||||
if (HaveSystemsFile) {
|
|
||||||
SystemsAvailable?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HaveStationsFile) {
|
|
||||||
StationsAvailable?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Download(bool force) {
|
|
||||||
if (!HaveSystemsFile || force) {
|
|
||||||
DownloadFile(EDDB_SYSTEMS_ARCHIVE, systems_file, SystemsAvailable);
|
|
||||||
} else if (HaveSystemsFile) {
|
|
||||||
SystemsAvailable?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!HaveStationsFile || force) {
|
|
||||||
DownloadFile(EDDB_STATIONS_ARCHIVE, stations_file, StationsAvailable);
|
|
||||||
} else if (HaveStationsFile) {
|
|
||||||
StationsAvailable?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Download() {
|
|
||||||
Download(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HaveSystemsFile {
|
|
||||||
get { return systems_file != null && File.Exists(systems_file); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HaveStationsFile {
|
|
||||||
get { return stations_file != null && File.Exists(stations_file); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HaveStationsFileShort {
|
|
||||||
get { return stations_file_short != null && File.Exists(stations_file_short); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public PopulatedSystems MakePopulatedSystems() {
|
|
||||||
if (!HaveSystemsFile) {
|
|
||||||
throw new InvalidOperationException("no local systems file downloaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
return PopulatedSystems.FromFile(SystemsFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stations MakeStations() {
|
|
||||||
if (!HaveStationsFile) {
|
|
||||||
throw new InvalidOperationException("no local systems file downloaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
TranslateStations();
|
|
||||||
|
|
||||||
return Stations.FromFile(StationsFileShort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace EliteBGS.EDDB {
|
|
||||||
public class PopulatedSystems {
|
|
||||||
private string json_file = null;
|
|
||||||
private JArray root = null;
|
|
||||||
private string[] system_names = null;
|
|
||||||
private Dictionary<string, int> to_id;
|
|
||||||
|
|
||||||
public static PopulatedSystems FromFile(string file) {
|
|
||||||
PopulatedSystems pop = new PopulatedSystems();
|
|
||||||
string content = File.ReadAllText(file);
|
|
||||||
|
|
||||||
pop.json_file = file;
|
|
||||||
pop.root = JArray.Parse(content);
|
|
||||||
pop.Initialise();
|
|
||||||
|
|
||||||
return pop;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Initialise() {
|
|
||||||
MakeSystemNames();
|
|
||||||
|
|
||||||
to_id = root.ToDictionary(x => x.Value<string>("name"), x => x.Value<int>("id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ToId(string name) {
|
|
||||||
return to_id.First(x => string.Compare(x.Key, name, true) == 0).Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MakeSystemNames() {
|
|
||||||
if (root == null) {
|
|
||||||
throw new InvalidDataException("no JSON loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system_names != null && system_names.Length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var names = root.Children<JObject>().Select(x => x.Value<string>("name"));
|
|
||||||
system_names = names.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] SystemNames {
|
|
||||||
get {
|
|
||||||
MakeSystemNames();
|
|
||||||
return system_names;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] SystemNamesByFilter(string filter) {
|
|
||||||
MakeSystemNames();
|
|
||||||
var culture = CultureInfo.InvariantCulture;
|
|
||||||
return system_names.Where(x => culture.CompareInfo.IndexOf(x, filter, CompareOptions.IgnoreCase) > -1)
|
|
||||||
.ToArray()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string JSONFile {
|
|
||||||
get => json_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JArray Root {
|
|
||||||
get => root;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using System.Globalization;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace EliteBGS.EDDB {
|
|
||||||
public class Stations {
|
|
||||||
private JObject root = null;
|
|
||||||
private Dictionary<int, List<string>> by_system_id = null;
|
|
||||||
|
|
||||||
public JObject JSON => root;
|
|
||||||
|
|
||||||
private Stations() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Initialise() {
|
|
||||||
by_system_id = new Dictionary<int, List<string>>();
|
|
||||||
foreach (var station in root.Properties()) {
|
|
||||||
int id = int.Parse(station.Name);
|
|
||||||
var names = root.Value<JArray>(id.ToString()).Values<string>().ToArray();
|
|
||||||
|
|
||||||
if (!by_system_id.ContainsKey(id)) {
|
|
||||||
by_system_id[id] = new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
by_system_id[id].AddRange(names);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Stations FromFile(string filename) {
|
|
||||||
string alltext = File.ReadAllText(filename);
|
|
||||||
Stations stations = new Stations {
|
|
||||||
root = JObject.Parse(alltext),
|
|
||||||
};
|
|
||||||
stations.Initialise();
|
|
||||||
|
|
||||||
return stations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] StationNamesBySystemId(int systemid, string filter) {
|
|
||||||
if (!by_system_id.ContainsKey(systemid)) {
|
|
||||||
return new string[0];
|
|
||||||
}
|
|
||||||
return by_system_id[systemid]
|
|
||||||
.Where(x => CultureInfo.InvariantCulture.CompareInfo.IndexOf(x, filter, CompareOptions.IgnoreCase) > -1)
|
|
||||||
.ToArray()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -107,8 +107,6 @@
|
|||||||
<Compile Include="BGS\SellCargo.cs" />
|
<Compile Include="BGS\SellCargo.cs" />
|
||||||
<Compile Include="BGS\SellMicroResources.cs" />
|
<Compile Include="BGS\SellMicroResources.cs" />
|
||||||
<Compile Include="BGS\FactionKillBonds.cs" />
|
<Compile Include="BGS\FactionKillBonds.cs" />
|
||||||
<Compile Include="EDDB\PopulatedSystems.cs" />
|
|
||||||
<Compile Include="EDDB\Stations.cs" />
|
|
||||||
<Compile Include="LoadEntriesWindow.xaml.cs">
|
<Compile Include="LoadEntriesWindow.xaml.cs">
|
||||||
<DependentUpon>LoadEntriesWindow.xaml</DependentUpon>
|
<DependentUpon>LoadEntriesWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -117,14 +115,8 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\StationSuggestionProvider.cs" />
|
|
||||||
<Compile Include="UI\SystemSuggestionProvider.cs" />
|
|
||||||
<Compile Include="Util\AppConfig.cs" />
|
<Compile Include="Util\AppConfig.cs" />
|
||||||
<Compile Include="Util\Config.cs" />
|
<Compile Include="Util\Config.cs" />
|
||||||
<Compile Include="EDDB\API.cs" />
|
|
||||||
<Compile Include="ProgressDialog.xaml.cs">
|
|
||||||
<DependentUpon>ProgressDialog.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="CombatZoneDialog.xaml.cs">
|
<Compile Include="CombatZoneDialog.xaml.cs">
|
||||||
<DependentUpon>CombatZoneDialog.xaml</DependentUpon>
|
<DependentUpon>CombatZoneDialog.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -155,10 +147,6 @@
|
|||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Page Include="ProgressDialog.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="CombatZoneDialog.xaml">
|
<Page Include="CombatZoneDialog.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<Label Content="System:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
<Label Content="System:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||||
<abc:AutoCompleteTextBox x:Name="system" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown"/>
|
<abc:AutoCompleteTextBox x:Name="system" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown"/>
|
||||||
<Label Content="Station:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
<Label Content="Station:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||||
<abc:AutoCompleteTextBox x:Name="station" Margin="0" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown" GotFocus="station_GotFocus"/>
|
<abc:AutoCompleteTextBox x:Name="station" Margin="0" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown" />
|
||||||
<Label Content="Faction:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
<Label Content="Faction:" Height="26.2857142857143" VerticalAlignment="Top"/>
|
||||||
<abc:AutoCompleteTextBox x:Name="faction" Margin="0" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown"/>
|
<abc:AutoCompleteTextBox x:Name="faction" Margin="0" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown"/>
|
||||||
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
|
||||||
@ -124,20 +124,6 @@
|
|||||||
<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"/>
|
<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>
|
</Grid>
|
||||||
</GroupBox>
|
</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="*"/>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
</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="1" Click="useeddb_Click"/>
|
|
||||||
<Button x:Name="DownloadData" Content="Download Data" HorizontalAlignment="Center" Grid.Column="1" VerticalAlignment="Center" Width="Auto" Click="DownloadData_Click"/>
|
|
||||||
</Grid>
|
|
||||||
</GroupBox>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Event Log" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top">
|
<TabItem Header="Event Log" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top">
|
||||||
|
@ -9,8 +9,6 @@ using Ookii.Dialogs.Wpf;
|
|||||||
using EDJournal;
|
using EDJournal;
|
||||||
using EliteBGS.BGS;
|
using EliteBGS.BGS;
|
||||||
using EliteBGS.Util;
|
using EliteBGS.Util;
|
||||||
using EliteBGS.UI;
|
|
||||||
using EliteBGS.EDDB;
|
|
||||||
|
|
||||||
namespace EliteBGS {
|
namespace EliteBGS {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -20,10 +18,6 @@ namespace EliteBGS {
|
|||||||
private PlayerJournal journal = null;
|
private PlayerJournal journal = null;
|
||||||
private Report report = new Report();
|
private Report report = new Report();
|
||||||
private Config config = new Config();
|
private Config config = new Config();
|
||||||
private API api = null;
|
|
||||||
|
|
||||||
private PopulatedSystems systems_db = null;
|
|
||||||
private Stations stations_db = null;
|
|
||||||
|
|
||||||
public Config Config => config;
|
public Config Config => config;
|
||||||
|
|
||||||
@ -59,14 +53,12 @@ namespace EliteBGS {
|
|||||||
LogType.SelectedIndex = 0;
|
LogType.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
api = new API(config.ConfigPath);
|
|
||||||
journal = new PlayerJournal(config.Global.JournalLocation);
|
journal = new PlayerJournal(config.Global.JournalLocation);
|
||||||
|
|
||||||
// Set both to now
|
// Set both to now
|
||||||
startdate.SelectedDate = DateTime.Now;
|
startdate.SelectedDate = DateTime.Now;
|
||||||
enddate.SelectedDate = DateTime.Now;
|
enddate.SelectedDate = DateTime.Now;
|
||||||
journallocation.Text = Config.Global.JournalLocation;
|
journallocation.Text = Config.Global.JournalLocation;
|
||||||
useeddb.IsChecked = Config.Global.UseEDDB;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.LoadObjectives(Report);
|
config.LoadObjectives(Report);
|
||||||
@ -74,15 +66,6 @@ namespace EliteBGS {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log(e.Message);
|
Log(e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.SystemsAvailable += Api_SystemsAvailable;
|
|
||||||
api.StationsAvailable += Api_StationsAvailable;
|
|
||||||
|
|
||||||
try {
|
|
||||||
api.CheckDatabases();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log(e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
||||||
@ -96,23 +79,6 @@ namespace EliteBGS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Api_StationsAvailable() {
|
|
||||||
try {
|
|
||||||
stations_db = api.MakeStations();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Api_SystemsAvailable() {
|
|
||||||
try {
|
|
||||||
systems_db = api.MakePopulatedSystems();
|
|
||||||
system.Provider = new SystemSuggestionProvider(systems_db);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Report_OnLog(string message) {
|
private void Report_OnLog(string message) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
@ -234,44 +200,12 @@ namespace EliteBGS {
|
|||||||
journal = new PlayerJournal(config.Global.JournalLocation);
|
journal = new PlayerJournal(config.Global.JournalLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useeddb_Click(object sender, RoutedEventArgs e) {
|
|
||||||
Config.Global.UseEDDB = (bool)useeddb.IsChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Filter_KeyDown(object sender, KeyEventArgs e) {
|
private void Filter_KeyDown(object sender, KeyEventArgs e) {
|
||||||
if (e.Key == Key.Enter) {
|
if (e.Key == Key.Enter) {
|
||||||
AddObjective();
|
AddObjective();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void station_GotFocus(object sender, RoutedEventArgs e) {
|
|
||||||
try {
|
|
||||||
if (stations_db == null || systems_db == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sys = system.Text;
|
|
||||||
if (sys == null || sys.Length <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int system_id = systems_db.ToId(sys);
|
|
||||||
station.Provider = new StationSuggestionProvider(stations_db, system_id);
|
|
||||||
} catch (Exception exc) {
|
|
||||||
Log(exc.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DownloadData_Click(object sender, RoutedEventArgs e) {
|
|
||||||
if (!Config.Global.UseEDDB) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProgressDialog dialog = new ProgressDialog(api);
|
|
||||||
dialog.StartDownload();
|
|
||||||
dialog.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
||||||
if (entries.SelectedItem == null) {
|
if (entries.SelectedItem == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<Window x:Class="EliteBGS.ProgressDialog"
|
|
||||||
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="Progress" Height="100" Width="450" Icon="EliteBGS.ico">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Content="Downloading EDDB databases might take a while, please be patient." Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top"/>
|
|
||||||
<ProgressBar x:Name="progress" Height="25" Margin="10,10" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Width="Auto" IsIndeterminate="True"/>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
@ -1,30 +0,0 @@
|
|||||||
using System.Windows;
|
|
||||||
using EliteBGS.EDDB;
|
|
||||||
|
|
||||||
namespace EliteBGS {
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for Window1.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class ProgressDialog : Window {
|
|
||||||
private readonly API api = null;
|
|
||||||
|
|
||||||
public ProgressDialog(API api) {
|
|
||||||
InitializeComponent();
|
|
||||||
this.api = api;
|
|
||||||
this.api.DatabaseUpdateFinished += Api_DatabaseUpdateFinished;
|
|
||||||
this.api.DatabaseUpdateProgress += Api_DatabaseUpdateProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Api_DatabaseUpdateProgress() {
|
|
||||||
progress.Value = (progress.Value + 1) % 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Api_DatabaseUpdateFinished() {
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartDownload() {
|
|
||||||
api.Download(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using AutoCompleteTextBox.Editors;
|
|
||||||
using EliteBGS.EDDB;
|
|
||||||
|
|
||||||
namespace EliteBGS.UI {
|
|
||||||
public class StationSuggestionProvider : ISuggestionProvider {
|
|
||||||
private int system_id = 0;
|
|
||||||
private Stations stations = null;
|
|
||||||
|
|
||||||
public StationSuggestionProvider(Stations stations, int system_id) {
|
|
||||||
this.system_id = system_id;
|
|
||||||
this.stations = stations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable GetSuggestions(string filter) {
|
|
||||||
return stations.StationNamesBySystemId(system_id, filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using AutoCompleteTextBox.Editors;
|
|
||||||
using EliteBGS.EDDB;
|
|
||||||
|
|
||||||
namespace EliteBGS.UI {
|
|
||||||
public class SystemSuggestionProvider : ISuggestionProvider {
|
|
||||||
private PopulatedSystems systems = null;
|
|
||||||
|
|
||||||
public SystemSuggestionProvider(PopulatedSystems systems) {
|
|
||||||
this.systems = systems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PopulatedSystems Data {
|
|
||||||
get => systems;
|
|
||||||
set => systems = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable GetSuggestions(string filter) {
|
|
||||||
return systems.SystemNamesByFilter(filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,19 +4,10 @@ namespace EliteBGS.Util {
|
|||||||
public class AppConfig : INotifyPropertyChanged {
|
public class AppConfig : INotifyPropertyChanged {
|
||||||
private static readonly string default_journal_location = "%UserProfile%\\Saved Games\\Frontier Developments\\Elite Dangerous";
|
private static readonly string default_journal_location = "%UserProfile%\\Saved Games\\Frontier Developments\\Elite Dangerous";
|
||||||
private string journal_location = default_journal_location;
|
private string journal_location = default_journal_location;
|
||||||
private bool useeddb = false;
|
|
||||||
private string lastdiscordlog;
|
private string lastdiscordlog;
|
||||||
|
|
||||||
public string DefaultJournalLocation => default_journal_location;
|
public string DefaultJournalLocation => default_journal_location;
|
||||||
|
|
||||||
public bool UseEDDB {
|
|
||||||
get => useeddb;
|
|
||||||
set {
|
|
||||||
useeddb = value;
|
|
||||||
FirePropertyChanged("UseEDDB");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string LastUsedDiscordTemplate {
|
public string LastUsedDiscordTemplate {
|
||||||
get => lastdiscordlog;
|
get => lastdiscordlog;
|
||||||
set {
|
set {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user