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/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/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 @@