diff --git a/Barotrauma/BarotraumaClient/BarotraumaClient.csproj b/Barotrauma/BarotraumaClient/BarotraumaClient.csproj index e0f8c8219..850f2192d 100644 --- a/Barotrauma/BarotraumaClient/BarotraumaClient.csproj +++ b/Barotrauma/BarotraumaClient/BarotraumaClient.csproj @@ -103,7 +103,6 @@ - diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs index 8e9de9c14..c61fae4a4 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.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); } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/TraitorManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/TraitorManager.cs deleted file mode 100644 index 801cf452d..000000000 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/TraitorManager.cs +++ /dev/null @@ -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); - } - } -} diff --git a/Barotrauma/BarotraumaClient/Source/Items/FixRequirement.cs b/Barotrauma/BarotraumaClient/Source/Items/FixRequirement.cs index 009a97100..454b4dbe6 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/FixRequirement.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/FixRequirement.cs @@ -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; diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 25a2ea8b8..c2f90ed0f 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -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(); diff --git a/Barotrauma/BarotraumaShared/Content/Texts.xml b/Barotrauma/BarotraumaShared/Content/Texts.xml index 44785f1dc..475b56b98 100644 --- a/Barotrauma/BarotraumaShared/Content/Texts.xml +++ b/Barotrauma/BarotraumaShared/Content/Texts.xml @@ -154,7 +154,7 @@ Settings Spectate Gender - JobPreferences + Job preferences Playing as a spectator Submarine not found in your submarine folder Your version of the submarine doesn't match the servers version @@ -233,6 +233,23 @@ You have been kicked by the spam filter. You have been blocked by the spam filter. Try again after 10 seconds. + + Attempting to fix [itemname] + Fix + + + New traitor + 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. + 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]. + [traitorname] is the traitor and the target is [targetname]. + + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful. + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor did not make it out alive either. + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was successful, but the traitor was succesfully detained. + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task was unsuccessful. + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname], but [gendernoun] got [gendernounreflexive] killed before completing it. + [traitorname] was a traitor! [Gendernounpossessive] task was to assassinate [targetname]. The task failed - [gendernoun] was successfully detained. + Succumbed to their injuries Bled out diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs index 027561f23..3d29b4636 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs @@ -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); - // } - //} } } diff --git a/Barotrauma/BarotraumaShared/Source/TextManager.cs b/Barotrauma/BarotraumaShared/Source/TextManager.cs index 976306343..3f6435ddd 100644 --- a/Barotrauma/BarotraumaShared/Source/TextManager.cs +++ b/Barotrauma/BarotraumaShared/Source/TextManager.cs @@ -8,7 +8,7 @@ namespace Barotrauma { static class TextManager { - private static Dictionary> infoTexts; + private static Dictionary> texts; static TextManager() { @@ -17,7 +17,7 @@ namespace Barotrauma private static void Load(string file) { - infoTexts = new Dictionary>(); + texts = new Dictionary>(); 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 infoList = null; - if (!infoTexts.TryGetValue(infoName, out infoList)) + if (!texts.TryGetValue(infoName, out infoList)) { infoList = new List(); - 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 infoList = null; - if (!infoTexts.TryGetValue(infoName.ToLowerInvariant(), out infoList) || !infoList.Any()) + List 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"); + } + } } }