make notice line separator configurable for different parsers
(updated tekno's as it doesn't support \n)
This commit is contained in:
parent
d58b24b5b2
commit
8ef2959f63
@ -63,6 +63,10 @@ namespace IW4MAdmin.Application.Localization
|
||||
{
|
||||
var localizationContents = File.ReadAllText(filePath, Encoding.UTF8);
|
||||
var eachLocalizationFile = Newtonsoft.Json.JsonConvert.DeserializeObject<SharedLibraryCore.Localization.Layout>(localizationContents);
|
||||
if (eachLocalizationFile == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var item in eachLocalizationFile.LocalizationIndex.Set)
|
||||
{
|
||||
|
@ -25,18 +25,29 @@ namespace IW4MAdmin.Application.Misc
|
||||
|
||||
public string BuildFormattedMessage(IRConParserConfiguration config, EFPenalty currentPenalty, EFPenalty originalPenalty = null)
|
||||
{
|
||||
var isNewLineSeparator = config.NoticeLineSeparator == Environment.NewLine;
|
||||
var penalty = originalPenalty ?? currentPenalty;
|
||||
var builder = new StringBuilder();
|
||||
// build the top level header
|
||||
var header = _transLookup[$"SERVER_{penalty.Type.ToString().ToUpper()}_TEXT"];
|
||||
builder.Append(header);
|
||||
builder.Append(Environment.NewLine);
|
||||
builder.Append(config.NoticeLineSeparator);
|
||||
// build the reason
|
||||
var reason = _transLookup["GAME_MESSAGE_PENALTY_REASON"].FormatExt(penalty.Offense);
|
||||
foreach (var splitReason in SplitOverMaxLength(reason, config.NoticeMaxCharactersPerLine))
|
||||
|
||||
if (isNewLineSeparator)
|
||||
{
|
||||
builder.Append(splitReason);
|
||||
builder.Append(Environment.NewLine);
|
||||
foreach (var splitReason in SplitOverMaxLength(reason, config.NoticeMaxCharactersPerLine))
|
||||
{
|
||||
builder.Append(splitReason);
|
||||
builder.Append(config.NoticeLineSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
builder.Append(reason);
|
||||
builder.Append(config.NoticeLineSeparator);
|
||||
}
|
||||
|
||||
if (penalty.Type == EFPenalty.PenaltyType.TempBan)
|
||||
@ -46,11 +57,19 @@ namespace IW4MAdmin.Application.Misc
|
||||
? (penalty.Expires - DateTime.UtcNow).Value.HumanizeForCurrentCulture()
|
||||
: "--";
|
||||
var timeRemaining = _transLookup["GAME_MESSAGE_PENALTY_TIME_REMAINING"].FormatExt(timeRemainingValue);
|
||||
|
||||
foreach (var splitReason in SplitOverMaxLength(timeRemaining, config.NoticeMaxCharactersPerLine))
|
||||
|
||||
if (isNewLineSeparator)
|
||||
{
|
||||
builder.Append(splitReason);
|
||||
builder.Append(Environment.NewLine);
|
||||
foreach (var splitReason in SplitOverMaxLength(timeRemaining, config.NoticeMaxCharactersPerLine))
|
||||
{
|
||||
builder.Append(splitReason);
|
||||
builder.Append(config.NoticeLineSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
builder.Append(timeRemaining);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using SharedLibraryCore.RCon;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@ -24,6 +25,7 @@ namespace IW4MAdmin.Application.RconParsers
|
||||
public IDictionary<string, string> DefaultDvarValues { get; set; } = new Dictionary<string, string>();
|
||||
public int NoticeMaximumLines { get; set; } = 8;
|
||||
public int NoticeMaxCharactersPerLine { get; set; } = 50;
|
||||
public string NoticeLineSeparator { get; set; } = Environment.NewLine;
|
||||
|
||||
public DynamicRConParserConfiguration(IParserRegexFactory parserRegexFactory)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ var eventParser;
|
||||
|
||||
var plugin = {
|
||||
author: 'RaidMax',
|
||||
version: 0.7,
|
||||
version: 0.8,
|
||||
name: 'Tekno MW3 Parser',
|
||||
isParser: true,
|
||||
|
||||
@ -27,6 +27,7 @@ var plugin = {
|
||||
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
||||
rconParser.Configuration.Dvar.AddMapping(107, 1); // RCon DvarValue
|
||||
rconParser.Configuration.Dvar.Pattern = '^(.*)$';
|
||||
rconParser.Configuration.NoticeLineSeparator = '. ';
|
||||
|
||||
rconParser.Configuration.DefaultDvarValues.Add('sv_running', '1');
|
||||
rconParser.Configuration.OverrideDvarNameMapping.Add('_website', 'sv_clanWebsite');
|
||||
|
@ -63,8 +63,19 @@ namespace SharedLibraryCore.Interfaces
|
||||
/// </summary>
|
||||
IDictionary<string, string> DefaultDvarValues { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// specifies how many lines can be used for ingame notice
|
||||
/// </summary>
|
||||
int NoticeMaximumLines { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// specifies how many characters can be displayed per notice line
|
||||
/// </summary>
|
||||
int NoticeMaxCharactersPerLine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// specifies the characters used to split a line
|
||||
/// </summary>
|
||||
string NoticeLineSeparator { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user