Merge branch 'master' into new-netcode
Conflicts: Subsurface/Source/GameMain.cs Subsurface/Source/Networking/ChatMessage.cs Subsurface/Source/Networking/NetworkMember.cs Subsurface/Source/Screens/NetLobbyScreen.cs
This commit is contained in:
@@ -207,31 +207,7 @@ namespace Barotrauma
|
||||
{
|
||||
y += child.Rect.Height + spacing;
|
||||
}
|
||||
|
||||
|
||||
if (scrollBar.IsHorizontal)
|
||||
{
|
||||
if (child.Rect.Right < rect.X) continue;
|
||||
if (child.Rect.Right > rect.Right) break;
|
||||
|
||||
if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
|
||||
{
|
||||
x = rect.X;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (child.Rect.Y + child.Rect.Height < rect.Y) continue;
|
||||
if (child.Rect.Y + child.Rect.Height > rect.Y + rect.Height) break;
|
||||
|
||||
if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
|
||||
{
|
||||
y = rect.Y;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (deltaTime>0.0f) child.Update(deltaTime);
|
||||
if (enabled && child.CanBeFocused &&
|
||||
(MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
|
||||
@@ -407,6 +383,8 @@ namespace Barotrauma
|
||||
|
||||
if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
|
||||
|
||||
GameMain.CurrGraphicsDevice.ScissorRectangle = frame.Rect;
|
||||
|
||||
int lastVisible = 0;
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
{
|
||||
@@ -422,6 +400,8 @@ namespace Barotrauma
|
||||
lastVisible = i;
|
||||
child.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
}
|
||||
|
||||
private bool IsChildVisible(GUIComponent child)
|
||||
@@ -431,22 +411,12 @@ namespace Barotrauma
|
||||
if (scrollBar.IsHorizontal)
|
||||
{
|
||||
if (child.Rect.Right < rect.X) return false;
|
||||
if (child.Rect.Right > rect.Right) return false;
|
||||
|
||||
if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (child.Rect.X > rect.Right) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (child.Rect.Y + child.Rect.Height < rect.Y) return false;
|
||||
if (child.Rect.Y + child.Rect.Height > rect.Y + rect.Height) return false;
|
||||
|
||||
if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (child.Rect.Bottom < rect.Y) return false;
|
||||
if (child.Rect.Y > rect.Bottom) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace Barotrauma
|
||||
|
||||
public bool Wrap;
|
||||
|
||||
private bool overflowClipActive;
|
||||
public bool OverflowClip;
|
||||
|
||||
private float textDepth;
|
||||
|
||||
public override Vector4 Padding
|
||||
@@ -84,13 +87,7 @@ namespace Barotrauma
|
||||
get { return textDepth; }
|
||||
set { textDepth = MathHelper.Clamp(value, 0.0f, 1.0f); }
|
||||
}
|
||||
|
||||
public bool LimitText
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public Vector2 TextPos
|
||||
{
|
||||
get { return textPos; }
|
||||
@@ -157,8 +154,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
public GUITextBlock(Rectangle rect, string text, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, string style = null, GUIComponent parent = null, bool wrap = false)
|
||||
: this (rect, text, style, alignment, textAlignment, parent, wrap, null)
|
||||
public GUITextBlock(Rectangle rect, string text, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, string style = null, GUIComponent parent = null, bool wrap = false, ScalableFont font = null)
|
||||
: this (rect, text, style, alignment, textAlignment, parent, wrap, font)
|
||||
{
|
||||
if (color != null) this.color = (Color)color;
|
||||
if (textColor != null) this.textColor = (Color)textColor;
|
||||
@@ -198,32 +195,29 @@ namespace Barotrauma
|
||||
{
|
||||
if (text == null) return;
|
||||
|
||||
overflowClipActive = false;
|
||||
|
||||
wrappedText = text;
|
||||
|
||||
Vector2 size = MeasureText(text);
|
||||
Vector2 size = MeasureText(text);
|
||||
|
||||
if (Wrap && rect.Width > 0)
|
||||
{
|
||||
wrappedText = ToolBox.WrapText(text, rect.Width - padding.X - padding.Z, Font, textScale);
|
||||
|
||||
Vector2 newSize = MeasureText(wrappedText);
|
||||
|
||||
size = newSize;
|
||||
size = MeasureText(wrappedText);
|
||||
}
|
||||
|
||||
if (LimitText && text.Length>1 && size.Y > rect.Height)
|
||||
else if (OverflowClip)
|
||||
{
|
||||
string[] lines = text.Split('\n');
|
||||
text = string.Join("\n", lines, 0, lines.Length-1);
|
||||
overflowClipActive = size.X > rect.Width;
|
||||
}
|
||||
|
||||
|
||||
textPos = new Vector2(rect.Width / 2.0f, rect.Height / 2.0f);
|
||||
origin = size * 0.5f;
|
||||
|
||||
if (textAlignment.HasFlag(Alignment.Left))
|
||||
if (textAlignment.HasFlag(Alignment.Left) && !overflowClipActive)
|
||||
origin.X += (rect.Width / 2.0f - padding.X) - size.X / 2;
|
||||
|
||||
if (textAlignment.HasFlag(Alignment.Right))
|
||||
if (textAlignment.HasFlag(Alignment.Right) || overflowClipActive)
|
||||
origin.X -= (rect.Width / 2.0f - padding.Z) - size.X / 2;
|
||||
|
||||
if (textAlignment.HasFlag(Alignment.Top))
|
||||
@@ -253,7 +247,7 @@ namespace Barotrauma
|
||||
|
||||
private Vector2 MeasureText(string text)
|
||||
{
|
||||
if (Font==null) return Vector2.Zero;
|
||||
if (Font == null) return Vector2.Zero;
|
||||
|
||||
Vector2 size = Vector2.Zero;
|
||||
while (size == Vector2.Zero)
|
||||
@@ -280,13 +274,13 @@ namespace Barotrauma
|
||||
|
||||
Rectangle drawRect = rect;
|
||||
if (offset != Vector2.Zero) drawRect.Location += offset.ToPoint();
|
||||
|
||||
//if (currColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
|
||||
|
||||
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (TextGetter != null) Text = TextGetter();
|
||||
|
||||
if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = rect;
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
Font.DrawString(spriteBatch,
|
||||
@@ -297,6 +291,8 @@ namespace Barotrauma
|
||||
SpriteEffects.None, textDepth);
|
||||
}
|
||||
|
||||
if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
DrawChildren(spriteBatch);
|
||||
|
||||
if (OutlineColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (currColor.A / 255.0f), false);
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Barotrauma
|
||||
public OnTextChangedHandler OnTextChanged;
|
||||
|
||||
public bool CaretEnabled;
|
||||
|
||||
private int? maxTextWidth;
|
||||
|
||||
public GUITextBlock.TextGetterHandler TextGetter
|
||||
{
|
||||
@@ -40,12 +42,17 @@ namespace Barotrauma
|
||||
set { textBlock.Wrap = value; }
|
||||
}
|
||||
|
||||
public bool LimitText
|
||||
public int? MaxTextWidth
|
||||
{
|
||||
get { return textBlock.LimitText; }
|
||||
set { textBlock.LimitText = value; }
|
||||
get { return maxTextWidth; }
|
||||
set
|
||||
{
|
||||
textBlock.OverflowClip = value != null && (int)value > textBlock.Rect.Width - textBlock.Padding.X - textBlock.Padding.Z;
|
||||
|
||||
maxTextWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get;
|
||||
@@ -118,7 +125,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public String Text
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -126,28 +133,22 @@ namespace Barotrauma
|
||||
}
|
||||
set
|
||||
{
|
||||
if (textBlock.Text == value) return;
|
||||
|
||||
textBlock.Text = value;
|
||||
if (textBlock.Text == null) textBlock.Text = "";
|
||||
|
||||
if (textBlock.Text != "")
|
||||
{
|
||||
/*//if you attempt to display a Character that is not in your font
|
||||
//you will get an exception, so we filter the characters
|
||||
//remove the filtering if you're using a default Character in your spritefont
|
||||
String filtered = "";
|
||||
foreach (char c in value)
|
||||
if (!Wrap)
|
||||
{
|
||||
if (Font.Characters.Contains(c)) filtered += c;
|
||||
}
|
||||
int maxWidth = MaxTextWidth == null ? (int)(textBlock.Rect.Width - textBlock.Padding.X - textBlock.Padding.Z) : (int)MaxTextWidth;
|
||||
|
||||
textBlock.Text = filtered;*/
|
||||
|
||||
if (!Wrap && Font.MeasureString(textBlock.Text).X > rect.Width)
|
||||
{
|
||||
//ensure that text cannot be larger than the box
|
||||
Text = textBlock.Text.Substring(0, textBlock.Text.Length - 1);
|
||||
if (Font.MeasureString(textBlock.Text).X > maxWidth)
|
||||
{
|
||||
Text = textBlock.Text.Substring(0, textBlock.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,8 +179,9 @@ namespace Barotrauma
|
||||
if (parent != null)
|
||||
parent.AddChild(this);
|
||||
|
||||
textBlock = new GUITextBlock(new Rectangle(0,0,0,0), "", color, textColor, textAlignment, style, this);
|
||||
|
||||
textBlock = new GUITextBlock(new Rectangle(0,0,0,0), "", color, textColor, textAlignment, style, this);
|
||||
|
||||
Font = GUI.Font;
|
||||
|
||||
GUI.Style.Apply(textBlock, style == "" ? "GUITextBox" : style);
|
||||
|
||||
Reference in New Issue
Block a user