Compare commits

...

9 Commits

6 changed files with 105 additions and 40 deletions

View File

@ -111,10 +111,7 @@ internal class TransactionParserContext {
.Count() .Count()
; ;
if (warzoneNpcs >= 2 && grade != CombatZones.DifficultyHigh) { if (warzoneNpcs >= 1 && grade == CombatZones.DifficultyLow) {
// Only large combat zones have two NPCs
grade = CombatZones.DifficultyHigh;
} else if (warzoneNpcs >= 1 && grade == CombatZones.DifficultyLow) {
grade = CombatZones.DifficultyMedium; grade = CombatZones.DifficultyMedium;
} }
} }

View File

@ -55,11 +55,12 @@
<Resource Include="EliteBGS.ico" /> <Resource Include="EliteBGS.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" /> <PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" /> <PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -13,8 +13,10 @@ public class MissionFormat : LogFormatter {
int total_influence = 0; int total_influence = 0;
var missions = objective.EnabledOfType<MissionCompleted>(); var missions = objective.EnabledOfType<MissionCompleted>();
var support = objective.EnabledOfType<InfluenceSupport>();
if (missions == null || missions.Count == 0) { if ((missions == null || missions.Count == 0) &&
(support == null || support.Count == 0)) {
return ""; return "";
} }
@ -56,7 +58,6 @@ public class MissionFormat : LogFormatter {
output.Append("\n\n"); output.Append("\n\n");
var support = objective.EnabledOfType<InfluenceSupport>();
foreach (InfluenceSupport inf in support) { foreach (InfluenceSupport inf in support) {
output.Append(inf.ToString()); output.Append(inf.ToString());
output.Append("\n"); output.Append("\n");

View File

@ -4,10 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:abc="http://wpfcontrols.com/" xmlns:abc="http://wpfcontrols.com/"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:EliteBGS" xmlns:local="clr-namespace:EliteBGS"
xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow" 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="Salus.ico" Closing="window_Closing"> Title="Elite: Dangerous BGS Helper" Height="520" Width="950" Icon="Salus.ico" Closing="window_Closing">
<Window.Resources> <Window.Resources>
<Style x:Key="StretchingTreeViewStyle" TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}"> <Style x:Key="StretchingTreeViewStyle" TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
@ -27,24 +28,31 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition/>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/>
<RowDefinition Height="*" /> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ToolBar VerticalAlignment="Top" Grid.Row="1" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left"> <ToolBar VerticalAlignment="Top" Grid.Row="0" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/> <Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/> <Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Label Content="From:" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/> <Label Content="From (UTC):" VerticalAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
<DatePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/> <xctk:DateTimePicker x:Name="startdate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Content="To:" Height="26.2857142857143" VerticalAlignment="Top"/> <Label Content="To (UTC):" Height="26.2857142857143" VerticalAlignment="Top"/>
<DatePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/> <xctk:DateTimePicker x:Name="enddate" Height="26.2857142857143" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/> <Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" /> <Button x:Name="ResetTime" Content="Reset Time" Click="ResetTime_Click" />
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
<Button x:Name="ManuallyParse" Content="Manually Parse" Click="ManuallyParse_Click" />
</ToolBar>
<ToolBar Grid.Row="1" HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="3">
<Button x:Name="GenerateDiscord" Content="Generate Discord Report" VerticalAlignment="Stretch" Margin="0,0,0,0" VerticalContentAlignment="Center" Click="GenerateDiscord_Click" Height="26"/>
<Separator />
<ComboBox x:Name="LogType" VerticalAlignment="Stretch" Margin="0,3,0,3" Width="140" SelectionChanged="LogType_SelectionChanged" />
</ToolBar> </ToolBar>
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated" <TreeView CheckBox.Checked="TreeView_CheckBox_Updated"
CheckBox.Unchecked="TreeView_CheckBox_Updated" CheckBox.Unchecked="TreeView_CheckBox_Updated"
@ -65,15 +73,17 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5,0,5"> <StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,2,0,2">
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/> <CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
<TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="5,0,0,0"/> <TextBlock Text="System: " Visibility="{Binding HasSystem}" Margin="2,0,0,0"/>
<TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/> <TextBlock Text="{Binding System}" FontWeight="DemiBold" Visibility="{Binding HasSystem}"/>
<TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="5,0,0,0"/> <TextBlock Text="Faction: " Visibility="{Binding HasFaction}" Margin="2,0,0,0"/>
<TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/> <TextBlock Text="{Binding Faction}" FontWeight="DemiBold" Visibility="{Binding HasFaction}"/>
</StackPanel> </StackPanel>
<Separator Visibility="Hidden" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" /> <Separator Visibility="Hidden" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center"> <StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<ToggleButton x:Name="ToggleAll" Content="Toggle All" Click="ToggleAll_Click" IsChecked="True" IsThreeState="False"/>
<Separator Margin="2,0,2,0" />
<Button x:Name="AddCombatZone" Content="Add Combat Zone" Click="AddCombatZone_Click" /> <Button x:Name="AddCombatZone" Content="Add Combat Zone" Click="AddCombatZone_Click" />
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -83,7 +93,7 @@
<Grid Initialized="Transaction_Initialized" <Grid Initialized="Transaction_Initialized"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}" Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
Margin="0,5,0,5" Margin="0,2,0,2"
> >
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@ -93,7 +103,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Center"> <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/> <CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
<TextBlock Text="{Binding CompletedAt}" Margin="5,0,5,0" HorizontalAlignment="Right" TextAlignment="Center"/> <TextBlock Text="{Binding CompletedAt}" Margin="2,0,2,0" HorizontalAlignment="Right" TextAlignment="Center"/>
<TextBlock Text="{Binding Name}" FontWeight="DemiBold" TextAlignment="Center"/> <TextBlock Text="{Binding Name}" FontWeight="DemiBold" TextAlignment="Center"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="CombatZone" Visibility="{Binding IsCombatZone}"> <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="CombatZone" Visibility="{Binding IsCombatZone}">
@ -136,12 +146,8 @@
</Style> </Style>
</TreeView.ItemContainerStyle> </TreeView.ItemContainerStyle>
</TreeView> </TreeView>
<ToolBar HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="Auto" Grid.Row="3" Grid.ColumnSpan="2"> <GridSplitter Background="LightSkyBlue" Grid.Row="3" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.ColumnSpan="3" ResizeBehavior="PreviousAndNext"/>
<Button x:Name="GenerateDiscord" Content="Generate Discord Report" VerticalAlignment="Center" Margin="0,0,0,4.857" Click="GenerateDiscord_Click" Height="26"/> <TextBox x:Name="DiscordLog" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="4" Height="Auto" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.ColumnSpan="3" AcceptsReturn="True" AcceptsTab="True"/>
<Separator />
<ComboBox x:Name="LogType" Height="36" Margin="0" VerticalAlignment="Center" Width="140" SelectionChanged="LogType_SelectionChanged" />
</ToolBar>
<TextBox x:Name="DiscordLog" Height="Auto" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.Row="4" Grid.ColumnSpan="3" AcceptsReturn="True" AcceptsTab="True"/>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Settings" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="53.7142857142857"> <TabItem Header="Settings" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="53.7142857142857">

View File

@ -11,7 +11,9 @@ using EDPlayerJournal.BGS;
using EDPlayerJournal.Entries; using EDPlayerJournal.Entries;
using EliteBGS.BGS; using EliteBGS.BGS;
using EliteBGS.Util; using EliteBGS.Util;
using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Controls.Primitives;
namespace EliteBGS; namespace EliteBGS;
@ -56,11 +58,21 @@ public partial class MainWindow : Window {
journal = new PlayerJournal(Config.Global.JournalLocation); journal = new PlayerJournal(Config.Global.JournalLocation);
// Set both to now // Set both to now
startdate.SelectedDate = DateTime.Now; InitialiseTime();
enddate.SelectedDate = DateTime.Now;
journallocation.Text = Config.Global.JournalLocation; journallocation.Text = Config.Global.JournalLocation;
} }
private void InitialiseTime() {
DateTime today = DateTime.Today;
DateTime tomorrow = today.AddDays(1);
startdate.CultureInfo = enddate.CultureInfo = CultureInfo.InvariantCulture;
startdate.Value = today;
enddate.Value = tomorrow;
}
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) { private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
GenerateLog(); GenerateLog();
} }
@ -86,9 +98,8 @@ public partial class MainWindow : Window {
List<Transaction> transactions = parser.Parse(entries); List<Transaction> transactions = parser.Parse(entries);
// Filter the transactions down to the given time frame // Filter the transactions down to the given time frame
DateTime actualend = end.AddDays(1);
transactions = transactions transactions = transactions
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= actualend) .Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= end)
.ToList() .ToList()
; ;
@ -120,8 +131,8 @@ public partial class MainWindow : Window {
try { try {
TransactionParser parser = new TransactionParser(); TransactionParser parser = new TransactionParser();
DateTime start = startdate.SelectedDate ?? DateTime.Now; DateTime start = startdate.Value ?? DateTime.Now;
DateTime end = enddate.SelectedDate ?? DateTime.Now; DateTime end = enddate.Value ?? DateTime.Now;
journal.Open(); // Load all files journal.Open(); // Load all files
// Log files only get rotated if you restart the game client. This means that there might // Log files only get rotated if you restart the game client. This means that there might
@ -207,13 +218,17 @@ public partial class MainWindow : Window {
journal = new PlayerJournal(Config.Global.JournalLocation); journal = new PlayerJournal(Config.Global.JournalLocation);
} }
private void AddCombatZone_Click(object sender, RoutedEventArgs e) { private Objective GetObjectiveFromControl(object sender) {
System.Windows.Controls.Control control = sender as System.Windows.Controls.Control; System.Windows.Controls.Control control = sender as System.Windows.Controls.Control;
if (control == null || control.DataContext == null) { if (control == null || control.DataContext == null) {
return; return null;
} }
Objective objective = control.DataContext as Objective; return control.DataContext as Objective;
}
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
Objective objective = GetObjectiveFromControl(sender);
if (objective == null) { if (objective == null) {
return; return;
} }
@ -363,4 +378,38 @@ public partial class MainWindow : Window {
RefreshView(); RefreshView();
} }
} }
private DateTime ResetTimeToZero(DateTime d) {
DateTime obj = d;
obj = obj.AddHours(d.Hour * -1);
obj = obj.AddMinutes(d.Minute * -1);
obj = obj.AddSeconds(d.Second * -1);
return obj;
}
private void ResetTime_Click(object sender, RoutedEventArgs e) {
DateTime? d = startdate.Value;
if (d != null) {
startdate.Value = ResetTimeToZero(d.Value);
}
d = enddate.Value;
if (d != null) {
enddate.Value = ResetTimeToZero(d.Value);
}
}
private void ToggleAll_Click(object sender, RoutedEventArgs e) {
ToggleButton button = sender as ToggleButton;
Objective objective = GetObjectiveFromControl(sender);
if (objective == null) {
return;
}
objective.UITransactions
.ForEach(x => x.IsEnabled = (button.IsChecked ?? true))
;
}
} }

View File

@ -6,11 +6,22 @@ using EDPlayerJournal.BGS;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using EDPlayerJournal; using EDPlayerJournal;
using System.ComponentModel;
namespace EliteBGS; namespace EliteBGS;
public class UITransaction { public class UITransaction : INotifyPropertyChanged {
public bool IsEnabled { get; set; } = true; private bool isenabled = true;
public event PropertyChangedEventHandler PropertyChanged;
public bool IsEnabled {
get { return isenabled; }
set {
isenabled = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsEnabled"));
}
}
public bool IsExpanded { get; set; } = true; public bool IsExpanded { get; set; } = true;