mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-12 17:10:44 -05:00
add dev mode
This commit is contained in:
parent
47459c9051
commit
a4011f3e92
@ -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}");
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user