diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index b11b1f60b..9fed2075c 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -1106,336 +1106,6 @@ namespace Barotrauma NPCConversation.WriteToCSV(); })); - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - GameMain.Config.GraphicsWidth = 0; - GameMain.Config.GraphicsHeight = 0; - GameMain.Config.WindowMode = WindowMode.Fullscreen; - NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green); - NewMessage("Fullscreen enabled", Color.Green); - - GameSettings.ShowUserStatisticsPrompt = true; - - GameSettings.VerboseLogging = false; - - if (GameMain.Config.MasterServerUrl != "http://www.undertowgames.com/baromaster") - { - ThrowError("MasterServerUrl \"" + GameMain.Config.MasterServerUrl + "\"!"); - } - - GameMain.Config.SaveNewPlayerConfig(); - - var saveFiles = System.IO.Directory.GetFiles(SaveUtil.SaveFolder); - - foreach (string saveFile in saveFiles) - { - System.IO.File.Delete(saveFile); - NewMessage("Deleted " + saveFile, Color.Green); - } - - if (System.IO.Directory.Exists(System.IO.Path.Combine(SaveUtil.SaveFolder, "temp"))) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => - { - if (args.Length == 0) return; - LocalizationCSVtoXML.Convert(args[0]); - })); -#endif - - commands.Add(new Command("cleanbuild", "", (string[] args) => - { - GameMain.Config.MusicVolume = 0.5f; - GameMain.Config.SoundVolume = 0.5f; - NewMessage("Music and sound volume set to 0.5", Color.Green); - - commands.Add(new Command("camerasettings", "camerasettings [defaultzoom] [zoomsmoothness] [movesmoothness] [minzoom] [maxzoom]: debug command for testing camera settings. The values default to 1.1, 8.0, 8.0, 0.1 and 2.0.", (string[] args) => - { - float defaultZoom = Screen.Selected.Cam.DefaultZoom; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out defaultZoom); - - float zoomSmoothness = Screen.Selected.Cam.ZoomSmoothness; - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out zoomSmoothness); - float moveSmoothness = Screen.Selected.Cam.MoveSmoothness; - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out moveSmoothness); - - float minZoom = Screen.Selected.Cam.MinZoom; - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out minZoom); - float maxZoom = Screen.Selected.Cam.MaxZoom; - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out maxZoom); - - Screen.Selected.Cam.DefaultZoom = defaultZoom; - Screen.Selected.Cam.ZoomSmoothness = zoomSmoothness; - Screen.Selected.Cam.MoveSmoothness = moveSmoothness; - Screen.Selected.Cam.MinZoom = minZoom; - Screen.Selected.Cam.MaxZoom = maxZoom; - })); - - commands.Add(new Command("waterparams", "waterparams [distortionscalex] [distortionscaley] [distortionstrengthx] [distortionstrengthy] [bluramount]: default 0.5 0.5 0.5 0.5 1", (string[] args) => - { - float distortScaleX = 0.5f, distortScaleY = 0.5f; - float distortStrengthX = 0.5f, distortStrengthY = 0.5f; - float blurAmount = 0.0f; - if (args.Length > 0) float.TryParse(args[0], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleX); - if (args.Length > 1) float.TryParse(args[1], NumberStyles.Number, CultureInfo.InvariantCulture, out distortScaleY); - if (args.Length > 2) float.TryParse(args[2], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthX); - if (args.Length > 3) float.TryParse(args[3], NumberStyles.Number, CultureInfo.InvariantCulture, out distortStrengthY); - if (args.Length > 4) float.TryParse(args[4], NumberStyles.Number, CultureInfo.InvariantCulture, out blurAmount); - WaterRenderer.DistortionScale = new Vector2(distortScaleX, distortScaleY); - WaterRenderer.DistortionStrength = new Vector2(distortStrengthX, distortStrengthY); - WaterRenderer.BlurAmount = blurAmount; - })); - - - commands.Add(new Command("refreshrect", "Updates the dimensions of the selected items to match the ones defined in the prefab. Applied only in the subeditor.", (string[] args) => - { - //TODO: maybe do this automatically during loading when possible? - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s) first!"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Item item) - { - item.Rect = new Rectangle(item.Rect.X, item.Rect.Y, - (int)(item.Prefab.sprite.size.X * item.Prefab.Scale), - (int)(item.Prefab.sprite.size.Y * item.Prefab.Scale)); - } - else if (mapEntity is Structure structure) - { - if (!structure.ResizeHorizontal) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - (int)structure.Prefab.ScaledSize.X, - structure.Rect.Height); - } - if (!structure.ResizeVertical) - { - structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y, - structure.Rect.Width, - (int)structure.Prefab.ScaledSize.Y); - } - } - } - } - } - }, isCheat: false)); -#endif - - GameMain.Config.SaveNewPlayerConfig(); - - var saveFiles = System.IO.Directory.GetFiles(SaveUtil.SaveFolder); - - foreach (string saveFile in saveFiles) - { - lines.Add(element.ElementInnerText()); - } - File.WriteAllLines(Path.GetFileNameWithoutExtension(filePath) + ".txt", lines); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - TextManager.GetTextFiles().Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("loadtexts", "loadtexts [sourcefile] [destinationfile]: Loads all lines of text from a given .txt file and inserts them sequientially into the elements of an xml file. If the file paths are omitted, EnglishVanilla.txt and EnglishVanilla.xml are used.", (string[] args) => - { - string sourcePath = args.Length > 0 ? args[0] : "Content/Texts/EnglishVanilla.txt"; - string destinationPath = args.Length > 1 ? args[1] : "Content/Texts/EnglishVanilla.xml"; - - string[] lines; - try - { - lines = File.ReadAllLines(sourcePath); - } - catch (Exception e) - { - ThrowError("Reading the file \"" + sourcePath + "\" failed.", e); - return; - } - var doc = XMLExtensions.TryLoadXml(destinationPath); - int i = 0; - foreach (XElement element in doc.Root.Elements()) - { - if (i >= lines.Length) - { - ThrowError("Error while loading texts to the xml file. The xml has more elements than the number of lines in the text file."); - return; - } - element.Value = lines[i]; - i++; - } - doc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Select(f => f.Replace("\\", "/")); - return new string[][] - { - files.Where(f => Path.GetExtension(f)==".txt").ToArray(), - files.Where(f => Path.GetExtension(f)==".xml").ToArray() - }; - })); - - commands.Add(new Command("updatetextfile", "updatetextfile [sourcefile] [destinationfile]: Inserts all the xml elements that are only present in the source file into the destination file. Can be used to update outdated translation files more easily.", (string[] args) => - { - if (args.Length < 2) return; - string sourcePath = args[0]; - string destinationPath = args[1]; - - var sourceDoc = XMLExtensions.TryLoadXml(sourcePath); - var destinationDoc = XMLExtensions.TryLoadXml(destinationPath); - - XElement destinationElement = destinationDoc.Root.Elements().First(); - foreach (XElement element in sourceDoc.Root.Elements()) - { - if (destinationDoc.Root.Element(element.Name) == null) - { - element.Value = "!!!!!!!!!!!!!" + element.Value; - destinationElement.AddAfterSelf(element); - } - XNode nextNode = destinationElement.NextNode; - while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; - destinationElement = nextNode as XElement; - } - destinationDoc.Save(destinationPath); - }, - () => - { - var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); - return new string[][] - { - files, - files - }; - })); - - commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => - { - string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; - List lines = new List(); - foreach (MapEntityPrefab me in MapEntityPrefab.List) - { - lines.Add("" + me.Name + ""); - lines.Add("" + me.Description + ""); - } - File.WriteAllLines(filePath, lines); - })); -#if DEBUG - commands.Add(new Command("checkduplicates", "Checks the given language for duplicate translation keys and writes to file.", (string[] args) => - { - if (args.Length != 1) return; - TextManager.CheckForDuplicates(args[0]); - })); - - commands.Add(new Command("writetocsv", "Writes the default language (English) to a .csv file.", (string[] args) => - { - TextManager.WriteToCSV(); - NPCConversation.WriteToCSV(); - })); - commands.Add(new Command("csvtoxml", "csvtoxml [language] -> Converts .csv localization files in Content/NPCConversations & Content/Texts to .xml for use in-game.", (string[] args) => { if (args.Length == 0) return; diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 1451bace0..6044f8563 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -620,7 +620,7 @@ namespace Barotrauma } if (string.IsNullOrEmpty(text)) { return; } - chatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender)); + ChatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender)); } private IEnumerable KillCharacterAnim(GUIComponent component) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 196956df2..7d8076f56 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -80,6 +80,32 @@ namespace Barotrauma sender.UserData = null; } }; + clientNameBox.OnTextChanged += RefreshJoinButtonState; + + new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoHolder.RectTransform), TextManager.Get("ServerIP")); + ipBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.13f), infoHolder.RectTransform), ""); + ipBox.OnTextChanged += RefreshJoinButtonState; + ipBox.OnSelected += (sender, key) => + { + if (sender.UserData is ServerInfo) + { + sender.Text = ""; + sender.UserData = null; + } + }; + + var filterHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), leftColumn.RectTransform)) { RelativeSpacing = 0.05f }; + + new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), filterHolder.RectTransform), TextManager.Get("FilterServers")); + searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.13f), filterHolder.RectTransform), ""); + + var tickBoxHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), filterHolder.RectTransform)); + + searchBox.OnTextChanged += (txtBox, txt) => { FilterServers(); return true; }; + filterPassword = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterPassword")); + filterPassword.OnSelected += (tickBox) => { FilterServers(); return true; }; + filterIncompatible = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.27f), tickBoxHolder.RectTransform), TextManager.Get("FilterIncompatibleServers")); + filterIncompatible.OnSelected += (tickBox) => { FilterServers(); return true; }; var filterHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), leftColumn.RectTransform)) { RelativeSpacing = 0.05f }; @@ -151,46 +177,6 @@ namespace Barotrauma Enabled = false }; - //------------------------------------------------------------------------------------- - //right column - //------------------------------------------------------------------------------------- - - var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(1.0f - leftColumn.RectTransform.RelativeSize.X - 0.017f, 0.97f), - paddedFrame.RectTransform, Anchor.TopRight)) - { - RelativeSpacing = 0.02f, - Stretch = true - }; - - serverList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.85f), rightColumn.RectTransform, Anchor.Center)) - { - OnSelected = SelectServer - }; - - columnRelativeWidth = new float[] { 0.04f, 0.02f, 0.044f, 0.77f, 0.02f, 0.075f, 0.06f }; - - var buttonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.075f), rightColumn.RectTransform), style: null); - - GUIButton button = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform, Anchor.TopLeft), - TextManager.Get("Back"), style: "GUIButtonLarge") - { - OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu - }; - - var refreshButton = new GUIButton(new RectTransform(new Vector2(buttonContainer.Rect.Height / (float)buttonContainer.Rect.Width, 0.9f), buttonContainer.RectTransform, Anchor.Center), - "", style: "GUIButtonRefresh") { - - ToolTip = TextManager.Get("ServerListRefresh"), - OnClicked = RefreshServers - }; - - joinButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform, Anchor.TopRight), - TextManager.Get("ServerListJoin"), style: "GUIButtonLarge") - { - OnClicked = JoinServer, - Enabled = false - }; - //-------------------------------------------------------- button.SelectedColor = button.Color; @@ -233,6 +219,8 @@ namespace Barotrauma UserData = "noresults" }; } + + return true; } private bool RefreshJoinButtonState(GUIComponent component, object obj) diff --git a/Barotrauma/BarotraumaShared/SharedContent.projitems b/Barotrauma/BarotraumaShared/SharedContent.projitems index 87350b127..e95896c42 100644 --- a/Barotrauma/BarotraumaShared/SharedContent.projitems +++ b/Barotrauma/BarotraumaShared/SharedContent.projitems @@ -1986,6 +1986,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -2561,18 +2579,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 213beec73..a0434b600 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -462,6 +462,12 @@ namespace Barotrauma Tags = new HashSet(element.GetAttributeStringArray("Tags", new string[0], convertToLowerInvariant: true)); } + Tags = new HashSet(element.GetAttributeStringArray("tags", new string[0], convertToLowerInvariant: true)); + if (Tags.None()) + { + Tags = new HashSet(element.GetAttributeStringArray("Tags", new string[0], convertToLowerInvariant: true)); + } + if (element.Attribute("cargocontainername") != null) { DebugConsole.ThrowError("Error in item prefab \"" + name + "\" - cargo container should be configured using the item's identifier, not the name."); diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 3cfbaa599..03220257b 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -109,6 +109,25 @@ namespace Barotrauma } } + public string DisplayName + { + get; + private set; + } + + private string roomName; + [Editable, Serialize("", true, translationTextTag: "RoomName.")] + public string RoomName + { + get { return roomName; } + set + { + if (roomName == value) { return; } + roomName = value; + DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName; + } + } + public override Rectangle Rect { get