updated NLog to v5
fixed most of issues with world creating/loading fixed log window lags fixed some compiler warnings fixed empty log files creating fixed logging performance added better logging of load process commands autocomplete in torch GUI chat in torch GUI now has entered history (like console, use up/down arrows) abstraction of instance manager session name now correctly displaying in torchSessionManager messages TorchSession now has loaded world property (as torch now has more control about world load process) now only dedicated config locks after session start
This commit is contained in:
48
Torch.Server/Views/CommandSuggestionsProvider.cs
Normal file
48
Torch.Server/Views/CommandSuggestionsProvider.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using AutoCompleteTextBox.Editors;
|
||||
using Sandbox;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Commands;
|
||||
|
||||
namespace Torch.Server.Views;
|
||||
|
||||
public class CommandSuggestionsProvider : ISuggestionProvider
|
||||
{
|
||||
private readonly ITorchServer _server;
|
||||
private CommandManager _commandManager;
|
||||
|
||||
public CommandSuggestionsProvider(ITorchServer server)
|
||||
{
|
||||
_server = server;
|
||||
if (_server.CurrentSession is null)
|
||||
_server.GameStateChanged += ServerOnGameStateChanged;
|
||||
else
|
||||
_commandManager = _server.CurrentSession.Managers.GetManager<CommandManager>();
|
||||
}
|
||||
|
||||
private void ServerOnGameStateChanged(MySandboxGame game, TorchGameState newState)
|
||||
{
|
||||
if (_server.CurrentSession is { })
|
||||
_commandManager = _server.CurrentSession.Managers.GetManager<CommandManager>();
|
||||
}
|
||||
|
||||
public IEnumerable GetSuggestions(string filter)
|
||||
{
|
||||
if (_commandManager is null || !_commandManager.IsCommand(filter))
|
||||
yield break;
|
||||
var args = filter[1..].Split(' ').ToList();
|
||||
var skip = _commandManager.Commands.GetNode(args, out var node);
|
||||
if (skip == -1)
|
||||
yield break;
|
||||
var lastArg = args.Last();
|
||||
|
||||
foreach (var subcommandsKey in node.Subcommands.Keys)
|
||||
{
|
||||
if (lastArg != node.Name && !subcommandsKey.Contains(lastArg))
|
||||
continue;
|
||||
yield return $"!{string.Join(' ', node.GetPath())} {subcommandsKey}";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user