stairs fix, wraptext fix, moved drawing sprites from GUIFrame to GUIComponent, server name and "welcome text" in netlobby
This commit is contained in:
@@ -194,7 +194,25 @@ namespace Subsurface
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Color currColor = color;
|
||||
if (state == ComponentState.Selected) currColor = selectedColor;
|
||||
if (state == ComponentState.Hover) currColor = hoverColor;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
|
||||
|
||||
if (sprites != null)
|
||||
{
|
||||
foreach (Sprite sprite in sprites)
|
||||
{
|
||||
Vector2 startPos = new Vector2(rect.X, rect.Y);
|
||||
Vector2 size = new Vector2(sprite.SourceRect.Width, sprite.SourceRect.Height);
|
||||
|
||||
if (sprite.size.X == 0.0f) size.X = rect.Width;
|
||||
if (sprite.size.Y == 0.0f) size.Y = rect.Height;
|
||||
|
||||
sprite.DrawTiled(spriteBatch, startPos, size, currColor * (currColor.A / 255.0f));
|
||||
}
|
||||
}
|
||||
|
||||
//Color newColor = color;
|
||||
//if (state == ComponentState.Selected) newColor = selectedColor;
|
||||
|
||||
@@ -39,27 +39,14 @@ namespace Subsurface
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
|
||||
Color currColor = color;
|
||||
if (state == ComponentState.Selected) currColor = selectedColor;
|
||||
if (state == ComponentState.Hover) currColor = hoverColor;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
|
||||
|
||||
if (sprites != null)
|
||||
{
|
||||
foreach (Sprite sprite in sprites)
|
||||
{
|
||||
Vector2 startPos = new Vector2(rect.X, rect.Y);
|
||||
Vector2 size = new Vector2(sprite.SourceRect.Width, sprite.SourceRect.Height);
|
||||
|
||||
if (sprite.size.X == 0.0f) size.X = rect.Width;
|
||||
if (sprite.size.Y == 0.0f) size.Y = rect.Height;
|
||||
|
||||
sprite.DrawTiled(spriteBatch, startPos, size, currColor * (currColor.A / 255.0f));
|
||||
}
|
||||
}
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (OutlineColor != Color.Transparent)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace Subsurface
|
||||
public delegate string TextGetterHandler();
|
||||
public TextGetterHandler TextGetter;
|
||||
|
||||
private bool wrap;
|
||||
public bool Wrap;
|
||||
|
||||
|
||||
|
||||
public override Vector4 Padding
|
||||
{
|
||||
@@ -111,7 +113,7 @@ namespace Subsurface
|
||||
|
||||
//if (wrap)
|
||||
//{
|
||||
this.wrap = wrap;
|
||||
this.Wrap = wrap;
|
||||
// this.text = ToolBox.WrapText(this.text, rect.Width);
|
||||
//}
|
||||
|
||||
@@ -124,19 +126,19 @@ namespace Subsurface
|
||||
|
||||
Vector2 size = MeasureText();
|
||||
|
||||
if (wrap && rect.Width>0)
|
||||
if (Wrap && rect.Width>0)
|
||||
{
|
||||
text = text.Replace("\n"," ");
|
||||
//text = text.Replace("\n"," ");
|
||||
text = ToolBox.WrapText(text, rect.Width, Font);
|
||||
|
||||
Vector2 newSize = MeasureText();
|
||||
|
||||
Rectangle newRect = rect;
|
||||
//Rectangle newRect = rect;
|
||||
|
||||
//newRect.Width += (int)(newSize.X-size.X);
|
||||
newRect.Height += (int)(newSize.Y - size.Y);
|
||||
//newRect.Height += (int)(newSize.Y - size.Y);
|
||||
|
||||
Rect = newRect;
|
||||
//Rect = newRect;
|
||||
size = newSize;
|
||||
}
|
||||
|
||||
@@ -184,6 +186,8 @@ namespace Subsurface
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, currColor*(currColor.A/255.0f), true);
|
||||
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
if (TextGetter != null) text = TextGetter();
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
|
||||
@@ -24,6 +24,12 @@ namespace Subsurface
|
||||
public delegate bool OnTextChangedHandler(GUITextBox textBox, string text);
|
||||
public OnTextChangedHandler OnTextChanged;
|
||||
|
||||
public bool Wrap
|
||||
{
|
||||
get { return textBlock.Wrap; }
|
||||
set { textBlock.Wrap = value; }
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get;
|
||||
@@ -74,9 +80,9 @@ namespace Subsurface
|
||||
|
||||
textBlock.Text = filtered;
|
||||
|
||||
if (Font.MeasureString(textBlock.Text).X > rect.Width)
|
||||
if (!Wrap && Font.MeasureString(textBlock.Text).X > rect.Width)
|
||||
{
|
||||
//recursion to ensure that text cannot be larger than the box
|
||||
//ensure that text cannot be larger than the box
|
||||
Text = textBlock.Text.Substring(0, textBlock.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
@@ -111,7 +117,7 @@ namespace Subsurface
|
||||
if (parent != null)
|
||||
parent.AddChild(this);
|
||||
|
||||
textBlock = new GUITextBlock(new Rectangle(0,0,0,0), "", color, textColor, textAlignment, null, this);
|
||||
textBlock = new GUITextBlock(new Rectangle(0,0,0,0), "", color, textColor, textAlignment, style, this);
|
||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
|
||||
if (style != null) style.Apply(textBlock, this);
|
||||
|
||||
@@ -121,6 +127,7 @@ namespace Subsurface
|
||||
|
||||
public void Select()
|
||||
{
|
||||
Selected = true;
|
||||
keyboardDispatcher.Subscriber = this;
|
||||
if (Clicked != null) Clicked(this);
|
||||
}
|
||||
@@ -172,7 +179,7 @@ namespace Subsurface
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2((int)caretPos.X + 2, caretPos.Y + 3),
|
||||
new Vector2((int)caretPos.X + 2, caretPos.Y + rect.Height - 3),
|
||||
new Vector2((int)caretPos.X + 2, caretPos.Y + Font.MeasureString(Text).Y - 3),
|
||||
textBlock.TextColor * (textBlock.TextColor.A / 255.0f));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user