fix IW4x regression error with alternative encodings

add parser selection to server config setup
This commit is contained in:
RaidMax
2019-02-04 19:38:24 -06:00
parent ce02f5dd68
commit 29eedea093
7 changed files with 108 additions and 29 deletions

View File

@ -1,6 +1,7 @@
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
namespace SharedLibraryCore.Configuration
{
@ -11,11 +12,22 @@ namespace SharedLibraryCore.Configuration
public string Password { get; set; }
public IList<string> Rules { get; set; }
public IList<string> AutoMessages { get; set; }
public bool UseT6MParser { get; set; }
public string ManualLogPath { get; set; }
public string CustomParserVersion { get; set; }
public int ReservedSlotNumber { get; set; }
private readonly IList<IRConParser> rconParsers;
private readonly IList<IEventParser> eventParsers;
public ServerConfiguration()
{
rconParsers = new List<IRConParser>();
eventParsers = new List<IEventParser>();
}
public void AddRConParser(IRConParser parser) => rconParsers.Add(parser);
public void AddEventParser(IEventParser parser) => eventParsers.Add(parser);
public IBaseConfiguration Generate()
{
var loc = Utilities.CurrentLocalization.LocalizationIndex;
@ -38,9 +50,24 @@ namespace SharedLibraryCore.Configuration
Password = Utilities.PromptString(loc["SETUP_SERVER_RCON"]);
AutoMessages = new List<string>();
Rules = new List<string>();
UseT6MParser = Utilities.PromptBool(loc["SETUP_SERVER_USET6M"]);
ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32);
var parserVersions = rconParsers.Select(_parser => _parser.Version).ToArray();
var selection = Utilities.PromptSelection(loc["SETUP_SERVER_RCON_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
if (selection.Item1 > 0)
{
CustomParserVersion = selection.Item2;
}
parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray();
selection = Utilities.PromptSelection(loc["SETUP_SERVER_EVENT_PARSER_VERSION"], $"{loc["SETUP_PROMPT_DEFAULT"]} (IW4x)", null, parserVersions);
if (selection.Item1 > 0)
{
CustomParserVersion = selection.Item2;
}
return this;
}