Compare commits

...

4 Commits

Author SHA1 Message Date
1693d8882d fix a few issues around Date picker 2024-11-08 09:23:17 +01:00
043808fe0a fix check boxes 2024-11-08 09:16:30 +01:00
582d663baa fix message boxes 2024-11-08 09:16:22 +01:00
a3af0d43df fix includes 2024-11-08 09:11:52 +01:00

View File

@ -11,8 +11,10 @@ using System.Globalization;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Input;
using MsBox.Avalonia;
namespace EliteBGS;
@ -57,9 +59,9 @@ public partial class MainWindow : Window {
LogType.SelectedIndex = 0;
}
this.NoInfluenceSupport.IsOn = Config.Global.IgnoreInfluenceSupport;
this.NoMarketBuy.IsOn = Config.Global.IgnoreMarketBuy;
this.NoFleetCarrier.IsOn = Config.Global.IgnoreFleetCarrier;
this.NoInfluenceSupport.IsChecked = Config.Global.IgnoreInfluenceSupport;
this.NoMarketBuy.IsChecked = Config.Global.IgnoreMarketBuy;
this.NoFleetCarrier.IsChecked = Config.Global.IgnoreFleetCarrier;
/*
// Apply theme
@ -151,8 +153,8 @@ public partial class MainWindow : Window {
// HOCHKULTUR
startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT");
startdate.SelectedDateTime = today;
enddate.SelectedDateTime = tomorrow;
startdate.SelectedDate = today;
enddate.SelectedDate = tomorrow;
}
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
@ -213,7 +215,10 @@ public partial class MainWindow : Window {
}
private void HandleEntries(List<Entry> entries) {
HandleEntries(entries, startdate.SelectedDateTime ?? DateTime.Now, enddate.SelectedDateTime ?? DateTime.Now);
HandleEntries(entries,
startdate.SelectedDate?.Date ?? DateTime.Now,
enddate.SelectedDate?.Date ?? DateTime.Now
);
}
private void Loadentries_EntriesLoaded(List<Entry> lines) {
@ -224,21 +229,26 @@ public partial class MainWindow : Window {
try {
TransactionParser parser = new TransactionParser();
DateTime start = startdate.SelectedDateTime ?? DateTime.Now;
DateTime end = enddate.SelectedDateTime ?? DateTime.Now;
DateTime start = startdate.SelectedDate?.Date ?? DateTime.Now;
DateTime end = enddate.SelectedDate?.Date ?? DateTime.Now;
journal.Open(); // Load all files
// Log files only get rotated if you restart the game client. This means that there might
// be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This
// happens if you happen to play a session late into the night.
// At first I tried extracting the first and last line of a file to see the date range, but
// if you have a lot of files this becomes quite slow, and quite the memory hog (as journal
// files have to be read in their entirety to check this). So we assume that you can't play
// three days straight, and keep the code fast.
// Log files only get rotated if you restart the game
// client. This means that there might be - say - entries
// from the 4th of May in the file with a timestamp of 3rd
// of May. This happens if you happen to play a session
// late into the night. At first I tried extracting the
// first and last line of a file to see the date range,
// but if you have a lot of files this becomes quite slow,
// and quite the memory hog (as journal files have to be
// read in their entirety to check this). So we assume
// that you can't play three days straight, and keep the
// code fast.
DateTime actualstart = start.AddDays(-3);
DateTime actualend = end.AddDays(1);
List<Entry> entries = journal.Files
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= actualend)
.Where(f => f.NormalisedDateTime >= actualstart &&
f.NormalisedDateTime <= actualend)
.SelectMany(e => e.Entries)
.ToList()
;
@ -318,15 +328,11 @@ public partial class MainWindow : Window {
}
private void browsejournallocation_Click(object sender, RoutedEventArgs e) {
var dialog = new VistaFolderBrowserDialog();
// **TODO**
if ((bool)!dialog.ShowDialog()) {
return;
}
Config.Global.JournalLocation = dialog.SelectedPath;
journallocation.Text = Config.Global.JournalLocation;
journal = new PlayerJournal(Config.Global.JournalLocation);
//Config.Global.JournalLocation = dialog.SelectedPath;
//journallocation.Text = Config.Global.JournalLocation;
//journal = new PlayerJournal(Config.Global.JournalLocation);
}
private Objective GetObjectiveFromControl(object sender) {
@ -396,8 +402,12 @@ public partial class MainWindow : Window {
Config.SaveGlobal();
} catch (Exception error) {
var box = MessageBoxManager
.GetMessageBoxStandard("There was an error saving your settings" + error.Message);
box.Show();
.GetMessageBoxStandard(
"Error",
"There was an error saving your settings" + error.Message
);
var result = box.ShowAsPopupAsync(this);
result.Wait();
}
}
@ -509,14 +519,14 @@ public partial class MainWindow : Window {
}
private void ResetTime_Click(object sender, RoutedEventArgs e) {
DateTime? d = startdate.SelectedDateTime;
DateTime? d = startdate.SelectedDate?.Date;
if (d != null) {
startdate.SelectedDateTime = ResetTimeToZero(d.Value);
startdate.SelectedDate = ResetTimeToZero(d.Value);
}
d = enddate.SelectedDateTime;
d = enddate.SelectedDate;
if (d != null) {
enddate.SelectedDateTime = ResetTimeToZero(d.Value);
enddate.SelectedDate = ResetTimeToZero(d.Value);
}
}
@ -533,12 +543,12 @@ public partial class MainWindow : Window {
}
private void UpdateTheme() {
ThemeManager.Current.ChangeTheme(this, Config.Global.FullTheme);
//ThemeManager.Current.ChangeTheme(this, Config.Global.FullTheme);
}
private void SwitchTheme_Toggled(object sender, RoutedEventArgs e) {
ToggleSwitch toggle = sender as ToggleSwitch;
if (toggle.IsOn) {
if ((bool)toggle.IsChecked) {
Config.Global.Theme = "Dark";
} else {
Config.Global.Theme = "Light";
@ -566,15 +576,15 @@ public partial class MainWindow : Window {
*/
private void NoInfluenceSupport_Toggled(object sender, RoutedEventArgs e) {
Config.Global.IgnoreInfluenceSupport = this.NoInfluenceSupport.IsOn;
Config.Global.IgnoreInfluenceSupport = (bool)this.NoInfluenceSupport.IsChecked;
}
private void NoMarketBuy_Toggled(object sender, RoutedEventArgs e) {
Config.Global.IgnoreMarketBuy = this.NoMarketBuy.IsOn;
Config.Global.IgnoreMarketBuy = (bool)this.NoMarketBuy.IsChecked;
}
private void NoFleetCarrier_Toggled(object sender, RoutedEventArgs e) {
Config.Global.IgnoreFleetCarrier = this.NoFleetCarrier.IsOn;
Config.Global.IgnoreFleetCarrier = (bool)this.NoFleetCarrier.IsChecked;
}
private void OpenInExplorer_Click(object sender, RoutedEventArgs e) {
@ -675,12 +685,13 @@ public partial class MainWindow : Window {
} catch (Exception) {
var box = MessageBoxManager
.GetMessageBoxStandard(
"Sorry!",
"The log could not be split into discord appropriate length.\n" +
"This happens with the bigger logs formats if you do lots of things in one system.\n" +
"Try posting the log in the OneLine format.",
"Sorry!"
"Try posting the log in the OneLine format. "
);
box.Show();
var result = box.ShowAsPopupAsync(this);
result.Wait();
return;
}