- fix: Message on error
This commit is contained in:
@@ -174,6 +174,7 @@ public partial class ServerEntryModelView : ViewModelBase, IFilterConsumer, ILis
|
||||
|
||||
private async Task RunInstanceAsync(bool ignoreLoginCredentials = false)
|
||||
{
|
||||
_logger.Log("Running instance..." + RealName);
|
||||
if (!ignoreLoginCredentials && AccountInfoViewModel.Credentials.Value is null)
|
||||
{
|
||||
var warningContext = ViewHelperService.GetViewModel<IsLoginCredentialsNullPopupViewModel>()
|
||||
@@ -183,19 +184,30 @@ public partial class ServerEntryModelView : ViewModelBase, IFilterConsumer, ILis
|
||||
return;
|
||||
}
|
||||
|
||||
using var loadingContext = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loadingContext.LoadingName = "Loading instance...";
|
||||
((ILoadingHandler)loadingContext).AppendJob();
|
||||
try
|
||||
{
|
||||
using var loadingContext = ViewHelperService.GetViewModel<LoadingContextViewModel>();
|
||||
loadingContext.LoadingName = "Loading instance...";
|
||||
((ILoadingHandler)loadingContext).AppendJob();
|
||||
|
||||
PopupMessageService.Popup(loadingContext);
|
||||
_currentInstance =
|
||||
await GameRunnerPreparer.GetGameProcessStartInfoProvider(Address, loadingContext, CancellationService.Token);
|
||||
|
||||
_currentInstance.RegisterLogger(_currentContentLogConsumer);
|
||||
_currentInstance.RegisterLogger(new DebugLoggerBridge(DebugService.GetLogger($"PROCESS_{Random.Shared.Next(65535)}")));
|
||||
_currentInstance.OnProcessExited += OnProcessExited;
|
||||
RunVisible = false;
|
||||
_currentInstance.Start();
|
||||
PopupMessageService.Popup(loadingContext);
|
||||
_currentInstance =
|
||||
await GameRunnerPreparer.GetGameProcessStartInfoProvider(Address, loadingContext, CancellationService.Token);
|
||||
_logger.Log("Preparing instance...");
|
||||
_currentInstance.RegisterLogger(_currentContentLogConsumer);
|
||||
_currentInstance.RegisterLogger(new DebugLoggerBridge(DebugService.GetLogger($"PROCESS_{Random.Shared.Next(65535)}")));
|
||||
_currentInstance.OnProcessExited += OnProcessExited;
|
||||
RunVisible = false;
|
||||
_currentInstance.Start();
|
||||
_logger.Log("Starting instance..." + RealName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var error = new Exception("Error while attempt run instance", e);
|
||||
_logger.Error(error);
|
||||
PopupMessageService.Popup(error);
|
||||
RunVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProcessExited(ProcessRunHandler<GameProcessStartInfoProvider> obj)
|
||||
|
||||
@@ -2,15 +2,18 @@ using Nebula.Runner.Services;
|
||||
using Nebula.Shared;
|
||||
using Nebula.Shared.Models;
|
||||
using Nebula.Shared.Services;
|
||||
using Nebula.Shared.Services.Logging;
|
||||
using Nebula.Shared.Utils;
|
||||
using Robust.LoaderApi;
|
||||
|
||||
namespace Nebula.Runner;
|
||||
|
||||
[ServiceRegister]
|
||||
public sealed class App(RunnerService runnerService, ContentService contentService)
|
||||
public sealed class App(RunnerService runnerService, ContentService contentService, DebugService debugService)
|
||||
: IRedialApi
|
||||
{
|
||||
public ILogger logger = debugService.GetLogger("Runner");
|
||||
|
||||
public void Redial(Uri uri, string text = "")
|
||||
{
|
||||
}
|
||||
@@ -22,28 +25,36 @@ public sealed class App(RunnerService runnerService, ContentService contentServi
|
||||
|
||||
var url = urlraw.ToRobustUrl();
|
||||
|
||||
using var cancelTokenSource = new CancellationTokenSource();
|
||||
var buildInfo = await contentService.GetBuildInfo(url, cancelTokenSource.Token);
|
||||
|
||||
|
||||
var args = new List<string>
|
||||
try
|
||||
{
|
||||
"--username", login,
|
||||
"--cvar", "launch.launcher=true"
|
||||
};
|
||||
using var cancelTokenSource = new CancellationTokenSource();
|
||||
var buildInfo = await contentService.GetBuildInfo(url, cancelTokenSource.Token);
|
||||
|
||||
var connectionString = url.ToString();
|
||||
if (!string.IsNullOrEmpty(buildInfo.BuildInfo.ConnectAddress))
|
||||
connectionString = buildInfo.BuildInfo.ConnectAddress;
|
||||
|
||||
args.Add("--launcher");
|
||||
var args = new List<string>
|
||||
{
|
||||
"--username", login,
|
||||
"--cvar", "launch.launcher=true"
|
||||
};
|
||||
|
||||
args.Add("--connect-address");
|
||||
args.Add(connectionString);
|
||||
var connectionString = url.ToString();
|
||||
if (!string.IsNullOrEmpty(buildInfo.BuildInfo.ConnectAddress))
|
||||
connectionString = buildInfo.BuildInfo.ConnectAddress;
|
||||
|
||||
args.Add("--ss14-address");
|
||||
args.Add(url.ToString());
|
||||
args.Add("--launcher");
|
||||
|
||||
await runnerService.Run(args.ToArray(), buildInfo, this, new ConsoleLoadingHandler(), cancelTokenSource.Token);
|
||||
args.Add("--connect-address");
|
||||
args.Add(connectionString);
|
||||
|
||||
args.Add("--ss14-address");
|
||||
args.Add(url.ToString());
|
||||
|
||||
await runnerService.Run(args.ToArray(), buildInfo, this, new ConsoleLoadingHandler(), cancelTokenSource.Token);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user