From 51e3e8d667b2f75cb3b20220ae2a1f4d545b878e Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 21:52:36 +0300 Subject: [PATCH] (2c8393f34) Fixed "The suitable treatments list may be inaccurate" overflowing in German & Russian, show item name tooltips when hovering over the treatment suggestions --- .../Characters/Health/CharacterHealth.cs | 29 +++-- .../BarotraumaShared/Source/GameSettings.cs | 105 ++++++++++++++++-- 2 files changed, 111 insertions(+), 23 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs index d41b84777..afa1d3daf 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs @@ -188,14 +188,9 @@ namespace Barotrauma afflictionInfoContainer = new GUIListBox(new RectTransform(new Vector2(0.7f, 0.85f), paddedInfoFrame.RectTransform, Anchor.BottomLeft)); - lowSkillIndicator = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedInfoFrame.RectTransform, Anchor.TopRight), - TextManager.Get("LowMedicalSkillWarning"), Color.Orange, textAlignment: Alignment.TopRight, font: GUI.SmallFont, wrap: true) - { - Visible = false - }; - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedInfoFrame.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.05f) }, TextManager.Get("SuitableTreatments"), textAlignment: Alignment.BottomRight); + new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), paddedInfoFrame.RectTransform, Anchor.TopRight), TextManager.Get("SuitableTreatments"), textAlignment: Alignment.TopRight); - recommendedTreatmentContainer = new GUIListBox(new RectTransform(new Vector2(0.28f, 0.5f), paddedInfoFrame.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, 0.12f) }); + recommendedTreatmentContainer = new GUIListBox(new RectTransform(new Vector2(0.28f, 0.47f), paddedInfoFrame.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, 0.15f) }); dropItemArea = new GUIFrame(new RectTransform(new Vector2(0.28f, 0.3f), paddedInfoFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.02f, 0.0f) }, style: null) { @@ -203,6 +198,17 @@ namespace Barotrauma }; dropItemArea.RectTransform.NonScaledSize = new Point(dropItemArea.Rect.Width); + lowSkillIndicator = new GUIImage(new RectTransform(new Vector2(0.5f, 0.22f), paddedInfoFrame.RectTransform, Anchor.TopRight, Pivot.Center) { RelativeOffset = new Vector2(0.16f, 0.12f) }, + style: "GUINotificationButton") + { + ToolTip = TextManager.Get("lowmedicalskillwarning"), + Color = Color.OrangeRed, + HoverColor = Color.Orange, + PressedColor = Color.Orange, + Visible = false + }; + lowSkillIndicator.RectTransform.MaxSize = new Point(lowSkillIndicator.Rect.Height); + string[] healthCircleStyles = new string[] { "HealthCircleInner", "HealthCircleMid", "HealthCircleOuter" }; foreach (string healthCircleStyle in healthCircleStyles) { @@ -657,7 +663,8 @@ namespace Barotrauma openHealthWindow = null; } - lowSkillIndicator.Visible = Timing.TotalTime % 1.0f < 0.8f && Character.Controlled != null && Character.Controlled.GetSkillLevel("medical") < 50.0f; + lowSkillIndicator.Visible = Character.Controlled != null && Character.Controlled.GetSkillLevel("medical") < 50.0f; + lowSkillIndicator.Color = new Color(lowSkillIndicator.Color, MathHelper.Lerp(0.1f, 1.0f, (float)(Math.Sin(Timing.TotalTime * 5.0f) + 1.0f) / 2.0f)); float rotationSpeed = 0.25f; int i = 0; @@ -1053,10 +1060,10 @@ namespace Barotrauma var itemSlot = new GUIFrame(new RectTransform(new Point(recommendedTreatmentContainer.Content.Rect.Width, slotSize), recommendedTreatmentContainer.Content.RectTransform, Anchor.TopCenter), style: "InnerGlow") { - UserData = item, - CanBeFocused = false + UserData = item }; itemSlot.Color = ToolBox.GradientLerp(treatment.Value, Color.Red, Color.Orange, Color.LightGreen); + itemSlot.SelectedColor = itemSlot.HoverColor = itemSlot.Color; Sprite itemSprite = item.InventoryIcon ?? item.sprite; Color itemColor = itemSprite == item.sprite ? item.SpriteColor : item.InventoryIconColor; @@ -1068,7 +1075,7 @@ namespace Barotrauma HoverColor = itemColor, SelectedColor = itemColor }; - itemSlot.ToolTip = item.Name + "\n" + item.Description; + itemSlot.ToolTip = item.Name; } afflictionInfoContainer.Content.RectTransform.SortChildren((r1, r2) => diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index ed93b56b7..74714c289 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -337,6 +337,79 @@ namespace Barotrauma keyMapping[(int)InputType.SelectNextCharacter] = new KeyOrMouse(Keys.Z); keyMapping[(int)InputType.SelectPreviousCharacter] = new KeyOrMouse(Keys.X); } + } + + public void CheckBindings(bool useDefaults) + { + foreach (InputType inputType in Enum.GetValues(typeof(InputType))) + { + var binding = keyMapping[(int)inputType]; + if (binding == null) + { + switch (inputType) + { + case InputType.Deselect: + if (useDefaults) + { + binding = new KeyOrMouse(1); + } + else + { + // Legacy support + var selectKey = keyMapping[(int)InputType.Select]; + if (selectKey != null && selectKey.Key != Keys.None) + { + binding = new KeyOrMouse(selectKey.Key); + } + } + break; + case InputType.Shoot: + if (useDefaults) + { + binding = new KeyOrMouse(0); + } + else + { + // Legacy support + var useKey = keyMapping[(int)InputType.Use]; + if (useKey != null && useKey.MouseButton.HasValue) + { + binding = new KeyOrMouse(useKey.MouseButton.Value); + } + } + break; + default: + break; + } + if (binding == null) + { + DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!"); + binding = new KeyOrMouse(Keys.D1); + } + keyMapping[(int)inputType] = binding; + } + } + } + + #region Load DefaultConfig + private void LoadDefaultConfig(bool setLanguage = true) + { + XDocument doc = XMLExtensions.TryLoadXml(savePath); + + if (setLanguage || string.IsNullOrEmpty(Language)) + { + Language = doc.Root.GetAttributeString("language", "English"); + } + + MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", ""); + + AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true); + WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false); + + VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false); + SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false); + + QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", ""); if (legacy) { @@ -1042,12 +1115,17 @@ namespace Barotrauma gMode = new XElement("graphicsmode"); doc.Root.Add(gMode); } - - //display error messages after all content packages have been loaded - //to make sure the package that contains text files has been loaded before we attempt to use TextManager - foreach (string missingPackagePath in missingPackagePaths) + if (GraphicsWidth == 0 || GraphicsHeight == 0) { - DebugConsole.ThrowError(TextManager.Get("ContentPackageNotFound").Replace("[packagepath]", missingPackagePath)); + gMode.ReplaceAttributes(new XAttribute("displaymode", windowMode)); + } + else + { + gMode.ReplaceAttributes( + new XAttribute("width", GraphicsWidth), + new XAttribute("height", GraphicsHeight), + new XAttribute("vsync", VSyncEnabled), + new XAttribute("displaymode", windowMode)); } XElement audio = doc.Root.Element("audio"); @@ -1086,17 +1164,18 @@ namespace Barotrauma doc.Root.Add(new XElement("contentpackage", new XAttribute("path", contentPackage.Path))); } - foreach (ContentPackage contentPackage in SelectedContentPackages) + + var keyMappingElement = new XElement("keymapping"); + doc.Root.Add(keyMappingElement); + for (int i = 0; i < keyMapping.Length; i++) { - bool packageOk = contentPackage.VerifyFiles(out List errorMessages); - if (!packageOk) + if (keyMapping[i].MouseButton == null) { - DebugConsole.ThrowError("Error in content package \"" + contentPackage.Name + "\":\n" + string.Join("\n", errorMessages)); - continue; + keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].Key)); } - foreach (ContentFile file in contentPackage.Files) + else { - ToolBox.IsProperFilenameCase(file.Path); + keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].MouseButton)); } } @@ -1106,6 +1185,8 @@ namespace Barotrauma { jobPreferences.Add(new XElement("job", new XAttribute("identifier", jobName))); } + gameplay.Add(jobPreferences); + doc.Root.Add(gameplay); var playerElement = new XElement("player", new XAttribute("name", defaultPlayerName ?? ""),