diff --git a/project/SPT.Launcher.Base/Controllers/LogManager.cs b/project/SPT.Launcher.Base/Controllers/LogManager.cs index 34dc624..4f263b5 100644 --- a/project/SPT.Launcher.Base/Controllers/LogManager.cs +++ b/project/SPT.Launcher.Base/Controllers/LogManager.cs @@ -8,6 +8,7 @@ using System; using System.IO; +using SPT.Launcher.Helpers; namespace SPT.Launcher.Controllers { @@ -34,14 +35,24 @@ namespace SPT.Launcher.Controllers Write($" ==== Launcher Started ===="); } + private string GetDevModeTag() + { + if (LauncherSettingsProvider.Instance != null && LauncherSettingsProvider.Instance.IsDevMode) + { + return "[DEV_MODE]"; + } + + return ""; + } + private void Write(string text) { if (!Directory.Exists(_filePath)) { Directory.CreateDirectory(_filePath); } - - File.AppendAllLines(_logFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{text}" }); + + File.AppendAllLines(_logFile, new[] { $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}]{GetDevModeTag()}{text}" }); } public void Debug(string text) => Write($"[Debug] {text}"); diff --git a/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs b/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs index e487448..6b31a70 100644 --- a/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs +++ b/project/SPT.Launcher.Base/Helpers/LauncherSettingsProvider.cs @@ -33,6 +33,43 @@ namespace SPT.Launcher.Helpers Json.SaveWithFormatting(LauncherSettingsProvider.DefaultSettingsFileLocation, this, Formatting.Indented); } + public void ResetDefaults() + { + string defaultUrl = "http://127.0.0.1:6969"; + string defaultPath = Environment.CurrentDirectory; + + // don't reset if running in dev mode + if (IsDevMode) + { + LogManager.Instance.Info("Running in dev mode, not resetting"); + return; + } + + if (Server != null && Server.Url != defaultUrl) + { + LogManager.Instance.Info($"Server URL was '{Server.Url}'"); + LogManager.Instance.Info($"Server URL was reset to default '{defaultUrl}'"); + Server.Url = defaultUrl; + } + else + { + LogManager.Instance.Info($"Server URL is already set to default '{defaultUrl}'"); + } + + if (GamePath != defaultPath) + { + LogManager.Instance.Info($"Game path was '{GamePath}'"); + LogManager.Instance.Info($"Game path was reset to default '{defaultPath}'"); + GamePath = defaultPath; + } + else + { + LogManager.Instance.Info($"Game path is already set to default '{defaultPath}'"); + } + + SaveSettings(); + } + public string DefaultLocale { get; set; } = "English"; private bool _IsAddingServer; @@ -108,6 +145,21 @@ namespace SPT.Launcher.Helpers } } + private bool _IsDevMode; + + public bool IsDevMode + { + get => _IsDevMode; + set + { + if (_IsDevMode != value) + { + _IsDevMode = value; + RaisePropertyChanged(nameof(IsDevMode)); + } + } + } + private string _GamePath; public string GamePath { @@ -148,6 +200,7 @@ namespace SPT.Launcher.Helpers LauncherStartGameAction = LauncherAction.MinimizeAction; UseAutoLogin = true; GamePath = Environment.CurrentDirectory; + IsDevMode = false; Server = new ServerSetting { Name = "SPT", Url = "http://127.0.0.1:6969" }; SaveSettings(); diff --git a/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs b/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs index 7ab2202..b432ba1 100644 --- a/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs +++ b/project/SPT.Launcher.Base/Helpers/LocalizationProvider.cs @@ -190,6 +190,7 @@ namespace SPT.Launcher.Helpers "These mods have not been loaded by the server, but your profile has used them in the past"; 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"; #endregion Directory.CreateDirectory(LocalizationProvider.DefaultLocaleFolderPath); @@ -225,6 +226,22 @@ namespace SPT.Launcher.Helpers //this is going to be some pretty long boiler plate code. So I'm putting everything into regions. #region All Properties + + #region dev_mode + private string _dev_mode; + public string dev_mode + { + get => _dev_mode; + set + { + if (_dev_mode != value) + { + _dev_mode = value; + RaisePropertyChanged(nameof(dev_mode)); + } + } + } + #endregion #region ietf_tag diff --git a/project/SPT.Launcher/Models/GameStarterFrontend.cs b/project/SPT.Launcher/Models/GameStarterFrontend.cs index 498ff4a..016347e 100644 --- a/project/SPT.Launcher/Models/GameStarterFrontend.cs +++ b/project/SPT.Launcher/Models/GameStarterFrontend.cs @@ -29,7 +29,8 @@ namespace SPT.Launcher.Models string serverVersion = ServerManager.GetVersion(); var localeText = string.Format(LocalizationProvider.Instance.file_mismatch_dialog_message, serverVersion); - var result = await DialogHost.DialogHost.Show(new ConfirmationDialogViewModel(null, localeText)); + + var result = await DialogHost.DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode)); if(result != null && result is bool confirmation && !confirmation) { 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 ac366e9..584384d 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Simplified).json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } 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 731afa2..9a869a0 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Chinese (Traditional).json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 2277f34..dfaf89d 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/English.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 861df07..dc1cf96 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/French.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 0eac043..acb7f0e 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/German.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 43d00cd..30a0343 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Italian.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 b600861..8aff439 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Japanese.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 42a0427..a70e518 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Korean.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 477548b..82a7971 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Polish.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Tryb Dewelopera" } \ 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 6a96ba0..eb6506e 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Russian.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Неактивные серверные моды", "inactive_server_mods_info_text": "Эти моды не были загружены сервером, но ваш профиль использовал их раньше", "open_link_question_format_1": "Вы уверены, что хотите открыть следующую ссылку? \n{0}", - "open_link": "Открыть ссылку" + "open_link": "Открыть ссылку", + "dev_mode": "Developer Mode" } \ 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 a198321..b5c3e81 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Spanish.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Inactive Server Mods", "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" + "open_link": "Open Link", + "dev_mode": "Developer Mode" } \ 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 3d386d3..3a90006 100644 --- a/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json +++ b/project/SPT.Launcher/SPT_Data/Launcher/Locales/Turkish.json @@ -93,5 +93,6 @@ "inactive_server_mods": "Aktif Olmayan Sunucu Modları", "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ç" + "open_link": "Bağlantıyı Aç", + "dev_mode": "Developer Mode" } \ No newline at end of file diff --git a/project/SPT.Launcher/ViewModels/Dialogs/ConfirmationDialogViewModel.cs b/project/SPT.Launcher/ViewModels/Dialogs/ConfirmationDialogViewModel.cs index ada55ec..aca2836 100644 --- a/project/SPT.Launcher/ViewModels/Dialogs/ConfirmationDialogViewModel.cs +++ b/project/SPT.Launcher/ViewModels/Dialogs/ConfirmationDialogViewModel.cs @@ -8,6 +8,7 @@ namespace SPT.Launcher.ViewModels.Dialogs public string Question { get; set; } public string ConfirmButtonText { get; set; } public string DenyButtonText { get; set; } + public bool AllowConfirm { get; set; } /// /// A confirmation dialog @@ -16,11 +17,12 @@ namespace SPT.Launcher.ViewModels.Dialogs /// /// /// - public ConfirmationDialogViewModel(IScreen Host, string Question, string? ConfirmButtonText = null, string? DenyButtonText = null) : base(Host) + public ConfirmationDialogViewModel(IScreen Host, string Question, string? ConfirmButtonText = null, string? DenyButtonText = null, bool allowConfirm = true) : base(Host) { this.Question = Question; this.ConfirmButtonText = ConfirmButtonText ?? LocalizationProvider.Instance.yes; this.DenyButtonText = DenyButtonText ?? LocalizationProvider.Instance.no; + this.AllowConfirm = allowConfirm; } } } diff --git a/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs b/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs index 6649eca..6091479 100644 --- a/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs +++ b/project/SPT.Launcher/ViewModels/MainWindowViewModel.cs @@ -30,6 +30,8 @@ namespace SPT.Launcher.ViewModels Locator.CurrentMutable.RegisterConstant(Background, "bgimage"); Locator.CurrentMutable.RegisterConstant(VersionInfo, "sptversion"); + + LauncherSettingsProvider.Instance.ResetDefaults(); LauncherSettingsProvider.Instance.AllowSettings = true; diff --git a/project/SPT.Launcher/Views/Dialogs/ConfirmationDialogView.axaml b/project/SPT.Launcher/Views/Dialogs/ConfirmationDialogView.axaml index 81b6dab..893497e 100644 --- a/project/SPT.Launcher/Views/Dialogs/ConfirmationDialogView.axaml +++ b/project/SPT.Launcher/Views/Dialogs/ConfirmationDialogView.axaml @@ -19,6 +19,7 @@