Compare commits

...

6 Commits

5 changed files with 69 additions and 8 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -8,7 +9,7 @@ namespace EliteBGS.BGS {
public class GenericDiscordLog : IDiscordLogGenerator { public class GenericDiscordLog : IDiscordLogGenerator {
private string FormatDate() { private string FormatDate() {
DateTime today = DateTime.Now; DateTime today = DateTime.Now;
return today.ToShortDateString(); return today.ToString("dd/MM/yyyy");
} }
private string BuildCartoGraphics(Objective objective) { private string BuildCartoGraphics(Objective objective) {
@ -24,7 +25,7 @@ namespace EliteBGS.BGS {
} }
return string.Format("Sold {0} page(s) worth of universal cartographics\n" + return string.Format("Sold {0} page(s) worth of universal cartographics\n" +
"(Total value: {1})\n", pages, Credits.FormatCredits(sum)); "(Total value: {1})\n\n", pages, Credits.FormatCredits(sum));
} }
private string BuildCargoSold(Objective objective) { private string BuildCargoSold(Objective objective) {
@ -164,6 +165,17 @@ namespace EliteBGS.BGS {
output.Append(")\n\n"); output.Append(")\n\n");
} }
var support = objective.LogEntries.OfType<InfluenceSupport>();
foreach (InfluenceSupport inf in support) {
output.Append(inf.ToString());
output.Append("\n");
total_influence += inf.Influence.Length;
}
if (support.Count() > 0) {
output.Append("\n");
}
if (total_influence > 0) { if (total_influence > 0) {
output.AppendFormat("Total Influence: {0}\n\n", total_influence); output.AppendFormat("Total Influence: {0}\n\n", total_influence);
} }

View File

@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Globalization;
using EDJournal; using EDJournal;
namespace EliteBGS.BGS { namespace EliteBGS.BGS {
public class NonaDiscordLog : IDiscordLogGenerator { public class NonaDiscordLog : IDiscordLogGenerator {
private string FormatDate() { private string FormatDate() {
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
StringBuilder date = new StringBuilder(); StringBuilder date = new StringBuilder();
DateTime today = DateTime.Now; DateTime today = DateTime.Now;
string suffix; string suffix;
@ -20,7 +22,8 @@ namespace EliteBGS.BGS {
} }
date.AppendFormat("{0} {1}{2}, {3}", date.AppendFormat("{0} {1}{2}, {3}",
today.ToString("MMMM"), today.Day, suffix, cultureInfo.DateTimeFormat.GetMonthName(today.Month),
today.Day, suffix,
today.Year + EliteDangerous.YearOffset today.Year + EliteDangerous.YearOffset
); );
@ -40,7 +43,9 @@ namespace EliteBGS.BGS {
} }
return string.Format("Sold {0} page(s) worth of universal cartographics\n" + return string.Format("Sold {0} page(s) worth of universal cartographics\n" +
"(Total value: {1})\n", pages, Credits.FormatCredits(sum)); "(Total value: {1})\n\n",
pages, Credits.FormatCredits(sum)
);
} }
private string BuildCargoSold(Objective objective) { private string BuildCargoSold(Objective objective) {
@ -160,6 +165,17 @@ namespace EliteBGS.BGS {
output.Append(")\n\n"); output.Append(")\n\n");
} }
var support = objective.LogEntries.OfType<InfluenceSupport>();
foreach (InfluenceSupport inf in support) {
output.Append(inf.ToString());
output.Append("\n");
total_influence += inf.Influence.Length;
}
if (support.Count() > 0) {
output.Append("\n");
}
if (total_influence > 0) { if (total_influence > 0) {
output.AppendFormat("Total Influence: {0}\n\n", total_influence); output.AppendFormat("Total Influence: {0}\n\n", total_influence);
} }

View File

@ -86,7 +86,7 @@
<ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="2"> <ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="2">
<Button x:Name="GenerateDiscord" Content="Generate Discord Report" VerticalAlignment="Center" Margin="0,0,0,4.857" Click="GenerateDiscord_Click" Height="26"/> <Button x:Name="GenerateDiscord" Content="Generate Discord Report" VerticalAlignment="Center" Margin="0,0,0,4.857" Click="GenerateDiscord_Click" Height="26"/>
<Separator /> <Separator />
<ComboBox x:Name="LogType" Height="36" Margin="0" VerticalAlignment="Center" Width="140" /> <ComboBox x:Name="LogType" Height="36" Margin="0" VerticalAlignment="Center" Width="140" SelectionChanged="LogType_SelectionChanged" />
</ToolBar> </ToolBar>
<TextBox x:Name="DiscordLog" Height="Auto" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.Row="1" Grid.ColumnSpan="3" AcceptsReturn="True" AcceptsTab="True"/> <TextBox x:Name="DiscordLog" Height="Auto" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.Row="1" Grid.ColumnSpan="3" AcceptsReturn="True" AcceptsTab="True"/>
</Grid> </Grid>

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Linq;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -27,6 +29,11 @@ namespace EliteBGS {
public Report Report => report; public Report Report => report;
private static readonly List<IDiscordLogGenerator> logtypes = new List<IDiscordLogGenerator>() {
new NonaDiscordLog(),
new GenericDiscordLog(),
};
public MainWindow() { public MainWindow() {
InitializeComponent(); InitializeComponent();
@ -38,9 +45,17 @@ namespace EliteBGS {
report.OnLog += Report_OnLog; report.OnLog += Report_OnLog;
LogType.Items.Add(new NonaDiscordLog()); foreach (IDiscordLogGenerator type in logtypes) {
LogType.Items.Add(new GenericDiscordLog()); LogType.Items.Add(type);
LogType.SelectedIndex = 0; }
string lastused = config.Global.LastUsedDiscordTemplate;
int lastindex = logtypes.FindIndex(x => x.ToString() == lastused);
if (lastindex > -1) {
LogType.SelectedIndex = lastindex;
} else {
LogType.SelectedIndex = 0;
}
api = new API(config.ConfigPath); api = new API(config.ConfigPath);
journal = new PlayerJournal(config.Global.JournalLocation); journal = new PlayerJournal(config.Global.JournalLocation);
@ -297,5 +312,14 @@ namespace EliteBGS {
RefreshObjectives(); RefreshObjectives();
} }
} }
private void LogType_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (LogType.SelectedItem == null) {
return;
}
string template = LogType.SelectedItem.ToString();
config.Global.LastUsedDiscordTemplate = template;
}
} }
} }

View File

@ -5,6 +5,7 @@ namespace EliteBGS.Util {
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 bool useeddb = false;
private string lastdiscordlog;
public string DefaultJournalLocation => default_journal_location; public string DefaultJournalLocation => default_journal_location;
@ -16,6 +17,14 @@ namespace EliteBGS.Util {
} }
} }
public string LastUsedDiscordTemplate {
get => lastdiscordlog;
set {
lastdiscordlog = value;
FirePropertyChanged("LastUsedDiscordTemplate");
}
}
public string JournalLocation { public string JournalLocation {
get { get {
if (journal_location == null) { if (journal_location == null) {