(0185896f9) More fixes to messagebox & tutorial info box scaling
This commit is contained in:
@@ -46,15 +46,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
|
Header = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
|
||||||
headerText, textAlignment: Alignment.Center, wrap: true);
|
headerText, textAlignment: Alignment.Center, wrap: true);
|
||||||
Header.RectTransform.MinSize = new Point(0, Header.Rect.Height);
|
|
||||||
GUI.Style.Apply(Header, "", this);
|
GUI.Style.Apply(Header, "", this);
|
||||||
|
Header.RectTransform.MinSize = new Point(0, Header.Rect.Height);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
{
|
{
|
||||||
Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
|
Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
|
||||||
text, textAlignment: textAlignment, wrap: true);
|
text, textAlignment: textAlignment, wrap: true);
|
||||||
Text.RectTransform.MinSize = new Point(0, Text.Rect.Height);
|
|
||||||
GUI.Style.Apply(Text, "", this);
|
GUI.Style.Apply(Text, "", this);
|
||||||
|
Text.RectTransform.NonScaledSize = Text.RectTransform.MinSize = Text.RectTransform.MaxSize =
|
||||||
|
new Point(Text.Rect.Width, Text.Rect.Height);
|
||||||
|
Text.RectTransform.IsFixedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), Content.RectTransform, Anchor.BottomCenter, maxSize: new Point(1000, 50)),
|
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), Content.RectTransform, Anchor.BottomCenter, maxSize: new Point(1000, 50)),
|
||||||
@@ -65,6 +67,7 @@ namespace Barotrauma
|
|||||||
};
|
};
|
||||||
buttonContainer.RectTransform.NonScaledSize = buttonContainer.RectTransform.MinSize = buttonContainer.RectTransform.MaxSize =
|
buttonContainer.RectTransform.NonScaledSize = buttonContainer.RectTransform.MinSize = buttonContainer.RectTransform.MaxSize =
|
||||||
new Point(buttonContainer.Rect.Width, (int)(30 * GUI.Scale));
|
new Point(buttonContainer.Rect.Width, (int)(30 * GUI.Scale));
|
||||||
|
buttonContainer.RectTransform.IsFixedSize = true;
|
||||||
|
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
{
|
{
|
||||||
@@ -72,7 +75,10 @@ namespace Barotrauma
|
|||||||
height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing;
|
height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing;
|
||||||
height += buttonContainer.Rect.Height;
|
height += buttonContainer.Rect.Height;
|
||||||
|
|
||||||
InnerFrame.RectTransform.NonScaledSize = new Point(InnerFrame.Rect.Width, (int)(height / Content.RectTransform.RelativeSize.Y));
|
InnerFrame.RectTransform.NonScaledSize =
|
||||||
|
new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + 50));
|
||||||
|
Content.RectTransform.NonScaledSize =
|
||||||
|
new Point(Content.Rect.Width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
Buttons = new List<GUIButton>(buttons.Length);
|
Buttons = new List<GUIButton>(buttons.Length);
|
||||||
|
|||||||
@@ -744,12 +744,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var msgBox = new GUIMessageBox(TextManager.Get("EditorDisclaimerTitle"), TextManager.Get("EditorDisclaimerText"));
|
var msgBox = new GUIMessageBox(TextManager.Get("EditorDisclaimerTitle"), TextManager.Get("EditorDisclaimerText"));
|
||||||
var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f };
|
var linkHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), msgBox.Content.RectTransform)) { Stretch = true, RelativeSpacing = 0.025f };
|
||||||
|
linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
|
||||||
List<Pair<string, string>> links = new List<Pair<string, string>>()
|
List<Pair<string, string>> links = new List<Pair<string, string>>()
|
||||||
{
|
{
|
||||||
new Pair<string, string>(TextManager.Get("EditorDisclaimerWikiLink"),TextManager.Get("EditorDisclaimerWikiUrl")),
|
new Pair<string, string>(TextManager.Get("EditorDisclaimerWikiLink"),TextManager.Get("EditorDisclaimerWikiUrl")),
|
||||||
new Pair<string, string>(TextManager.Get("EditorDisclaimerDiscordLink"),TextManager.Get("EditorDisclaimerDiscordUrl")),
|
new Pair<string, string>(TextManager.Get("EditorDisclaimerDiscordLink"),TextManager.Get("EditorDisclaimerDiscordUrl")),
|
||||||
new Pair<string, string>(TextManager.Get("EditorDisclaimerForumLink"),TextManager.Get("EditorDisclaimerForumUrl")),
|
new Pair<string, string>(TextManager.Get("EditorDisclaimerForumLink"),TextManager.Get("EditorDisclaimerForumUrl")),
|
||||||
};
|
};
|
||||||
foreach (var link in links)
|
foreach (var link in links)
|
||||||
{
|
{
|
||||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), linkHolder.RectTransform), link.First, style: "MainMenuGUIButton", textAlignment: Alignment.Left)
|
new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), linkHolder.RectTransform), link.First, style: "MainMenuGUIButton", textAlignment: Alignment.Left)
|
||||||
@@ -763,9 +764,8 @@ namespace Barotrauma
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
msgBox.Text.RectTransform.MaxSize = new Point(int.MaxValue, msgBox.Text.Rect.Height);
|
msgBox.InnerFrame.RectTransform.MinSize = new Point(0,
|
||||||
linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
|
msgBox.InnerFrame.Rect.Height + linkHolder.Rect.Height + msgBox.Content.AbsoluteSpacing * 2 + 10);
|
||||||
msgBox.RectTransform.MinSize = new Point(0, msgBox.Rect.Height + linkHolder.Rect.Height + msgBox.Buttons.First().Rect.Height * 8);
|
|
||||||
Config.EditorDisclaimerShown = true;
|
Config.EditorDisclaimerShown = true;
|
||||||
Config.SaveNewPlayerConfig();
|
Config.SaveNewPlayerConfig();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,10 +485,9 @@ namespace Barotrauma.Tutorials
|
|||||||
{
|
{
|
||||||
if (hasButton) height += 60;
|
if (hasButton) height += 60;
|
||||||
|
|
||||||
float textScale = GUI.Scale;
|
string wrappedText = ToolBox.WrapText(text, width, GUI.Font);
|
||||||
string wrappedText = ToolBox.WrapText(text, width, GUI.Font, textScale);
|
|
||||||
|
|
||||||
height += (int)(GUI.Font.MeasureString(wrappedText).Y * textScale + 50);
|
height += (int)(GUI.Font.MeasureString(wrappedText).Y + 50);
|
||||||
if (title.Length > 0)
|
if (title.Length > 0)
|
||||||
{
|
{
|
||||||
height += 35;
|
height += 35;
|
||||||
@@ -509,17 +508,18 @@ namespace Barotrauma.Tutorials
|
|||||||
var infoContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), infoBlock.RectTransform, Anchor.Center))
|
var infoContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), infoBlock.RectTransform, Anchor.Center))
|
||||||
{
|
{
|
||||||
Stretch = true,
|
Stretch = true,
|
||||||
RelativeSpacing = 0.02f
|
AbsoluteSpacing = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
if (title.Length > 0)
|
if (title.Length > 0)
|
||||||
{
|
{
|
||||||
var titleBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform),
|
var titleBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform),
|
||||||
title, font: GUI.VideoTitleFont, textAlignment: Alignment.Center, textColor: new Color(253, 174, 0));
|
title, font: GUI.VideoTitleFont, textAlignment: Alignment.Center, textColor: new Color(253, 174, 0));
|
||||||
titleBlock.TextScale = textScale;
|
titleBlock.RectTransform.IsFixedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform), text, wrap: true);
|
var textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform), text, wrap: true);
|
||||||
|
textBlock.RectTransform.IsFixedSize = true;
|
||||||
|
|
||||||
infoBoxClosedCallback = callback;
|
infoBoxClosedCallback = callback;
|
||||||
|
|
||||||
@@ -530,6 +530,7 @@ namespace Barotrauma.Tutorials
|
|||||||
Stretch = true,
|
Stretch = true,
|
||||||
RelativeSpacing = 0.1f
|
RelativeSpacing = 0.1f
|
||||||
};
|
};
|
||||||
|
buttonContainer.RectTransform.IsFixedSize = true;
|
||||||
|
|
||||||
if (showVideo != null)
|
if (showVideo != null)
|
||||||
{
|
{
|
||||||
@@ -551,6 +552,8 @@ namespace Barotrauma.Tutorials
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infoBlock.RectTransform.NonScaledSize = new Point(infoBlock.Rect.Width, (int)(infoContent.Children.Sum(c => c.Rect.Height + infoContent.AbsoluteSpacing) / infoContent.RectTransform.RelativeSize.Y));
|
||||||
|
|
||||||
GUI.PlayUISound(GUISoundType.UIMessage);
|
GUI.PlayUISound(GUISoundType.UIMessage);
|
||||||
|
|
||||||
return background;
|
return background;
|
||||||
|
|||||||
Reference in New Issue
Block a user