mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-13 02:10:44 -05:00
add dev mode
This commit is contained in:
parent
47459c9051
commit
a4011f3e92
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using SPT.Launcher.Helpers;
|
||||||
|
|
||||||
namespace SPT.Launcher.Controllers
|
namespace SPT.Launcher.Controllers
|
||||||
{
|
{
|
||||||
@ -34,6 +35,16 @@ namespace SPT.Launcher.Controllers
|
|||||||
Write($" ==== Launcher Started ====");
|
Write($" ==== Launcher Started ====");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDevModeTag()
|
||||||
|
{
|
||||||
|
if (LauncherSettingsProvider.Instance != null && LauncherSettingsProvider.Instance.IsDevMode)
|
||||||
|
{
|
||||||
|
return "[DEV_MODE]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
private void Write(string text)
|
private void Write(string text)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(_filePath))
|
if (!Directory.Exists(_filePath))
|
||||||
@ -41,7 +52,7 @@ namespace SPT.Launcher.Controllers
|
|||||||
Directory.CreateDirectory(_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}");
|
public void Debug(string text) => Write($"[Debug] {text}");
|
||||||
|
@ -33,6 +33,43 @@ namespace SPT.Launcher.Helpers
|
|||||||
Json.SaveWithFormatting(LauncherSettingsProvider.DefaultSettingsFileLocation, this, Formatting.Indented);
|
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";
|
public string DefaultLocale { get; set; } = "English";
|
||||||
|
|
||||||
private bool _IsAddingServer;
|
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;
|
private string _GamePath;
|
||||||
public string GamePath
|
public string GamePath
|
||||||
{
|
{
|
||||||
@ -148,6 +200,7 @@ namespace SPT.Launcher.Helpers
|
|||||||
LauncherStartGameAction = LauncherAction.MinimizeAction;
|
LauncherStartGameAction = LauncherAction.MinimizeAction;
|
||||||
UseAutoLogin = true;
|
UseAutoLogin = true;
|
||||||
GamePath = Environment.CurrentDirectory;
|
GamePath = Environment.CurrentDirectory;
|
||||||
|
IsDevMode = false;
|
||||||
|
|
||||||
Server = new ServerSetting { Name = "SPT", Url = "http://127.0.0.1:6969" };
|
Server = new ServerSetting { Name = "SPT", Url = "http://127.0.0.1:6969" };
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
|
@ -29,7 +29,8 @@ namespace SPT.Launcher.Models
|
|||||||
string serverVersion = ServerManager.GetVersion();
|
string serverVersion = ServerManager.GetVersion();
|
||||||
|
|
||||||
var localeText = string.Format(LocalizationProvider.Instance.file_mismatch_dialog_message, serverVersion);
|
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)
|
if(result != null && result is bool confirmation && !confirmation)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@ namespace SPT.Launcher.ViewModels.Dialogs
|
|||||||
public string Question { get; set; }
|
public string Question { get; set; }
|
||||||
public string ConfirmButtonText { get; set; }
|
public string ConfirmButtonText { get; set; }
|
||||||
public string DenyButtonText { get; set; }
|
public string DenyButtonText { get; set; }
|
||||||
|
public bool AllowConfirm { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A confirmation dialog
|
/// A confirmation dialog
|
||||||
@ -16,11 +17,12 @@ namespace SPT.Launcher.ViewModels.Dialogs
|
|||||||
/// <param name="Question"></param>
|
/// <param name="Question"></param>
|
||||||
/// <param name="ConfirmButtonText"></param>
|
/// <param name="ConfirmButtonText"></param>
|
||||||
/// <param name="DenyButtonText"></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.Question = Question;
|
||||||
this.ConfirmButtonText = ConfirmButtonText ?? LocalizationProvider.Instance.yes;
|
this.ConfirmButtonText = ConfirmButtonText ?? LocalizationProvider.Instance.yes;
|
||||||
this.DenyButtonText = DenyButtonText ?? LocalizationProvider.Instance.no;
|
this.DenyButtonText = DenyButtonText ?? LocalizationProvider.Instance.no;
|
||||||
|
this.AllowConfirm = allowConfirm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ namespace SPT.Launcher.ViewModels
|
|||||||
|
|
||||||
Locator.CurrentMutable.RegisterConstant<SPTVersion>(VersionInfo, "sptversion");
|
Locator.CurrentMutable.RegisterConstant<SPTVersion>(VersionInfo, "sptversion");
|
||||||
|
|
||||||
|
LauncherSettingsProvider.Instance.ResetDefaults();
|
||||||
|
|
||||||
LauncherSettingsProvider.Instance.AllowSettings = true;
|
LauncherSettingsProvider.Instance.AllowSettings = true;
|
||||||
|
|
||||||
if (LauncherSettingsProvider.Instance.FirstRun)
|
if (LauncherSettingsProvider.Instance.FirstRun)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<Button Content="{Binding ConfirmButtonText}"
|
<Button Content="{Binding ConfirmButtonText}"
|
||||||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
|
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
|
||||||
Classes="yellow"
|
Classes="yellow"
|
||||||
|
IsEnabled="{Binding AllowConfirm}"
|
||||||
>
|
>
|
||||||
<Button.CommandParameter>
|
<Button.CommandParameter>
|
||||||
<s:Boolean>True</s:Boolean>
|
<s:Boolean>True</s:Boolean>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="SPT.Launcher.Views.SettingsView">
|
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 -->
|
<!-- Backdrop -->
|
||||||
<Rectangle Fill="{StaticResource SPT_Background_Dark}"
|
<Rectangle Fill="{StaticResource SPT_Background_Dark}"
|
||||||
@ -62,15 +62,19 @@
|
|||||||
<cc:LocalizedLauncherActionSelector />
|
<cc:LocalizedLauncherActionSelector />
|
||||||
</StackPanel>
|
</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 -->
|
<!-- 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}"/>
|
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=game_path}"/>
|
||||||
<TextBox Watermark="{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}"
|
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=GamePath}"
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</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 -->
|
<!-- Select Folder -->
|
||||||
<Button x:Name="sfb" Command="{Binding SelectGameFolderCommand}" Margin="0 0 10 5">
|
<Button x:Name="sfb" Command="{Binding SelectGameFolderCommand}" Margin="0 0 10 5">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
@ -93,7 +97,7 @@
|
|||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
<!-- Server URL -->
|
<!-- 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}"/>
|
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=url}"/>
|
||||||
<TextBox Watermark="{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}"
|
Text="{Binding Source={x:Static helpers:LauncherSettingsProvider.Instance}, Path=Server.Url}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user