0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-12 17:10:44 -05:00

Merge pull request 'add-dev-mode' (!53) from waffle.lord/Launcher:add-dev-mode into master

Reviewed-on: SPT/Launcher#53
This commit is contained in:
IsWaffle 2024-06-02 19:01:05 +00:00
commit 3b8baa76e4
20 changed files with 123 additions and 20 deletions

View File

@ -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}");

View File

@ -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();

View File

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

View File

@ -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)
{

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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; }
/// <summary>
/// A confirmation dialog
@ -16,11 +17,12 @@ namespace SPT.Launcher.ViewModels.Dialogs
/// <param name="Question"></param>
/// <param name="ConfirmButtonText"></param>
/// <param name="DenyButtonText"></param>
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;
}
}
}

View File

@ -30,6 +30,8 @@ namespace SPT.Launcher.ViewModels
Locator.CurrentMutable.RegisterConstant<ImageHelper>(Background, "bgimage");
Locator.CurrentMutable.RegisterConstant<SPTVersion>(VersionInfo, "sptversion");
LauncherSettingsProvider.Instance.ResetDefaults();
LauncherSettingsProvider.Instance.AllowSettings = true;

View File

@ -19,6 +19,7 @@
<Button Content="{Binding ConfirmButtonText}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
Classes="yellow"
IsEnabled="{Binding AllowConfirm}"
>
<Button.CommandParameter>
<s:Boolean>True</s:Boolean>

View File

@ -8,7 +8,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.SettingsView">
<Grid RowDefinitions="10,AUTO,AUTO,AUTO,*,10" ColumnDefinitions="10,2*,2*,AUTO,10">
<Grid RowDefinitions="10,AUTO,AUTO,*, AUTO, AUTO, AUTO,10" ColumnDefinitions="10,2*,2*,AUTO,10">
<!-- Backdrop -->
<Rectangle Fill="{StaticResource SPT_Background_Dark}"
@ -62,15 +62,19 @@
<cc:LocalizedLauncherActionSelector />
</StackPanel>
<!-- ROW 3 (extended space) -->
<CheckBox Grid.Row="4" Grid.Column="1" Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=dev_mode}" IsChecked="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}"/>
<!-- Game Path -->
<StackPanel Grid.Row="3" Grid.Column="1" Margin="0 10 10 10">
<StackPanel Grid.Row="5" Grid.Column="1" Margin="0 10 10 10" IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}">
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"/>
<TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=GamePath}"
/>
</StackPanel>
<WrapPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Margin="0 30 0 0">
<WrapPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" Margin="0 30 0 0" IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}">
<!-- Select Folder -->
<Button x:Name="sfb" Command="{Binding SelectGameFolderCommand}" Margin="0 0 10 5">
<StackPanel Orientation="Horizontal" Spacing="5">
@ -93,7 +97,7 @@
</WrapPanel>
<!-- Server URL -->
<StackPanel Grid.Row="4" Grid.Column="1">
<StackPanel Grid.Row="6" Grid.Column="1" IsEnabled="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=IsDevMode}">
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"/>
<TextBox Watermark="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=Server.Url}"