Skip to content
Merged
8 changes: 7 additions & 1 deletion Knossos.NET/AppStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@
</Border>
</Design.PreviewWith>

<!--Icons-->
<!--https://avaloniaui.github.io/icons.html-->
<Styles.Resources>
<StreamGeometry x:Key="3LinesRegular">M2 4.5C2 4.22386 2.22386 4 2.5 4H17.5C17.7761 4 18 4.22386 18 4.5C18 4.77614 17.7761 5 17.5 5H2.5C2.22386 5 2 4.77614 2 4.5Z M2 9.5C2 9.22386 2.22386 9 2.5 9H17.5C17.7761 9 18 9.22386 18 9.5C18 9.77614 17.7761 10 17.5 10H2.5C2.22386 10 2 9.77614 2 9.5Z M2.5 14C2.22386 14 2 14.2239 2 14.5C2 14.7761 2.22386 15 2.5 15H17.5C17.7761 15 18 14.7761 18 14.5C18 14.2239 17.7761 14 17.5 14H2.5Z</StreamGeometry>
</Styles.Resources>

<!--Color Resource Definition-->
<Styles.Resources>
<SolidColorBrush x:Key="BackgroundColorPrimary">#18191A</SolidColorBrush>
<SolidColorBrush x:Key="BackgroundColorSecondary">#422626</SolidColorBrush>
<SolidColorBrush x:Key="BackgroundColorSecondary">#2d2d2d</SolidColorBrush>
<SolidColorBrush x:Key="BackgroundColorTertiary">#131414</SolidColorBrush>

<SolidColorBrush x:Key="PrimaryColor">#257200</SolidColorBrush>
Expand Down
Binary file modified Knossos.NET/Assets/fs2_res/kn_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_screen_9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/fs2_res/kn_tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/NebulaDefault.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/clean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/custom-config-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/discordicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/fred.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/fsolua.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Knossos.NET/Assets/general/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/menu_community.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/menu_debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/menu_develop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/menu_engine.png
Binary file added Knossos.NET/Assets/general/menu_explore.png
Binary file added Knossos.NET/Assets/general/menu_multiplayer.png
Binary file added Knossos.NET/Assets/general/menu_play.png
Binary file added Knossos.NET/Assets/general/menu_settings.png
Binary file modified Knossos.NET/Assets/general/play-button.png
Binary file modified Knossos.NET/Assets/general/questionmark.png
Binary file modified Knossos.NET/Assets/general/refresh.png
Binary file modified Knossos.NET/Assets/general/restart.png
Binary file modified Knossos.NET/Assets/general/resume.png
Binary file modified Knossos.NET/Assets/general/screenshot.png
Binary file modified Knossos.NET/Assets/general/sort-icon.png
Binary file modified Knossos.NET/Assets/general/x.png
5 changes: 1 addition & 4 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ public static async void StartUp(bool isQuickLaunch, bool forceUpdate)

//Load knossos config
globalSettings.Load();

if (MainWindowViewModel.Instance != null){
MainWindowViewModel.Instance.applySettingsToList();
}
MainWindowViewModel.Instance?.ApplySettings();


//Print Decompressor Type
Expand Down
45 changes: 45 additions & 0 deletions Knossos.NET/Converters/BitmapAssetValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Avalonia.Data.Converters;
using System;
using System.Globalization;
using Avalonia.Platform;
using System.Reflection;
using Avalonia.Media.Imaging;

