From eb6c5ac1c52fe4b8986d37a3147f3f7159caa671 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 26 Apr 2019 11:18:00 +0300 Subject: [PATCH] (251e3f856) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev --- .../Source/GUI/GUIMessageBox.cs | 34 +++++++++---------- .../Source/Map/ItemAssemblyPrefab.cs | 4 +-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs index ec9c026e6..55114def0 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs @@ -41,32 +41,19 @@ namespace Barotrauma InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null); GUI.Style.Apply(InnerFrame, "", this); - InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null); - GUI.Style.Apply(InnerFrame, "", this); - Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 }; Tag = tag; - - if (height == 0) - { - string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font); - string[] lines = wrappedText.Split('\n'); - foreach (string line in lines) - { - height += (int)GUI.Font.MeasureString(line).Y; - } - height += string.IsNullOrWhiteSpace(headerText) ? 220 : 220 - headerHeight; - } - InnerFrame.RectTransform.NonScaledSize = new Point(InnerFrame.Rect.Width, height); - + Header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform), headerText, textAlignment: Alignment.Center, wrap: true); + Header.RectTransform.MinSize = new Point(0, Header.Rect.Height); GUI.Style.Apply(Header, "", this); - if (height == 0) + if (!string.IsNullOrWhiteSpace(text)) { Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform), text, textAlignment: textAlignment, wrap: true); + Text.RectTransform.MinSize = new Point(0, Text.Rect.Height); GUI.Style.Apply(Text, "", this); } @@ -76,7 +63,18 @@ namespace Barotrauma AbsoluteSpacing = 5, IgnoreLayoutGroups = true }; - + buttonContainer.RectTransform.NonScaledSize = buttonContainer.RectTransform.MinSize = buttonContainer.RectTransform.MaxSize = + new Point(buttonContainer.Rect.Width, (int)(30 * GUI.Scale)); + + if (height == 0) + { + height += Header.Rect.Height + Content.AbsoluteSpacing; + height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing; + height += buttonContainer.Rect.Height; + + InnerFrame.RectTransform.NonScaledSize = new Point(InnerFrame.Rect.Width, (int)(height / Content.RectTransform.RelativeSize.Y)); + } + Buttons = new List(buttons.Length); for (int i = 0; i < buttons.Length; i++) { diff --git a/Barotrauma/BarotraumaClient/Source/Map/ItemAssemblyPrefab.cs b/Barotrauma/BarotraumaClient/Source/Map/ItemAssemblyPrefab.cs index 7c8bfc1e6..02184babd 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/ItemAssemblyPrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/ItemAssemblyPrefab.cs @@ -22,7 +22,7 @@ namespace Barotrauma drawRect = new Rectangle( (int)(drawRect.X * scale) + drawArea.Center.X, -((int)((drawRect.Y - drawRect.Height) * scale) + drawArea.Center.Y), (int)(drawRect.Width * scale), (int)(drawRect.Height * scale)); - entity.First.DrawPlacing(spriteBatch, drawRect, scale); + entity.First.DrawPlacing(spriteBatch, drawRect, entity.First.Scale * scale); } } @@ -34,7 +34,7 @@ namespace Barotrauma { Rectangle drawRect = entity.Second; drawRect.Location += Submarine.MouseToWorldGrid(cam, Submarine.MainSub).ToPoint(); - entity.First.DrawPlacing(spriteBatch, drawRect); + entity.First.DrawPlacing(spriteBatch, drawRect, entity.First.Scale); } }