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 localizationContents = File.ReadAllText(filePath, Encoding.UTF8);
|
||||||
var eachLocalizationFile = Newtonsoft.Json.JsonConvert.DeserializeObject<SharedLibraryCore.Localization.Layout>(localizationContents);
|
var eachLocalizationFile = Newtonsoft.Json.JsonConvert.DeserializeObject<SharedLibraryCore.Localization.Layout>(localizationContents);
|
||||||
|
if (eachLocalizationFile == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in eachLocalizationFile.LocalizationIndex.Set)
|
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)
|
public string BuildFormattedMessage(IRConParserConfiguration config, EFPenalty currentPenalty, EFPenalty originalPenalty = null)
|
||||||
{
|
{
|
||||||
|
var isNewLineSeparator = config.NoticeLineSeparator == Environment.NewLine;
|
||||||
var penalty = originalPenalty ?? currentPenalty;
|
var penalty = originalPenalty ?? currentPenalty;
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
// build the top level header
|
// build the top level header
|
||||||
var header = _transLookup[$"SERVER_{penalty.Type.ToString().ToUpper()}_TEXT"];
|
var header = _transLookup[$"SERVER_{penalty.Type.ToString().ToUpper()}_TEXT"];
|
||||||
builder.Append(header);
|
builder.Append(header);
|
||||||
builder.Append(Environment.NewLine);
|
builder.Append(config.NoticeLineSeparator);
|
||||||
// build the reason
|
// build the reason
|
||||||
var reason = _transLookup["GAME_MESSAGE_PENALTY_REASON"].FormatExt(penalty.Offense);
|
var reason = _transLookup["GAME_MESSAGE_PENALTY_REASON"].FormatExt(penalty.Offense);
|
||||||
|
|
||||||
|
if (isNewLineSeparator)
|
||||||
|
{
|
||||||
foreach (var splitReason in SplitOverMaxLength(reason, config.NoticeMaxCharactersPerLine))
|
foreach (var splitReason in SplitOverMaxLength(reason, config.NoticeMaxCharactersPerLine))
|
||||||
{
|
{
|
||||||
builder.Append(splitReason);
|
builder.Append(splitReason);
|
||||||
builder.Append(Environment.NewLine);
|
builder.Append(config.NoticeLineSeparator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(reason);
|
||||||
|
builder.Append(config.NoticeLineSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (penalty.Type == EFPenalty.PenaltyType.TempBan)
|
if (penalty.Type == EFPenalty.PenaltyType.TempBan)
|
||||||
@ -47,10 +58,18 @@ namespace IW4MAdmin.Application.Misc
|
|||||||
: "--";
|
: "--";
|
||||||
var timeRemaining = _transLookup["GAME_MESSAGE_PENALTY_TIME_REMAINING"].FormatExt(timeRemainingValue);
|
var timeRemaining = _transLookup["GAME_MESSAGE_PENALTY_TIME_REMAINING"].FormatExt(timeRemainingValue);
|
||||||
|
|
||||||
|
if (isNewLineSeparator)
|
||||||
|
{
|
||||||
foreach (var splitReason in SplitOverMaxLength(timeRemaining, config.NoticeMaxCharactersPerLine))
|
foreach (var splitReason in SplitOverMaxLength(timeRemaining, config.NoticeMaxCharactersPerLine))
|
||||||
{
|
{
|
||||||
builder.Append(splitReason);
|
builder.Append(splitReason);
|
||||||
builder.Append(Environment.NewLine);
|
builder.Append(config.NoticeLineSeparator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(timeRemaining);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SharedLibraryCore.Interfaces;
|
using System;
|
||||||
|
using SharedLibraryCore.Interfaces;
|
||||||
using SharedLibraryCore.RCon;
|
using SharedLibraryCore.RCon;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@ -24,6 +25,7 @@ namespace IW4MAdmin.Application.RconParsers
|
|||||||
public IDictionary<string, string> DefaultDvarValues { get; set; } = new Dictionary<string, string>();
|
public IDictionary<string, string> DefaultDvarValues { get; set; } = new Dictionary<string, string>();
|
||||||
public int NoticeMaximumLines { get; set; } = 8;
|
public int NoticeMaximumLines { get; set; } = 8;
|
||||||
public int NoticeMaxCharactersPerLine { get; set; } = 50;
|
public int NoticeMaxCharactersPerLine { get; set; } = 50;
|
||||||
|
public string NoticeLineSeparator { get; set; } = Environment.NewLine;
|
||||||
|
|
||||||
public DynamicRConParserConfiguration(IParserRegexFactory parserRegexFactory)
|
public DynamicRConParserConfiguration(IParserRegexFactory parserRegexFactory)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ var eventParser;
|
|||||||
|
|
||||||
var plugin = {
|
var plugin = {
|
||||||
author: 'RaidMax',
|
author: 'RaidMax',
|
||||||
version: 0.7,
|
version: 0.8,
|
||||||
name: 'Tekno MW3 Parser',
|
name: 'Tekno MW3 Parser',
|
||||||
isParser: true,
|
isParser: true,
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ var plugin = {
|
|||||||
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
|
||||||
rconParser.Configuration.Dvar.AddMapping(107, 1); // RCon DvarValue
|
rconParser.Configuration.Dvar.AddMapping(107, 1); // RCon DvarValue
|
||||||
rconParser.Configuration.Dvar.Pattern = '^(.*)$';
|
rconParser.Configuration.Dvar.Pattern = '^(.*)$';
|
||||||
|
rconParser.Configuration.NoticeLineSeparator = '. ';
|
||||||
|
|
||||||
rconParser.Configuration.DefaultDvarValues.Add('sv_running', '1');
|
rconParser.Configuration.DefaultDvarValues.Add('sv_running', '1');
|
||||||
rconParser.Configuration.OverrideDvarNameMapping.Add('_website', 'sv_clanWebsite');
|
rconParser.Configuration.OverrideDvarNameMapping.Add('_website', 'sv_clanWebsite');
|
||||||
|
@ -63,8 +63,19 @@ namespace SharedLibraryCore.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IDictionary<string, string> DefaultDvarValues { get; set; }
|
IDictionary<string, string> DefaultDvarValues { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// specifies how many lines can be used for ingame notice
|
||||||
|
/// </summary>
|
||||||
int NoticeMaximumLines { get; set; }
|
int NoticeMaximumLines { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// specifies how many characters can be displayed per notice line
|
||||||
|
/// </summary>
|
||||||
int NoticeMaxCharactersPerLine { get; set; }
|
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