namespace Knossos.NET.Converters
{
public class BitmapAssetValueConverter : IValueConverter
{
public static BitmapAssetValueConverter Instance { get; } = new();

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value == null) return null;

if (value is not string rawUri || !targetType.IsAssignableFrom(typeof(Bitmap)))
{
throw new NotSupportedException();
}

Uri uri;

if (rawUri.StartsWith("avares://"))
{
uri = new Uri(rawUri);
}
else
{
var assemblyName = Assembly.GetEntryAssembly()?.GetName().Name;
uri = new Uri($"avares://{assemblyName}/{rawUri.TrimStart('/')}");
}

var asset = AssetLoader.Open(uri);

return new Bitmap(asset);
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
94 changes: 75 additions & 19 deletions Knossos.NET/Models/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,58 @@ public AutoUpdateFsoBuilds(bool stable = false, bool rc = false, bool nightly =
[JsonPropertyName("warn_new_settings_system")]
public bool warnNewSettingsSystem { get; set; } = true;

/*
* Settings that can wait to be saved at app close so we dont have to call save() all the time
* use JsonIgnore, private and '_' for the actual variable name
*/
[JsonIgnore]
private bool pendingChangesOnAppClose { get; set; } = false;

[JsonIgnore]
private bool _mainMenuOpen = true;
[JsonPropertyName("main_menu_open")]
public bool mainMenuOpen
{
get { return _mainMenuOpen; }
set { if ( _mainMenuOpen != value ) { _mainMenuOpen = value; pendingChangesOnAppClose = true; } }
}

[JsonIgnore]
private bool _hideBuildRC = true;
[JsonPropertyName("hide_build_rc")]
public bool hideBuildRC
{
get { return _hideBuildRC; }
set { if (_hideBuildRC != value) { _hideBuildRC = value; pendingChangesOnAppClose = true; } }
}

[JsonIgnore]
private bool _hideBuildCustom = true;
[JsonPropertyName("hide_build_custom")]
public bool hideBuildCustom
{
get { return _hideBuildCustom; }
set { if (_hideBuildCustom != value) { _hideBuildCustom = value; pendingChangesOnAppClose = true; } }
}

[JsonIgnore]
private bool _hideBuildNightly = true;
[JsonPropertyName("hide_build_nightly")]
public bool hideBuildNightly
{
get { return _hideBuildNightly; }
set { if (_hideBuildNightly != value) { _hideBuildNightly = value; pendingChangesOnAppClose = true; } }
}

[JsonIgnore]
private MainWindowViewModel.SortType _sortType = MainWindowViewModel.SortType.name;
[JsonPropertyName("last_sort_type"), JsonConverter(typeof(JsonStringEnumConverter))]
public MainWindowViewModel.SortType sortType
{
get { return _sortType; }
set { if (_sortType != value) { _sortType = value; pendingChangesOnAppClose = true; } }
}

/* FSO Settings that use the fs2_open.ini are json ignored */

/* Video Settings */
Expand Down Expand Up @@ -210,15 +262,6 @@ public AutoUpdateFsoBuilds(bool stable = false, bool rc = false, bool nightly =
[JsonIgnore]
public string pxoPassword { get; set; } = "";

[JsonPropertyName("hide_build_rc")]
public bool hideBuildRC { get; set; } = true;
[JsonPropertyName("hide_build_custom")]
public bool hideBuildCustom { get; set; } = false;
[JsonPropertyName("hide_build_nightly")]
public bool hideBuildNightly { get; set; } = true;
[JsonPropertyName("last_sort_type"), JsonConverter(typeof(JsonStringEnumConverter))]
public MainWindowViewModel.SortType sortType { get; set; } = MainWindowViewModel.SortType.name;

/* Developer Settings */
[JsonPropertyName("no_system_cmd")]
public bool noSystemCMD { get; set; } = false;
Expand All @@ -232,6 +275,18 @@ public AutoUpdateFsoBuilds(bool stable = false, bool rc = false, bool nightly =
[JsonIgnore]
private FileSystemWatcher? iniWatcher = null;

/// <summary>
/// Call this when the app is closing to save settings if we have pending changes
/// Note: this only applies to Knossos setting and not anything saved on the fs2_open.ini
/// </summary>
public void SaveSettingsOnAppClose()
{
if(pendingChangesOnAppClose)
{
Save(false);
}
}

/// <summary>
/// When the User is on the settings tab we must watch the fs2_open.ini for external changes
/// This is the initial call that must be called once, then we start or stop raising of events
Expand Down Expand Up @@ -265,8 +320,13 @@ private void OnIniChanged(object sender, FileSystemEventArgs e)
/// </summary>
public void EnableIniWatch()
{
if(iniWatcher != null)
if (iniWatcher != null)
iniWatcher.EnableRaisingEvents = true;
else
{
StartWatchingDirectory();
EnableIniWatch();
}
}

/// <summary>
Expand Down Expand Up @@ -294,12 +354,6 @@ private void ReadFS2IniValues()
var data = parser.ReadFile(KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "fs2_open.ini");
data.Configuration.AssigmentSpacer = string.Empty;

if(iniWatcher == null)
{
StartWatchingDirectory();
}


//LEGACY ENTRIES, mostly read only by fso
/* Default Section */
var resoItem = data["Default"]["VideocardFs2open"];
Expand Down Expand Up @@ -611,12 +665,13 @@ public void Load()
envVars = tempSettings.envVars;
showDevOptions = tempSettings.showDevOptions;
warnNewSettingsSystem = tempSettings.warnNewSettingsSystem;

if (MainWindowViewModel.Instance != null)
MainWindowViewModel.Instance.sharedSortType = tempSettings.sortType;
mainMenuOpen = tempSettings.mainMenuOpen;
sortType = tempSettings.sortType;

ReadFS2IniValues();
Log.Add(Log.LogSeverity.Information, "GlobalSettings.Load()", "Global settings have been loaded");

pendingChangesOnAppClose = false;
}

}
Expand Down Expand Up @@ -833,6 +888,7 @@ public void Save(bool writeIni = true)
var json = JsonSerializer.Serialize(this, options);
File.WriteAllText(KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "settings.json", json, new UTF8Encoding(false));
Log.Add(Log.LogSeverity.Information, "GlobalSettings.Save()", "Global settings have been saved.");
pendingChangesOnAppClose = false;
}
catch (Exception ex)
{
Expand Down
Loading