From 508bd960be3d20a90c51a9fa2882afa4cd2e5c0c Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 1 Apr 2019 22:51:21 +0300 Subject: [PATCH] (b378675eb) Improved New Game panel --- Barotrauma/BarotraumaClient/Source/GUI/GUI.cs | 7 +++ .../Source/Screens/CampaignSetupUI.cs | 47 +++++++------------ .../Source/Screens/MainMenuScreen.cs | 2 +- .../Source/Characters/AI/EnemyAIController.cs | 41 ---------------- .../Source/Items/ItemPrefab.cs | 33 +++++++++++++ 5 files changed, 59 insertions(+), 71 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index ec5b88851..cbb751f50 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -656,6 +656,13 @@ namespace Barotrauma msg.Timer -= deltaTime; msg.Pos += msg.Velocity * deltaTime; } + + foreach (GUIMessage msg in messages) + { + if (!msg.WorldSpace) continue; + msg.Timer -= deltaTime; + msg.Pos += msg.Velocity * deltaTime; + } } messages.RemoveAll(m => m.Timer <= 0.0f); diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs index b173ae194..53aa51c22 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs @@ -39,44 +39,32 @@ namespace Barotrauma this.newGameContainer = newGameContainer; this.loadGameContainer = loadGameContainer; - var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: true) - { - Stretch = true, - RelativeSpacing = 0.05f - }; + var columnContainer = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform)) { RelativeSpacing = 0.005f }; - var leftColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)) - { - Stretch = true, - RelativeSpacing = 0.02f - }; + //var rightColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)); - var rightColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)) - { - RelativeSpacing = 0.02f - }; + //var leftColumn = new GUILayoutGroup(new RectTransform(Vector2.One, columnContainer.RectTransform)); - // New game left side - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), leftColumn.RectTransform), TextManager.Get("SelectedSub") + ":", textAlignment: Alignment.BottomLeft); - subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform)); + // New game right side + new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnContainer.RectTransform), TextManager.Get("SaveName") + ":"); + saveNameBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 0.075f), columnContainer.RectTransform), string.Empty); - UpdateSubList(submarines); - - // New game right sideon - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), TextManager.Get("SaveName") + ":", textAlignment: Alignment.BottomLeft); - saveNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), string.Empty); - - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), TextManager.Get("MapSeed") + ":", textAlignment: Alignment.BottomLeft); - seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), ToolBox.RandomSeed(8)); + new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnContainer.RectTransform), TextManager.Get("MapSeed") + ":"); + seedBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 0.075f), columnContainer.RectTransform), ToolBox.RandomSeed(8)); if (!isMultiplayer) { - new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), rightColumn.RectTransform), TextManager.Get("TutorialActive") + ":", textAlignment: Alignment.BottomLeft); - contextualTutorialBox = new GUITickBox(new RectTransform(new Point(30, 30), rightColumn.RectTransform), string.Empty); + contextualTutorialBox = new GUITickBox(new RectTransform(new Point(30, 30), columnContainer.RectTransform), TextManager.Get("TutorialActive")); UpdateTutorialSelection(); } - var startButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.13f), rightColumn.RectTransform, Anchor.BottomRight), TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge") + // New game left side + new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), columnContainer.RectTransform), TextManager.Get("SelectedSub") + ":"); + subList = new GUIListBox(new RectTransform(new Vector2(0.5f, 0.5f), columnContainer.RectTransform)); + + UpdateSubList(submarines); + + var startButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), columnContainer.RectTransform, Anchor.BottomCenter), TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge") { IgnoreLayoutGroups = true, OnClicked = (GUIButton btn, object userData) => @@ -205,12 +193,13 @@ namespace Barotrauma foreach (Submarine sub in subsToShow) { var textBlock = new GUITextBlock( - new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) + new RectTransform(new Vector2(1, 0.2f), subList.Content.RectTransform) { AbsoluteOffset = new Point(10, 0) }, ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 65), style: "ListBoxElement") { + IgnoreLayoutGroups = true, ToolTip = sub.Description, UserData = sub }; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs index 01fba6b49..66b0031e6 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/MainMenuScreen.cs @@ -283,7 +283,7 @@ namespace Barotrauma style: null); menuTabs[(int)Tab.NewGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing }); - var paddedNewGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.NewGame].RectTransform, Anchor.Center), style: null); + var paddedNewGame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), menuTabs[(int)Tab.NewGame].RectTransform, Anchor.Center)) { Stretch = true }; menuTabs[(int)Tab.LoadGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing }); var paddedLoadGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.LoadGame].RectTransform, Anchor.Center), style: null); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 2dafda0cc..42567d00b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -1216,43 +1216,6 @@ namespace Barotrauma targetingTag = "room"; } if (door != null) - { - // If there's not a more specific tag for the door - if (string.IsNullOrEmpty(targetingTag) || targetingTag == "room") - { - targetingTag = "door"; - } - bool isOutdoor = door.LinkedGap?.FlowTargetHull != null && !door.LinkedGap.IsRoomToRoom; - bool isOpen = door.IsOpen || door.Item.Condition <= 0.0f; - //increase priority if the character is outside and an aggressive boarder, and the door is from outside to inside - if (aggressiveBoarding) - { - if (character.CurrentHull == null) - { - valueModifier = isOutdoor ? 1 : 0; - valueModifier *= isOpen ? 5 : 1; - } - } - else - { - // Ignore disabled walls - bool isDisabled = true; - for (int i = 0; i < s.Sections.Length; i++) - { - valueModifier = isOutdoor ? 0 : 1; - valueModifier *= isOpen ? 0 : 1; - } - if (isDisabled) - { - valueModifier = 0; - } - } - } - else - { - targetingTag = "room"; - } - if (door != null) { // If there's not a more specific tag for the door if (string.IsNullOrEmpty(targetingTag) || targetingTag == "room") @@ -1279,10 +1242,6 @@ namespace Barotrauma { continue; } - else if (isOpen) //ignore broken and open doors - { - continue; - } } else if (target.Entity is IDamageable targetDamageable && targetDamageable.Health <= 0.0f) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 95820fd6b..e900ed7f7 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -1115,6 +1115,39 @@ namespace Barotrauma AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList(); + if (sprite == null) + { + DebugConsole.ThrowError("Item \"" + Name + "\" has no sprite!"); +#if SERVER + sprite = new Sprite("", Vector2.Zero); + sprite.SourceRect = new Rectangle(0, 0, 32, 32); +#else + sprite = new Sprite(TextureLoader.PlaceHolderTexture, null, null) + { + Origin = TextureLoader.PlaceHolderTexture.Bounds.Size.ToVector2() / 2 + }; +#endif + size = sprite.size; + sprite.EntityID = identifier; + } + + if (!category.HasFlag(MapEntityCategory.Legacy) && string.IsNullOrEmpty(identifier)) + { + DebugConsole.ThrowError( + "Item prefab \"" + name + "\" has no identifier. All item prefabs have a unique identifier string that's used to differentiate between items during saving and loading."); + } + if (!string.IsNullOrEmpty(identifier)) + { + MapEntityPrefab existingPrefab = List.Find(e => e.Identifier == identifier); + if (existingPrefab != null) + { + DebugConsole.ThrowError( + "Map entity prefabs \"" + name + "\" and \"" + existingPrefab.Name + "\" have the same identifier!"); + } + } + + AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList(); + List.Add(this); }