- TextManager automatically replaces "\n" strings with a newline.
- Removed instantiating traitor start popup from client-side TraitorManager (instead the client receives the start message from the server). - GUIMessageBoxes don't leave unnecessary empty space for the header if the header text is empty. - More hard-coded text removal.
This commit is contained in:
@@ -103,7 +103,6 @@
|
||||
<Compile Include="Source\GameSession\CrewManager.cs" />
|
||||
<Compile Include="Source\GameSession\GameMode.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\SinglePlayerCampaign.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\TraitorManager.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\BasicTutorial.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\EditorTutorial.cs" />
|
||||
<Compile Include="Source\GameSession\GameModes\Tutorials\TutorialMode.cs" />
|
||||
|
||||
@@ -43,6 +43,8 @@ namespace Barotrauma
|
||||
: base(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Black * 0.5f, Alignment.TopLeft, null, parent)
|
||||
{
|
||||
int headerHeight = 30;
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
string wrappedText = ToolBox.WrapText(text, width, GUI.Font);
|
||||
@@ -51,18 +53,18 @@ namespace Barotrauma
|
||||
{
|
||||
height += (int)GUI.Font.MeasureString(line).Y;
|
||||
}
|
||||
height += 220;
|
||||
height += string.IsNullOrWhiteSpace(headerText) ? 220 : 220 - headerHeight;
|
||||
}
|
||||
|
||||
var frame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", this);
|
||||
GUI.Style.Apply(frame, "", this);
|
||||
|
||||
var header = new GUITextBlock(new Rectangle(0, 0, 0, 30), headerText, null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(header, "", this);
|
||||
|
||||
var header = new GUITextBlock(new Rectangle(0, 0, 0, headerHeight), headerText, null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(header, "", this);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
var textBlock = new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text,
|
||||
var textBlock = new GUITextBlock(new Rectangle(0, string.IsNullOrWhiteSpace(headerText) ? 0 : headerHeight, 0, height - 70), text,
|
||||
null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(textBlock, "", this);
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class TraitorManager
|
||||
{
|
||||
public static void CreateStartPopUp(string targetName)
|
||||
{
|
||||
new GUIMessageBox("You are the Traitor!",
|
||||
"Your secret task is to assassinate " + targetName + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew "
|
||||
+ "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.", 400, 350);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace Barotrauma
|
||||
frame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||
frame.UserData = item;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), "Attempting to fix " + item.Name, "", frame);
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), TextManager.Get("FixHeader").Replace("[itemname]", item.Name), "", frame);
|
||||
|
||||
y = y + 40;
|
||||
foreach (FixRequirement requirement in item.FixRequirements)
|
||||
@@ -60,7 +60,7 @@ namespace Barotrauma
|
||||
reqFrame.UserData = requirement;
|
||||
|
||||
|
||||
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), "Fix", "", reqFrame);
|
||||
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), TextManager.Get("Fix"), "", reqFrame);
|
||||
fixButton.OnClicked = FixButtonPressed;
|
||||
fixButton.UserData = requirement;
|
||||
|
||||
|
||||
@@ -756,12 +756,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.UsingShuttle ? GameMain.NetLobbyScreen.SelectedShuttle : null);
|
||||
|
||||
if (isTraitor)
|
||||
{
|
||||
TraitorManager.CreateStartPopUp(traitorTargetName);
|
||||
}
|
||||
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
GameMain.GameScreen.Select();
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
<ServerSettingsButton>Settings</ServerSettingsButton>
|
||||
<SpectateButton>Spectate</SpectateButton>
|
||||
<Gender>Gender</Gender>
|
||||
<JobPreferences>JobPreferences</JobPreferences>
|
||||
<JobPreferences>Job preferences</JobPreferences>
|
||||
<PlayingAsSpectator>Playing as a spectator</PlayingAsSpectator>
|
||||
<SubNotFound>Submarine not found in your submarine folder</SubNotFound>
|
||||
<SubDoesntMatch>Your version of the submarine doesn't match the servers version</SubDoesntMatch>
|
||||
@@ -233,6 +233,23 @@
|
||||
<SpamFilterKicked>You have been kicked by the spam filter.</SpamFilterKicked>
|
||||
<SpamFilterBlocked>You have been blocked by the spam filter. Try again after 10 seconds.</SpamFilterBlocked>
|
||||
|
||||
<!-- Item fixing -->
|
||||
<FixHeader>Attempting to fix [itemname]</FixHeader>
|
||||
<FixButton>Fix</FixButton>
|
||||
|
||||
<!-- Traitors -->
|
||||
<NewTraitor>New traitor</NewTraitor>
|
||||
<TraitorStartMessage>You are the Traitor! Your secret task is to assassinate [targetname]! Discretion is an utmost concern; sinking the submarine and killing the entire crew will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.</TraitorStartMessage>
|
||||
<TraitorMoreAgentsMessage>It is possible that there are other agents on this submarine. You don't know their names, but you do have a method of communication. Use the code words to greet the agent and code response to respond. Disguise such words in a normal-looking phrase so the crew doesn't suspect anything.\n\nThe code words are: [codewords].\nThe code response is: [coderesponse].</TraitorMoreAgentsMessage>
|
||||
<TraitorStartMessageServer>[traitorname] is the traitor and the target is [targetname].</TraitorStartMessageServer>
|
||||
|
||||
<TraitorEndMessageSuccess>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful.</TraitorEndMessageSuccess>
|
||||
<TraitorEndMessageSuccessTraitorDead>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor did not make it out alive either.</TraitorEndMessageSuccessTraitorDead>
|
||||
<TraitorEndMessageSuccessTraitorDetained>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor was succesfully detained.</TraitorEndMessageSuccessTraitorDetained>
|
||||
<TraitorEndMessageFailure>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was unsuccessful.</TraitorEndMessageFailure>
|
||||
<TraitorEndMessageFailureTraitorDead>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname], but [gendernoun] got [gendernounreflexive] killed before completing it.</TraitorEndMessageFailureTraitorDead>
|
||||
<TraitorEndMessageFailureTraitorDetained>[traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task failed - [gendernoun] was successfully detained.</TraitorEndMessageFailureTraitorDetained>
|
||||
|
||||
<!-- Causes of death -->
|
||||
<CauseOfDeath.Damage>Succumbed to their injuries</CauseOfDeath.Damage>
|
||||
<CauseOfDeath.Bloodloss>Bled out</CauseOfDeath.Bloodloss>
|
||||
|
||||
@@ -16,43 +16,39 @@ namespace Barotrauma
|
||||
|
||||
public void Greet(GameServer server, string codeWords, string codeResponse)
|
||||
{
|
||||
//Greeting messages TODO: Move this to a function in Traitor class
|
||||
string greetingMessage = "You are the Traitor! Your secret task is to assassinate " + TargetCharacter.Name + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew "
|
||||
+ "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.";
|
||||
string moreAgentsMessage = "It is possible that there are other agents on this submarine. You don't know their names, but you do have a method of communication. "
|
||||
+ "Use the code words to greet the agent and code response to respond. Disguise such words in a normal-looking phrase so the crew doesn't suspect anything.";
|
||||
moreAgentsMessage += "\nThe code words are: " + codeWords + ".";
|
||||
moreAgentsMessage += "\nThe code response is: " + codeResponse + ".\n";
|
||||
string greetingMessage = TextManager.Get("TraitorStartMessage").Replace("[targetname]", TargetCharacter.Name);
|
||||
string moreAgentsMessage = TextManager.Get("TraitorMoreAgentsMessage")
|
||||
.Replace("[codewords]", codeWords)
|
||||
.Replace("[coderesponse]", codeResponse);
|
||||
|
||||
if (server.Character != Character)
|
||||
{
|
||||
var chatMsg = ChatMessage.Create(
|
||||
null,
|
||||
greetingMessage + "\n" + moreAgentsMessage,
|
||||
(ChatMessageType)ChatMessageType.Server,
|
||||
null);
|
||||
|
||||
var msgBox = ChatMessage.Create(
|
||||
null,
|
||||
"There might be other agents. Use these to communicate with them." +
|
||||
"\nThe code words are: " + codeWords + "." +
|
||||
"\nThe code response is: " + codeResponse + ".",
|
||||
(ChatMessageType)ChatMessageType.MessageBox,
|
||||
null);
|
||||
var greetingChatMsg = ChatMessage.Create(null, greetingMessage, ChatMessageType.Server, null);
|
||||
var moreAgentsChatMsg = ChatMessage.Create(null, moreAgentsMessage, ChatMessageType.Server, null);
|
||||
|
||||
var greetingMsgBox = ChatMessage.Create(null, greetingMessage, ChatMessageType.MessageBox, null);
|
||||
var moreAgentsMsgBox = ChatMessage.Create(null, moreAgentsMessage, ChatMessageType.MessageBox, null);
|
||||
|
||||
Client client = server.ConnectedClients.Find(c => c.Character == Character);
|
||||
GameMain.Server.SendChatMessage(chatMsg, client);
|
||||
GameMain.Server.SendChatMessage(msgBox, client);
|
||||
GameMain.Server.SendChatMessage(greetingChatMsg, client);
|
||||
GameMain.Server.SendChatMessage(moreAgentsChatMsg, client);
|
||||
GameMain.Server.SendChatMessage(greetingMsgBox, client);
|
||||
GameMain.Server.SendChatMessage(moreAgentsMsgBox, client);
|
||||
}
|
||||
|
||||
#if CLIENT
|
||||
if (server.Character == null)
|
||||
{
|
||||
new GUIMessageBox("New traitor", Character.Name + " is the traitor and the target is " + TargetCharacter.Name+".");
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("NewTraitor"),
|
||||
TextManager.Get("TraitorStartMessageServer").Replace("[targetname]", TargetCharacter.Name).Replace("[traitorname]", Character.Name));
|
||||
}
|
||||
else if (server.Character == Character)
|
||||
{
|
||||
TraitorManager.CreateStartPopUp(TargetCharacter.Name);
|
||||
new GUIMessageBox("", greetingMessage);
|
||||
new GUIMessageBox("", moreAgentsMessage);
|
||||
|
||||
GameMain.NetworkMember.AddChatMessage(greetingMessage, ChatMessageType.Server);
|
||||
GameMain.NetworkMember.AddChatMessage(moreAgentsMessage, ChatMessageType.Server);
|
||||
return;
|
||||
}
|
||||
@@ -151,72 +147,43 @@ namespace Barotrauma
|
||||
{
|
||||
Character traitorCharacter = traitor.Character;
|
||||
Character targetCharacter = traitor.TargetCharacter;
|
||||
endMessage += traitorCharacter.Name + " was a traitor! ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
|
||||
endMessage += " task was to assassinate " + targetCharacter.Name;
|
||||
string messageTag;
|
||||
|
||||
if (targetCharacter.IsDead) //Partial or complete mission success
|
||||
{
|
||||
endMessage += ". The task was successful";
|
||||
if (traitorCharacter.IsDead)
|
||||
{
|
||||
endMessage += ", but luckily the bastard didn't make it out alive either.";
|
||||
messageTag = "TraitorEndMessageSuccessTraitorDead";
|
||||
}
|
||||
else if (traitorCharacter.LockHands)
|
||||
{
|
||||
endMessage += ", but ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
endMessage += " was successfuly detained.";
|
||||
messageTag = "TraitorEndMessageSuccessTraitorDetained";
|
||||
}
|
||||
else
|
||||
endMessage += ".";
|
||||
messageTag = "TraitorEndMessageSuccess";
|
||||
}
|
||||
else //Partial or complete failure
|
||||
{
|
||||
if (traitorCharacter.IsDead)
|
||||
{
|
||||
endMessage += ", but ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
endMessage += " got " + ((traitorCharacter.Info.Gender == Gender.Male) ? "himself" : "herself");
|
||||
endMessage += " killed before completing it.";
|
||||
messageTag = "TraitorEndMessageFailureTraitorDead";
|
||||
}
|
||||
else if (traitorCharacter.LockHands)
|
||||
{
|
||||
messageTag = "TraitorEndMessageFailureTraitorDetained";
|
||||
}
|
||||
else
|
||||
{
|
||||
endMessage += ". The task was unsuccessful";
|
||||
if (traitorCharacter.LockHands)
|
||||
{
|
||||
endMessage += " - ";
|
||||
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
|
||||
endMessage += " was successfuly detained";
|
||||
}
|
||||
if (Submarine.MainSub.AtEndPosition)
|
||||
{
|
||||
endMessage += (traitorCharacter.LockHands ? " and " : " - ");
|
||||
endMessage += "the submarine has reached its destination";
|
||||
}
|
||||
endMessage += ".";
|
||||
messageTag = "TraitorEndMessageFailure";
|
||||
}
|
||||
}
|
||||
endMessage += "\n";
|
||||
|
||||
endMessage += (TextManager.ReplaceGenderNouns(TextManager.Get(messageTag), traitorCharacter.Info.Gender) + "\n")
|
||||
.Replace("[traitorname]", traitorCharacter.Name)
|
||||
.Replace("[targetname]", targetCharacter.Name);
|
||||
}
|
||||
|
||||
return endMessage;
|
||||
return endMessage;
|
||||
}
|
||||
|
||||
//public void CharacterLeft(Character character)
|
||||
//{
|
||||
// if (character != traitorCharacter && character != targetCharacter) return;
|
||||
|
||||
// if (character == traitorCharacter)
|
||||
// {
|
||||
// string endMessage = "The traitor has disconnected from the server.";
|
||||
// End(endMessage);
|
||||
// }
|
||||
// else if (character == targetCharacter)
|
||||
// {
|
||||
// string endMessage = "The traitor's target has disconnected from the server.";
|
||||
// End(endMessage);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Barotrauma
|
||||
{
|
||||
static class TextManager
|
||||
{
|
||||
private static Dictionary<string, List<string>> infoTexts;
|
||||
private static Dictionary<string, List<string>> texts;
|
||||
|
||||
static TextManager()
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace Barotrauma
|
||||
|
||||
private static void Load(string file)
|
||||
{
|
||||
infoTexts = new Dictionary<string, List<string>>();
|
||||
texts = new Dictionary<string, List<string>>();
|
||||
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
@@ -26,26 +26,26 @@ namespace Barotrauma
|
||||
{
|
||||
string infoName = subElement.Name.ToString().ToLowerInvariant();
|
||||
List<string> infoList = null;
|
||||
if (!infoTexts.TryGetValue(infoName, out infoList))
|
||||
if (!texts.TryGetValue(infoName, out infoList))
|
||||
{
|
||||
infoList = new List<string>();
|
||||
infoTexts.Add(infoName, infoList);
|
||||
texts.Add(infoName, infoList);
|
||||
}
|
||||
|
||||
infoList.Add(subElement.ElementInnerText());
|
||||
}
|
||||
}
|
||||
|
||||
public static string Get(string infoName)
|
||||
public static string Get(string textTag)
|
||||
{
|
||||
List<string> infoList = null;
|
||||
if (!infoTexts.TryGetValue(infoName.ToLowerInvariant(), out infoList) || !infoList.Any())
|
||||
List<string> textList = null;
|
||||
if (!texts.TryGetValue(textTag.ToLowerInvariant(), out textList) || !textList.Any())
|
||||
{
|
||||
DebugConsole.ThrowError("Info text \"" + infoName + "\" not found");
|
||||
return infoName;
|
||||
DebugConsole.ThrowError("Text \"" + textTag + "\" not found");
|
||||
return textTag;
|
||||
}
|
||||
|
||||
string text = infoList[Rand.Int(infoList.Count)];
|
||||
string text = textList[Rand.Int(textList.Count)].Replace(@"\n", "\n");
|
||||
|
||||
//todo: get rid of these and only do where needed?
|
||||
#if CLIENT
|
||||
@@ -56,5 +56,27 @@ namespace Barotrauma
|
||||
#endif
|
||||
return text;
|
||||
}
|
||||
|
||||
public static string ReplaceGenderNouns(string text, Gender gender)
|
||||
{
|
||||
if (gender == Gender.Male)
|
||||
{
|
||||
return text.Replace("[gendernoun]", "he")
|
||||
.Replace("[gendernounpossessive]", "his")
|
||||
.Replace("[gendernounreflexive]", "himself")
|
||||
.Replace("[Gendernoun]", "He")
|
||||
.Replace("[Gendernounpossessive]", "His")
|
||||
.Replace("[Gendernounreflexive]", "Himself");
|
||||
}
|
||||
else
|
||||
{
|
||||
return text.Replace("[gendernoun]", "she")
|
||||
.Replace("[gendernounpossessive]", "her")
|
||||
.Replace("[gendernounreflexive]", "herself")
|
||||
.Replace("[Gendernoun]", "She")
|
||||
.Replace("[Gendernounpossessive]", "Her")
|
||||
.Replace("[Gendernounreflexive]", "Herself");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user