allow exclusion of specific log entries from discord log

This commit is contained in:
Florian Stinglmayr 2022-04-06 16:33:04 +02:00
parent d087c1862a
commit 773d98a4fb
10 changed files with 33 additions and 10 deletions

View File

@ -9,6 +9,8 @@ namespace EliteBGS.BGS {
public bool IsExpanded { get; set; }
public bool IsEnabled { get; set; } = true;
/// <summary>
/// Controlling faction of the station this entry was made/turned into.
/// </summary>

View File

@ -8,6 +8,7 @@ namespace EliteBGS.BGS.LogGenerator {
StringBuilder builder = new StringBuilder();
SellCargo[] sold = objective.LogEntries
.OfType<SellCargo>()
.Where(x => x.IsEnabled)
.ToArray()
;

View File

@ -4,9 +4,12 @@ using EDJournal;
namespace EliteBGS.BGS.LogGenerator {
public class CartographicsFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var total = objective.LogEntries.OfType<Cartographics>();
var total = objective.LogEntries
.OfType<Cartographics>()
.Where(x => x.IsEnabled)
;
var pages = total.Count();
long sum = total.Sum(x => (x as Cartographics).TotalSum);
long sum = total.Sum(x => x.TotalSum);
if (pages <= 0 || sum <= 0) {
return "";

View File

@ -5,7 +5,12 @@ using EDJournal;
namespace EliteBGS.BGS.LogGenerator {
public class FailedMissionFormat : LogFormatter {
public string GenerateLog(Objective objective) {
MissionFailed[] missions = objective.LogEntries.OfType<MissionFailed>().ToArray();
MissionFailed[] missions = objective
.LogEntries
.OfType<MissionFailed>()
.Where(x => x.IsEnabled)
.ToArray()
;
StringBuilder builder = new StringBuilder();
if (missions.Length <= 0) {

View File

@ -8,9 +8,9 @@ namespace EliteBGS.BGS.LogGenerator {
/// per line
/// </summary>
/// <typeparam name="Type">LogEntry subtype to work on</typeparam>
public class GenericFormat<Type> : LogFormatter {
public class GenericFormat<Type> : LogFormatter where Type : LogEntry {
public string GenerateLog(Objective objective) {
IEnumerable<Type> logs = objective.LogEntries.OfType<Type>();
IEnumerable<Type> logs = objective.LogEntries.OfType<Type>().Where(x => x.IsEnabled);
StringBuilder builder = new StringBuilder();
if (logs == null || logs.Count() <= 0) {

View File

@ -4,7 +4,10 @@ using EDJournal;
namespace EliteBGS.BGS.LogGenerator {
public class MicroResourcesFormat : LogFormatter {
public string GenerateLog(Objective objective) {
var total = objective.LogEntries.OfType<SellMicroResources>();
var total = objective.LogEntries
.OfType<SellMicroResources>()
.Where(x => x.IsEnabled)
;
long sum = total.Sum(x => x.TotalSum);
if (total == null || total.Count() <= 0 || sum <= 0) {

View File

@ -9,7 +9,10 @@ namespace EliteBGS.BGS.LogGenerator {
StringBuilder output = new StringBuilder();
int total_influence = 0;
var missions = objective.LogEntries.OfType<MissionCompleted>();
var missions = objective.LogEntries
.OfType<MissionCompleted>()
.Where(x => x.IsEnabled)
;
if (missions == null) {
return "";

View File

@ -1,4 +1,4 @@
namespace EliteBGS.BGS.LogGenerator {
class VistaGenomicsFormat : GenericFormat<VistaGenomicsFormat> {
class VistaGenomicsFormat : GenericFormat<OrganicData> {
}
}

View File

@ -6,7 +6,10 @@ namespace EliteBGS.BGS.LogGenerator {
public class VoucherFormat : LogFormatter {
public string GenerateLog(Objective objective) {
StringBuilder builder = new StringBuilder();
var missions = objective.LogEntries.OfType<Vouchers>();
var missions = objective.LogEntries
.OfType<Vouchers>()
.Where(x => x.IsEnabled)
;
if (missions == null || missions.Count() <= 0) {
return "";

View File

@ -61,7 +61,10 @@
</StackPanel>
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate>
<TextBlock Text="{Binding Name}"/>
<StackPanel Orientation="Horizontal">
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>