remember last selected discord log template

This commit is contained in:
Florian Stinglmayr 2022-01-22 09:19:16 +01:00
parent 654444d39c
commit c9cb3e26e0
3 changed files with 37 additions and 4 deletions

View File

@ -86,7 +86,7 @@
<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"/>
<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>
<TextBox x:Name="DiscordLog" Height="Auto" TextWrapping="Wrap" FontFamily="Consolas" FontSize="14" Grid.Row="1" Grid.ColumnSpan="3" AcceptsReturn="True" AcceptsTab="True"/>
</Grid>

View File

@ -1,4 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@ -27,6 +29,11 @@ namespace EliteBGS {
public Report Report => report;
private static readonly List<IDiscordLogGenerator> logtypes = new List<IDiscordLogGenerator>() {
new NonaDiscordLog(),
new GenericDiscordLog(),
};
public MainWindow() {
InitializeComponent();
@ -38,9 +45,17 @@ namespace EliteBGS {
report.OnLog += Report_OnLog;
LogType.Items.Add(new NonaDiscordLog());
LogType.Items.Add(new GenericDiscordLog());
foreach (IDiscordLogGenerator type in logtypes) {
LogType.Items.Add(type);
}
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);
journal = new PlayerJournal(config.Global.JournalLocation);
@ -297,5 +312,14 @@ namespace EliteBGS {
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 string journal_location = default_journal_location;
private bool useeddb = false;
private string lastdiscordlog;
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 {
get {
if (journal_location == null) {