(36d2ff935) Merge branch 'dev' of github.com:Regalis11/Barotrauma-development into dev

This commit is contained in:
Joonas Rikkonen
2019-05-20 20:18:17 +03:00
parent 1340780205
commit 120dc39a9e
9 changed files with 101 additions and 76 deletions
@@ -188,14 +188,9 @@ namespace Barotrauma
afflictionInfoContainer = new GUIListBox(new RectTransform(new Vector2(0.7f, 0.85f), paddedInfoFrame.RectTransform, Anchor.BottomLeft)); 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), new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), paddedInfoFrame.RectTransform, Anchor.TopRight), TextManager.Get("SuitableTreatments"), textAlignment: Alignment.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.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) dropItemArea = new GUIFrame(new RectTransform(new Vector2(0.28f, 0.3f), paddedInfoFrame.RectTransform, Anchor.BottomRight)
{ RelativeOffset = new Vector2(0.02f, 0.0f) }, style: null) { RelativeOffset = new Vector2(0.02f, 0.0f) }, style: null)
{ {
@@ -203,6 +198,17 @@ namespace Barotrauma
}; };
dropItemArea.RectTransform.NonScaledSize = new Point(dropItemArea.Rect.Width); 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" }; string[] healthCircleStyles = new string[] { "HealthCircleInner", "HealthCircleMid", "HealthCircleOuter" };
foreach (string healthCircleStyle in healthCircleStyles) foreach (string healthCircleStyle in healthCircleStyles)
{ {
@@ -657,7 +663,8 @@ namespace Barotrauma
openHealthWindow = null; 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; float rotationSpeed = 0.25f;
int i = 0; 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), var itemSlot = new GUIFrame(new RectTransform(new Point(recommendedTreatmentContainer.Content.Rect.Width, slotSize), recommendedTreatmentContainer.Content.RectTransform, Anchor.TopCenter),
style: "InnerGlow") style: "InnerGlow")
{ {
UserData = item, UserData = item
CanBeFocused = false
}; };
itemSlot.Color = ToolBox.GradientLerp(treatment.Value, Color.Red, Color.Orange, Color.LightGreen); itemSlot.Color = ToolBox.GradientLerp(treatment.Value, Color.Red, Color.Orange, Color.LightGreen);
itemSlot.SelectedColor = itemSlot.HoverColor = itemSlot.Color;
Sprite itemSprite = item.InventoryIcon ?? item.sprite; Sprite itemSprite = item.InventoryIcon ?? item.sprite;
Color itemColor = itemSprite == item.sprite ? item.SpriteColor : item.InventoryIconColor; Color itemColor = itemSprite == item.sprite ? item.SpriteColor : item.InventoryIconColor;
@@ -1068,7 +1075,7 @@ namespace Barotrauma
HoverColor = itemColor, HoverColor = itemColor,
SelectedColor = itemColor SelectedColor = itemColor
}; };
itemSlot.ToolTip = item.Name + "\n" + item.Description; itemSlot.ToolTip = item.Name;
} }
afflictionInfoContainer.Content.RectTransform.SortChildren((r1, r2) => afflictionInfoContainer.Content.RectTransform.SortChildren((r1, r2) =>
@@ -16,7 +16,7 @@ namespace Barotrauma
private RenderTarget2D renderTarget; private RenderTarget2D renderTarget;
private Sprite languageSelectionCursor; private Sprite languageSelectionCursor;
private ScalableFont languageSelectionFont; private ScalableFont languageSelectionFont, languageSelectionFontCJK;
private Video currSplashScreen; private Video currSplashScreen;
private DateTime videoStartTime; private DateTime videoStartTime;
@@ -220,7 +220,13 @@ namespace Barotrauma
{ {
if (languageSelectionFont == null) if (languageSelectionFont == null)
{ {
languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice); 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);
} }
if (languageSelectionCursor == null) if (languageSelectionCursor == null)
{ {
@@ -231,13 +237,15 @@ namespace Barotrauma
Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count()); Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count());
foreach (string language in TextManager.AvailableLanguages) foreach (string language in TextManager.AvailableLanguages)
{ {
Vector2 textSize = languageSelectionFont.MeasureString(language); string localizedLanguageName = TextManager.GetTranslatedLanguageName(language);
var font = TextManager.IsCJK(localizedLanguageName) ? languageSelectionFontCJK : languageSelectionFont;
Vector2 textSize = font.MeasureString(localizedLanguageName);
bool hover = bool hover =
Math.Abs(PlayerInput.MousePosition.X - textPos.X) < textSize.X / 2 && Math.Abs(PlayerInput.MousePosition.X - textPos.X) < textSize.X / 2 &&
Math.Abs(PlayerInput.MousePosition.Y - textPos.Y) < textSpacing.Y / 2; Math.Abs(PlayerInput.MousePosition.Y - textPos.Y) < textSpacing.Y / 2;
//TODO: display the name of the language in the target language? font.DrawString(spriteBatch, localizedLanguageName, textPos - textSize / 2,
languageSelectionFont.DrawString(spriteBatch, language, textPos - textSize / 2,
hover ? Color.White : Color.White * 0.6f); hover ? Color.White : Color.White * 0.6f);
if (hover && PlayerInput.LeftButtonClicked()) if (hover && PlayerInput.LeftButtonClicked())
{ {
@@ -247,12 +255,15 @@ namespace Barotrauma
GameMain.Config.SetDefaultBindings(legacy: false); GameMain.Config.SetDefaultBindings(legacy: false);
GameMain.Config.CheckBindings(useDefaults: true); GameMain.Config.CheckBindings(useDefaults: true);
WaitForLanguageSelection = false; WaitForLanguageSelection = false;
languageSelectionFont?.Dispose(); languageSelectionFont = null;
languageSelectionFontCJK?.Dispose(); languageSelectionFontCJK = null;
break;
} }
textPos += textSpacing; textPos += textSpacing;
} }
languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition); languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition, scale: 0.5f);
} }
private void DrawSplashScreen(SpriteBatch spriteBatch, GraphicsDevice graphics) private void DrawSplashScreen(SpriteBatch spriteBatch, GraphicsDevice graphics)
@@ -111,7 +111,7 @@ namespace Barotrauma
string currWord = ""; string currWord = "";
for (int i = 0; i < text.Length; i++) for (int i = 0; i < text.Length; i++)
{ {
if (isCJK.IsMatch(text[i].ToString())) if (TextManager.IsCJK(text[i].ToString()))
{ {
if (currWord.Length > 0) if (currWord.Length > 0)
{ {
@@ -200,24 +200,13 @@ namespace Barotrauma
linePos = size.X + spaceSize.X; linePos = size.X + spaceSize.X;
} }
if (i < words.Count - 1 && !isCJK.IsMatch(words[i]) && !isCJK.IsMatch(words[i + 1])) if (i < words.Count - 1 && !TextManager.IsCJK(words[i]) && !TextManager.IsCJK(words[i + 1]))
{ {
wrappedText.Append(" "); wrappedText.Append(" ");
} }
} }
return wrappedText.ToString().Replace(" \n ", "\n"); 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}");
} }
} }
@@ -485,7 +485,11 @@ namespace Barotrauma
} }
else if (ObjectiveManager.CurrentOrder is AIObjectiveRescueAll rescueAll && rescueAll.Targets.None()) else if (ObjectiveManager.CurrentOrder is AIObjectiveRescueAll rescueAll && rescueAll.Targets.None())
{ {
Character.Speak(TextManager.Get("DialogNoRescueTargets"), null, 3.0f, "norescuetargets"); //TODO: re-enable on all languages after DialogNoRescueTargets has been translated
if (TextManager.Language == "English")
{
Character.Speak(TextManager.Get("DialogNoRescueTargets"), null, 3.0f, "norescuetargets");
}
} }
else if (ObjectiveManager.CurrentOrder is AIObjectivePumpWater pumpWater && pumpWater.Targets.None()) else if (ObjectiveManager.CurrentOrder is AIObjectivePumpWater pumpWater && pumpWater.Targets.None())
{ {
@@ -22,7 +22,16 @@ namespace Barotrauma
public AIObjectiveRescue(Character character, Character targetCharacter, AIObjectiveManager objectiveManager, float priorityModifier = 1) public AIObjectiveRescue(Character character, Character targetCharacter, AIObjectiveManager objectiveManager, float priorityModifier = 1)
: base(character, objectiveManager, priorityModifier) : base(character, objectiveManager, priorityModifier)
{ {
if (targetCharacter != character) 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)
{ {
// TODO: enable healing self too // TODO: enable healing self too
abandon = true; abandon = true;
@@ -39,6 +48,11 @@ namespace Barotrauma
protected override void Act(float deltaTime) 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 // 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) if (targetCharacter.IsUnconscious && HumanAIController.GetHullSafety(targetCharacter.CurrentHull, targetCharacter) < HumanAIController.HULL_SAFETY_THRESHOLD)
{ {
@@ -206,13 +220,19 @@ namespace Barotrauma
public override bool IsCompleted() 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); bool isCompleted = targetCharacter.Bleeding <= 0 && targetCharacter.Vitality / targetCharacter.MaxVitality > AIObjectiveRescueAll.GetVitalityThreshold(objectiveManager);
if (isCompleted) if (isCompleted)
{ {
character.Speak(TextManager.Get("DialogTargetHealed").Replace("[targetname]", targetCharacter.Name), character.Speak(TextManager.Get("DialogTargetHealed").Replace("[targetname]", targetCharacter.Name),
null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f); null, 1.0f, "targethealed" + targetCharacter.Name, 60.0f);
} }
return isCompleted || targetCharacter.Removed || targetCharacter.IsDead; return isCompleted || targetCharacter.IsDead;
} }
public override float GetPriority() public override float GetPriority()
@@ -240,6 +240,11 @@ namespace Barotrauma
errorMessages = new List<string>(); errorMessages = new List<string>();
foreach (ContentFile file in Files) 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)) if (!File.Exists(file.Path))
{ {
errorMessages.Add("File \"" + file.Path + "\" not found."); errorMessages.Add("File \"" + file.Path + "\" not found.");
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
namespace Barotrauma namespace Barotrauma
{ {
@@ -42,6 +43,26 @@ namespace Barotrauma
GetTextFilesRecursive(subDir, ref list); GetTextFilesRecursive(subDir, ref list);
} }
} }
/// <summary>
/// Returns the name of the language in the respective language
/// </summary>
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<ContentPackage> selectedContentPackages) public static void LoadTextPacks(IEnumerable<ContentPackage> selectedContentPackages)
{ {
@@ -111,8 +132,6 @@ namespace Barotrauma
throw new Exception("No text packs available in English!"); throw new Exception("No text packs available in English!");
} }
} }
return false;
}
foreach (TextPack textPack in textPacks[Language]) foreach (TextPack textPack in textPacks[Language])
{ {
@@ -393,42 +412,6 @@ namespace Barotrauma
return isCJK.IsMatch(text); 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 #if DEBUG
public static void CheckForDuplicates(string lang) public static void CheckForDuplicates(string lang)
{ {
@@ -10,6 +10,11 @@ namespace Barotrauma
{ {
public readonly string Language; public readonly string Language;
/// <summary>
/// The name of the language in the language this pack is written in
/// </summary>
public readonly string TranslatedName;
private Dictionary<string, List<string>> texts; private Dictionary<string, List<string>> texts;
private readonly string filePath; private readonly string filePath;
@@ -23,6 +28,7 @@ namespace Barotrauma
if (doc == null || doc.Root == null) return; if (doc == null || doc.Root == null) return;
Language = doc.Root.GetAttributeString("language", "Unknown"); Language = doc.Root.GetAttributeString("language", "Unknown");
TranslatedName = doc.Root.GetAttributeString("translatedname", Language);
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
+4 -4
View File
@@ -43,12 +43,12 @@ namespace Facepunch.Steamworks
// //
//kind of a hack: //kind of a hack:
//use an outdated version number to hide private servers from the server list. //use an invalid 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 //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 //seem to work, the server info is still returned by the API calls
string versionString = isPublic ? init.VersionString : "0.0.0.0"; string versionString = isPublic ? init.VersionString : "-1";
if ( !native.InitServer( this, ipaddress, init.SteamPort, init.GamePort, init.QueryPort, init.Secure ? 3 : 2, if ( !native.InitServer( this, ipaddress, init.SteamPort, init.GamePort, init.QueryPort, isPublic ? (init.Secure ? 3 : 2) : 1,
isPublic ? init.VersionString : "0.0.0.0" ) ) versionString) )
{ {
native.Dispose(); native.Dispose();
native = null; native = null;