diff --git a/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs b/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs
index 6b31a70..12e6af2 100644
--- a/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs
+++ b/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs
@@ -27,10 +27,10 @@ namespace SPT.Launcher.Helpers
{
public bool FirstRun { get; set; } = true;
- public void SaveSettings()
+ public bool SaveSettings()
{
Server.Url = Path.TrimEndingDirectorySeparator(Server.Url);
- Json.SaveWithFormatting(LauncherSettingsProvider.DefaultSettingsFileLocation, this, Formatting.Indented);
+ return Json.SaveWithFormatting(LauncherSettingsProvider.DefaultSettingsFileLocation, this, Formatting.Indented);
}
public void ResetDefaults()
diff --git a/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs b/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs
index b432ba1..b4b4d73 100644
--- a/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs
+++ b/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs
@@ -191,6 +191,7 @@ namespace SPT.Launcher.Helpers
englishLocale.open_link_question_format_1 = "Are you sure you want to open the following link: \n{0}";
englishLocale.open_link = "Open Link";
englishLocale.dev_mode = "Developer Mode";
+ englishLocale.failed_to_save_settings = "Failed to save settings";
#endregion
Directory.CreateDirectory(LocalizationProvider.DefaultLocaleFolderPath);
@@ -227,6 +228,24 @@ namespace SPT.Launcher.Helpers
#region All Properties
+ #region failed_to_save_settings
+
+ private string _failed_to_save_settings;
+
+ public string failed_to_save_settings
+ {
+ get => _failed_to_save_settings;
+ set
+ {
+ if (_failed_to_save_settings != value)
+ {
+ _failed_to_save_settings = value;
+ RaisePropertyChanged(nameof(failed_to_save_settings));
+ }
+ }
+ }
+ #endregion
+
#region dev_mode
private string _dev_mode;
public string dev_mode
diff --git a/project/SPT.Launcher.Base/MiniCommon/Json.cs b/project/SPT.Launcher.Base/MiniCommon/Json.cs
index b7329f4..caf400a 100644
--- a/project/SPT.Launcher.Base/MiniCommon/Json.cs
+++ b/project/SPT.Launcher.Base/MiniCommon/Json.cs
@@ -7,10 +7,12 @@
*/
+using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Linq;
+using SPT.Launcher.Controllers;
namespace SPT.Launcher.MiniCommon
{
@@ -39,14 +41,26 @@ namespace SPT.Launcher.MiniCommon
/// Full path to file
/// Object to save to json file
/// NewtonSoft.Json Formatting
- public static void SaveWithFormatting(string filepath, T data, Formatting format)
+ public static bool SaveWithFormatting(string filepath, T data, Formatting format)
{
- if (!File.Exists(filepath))
+ try
{
- Directory.CreateDirectory(Path.GetDirectoryName(filepath));
- }
- File.WriteAllText(filepath, JsonConvert.SerializeObject(data, format));
+ if (!File.Exists(filepath))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(filepath));
+ }
+
+ File.WriteAllText(filepath, JsonConvert.SerializeObject(data, format));
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Instance.Exception(ex);
+ }
+
+ return false;
}
///
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json
index 584384d..5994d1b 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json
index 9a869a0..d94169b 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json
index dfaf89d..1655d75 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json
index dc1cf96..5cbc72c 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json
index acb7f0e..b168d6a 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json
index 30a0343..6673693 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json
index 8aff439..fa5ed8f 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json
index a70e518..0b8bbf5 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json
index 82a7971..e08485e 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Tryb Dewelopera"
+ "dev_mode": "Tryb Dewelopera",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json
index eb6506e..0e51916 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "Эти моды не были загружены сервером, но ваш профиль использовал их раньше",
"open_link_question_format_1": "Вы уверены, что хотите открыть следующую ссылку? \n{0}",
"open_link": "Открыть ссылку",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json
index b5c3e81..04d5f24 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "These mods have not been loaded by the server, but your profile has used them in the past",
"open_link_question_format_1": "Are you sure you want to open the following link: \n{0}",
"open_link": "Open Link",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json
index 3a90006..669c189 100644
--- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json
+++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json
@@ -94,5 +94,6 @@
"inactive_server_mods_info_text": "Bu modlar sunucu tarafından yüklenmedi, ancak profiliniz geçmişte bunları kullandı",
"open_link_question_format_1": "Aşağıdaki bağlantıyı açmak istediğinizden emin misiniz? \n{0}",
"open_link": "Bağlantıyı Aç",
- "dev_mode": "Developer Mode"
+ "dev_mode": "Developer Mode",
+ "failed_to_save_settings": "Failed to save settings"
}
\ No newline at end of file
diff --git a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
index da33f57..6010d71 100644
--- a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
+++ b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs
@@ -11,6 +11,7 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
+using Avalonia.Controls.Notifications;
namespace SPT.Launcher.ViewModels
{
@@ -41,7 +42,11 @@ namespace SPT.Launcher.ViewModels
}
LauncherSettingsProvider.Instance.AllowSettings = true;
- LauncherSettingsProvider.Instance.SaveSettings();
+
+ if (!LauncherSettingsProvider.Instance.SaveSettings())
+ {
+ SendNotification("", LocalizationProvider.Instance.failed_to_save_settings, NotificationType.Error);
+ }
NavigateBack();
}
@@ -52,11 +57,11 @@ namespace SPT.Launcher.ViewModels
if (filesCleared)
{
- SendNotification("", LocalizationProvider.Instance.clean_temp_files_succeeded, Avalonia.Controls.Notifications.NotificationType.Success);
+ SendNotification("", LocalizationProvider.Instance.clean_temp_files_succeeded, NotificationType.Success);
}
else
{
- SendNotification("", LocalizationProvider.Instance.clean_temp_files_failed, Avalonia.Controls.Notifications.NotificationType.Error);
+ SendNotification("", LocalizationProvider.Instance.clean_temp_files_failed, NotificationType.Error);
}
}
diff --git a/project/SPT.Launcher/Views/SettingsView.axaml b/project/SPT.Launcher/Views/SettingsView.axaml
index 62091fa..891c053 100644
--- a/project/SPT.Launcher/Views/SettingsView.axaml
+++ b/project/SPT.Launcher/Views/SettingsView.axaml
@@ -12,7 +12,7 @@