(5a377a8ee) Unstable v0.9.1000.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -304,6 +304,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < variableTags.Length; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(variableValues[i])) { continue; }
|
||||
if (formatCapitals[i])
|
||||
{
|
||||
variableValues[i] = HandleVariableCapitalization(text, variableTags[i], variableValues[i]);
|
||||
@@ -313,6 +314,13 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i < variableTags.Length; i++)
|
||||
{
|
||||
if (variableValues[i] == null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Error in TextManager.GetWithVariables (variable " + i + " was null).\n" + Environment.StackTrace);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
text = text.Replace(variableTags[i], variableValues[i]);
|
||||
}
|
||||
|
||||
@@ -643,6 +651,37 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches a single variable from a servermessage
|
||||
/// </summary>
|
||||
public static string GetServerMessageVariable(string message, string variable)
|
||||
{
|
||||
int variableIndex = message.IndexOf(variable);
|
||||
if (variableIndex == -1)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError($"Server message variable: '{variable}' not found in message: '{message}'");
|
||||
#endif
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
int startIndex = message.IndexOf('=', variableIndex) + 1;
|
||||
int endIndex = startIndex;
|
||||
|
||||
for (int i = startIndex; i < message.Length; i++)
|
||||
{
|
||||
if (message[i] == '/' || message[i] == '~')
|
||||
{
|
||||
endIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (endIndex == startIndex) endIndex = message.Length;
|
||||
|
||||
return message.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
|
||||
public static bool IsServerMessageWithVariables(string message)
|
||||
{
|
||||
for (int i = 0; i < serverMessageCharacters.Length; i++)
|
||||
|
||||
Reference in New Issue
Block a user