Unstable 0.17.3.0

This commit is contained in:
Juan Pablo Arce
2022-03-22 14:44:12 -03:00
parent cefac171f5
commit 4206f6db42
100 changed files with 1380 additions and 655 deletions
@@ -1,8 +1,7 @@
using System;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Linq;
namespace Barotrauma.Items.Components
{
@@ -2,12 +2,14 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
partial class ItemLabel : ItemComponent, IDrawableComponent
partial class ItemLabel : ItemComponent, IDrawableComponent, IHasExtraTextPickerEntries
{
private GUITextBlock textBlock;
@@ -106,7 +108,7 @@ namespace Barotrauma.Items.Components
set
{
scrollable = value;
IsActive = value;
IsActive = value || parseSpecialTextTagOnStart;
TextBlock.Wrap = !scrollable;
TextBlock.TextAlignment = scrollable ? Alignment.CenterLeft : Alignment.Center;
}
@@ -136,6 +138,11 @@ namespace Barotrauma.Items.Components
{
}
public IEnumerable<string> GetExtraTextPickerEntries()
{
return SpecialTextTags;
}
private void SetScrollingText()
{
if (!scrollable) { return; }
@@ -174,9 +181,18 @@ namespace Barotrauma.Items.Components
scrollIndex = MathHelper.Clamp(scrollIndex, 0, DisplayText.Length);
}
private static readonly string[] SpecialTextTags = new string[] { "[CurrentLocationName]", "[CurrentBiomeName]", "[CurrentSubName]" };
private bool parseSpecialTextTagOnStart;
private void SetDisplayText(string value)
{
if (SpecialTextTags.Contains(value))
{
parseSpecialTextTagOnStart = true;
IsActive = true;
}
DisplayText = IgnoreLocalization ? value : TextManager.Get(value).Fallback(value);
TextBlock.Text = DisplayText;
if (Screen.Selected == GameMain.SubEditorScreen && Scrollable)
{
@@ -198,9 +214,37 @@ namespace Barotrauma.Items.Components
};
}
private void ParseSpecialTextTag()
{
switch (text)
{
case "[CurrentLocationName]":
SetDisplayText(Level.Loaded?.StartLocation?.Name ?? string.Empty);
break;
case "[CurrentBiomeName]":
SetDisplayText(Level.Loaded?.LevelData?.Biome?.DisplayName.Value ?? string.Empty);
break;
case "[CurrentSubName]":
SetDisplayText(item.Submarine?.Info?.DisplayName.Value ?? string.Empty);
break;
default:
break;
}
}
public override void Update(float deltaTime, Camera cam)
{
if (!scrollable) { return; }
if (parseSpecialTextTagOnStart)
{
ParseSpecialTextTag();
parseSpecialTextTagOnStart = false;
}
if (!scrollable)
{
IsActive = false;
return;
}
if (scrollingText == null)
{
@@ -286,5 +330,6 @@ namespace Barotrauma.Items.Components
{
Text = msg.ReadString();
}
}
}
@@ -34,6 +34,13 @@ namespace Barotrauma.Items.Components
[Serialize("0.5,0.5)", IsPropertySaveable.No)]
public Vector2 Origin { get; set; } = new Vector2(0.5f, 0.5f);
[Serialize(true, IsPropertySaveable.No, description: "")]
public bool BreakFromMiddle
{
get;
set;
}
public Vector2 DrawSize
{
get
@@ -124,9 +131,14 @@ namespace Barotrauma.Items.Components
int width = (int)(SpriteWidth * snapState);
if (width > 0.0f)
{
DrawRope(spriteBatch, endPos - diff * snapState * 0.5f, endPos, width);
DrawRope(spriteBatch, startPos, startPos + diff * snapState * 0.5f, width);
{
float positionMultiplier = snapState;
if (BreakFromMiddle)
{
positionMultiplier /= 2;
DrawRope(spriteBatch, endPos - diff * positionMultiplier, endPos, width);
}
DrawRope(spriteBatch, startPos, startPos + diff * positionMultiplier, width);
}
}
else
@@ -143,7 +155,7 @@ namespace Barotrauma.Items.Components
float depth = Math.Min(item.GetDrawDepth() + (startSprite.Depth - item.Sprite.Depth), 0.999f);
startSprite?.Draw(spriteBatch, startPos, SpriteColor, angle, depth: depth);
}
if (endSprite != null)
if (endSprite != null && (!Snapped || BreakFromMiddle))
{
float depth = Math.Min(item.GetDrawDepth() + (endSprite.Depth - item.Sprite.Depth), 0.999f);
endSprite?.Draw(spriteBatch, endPos, SpriteColor, angle, depth: depth);