Fixed AIObjectiveGoto terminating if previous path was unreachable, BackGroundSpriteManager won't place a sprite if a suitable position isn't found, StatusEffect fire position fix, UI improvements, door convexhull fix, progress on Fabricators & Deconstructors, mapentities sorted by category in edit mode, item descriptions, TutorialMode refactoring to make it easier to add new types of tutorials

This commit is contained in:
Regalis
2015-12-28 13:21:24 +02:00
parent 8c032d8368
commit 92d396e6b2
69 changed files with 1264 additions and 455 deletions

View File

@@ -7,6 +7,34 @@ using System.Xml.Linq;
namespace Barotrauma
{
public class UISprite
{
public Sprite Sprite
{
get;
private set;
}
public bool Tile
{
get;
private set;
}
public bool MaintainAspectRatio
{
get;
private set;
}
public UISprite(Sprite sprite, bool tile, bool maintainAspectRatio)
{
Sprite = sprite;
Tile = tile;
MaintainAspectRatio = maintainAspectRatio;
}
}
public class GUIComponentStyle
{
public readonly Vector4 Padding;
@@ -20,12 +48,14 @@ namespace Barotrauma
public readonly Color OutlineColor;
public readonly List<Sprite> Sprites;
public readonly List<UISprite> Sprites;
public readonly bool TileSprites;
public GUIComponentStyle(XElement element)
{
Sprites = new List<Sprite>();
Sprites = new List<UISprite>();
Padding = ToolBox.GetAttributeVector4(element, "padding", Vector4.Zero);
@@ -43,13 +73,17 @@ namespace Barotrauma
colorVector = ToolBox.GetAttributeVector4(element, "outlinecolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
OutlineColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLower())
{
case "sprite":
Sprites.Add(new Sprite(subElement));
Sprite sprite = new Sprite(subElement);
bool maintainAspect = ToolBox.GetAttributeBool(subElement, "maintainaspectratio",false);
bool tile = ToolBox.GetAttributeBool(subElement, "tile", true);
Sprites.Add(new UISprite(sprite, tile, maintainAspect));
break;
}
}

View File

@@ -17,7 +17,23 @@ namespace Barotrauma
public bool CanBeSelected = true;
public bool Enabled { get; set; }
private bool enabled;
public bool Enabled
{
get
{
return enabled;
}
set
{
if (value == enabled) return;
enabled = value;
frame.Color = enabled ? color : Color.Gray * 0.7f;
}
}
public override Color Color
{
@@ -117,8 +133,6 @@ namespace Barotrauma
if (color!=null) this.color = (Color)color;
this.alignment = alignment;
Enabled = true;
if (parent != null) parent.AddChild(this);
frame = new GUIFrame(Rectangle.Empty, style, this);
@@ -127,6 +141,8 @@ namespace Barotrauma
textBlock = new GUITextBlock(Rectangle.Empty, text,
Color.Transparent, (this.style == null) ? Color.Black : this.style.textColor,
textAlignment, style, this);
Enabled = true;
}
public override void Draw(SpriteBatch spriteBatch)
@@ -175,7 +191,7 @@ namespace Barotrauma
DrawChildren(spriteBatch);
if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
}
}
}

View File

@@ -98,7 +98,7 @@ namespace Barotrauma
}
}
public List<Sprite> sprites;
public List<UISprite> sprites;
//public Alignment SpriteAlignment { get; set; }
//public bool RepeatSpriteX, RepeatSpriteY;
@@ -160,7 +160,7 @@ namespace Barotrauma
Font = GUI.Font;
sprites = new List<Sprite>();
sprites = new List<UISprite>();
children = new List<GUIComponent>();
CanBeFocused = true;
@@ -229,29 +229,38 @@ namespace Barotrauma
flashColor * (flashTimer / FlashDuration), true);
}
GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
if (currColor.A>0.0f && !sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
if (sprites != null)
{
foreach (Sprite sprite in sprites)
foreach (UISprite uiSprite in sprites)
{
if (TileSprites)
if (uiSprite.Tile)
{
Vector2 startPos = new Vector2(rect.X, rect.Y);
Vector2 size = new Vector2(Math.Min(sprite.SourceRect.Width,rect.Width), Math.Min(sprite.SourceRect.Height,rect.Height));
Vector2 size = new Vector2(Math.Min(uiSprite.Sprite.SourceRect.Width, rect.Width), Math.Min(uiSprite.Sprite.SourceRect.Height, rect.Height));
if (sprite.size.X == 0.0f) size.X = rect.Width;
if (sprite.size.Y == 0.0f) size.Y = rect.Height;
if (uiSprite.Sprite.size.X == 0.0f) size.X = rect.Width;
if (uiSprite.Sprite.size.Y == 0.0f) size.Y = rect.Height;
sprite.DrawTiled(spriteBatch, startPos, size, currColor * (currColor.A / 255.0f));
uiSprite.Sprite.DrawTiled(spriteBatch, startPos, size, currColor * (currColor.A / 255.0f));
}
else
{
float scale = (float)(rect.Width) / sprite.SourceRect.Width;
if (uiSprite.MaintainAspectRatio)
{
float scale = (float)(rect.Width) / uiSprite.Sprite.SourceRect.Width;
spriteBatch.Draw(uiSprite.Sprite.Texture, rect,
new Rectangle(uiSprite.Sprite.SourceRect.X, uiSprite.Sprite.SourceRect.Y, (int)(uiSprite.Sprite.SourceRect.Width), (int)(rect.Height / scale)),
currColor * (currColor.A / 255.0f), 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f);
}
else
{
spriteBatch.Draw(uiSprite.Sprite.Texture, rect, uiSprite.Sprite.SourceRect, currColor * (currColor.A / 255.0f));
}
spriteBatch.Draw(sprite.Texture, rect,
new Rectangle(sprite.SourceRect.X, sprite.SourceRect.Y, (int)(sprite.SourceRect.Width), (int)(rect.Height / scale)),
currColor * (currColor.A / 255.0f), 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f);
}
}
}
@@ -271,10 +280,13 @@ namespace Barotrauma
int width = 400;
if (toolTipBlock==null || (string)toolTipBlock.userData != ToolTip)
{
string wrappedText = ToolBox.WrapText(ToolTip, width, GUI.SmallFont);
toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, wrappedText.Split('\n').Length*15), ToolTip, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
toolTipBlock.Color = Color.Black*0.7f;
toolTipBlock.OutlineColor = Color.White;
//string wrappedText = ToolBox.WrapText(ToolTip, width, GUI.SmallFont);
toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, 18), ToolTip, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
toolTipBlock.padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
toolTipBlock.rect.Width = (int)(GUI.SmallFont.MeasureString(toolTipBlock.Text).X + 20);
toolTipBlock.rect.Height = toolTipBlock.Text.Split('\n').Length * 18;
toolTipBlock.Color = Color.Black * 0.7f;
//toolTipBlock.OutlineColor = Color.White;
toolTipBlock.userData = ToolTip;
}
@@ -353,7 +365,7 @@ namespace Barotrauma
selectedColor = style.SelectedColor;
padding = style.Padding;
sprites = new List<Sprite>(style.Sprites);
sprites = new List<UISprite>(style.Sprites);
OutlineColor = style.OutlineColor;

View File

@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using System;
using System.Linq;
namespace Barotrauma
{
@@ -45,7 +46,7 @@ namespace Barotrauma
if (state == ComponentState.Selected) currColor = selectedColor;
if (state == ComponentState.Hover) currColor = hoverColor;
GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
if (!sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
base.Draw(spriteBatch);
if (OutlineColor != Color.Transparent)