Compare commits
2 Commits
8d95a42698
...
0cc8a1f29a
Author | SHA1 | Date | |
---|---|---|---|
0cc8a1f29a | |||
22396c9b22 |
@ -224,6 +224,12 @@ internal class FSDJumpParser : TransactionParserPart {
|
||||
throw new InvalidJournalEntryException();
|
||||
}
|
||||
|
||||
// If you FSD jump straight out of the combat zone into a different system
|
||||
// then the combat zone will be placed in the wrong system otherwise.
|
||||
// This call needs to be *before* changing the current system.
|
||||
context.DiscernCombatZone(transactions, e);
|
||||
context.ResetCombatZone();
|
||||
|
||||
context.CurrentSystem = entry.StarSystem;
|
||||
context.CurrentSystemAddress = entry.SystemAddress;
|
||||
|
||||
|
@ -8,6 +8,12 @@
|
||||
xmlns:Util="clr-namespace:EliteBGS.Util" d:DataContext="{d:DesignInstance Type=Util:AppConfig}" x:Name="window" x:Class="EliteBGS.MainWindow"
|
||||
mc:Ignorable="d"
|
||||
Title="Elite: Dangerous BGS Helper" Height="520" Width="890" Icon="EliteBGS.ico" Closing="window_Closing">
|
||||
<Window.Resources>
|
||||
<Style x:Key="StretchingTreeViewStyle" TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
<local:MinusFortyFiveConverter x:Key="MinusFortyFiveConverter" />
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@ -44,20 +50,50 @@
|
||||
<Separator Margin="1" VerticalAlignment="Center" MinWidth="1" HorizontalAlignment="Center" MinHeight="22"/>
|
||||
<Button x:Name="ManuallyParse" Content="Manually Parse JSON" Click="ManuallyParse_Click" />
|
||||
</ToolBar>
|
||||
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated" CheckBox.Unchecked="TreeView_CheckBox_Updated" x:Name="entries" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Row="2" KeyUp="entries_KeyUp">
|
||||
<TreeView CheckBox.Checked="TreeView_CheckBox_Updated"
|
||||
CheckBox.Unchecked="TreeView_CheckBox_Updated"
|
||||
x:Name="entries" Margin="0,0,0,0"
|
||||
Grid.ColumnSpan="3" Grid.Row="2"
|
||||
KeyUp="entries_KeyUp"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}">
|
||||
<HierarchicalDataTemplate DataType="{x:Type local:Objective}" ItemsSource="{Binding UITransactions}" ItemContainerStyle="{StaticResource StretchingTreeViewStyle}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Name}" Margin="5,0" />
|
||||
</StackPanel>
|
||||
<HierarchicalDataTemplate.ItemTemplate>
|
||||
<HierarchicalDataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding CompletedAt}" Margin="5,0,5,0" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="{Binding Name}" FontWeight="DemiBold"/>
|
||||
</StackPanel>
|
||||
<!-- This will stretch out the width of the item-->
|
||||
<Grid Initialized="Transaction_Initialized"
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="{Binding ActualWidth, ElementName=entries, Converter={StaticResource MinusFortyFiveConverter}}"
|
||||
>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||
<CheckBox Focusable="False" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding CompletedAt}" Margin="5,0,5,0" HorizontalAlignment="Right" TextAlignment="Center"/>
|
||||
<TextBlock Text="{Binding Name}" FontWeight="DemiBold" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<Separator Visibility="Hidden" Grid.Column="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" x:Name="CombatZone">
|
||||
<Button x:Name="Low" Content="Low" Click="Low_Click"/>
|
||||
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||
<Button Content="Med" x:Name="Med" Click="Med_Click" />
|
||||
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||
<Button Content="High" x:Name="High" Click="High_Click"/>
|
||||
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||
<Button Content="On Foot" x:Name="OnFoot" Click="OnFoot_Click"/>
|
||||
<Separator Margin="2,0,2,0" VerticalAlignment="Top"/>
|
||||
<Button Content="Ship" x:Name="Ship" Click="Ship_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</HierarchicalDataTemplate>
|
||||
</HierarchicalDataTemplate.ItemTemplate>
|
||||
</HierarchicalDataTemplate>
|
||||
|
@ -11,6 +11,7 @@ using EDPlayerJournal.BGS;
|
||||
using EDPlayerJournal.Entries;
|
||||
using EliteBGS.BGS;
|
||||
using EliteBGS.Util;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace EliteBGS;
|
||||
|
||||
@ -183,7 +184,7 @@ public partial class MainWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
private void entries_KeyUp(object sender, KeyEventArgs e) {
|
||||
private void entries_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) {
|
||||
if (e.Key == Key.Delete) {
|
||||
RemoveCurrentObjective();
|
||||
}
|
||||
@ -312,4 +313,92 @@ public partial class MainWindow : Window {
|
||||
loadentries?.Close();
|
||||
loadentries = null;
|
||||
}
|
||||
|
||||
private void Transaction_Initialized(object sender, EventArgs e) {
|
||||
Grid grid = sender as Grid;
|
||||
if (grid == null || grid.DataContext == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UITransaction t = grid.DataContext as UITransaction;
|
||||
if (t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool iscombatzone = (t.Transaction.GetType() == typeof(CombatZone));
|
||||
|
||||
var children = grid
|
||||
.Children
|
||||
.OfType<StackPanel>()
|
||||
.Where(x => x.Name == "CombatZone")
|
||||
;
|
||||
|
||||
foreach (var child in children ) {
|
||||
child.Visibility = (iscombatzone ? Visibility.Visible : Visibility.Collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction {
|
||||
System.Windows.Controls.Control? button = sender as System.Windows.Controls.Control;
|
||||
if (button == null || button.DataContext == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UITransaction transaction = button.DataContext as UITransaction;
|
||||
if (transaction == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return transaction.Transaction as TransactionType;
|
||||
}
|
||||
|
||||
private void Low_Click(object sender, RoutedEventArgs e) {
|
||||
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||
if (transaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.Grade = "Low";
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void Med_Click(object sender, RoutedEventArgs e) {
|
||||
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||
if (transaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.Grade = "Medium";
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void High_Click(object sender, RoutedEventArgs e) {
|
||||
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||
if (transaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.Grade = "High";
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void OnFoot_Click(object sender, RoutedEventArgs e) {
|
||||
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||
if (transaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.Type = "OnFoot";
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void Ship_Click(object sender, RoutedEventArgs e) {
|
||||
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
||||
if (transaction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.Type = "Ship";
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
19
EliteBGS/MinusFortyFiveConverter.cs
Normal file
19
EliteBGS/MinusFortyFiveConverter.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System;
|
||||
|
||||
namespace EliteBGS;
|
||||
|
||||
public class MinusFortyFiveConverter : IValueConverter {
|
||||
/// <inheritdoc/>
|
||||
public object Convert(
|
||||
object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
return (double)value - 45;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object ConvertBack(
|
||||
object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
throw new NotSupportedException("Cannot convert back");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user