Unstable 0.17.2.0
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
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, IHasExtraTextPickerEntries
|
||||
partial class ItemLabel : ItemComponent, IDrawableComponent
|
||||
{
|
||||
private GUITextBlock textBlock;
|
||||
|
||||
@@ -108,7 +106,7 @@ namespace Barotrauma.Items.Components
|
||||
set
|
||||
{
|
||||
scrollable = value;
|
||||
IsActive = value || parseSpecialTextTagOnStart;
|
||||
IsActive = value;
|
||||
TextBlock.Wrap = !scrollable;
|
||||
TextBlock.TextAlignment = scrollable ? Alignment.CenterLeft : Alignment.Center;
|
||||
}
|
||||
@@ -138,11 +136,6 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetExtraTextPickerEntries()
|
||||
{
|
||||
return SpecialTextTags;
|
||||
}
|
||||
|
||||
private void SetScrollingText()
|
||||
{
|
||||
if (!scrollable) { return; }
|
||||
@@ -181,18 +174,9 @@ 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)
|
||||
{
|
||||
@@ -214,37 +198,9 @@ 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 (parseSpecialTextTagOnStart)
|
||||
{
|
||||
ParseSpecialTextTag();
|
||||
parseSpecialTextTagOnStart = false;
|
||||
}
|
||||
|
||||
if (!scrollable)
|
||||
{
|
||||
IsActive = false;
|
||||
return;
|
||||
}
|
||||
if (!scrollable) { return; }
|
||||
|
||||
if (scrollingText == null)
|
||||
{
|
||||
@@ -330,6 +286,5 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Text = msg.ReadString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,6 @@ 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
|
||||
@@ -131,14 +124,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
int width = (int)(SpriteWidth * snapState);
|
||||
if (width > 0.0f)
|
||||
{
|
||||
float positionMultiplier = snapState;
|
||||
if (BreakFromMiddle)
|
||||
{
|
||||
positionMultiplier /= 2;
|
||||
DrawRope(spriteBatch, endPos - diff * positionMultiplier, endPos, width);
|
||||
}
|
||||
DrawRope(spriteBatch, startPos, startPos + diff * positionMultiplier, width);
|
||||
{
|
||||
DrawRope(spriteBatch, endPos - diff * snapState * 0.5f, endPos, width);
|
||||
DrawRope(spriteBatch, startPos, startPos + diff * snapState * 0.5f, width);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -155,7 +143,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 && (!Snapped || BreakFromMiddle))
|
||||
if (endSprite != null)
|
||||
{
|
||||
float depth = Math.Min(item.GetDrawDepth() + (endSprite.Depth - item.Sprite.Depth), 0.999f);
|
||||
endSprite?.Draw(spriteBatch, endPos, SpriteColor, angle, depth: depth);
|
||||
|
||||
Reference in New Issue
Block a user