From 773d98a4fb93e11edfe93bfc80514a8e2d104daf Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Wed, 6 Apr 2022 16:33:04 +0200 Subject: [PATCH] allow exclusion of specific log entries from discord log --- BGS/LogEntry.cs | 2 ++ BGS/LogGenerator/CargoSoldFormatter.cs | 1 + BGS/LogGenerator/CartographicsFormat.cs | 7 +++++-- BGS/LogGenerator/FailedMissionFormat.cs | 7 ++++++- BGS/LogGenerator/GenericFormat.cs | 4 ++-- BGS/LogGenerator/MicroResourcesFormat.cs | 5 ++++- BGS/LogGenerator/MissionFormat.cs | 5 ++++- BGS/LogGenerator/VistaGenomicsFormat.cs | 2 +- BGS/LogGenerator/VoucherFormat.cs | 5 ++++- MainWindow.xaml | 5 ++++- 10 files changed, 33 insertions(+), 10 deletions(-) diff --git a/BGS/LogEntry.cs b/BGS/LogEntry.cs index 7feb482..197779c 100644 --- a/BGS/LogEntry.cs +++ b/BGS/LogEntry.cs @@ -9,6 +9,8 @@ namespace EliteBGS.BGS { public bool IsExpanded { get; set; } + public bool IsEnabled { get; set; } = true; + /// /// Controlling faction of the station this entry was made/turned into. /// diff --git a/BGS/LogGenerator/CargoSoldFormatter.cs b/BGS/LogGenerator/CargoSoldFormatter.cs index f0b2d18..7e286a9 100644 --- a/BGS/LogGenerator/CargoSoldFormatter.cs +++ b/BGS/LogGenerator/CargoSoldFormatter.cs @@ -8,6 +8,7 @@ namespace EliteBGS.BGS.LogGenerator { StringBuilder builder = new StringBuilder(); SellCargo[] sold = objective.LogEntries .OfType() + .Where(x => x.IsEnabled) .ToArray() ; diff --git a/BGS/LogGenerator/CartographicsFormat.cs b/BGS/LogGenerator/CartographicsFormat.cs index 181a1cf..8d1b698 100644 --- a/BGS/LogGenerator/CartographicsFormat.cs +++ b/BGS/LogGenerator/CartographicsFormat.cs @@ -4,9 +4,12 @@ using EDJournal; namespace EliteBGS.BGS.LogGenerator { public class CartographicsFormat : LogFormatter { public string GenerateLog(Objective objective) { - var total = objective.LogEntries.OfType(); + var total = objective.LogEntries + .OfType() + .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 ""; diff --git a/BGS/LogGenerator/FailedMissionFormat.cs b/BGS/LogGenerator/FailedMissionFormat.cs index a425c43..485ae2e 100644 --- a/BGS/LogGenerator/FailedMissionFormat.cs +++ b/BGS/LogGenerator/FailedMissionFormat.cs @@ -5,7 +5,12 @@ using EDJournal; namespace EliteBGS.BGS.LogGenerator { public class FailedMissionFormat : LogFormatter { public string GenerateLog(Objective objective) { - MissionFailed[] missions = objective.LogEntries.OfType().ToArray(); + MissionFailed[] missions = objective + .LogEntries + .OfType() + .Where(x => x.IsEnabled) + .ToArray() + ; StringBuilder builder = new StringBuilder(); if (missions.Length <= 0) { diff --git a/BGS/LogGenerator/GenericFormat.cs b/BGS/LogGenerator/GenericFormat.cs index 079437e..bf09b00 100644 --- a/BGS/LogGenerator/GenericFormat.cs +++ b/BGS/LogGenerator/GenericFormat.cs @@ -8,9 +8,9 @@ namespace EliteBGS.BGS.LogGenerator { /// per line /// /// LogEntry subtype to work on - public class GenericFormat : LogFormatter { + public class GenericFormat : LogFormatter where Type : LogEntry { public string GenerateLog(Objective objective) { - IEnumerable logs = objective.LogEntries.OfType(); + IEnumerable logs = objective.LogEntries.OfType().Where(x => x.IsEnabled); StringBuilder builder = new StringBuilder(); if (logs == null || logs.Count() <= 0) { diff --git a/BGS/LogGenerator/MicroResourcesFormat.cs b/BGS/LogGenerator/MicroResourcesFormat.cs index 021efb8..086607d 100644 --- a/BGS/LogGenerator/MicroResourcesFormat.cs +++ b/BGS/LogGenerator/MicroResourcesFormat.cs @@ -4,7 +4,10 @@ using EDJournal; namespace EliteBGS.BGS.LogGenerator { public class MicroResourcesFormat : LogFormatter { public string GenerateLog(Objective objective) { - var total = objective.LogEntries.OfType(); + var total = objective.LogEntries + .OfType() + .Where(x => x.IsEnabled) + ; long sum = total.Sum(x => x.TotalSum); if (total == null || total.Count() <= 0 || sum <= 0) { diff --git a/BGS/LogGenerator/MissionFormat.cs b/BGS/LogGenerator/MissionFormat.cs index e29e474..eee414a 100644 --- a/BGS/LogGenerator/MissionFormat.cs +++ b/BGS/LogGenerator/MissionFormat.cs @@ -9,7 +9,10 @@ namespace EliteBGS.BGS.LogGenerator { StringBuilder output = new StringBuilder(); int total_influence = 0; - var missions = objective.LogEntries.OfType(); + var missions = objective.LogEntries + .OfType() + .Where(x => x.IsEnabled) + ; if (missions == null) { return ""; diff --git a/BGS/LogGenerator/VistaGenomicsFormat.cs b/BGS/LogGenerator/VistaGenomicsFormat.cs index 64385cb..442ed5c 100644 --- a/BGS/LogGenerator/VistaGenomicsFormat.cs +++ b/BGS/LogGenerator/VistaGenomicsFormat.cs @@ -1,4 +1,4 @@ namespace EliteBGS.BGS.LogGenerator { - class VistaGenomicsFormat : GenericFormat { + class VistaGenomicsFormat : GenericFormat { } } diff --git a/BGS/LogGenerator/VoucherFormat.cs b/BGS/LogGenerator/VoucherFormat.cs index 85684ae..aeea55c 100644 --- a/BGS/LogGenerator/VoucherFormat.cs +++ b/BGS/LogGenerator/VoucherFormat.cs @@ -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(); + var missions = objective.LogEntries + .OfType() + .Where(x => x.IsEnabled) + ; if (missions == null || missions.Count() <= 0) { return ""; diff --git a/MainWindow.xaml b/MainWindow.xaml index e31461f..2081a1e 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -61,7 +61,10 @@ - + + + +