GUIStyle improvements & some simple UI graphics, networking bugfixes, separate Random class, some StyleCop cleanup
This commit is contained in:
+41
-17
@@ -1,28 +1,29 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
class GUIFrame : GUIComponent
|
||||
{
|
||||
public GUIFrame(Rectangle rect, Color color, Alignment alignment, GUIStyle style, GUIComponent parent = null)
|
||||
: this(rect, color, alignment, parent)
|
||||
{
|
||||
hoverColor = style.hoverColor;
|
||||
selectedColor = style.selectedColor;
|
||||
}
|
||||
|
||||
public GUIFrame(Rectangle rect, Color color, GUIComponent parent = null)
|
||||
: this(rect,color,(Alignment.Left | Alignment.Top), parent)
|
||||
{
|
||||
public GUIFrame(Rectangle rect, GUIStyle style = null, GUIComponent parent = null)
|
||||
: this(rect, null, (Alignment.Left | Alignment.Top), style, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public GUIFrame(Rectangle rect, Color color, Alignment alignment, GUIComponent parent = null)
|
||||
|
||||
public GUIFrame(Rectangle rect, Color color, GUIStyle style = null, GUIComponent parent = null)
|
||||
: this(rect, color, (Alignment.Left | Alignment.Top), style, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public GUIFrame(Rectangle rect, Color? color, Alignment alignment, GUIStyle style = null, GUIComponent parent = null)
|
||||
: base(style)
|
||||
{
|
||||
this.rect = rect;
|
||||
|
||||
this.alignment = alignment;
|
||||
|
||||
this.color = color;
|
||||
if (color!=null) this.color = (Color)color;
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
@@ -32,17 +33,40 @@ namespace Subsurface
|
||||
{
|
||||
UpdateDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
//if (style != null) ApplyStyle(style);
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
|
||||
Color newColor = color;
|
||||
if (state == ComponentState.Selected) newColor = selectedColor;
|
||||
if (state == ComponentState.Hover) newColor = hoverColor;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if (OutlineColor != Color.Transparent)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (OutlineColor.A/255.0f), false);
|
||||
}
|
||||
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, rect, newColor * alpha, true);
|
||||
DrawChildren(spriteBatch);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user