Unstable 0.17.2.0

This commit is contained in:
Markus Isberg
2022-03-30 00:06:59 +09:00
parent 4206f6db42
commit 2968e23ae8
100 changed files with 654 additions and 1379 deletions
@@ -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();
}
}
}