diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs index afa1d3daf..d41b84777 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs @@ -188,9 +188,14 @@ namespace Barotrauma afflictionInfoContainer = new GUIListBox(new RectTransform(new Vector2(0.7f, 0.85f), paddedInfoFrame.RectTransform, Anchor.BottomLeft)); - new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), paddedInfoFrame.RectTransform, Anchor.TopRight), TextManager.Get("SuitableTreatments"), textAlignment: Alignment.TopRight); + 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); - recommendedTreatmentContainer = new GUIListBox(new RectTransform(new Vector2(0.28f, 0.47f), paddedInfoFrame.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, 0.15f) }); + recommendedTreatmentContainer = new GUIListBox(new RectTransform(new Vector2(0.28f, 0.5f), paddedInfoFrame.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, 0.12f) }); dropItemArea = new GUIFrame(new RectTransform(new Vector2(0.28f, 0.3f), paddedInfoFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.02f, 0.0f) }, style: null) { @@ -198,17 +203,6 @@ 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) { @@ -663,8 +657,7 @@ namespace Barotrauma openHealthWindow = null; } - 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)); + lowSkillIndicator.Visible = Timing.TotalTime % 1.0f < 0.8f && Character.Controlled != null && Character.Controlled.GetSkillLevel("medical") < 50.0f; float rotationSpeed = 0.25f; int i = 0; @@ -1060,10 +1053,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 + UserData = item, + CanBeFocused = false }; 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; @@ -1075,7 +1068,7 @@ namespace Barotrauma HoverColor = itemColor, SelectedColor = itemColor }; - itemSlot.ToolTip = item.Name; + itemSlot.ToolTip = item.Name + "\n" + item.Description; } afflictionInfoContainer.Content.RectTransform.SortChildren((r1, r2) => diff --git a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs index ef928a8ac..4c352fbac 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs @@ -16,7 +16,7 @@ namespace Barotrauma private RenderTarget2D renderTarget; private Sprite languageSelectionCursor; - private ScalableFont languageSelectionFont, languageSelectionFontCJK; + private ScalableFont languageSelectionFont; private Video currSplashScreen; private DateTime videoStartTime; @@ -220,13 +220,7 @@ namespace Barotrauma { if (languageSelectionFont == null) { - languageSelectionFont = new ScalableFont("Content/Fonts/NotoSans/NotoSans-Bold.ttf", - (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice); - } - if (languageSelectionFontCJK == null) - { - languageSelectionFontCJK = new ScalableFont("Content/Fonts/NotoSans/NotoSansCJKsc-Bold.otf", - (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice, dynamicLoading: true); + languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice); } if (languageSelectionCursor == null) { @@ -237,15 +231,13 @@ namespace Barotrauma Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count()); foreach (string language in TextManager.AvailableLanguages) { - string localizedLanguageName = TextManager.GetTranslatedLanguageName(language); - var font = TextManager.IsCJK(localizedLanguageName) ? languageSelectionFontCJK : languageSelectionFont; - - Vector2 textSize = font.MeasureString(localizedLanguageName); + Vector2 textSize = languageSelectionFont.MeasureString(language); bool hover = Math.Abs(PlayerInput.MousePosition.X - textPos.X) < textSize.X / 2 && Math.Abs(PlayerInput.MousePosition.Y - textPos.Y) < textSpacing.Y / 2; - font.DrawString(spriteBatch, localizedLanguageName, textPos - textSize / 2, + //TODO: display the name of the language in the target language? + languageSelectionFont.DrawString(spriteBatch, language, textPos - textSize / 2, hover ? Color.White : Color.White * 0.6f); if (hover && PlayerInput.LeftButtonClicked()) { @@ -255,15 +247,12 @@ namespace Barotrauma GameMain.Config.SetDefaultBindings(legacy: false); GameMain.Config.CheckBindings(useDefaults: true); WaitForLanguageSelection = false; - languageSelectionFont?.Dispose(); languageSelectionFont = null; - languageSelectionFontCJK?.Dispose(); languageSelectionFontCJK = null; - break; } textPos += textSpacing; } - languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition, scale: 0.5f); + languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition); } private void DrawSplashScreen(SpriteBatch spriteBatch, GraphicsDevice graphics) diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs index e63f4b0c8..4d516fb8e 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs @@ -318,7 +318,7 @@ namespace Barotrauma.Tutorials do { yield return null; - if (IsSelectedItem(mechanic_brokenPump.Item)) + if (IsSelectedItem(mechanic_workingPump.Item)) { if (mechanic_workingPump.IsActiveSlider.FlashTimer <= 0) { @@ -527,6 +527,16 @@ namespace Barotrauma.Tutorials } } } + else + { + if (IsSelectedItem(mechanic_brokenPump.Item)) + { + if (mechanic_brokenPump.IsActiveSlider.FlashTimer <= 0) + { + mechanic_brokenPump.IsActiveSlider.Flash(uiHighlightColor, 1.5f, true); + } + } + } } while (!mechanic_brokenPump.Item.IsFullCondition || mechanic_brokenPump.FlowPercentage >= 0 || !mechanic_brokenPump.IsActive); RemoveCompletedObjective(segments[9]); SetHighlight(mechanic_brokenPump.Item, false); diff --git a/Barotrauma/BarotraumaClient/Source/Utils/ToolBox.cs b/Barotrauma/BarotraumaClient/Source/Utils/ToolBox.cs index c949e94fc..0a45900e2 100644 --- a/Barotrauma/BarotraumaClient/Source/Utils/ToolBox.cs +++ b/Barotrauma/BarotraumaClient/Source/Utils/ToolBox.cs @@ -111,7 +111,7 @@ namespace Barotrauma string currWord = ""; for (int i = 0; i < text.Length; i++) { - if (TextManager.IsCJK(text[i].ToString())) + if (isCJK.IsMatch(text[i].ToString())) { if (currWord.Length > 0) { @@ -200,13 +200,24 @@ namespace Barotrauma linePos = size.X + spaceSize.X; } - if (i < words.Count - 1 && !TextManager.IsCJK(words[i]) && !TextManager.IsCJK(words[i + 1])) + if (i < words.Count - 1 && !isCJK.IsMatch(words[i]) && !isCJK.IsMatch(words[i + 1])) { wrappedText.Append(" "); } } return wrappedText.ToString().Replace(" \n ", "\n"); - } + } + + static Regex isCJK = new Regex( + @"\p{IsHangulJamo}|" + + @"\p{IsCJKRadicalsSupplement}|" + + @"\p{IsCJKSymbolsandPunctuation}|" + + @"\p{IsEnclosedCJKLettersandMonths}|" + + @"\p{IsCJKCompatibility}|" + + @"\p{IsCJKUnifiedIdeographsExtensionA}|" + + @"\p{IsCJKUnifiedIdeographs}|" + + @"\p{IsHangulSyllables}|" + + @"\p{IsCJKCompatibilityForms}"); } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 7b61861e2..cf27e30b6 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -485,11 +485,7 @@ namespace Barotrauma } else if (ObjectiveManager.CurrentOrder is AIObjectiveRescueAll rescueAll && rescueAll.Targets.None()) { - //TODO: re-enable on all languages after DialogNoRescueTargets has been translated - if (TextManager.Language == "English") - { - Character.Speak(TextManager.Get("DialogNoRescueTargets"), null, 3.0f, "norescuetargets"); - } + Character.Speak(TextManager.Get("DialogNoRescueTargets"), null, 3.0f, "norescuetargets"); } else if (ObjectiveManager.CurrentOrder is AIObjectivePumpWater pumpWater && pumpWater.Targets.None()) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs index 4bc3f8ad5..ce223ae35 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs @@ -22,16 +22,7 @@ namespace Barotrauma public AIObjectiveRescue(Character character, Character targetCharacter, AIObjectiveManager objectiveManager, float priorityModifier = 1) : base(character, objectiveManager, priorityModifier) { - if (targetCharacter == null) - { - string errorMsg = "Attempted to create a Rescue objective with no target!\n" + Environment.StackTrace; - DebugConsole.ThrowError(errorMsg); - GameAnalyticsManager.AddErrorEventOnce("AIObjectiveRescue:ctor:targetnull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); - abandon = true; - return; - } - - if (targetCharacter == character) + if (targetCharacter != character) { // TODO: enable healing self too abandon = true; @@ -48,11 +39,6 @@ namespace Barotrauma protected override void Act(float deltaTime) { - if (targetCharacter == null || targetCharacter.Removed) - { - return; - } - // Unconcious target is not in a safe place -> Move to a safe place first if (targetCharacter.IsUnconscious && HumanAIController.GetHullSafety(targetCharacter.CurrentHull, targetCharacter) < HumanAIController.HULL_SAFETY_THRESHOLD) { @@ -220,19 +206,13 @@ namespace Barotrauma public override bool IsCompleted() { - if (targetCharacter == null || targetCharacter.Removed) - { - abandon = true; - return true; - } - bool isCompleted = targetCharacter.Bleeding <= 0 && targetCharacter.Vitality / targetCharacter.MaxVitality > AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager); if (isCompleted) { character.Speak(TextManager.Get("DialogTargetHealed").Replace("[targetname]", targetCharacter.Name), null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f); } - return isCompleted || targetCharacter.IsDead; + return isCompleted || targetCharacter.Removed || targetCharacter.IsDead; } public override float GetPriority() diff --git a/Barotrauma/BarotraumaShared/Source/ContentPackage.cs b/Barotrauma/BarotraumaShared/Source/ContentPackage.cs index 682e055ae..b9071ec17 100644 --- a/Barotrauma/BarotraumaShared/Source/ContentPackage.cs +++ b/Barotrauma/BarotraumaShared/Source/ContentPackage.cs @@ -240,11 +240,6 @@ namespace Barotrauma errorMessages = new List(); foreach (ContentFile file in Files) { -#if SERVER - //dedicated server doesn't care if the client executable is present or not - if (file.Type == ContentType.Executable) { continue; } -#endif - if (!File.Exists(file.Path)) { errorMessages.Add("File \"" + file.Path + "\" not found."); diff --git a/Barotrauma/BarotraumaShared/Source/TextManager.cs b/Barotrauma/BarotraumaShared/Source/TextManager.cs index 60ff00a43..75cac6efc 100644 --- a/Barotrauma/BarotraumaShared/Source/TextManager.cs +++ b/Barotrauma/BarotraumaShared/Source/TextManager.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; namespace Barotrauma { @@ -43,26 +42,6 @@ namespace Barotrauma GetTextFilesRecursive(subDir, ref list); } } - - /// - /// Returns the name of the language in the respective language - /// - public static string GetTranslatedLanguageName(string language) - { - if (!textPacks.ContainsKey(language)) - { - return language; - } - - foreach (var textPack in textPacks[language]) - { - if (textPack.Language == language) - { - return textPack.TranslatedName; - } - } - return language; - } public static void LoadTextPacks(IEnumerable selectedContentPackages) { @@ -132,6 +111,8 @@ namespace Barotrauma throw new Exception("No text packs available in English!"); } } + return false; + } foreach (TextPack textPack in textPacks[Language]) { @@ -412,6 +393,42 @@ namespace Barotrauma return isCJK.IsMatch(text); } +#if DEBUG + public static void CheckForDuplicates(string lang) + { + if (!textPacks.ContainsKey(lang)) + { + DebugConsole.ThrowError("No text packs available for the selected language (" + lang + ")!"); + return; + } + + int packIndex = 0; + foreach (TextPack textPack in textPacks[lang]) + { + textPack.CheckForDuplicates(packIndex); + packIndex++; + } + } + + public static void WriteToCSV() + { + string lang = "English"; + + if (!textPacks.ContainsKey(lang)) + { + DebugConsole.ThrowError("No text packs available for the selected language (" + lang + ")!"); + return; + } + + int packIndex = 0; + foreach (TextPack textPack in textPacks[lang]) + { + textPack.WriteToCSV(packIndex); + packIndex++; + } + } +#endif + #if DEBUG public static void CheckForDuplicates(string lang) { diff --git a/Barotrauma/BarotraumaShared/Source/TextPack.cs b/Barotrauma/BarotraumaShared/Source/TextPack.cs index 565b752da..18b0170d8 100644 --- a/Barotrauma/BarotraumaShared/Source/TextPack.cs +++ b/Barotrauma/BarotraumaShared/Source/TextPack.cs @@ -10,11 +10,6 @@ namespace Barotrauma { public readonly string Language; - /// - /// The name of the language in the language this pack is written in - /// - public readonly string TranslatedName; - private Dictionary> texts; private readonly string filePath; @@ -28,7 +23,6 @@ namespace Barotrauma if (doc == null || doc.Root == null) return; Language = doc.Root.GetAttributeString("language", "Unknown"); - TranslatedName = doc.Root.GetAttributeString("translatedname", Language); foreach (XElement subElement in doc.Root.Elements()) { diff --git a/Libraries/Facepunch.Steamworks/Server.cs b/Libraries/Facepunch.Steamworks/Server.cs index 13a01c804..8e49cb739 100644 --- a/Libraries/Facepunch.Steamworks/Server.cs +++ b/Libraries/Facepunch.Steamworks/Server.cs @@ -43,12 +43,12 @@ namespace Facepunch.Steamworks // //kind of a hack: - //use an invalid version number to hide private servers from the server list. + //use an outdated version number to hide private servers from the server list. //couldn't find a way to do it otherwise - using 1 as the eServerMode doesn't //seem to work, the server info is still returned by the API calls - string versionString = isPublic ? init.VersionString : "-1"; - if ( !native.InitServer( this, ipaddress, init.SteamPort, init.GamePort, init.QueryPort, isPublic ? (init.Secure ? 3 : 2) : 1, - versionString) ) + string versionString = isPublic ? init.VersionString : "0.0.0.0"; + if ( !native.InitServer( this, ipaddress, init.SteamPort, init.GamePort, init.QueryPort, init.Secure ? 3 : 2, + isPublic ? init.VersionString : "0.0.0.0" ) ) { native.Dispose(); native = null;