Unstable 0.17.0.0
This commit is contained in:
@@ -16,79 +16,35 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
{
|
||||
partial class BallastFloraBehavior
|
||||
{
|
||||
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global, UnusedAutoPropertyAccessor.Global, MemberCanBePrivate.Global
|
||||
internal class DamageParticle
|
||||
{
|
||||
[Serialize(defaultValue: "", isSaveable: false)]
|
||||
public string Identifier { get; set; } = "";
|
||||
|
||||
[Serialize(defaultValue: 0f, isSaveable: false)]
|
||||
public float MinRotation { get; set; }
|
||||
|
||||
[Serialize(defaultValue: 0f, isSaveable: false)]
|
||||
public float MaxRotation { get; set; }
|
||||
|
||||
[Serialize(defaultValue: 0f, isSaveable: false)]
|
||||
public float MinVelocity { get; set; }
|
||||
|
||||
[Serialize(defaultValue: 0f, isSaveable: false)]
|
||||
public float MaxVelocity { get; set; }
|
||||
|
||||
[Serialize(defaultValue: "255,255,255,255", isSaveable: false)]
|
||||
public Color ColorMultiplier { get; set; }
|
||||
|
||||
private float RandRotation() => Rand.Range(MinRotation, MaxRotation);
|
||||
private float RandVelocity() => Rand.Range(MinVelocity, MaxVelocity);
|
||||
|
||||
public void Emit(Vector2 pos)
|
||||
{
|
||||
Particle particle = GameMain.ParticleManager.CreateParticle(Identifier, pos, RandRotation(), RandVelocity());
|
||||
if (particle != null)
|
||||
{
|
||||
particle.ColorMultiplier = ColorMultiplier.ToVector4();
|
||||
}
|
||||
}
|
||||
|
||||
public DamageParticle(XElement element)
|
||||
{
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
}
|
||||
}
|
||||
|
||||
public Sprite? branchAtlas, decayAtlas;
|
||||
public readonly Dictionary<VineTileType, VineSprite> BranchSprites = new Dictionary<VineTileType, VineSprite>();
|
||||
public readonly List<Sprite> FlowerSprites = new List<Sprite>(), DamagedFlowerSprites = new List<Sprite>();
|
||||
public readonly List<Sprite> HiddenFlowerSprites = new List<Sprite>();
|
||||
public readonly List<Sprite> LeafSprites = new List<Sprite>(), DamagedLeafSprites = new List<Sprite>();
|
||||
|
||||
public readonly List<DamageParticle> DamageParticles = new List<DamageParticle>();
|
||||
public readonly List<DamageParticle> DeathParticles = new List<DamageParticle>();
|
||||
public readonly List<ParticleEmitter> DamageParticles = new List<ParticleEmitter>();
|
||||
public readonly List<ParticleEmitter> DeathParticles = new List<ParticleEmitter>();
|
||||
|
||||
public static bool AlwaysShowBallastFloraSprite = false;
|
||||
|
||||
partial void LoadPrefab(XElement element)
|
||||
partial void LoadPrefab(ContentXElement element)
|
||||
{
|
||||
string? branchAtlasPath = element.GetAttributeString("branchatlas", null);
|
||||
string? decayAtlasPath = element.GetAttributeString("decayatlas", null);
|
||||
|
||||
if (branchAtlasPath != null)
|
||||
if (element.GetAttributeContentPath("branchatlas") is { } branchAtlasPath)
|
||||
{
|
||||
branchAtlas = new Sprite(branchAtlasPath, Rectangle.Empty);
|
||||
}
|
||||
|
||||
if (decayAtlasPath != null)
|
||||
{
|
||||
decayAtlas = new Sprite(decayAtlasPath, Rectangle.Empty);
|
||||
branchAtlas = new Sprite(branchAtlasPath.Value, Rectangle.Empty);
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
if (element.GetAttributeContentPath("decayatlas") is { } decayAtlasPath)
|
||||
{
|
||||
decayAtlas = new Sprite(decayAtlasPath.Value, Rectangle.Empty);
|
||||
}
|
||||
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "branchsprite":
|
||||
var tileType = subElement.GetAttributeString("type", null);
|
||||
VineTileType type = Enum.Parse<VineTileType>(tileType);
|
||||
var type = subElement.GetAttributeEnum("type", VineTileType.Stem);
|
||||
BranchSprites.Add(type, new VineSprite(subElement));
|
||||
break;
|
||||
case "flowersprite":
|
||||
@@ -107,10 +63,10 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
DamagedLeafSprites.Add(new Sprite(subElement));
|
||||
break;
|
||||
case "damageparticle":
|
||||
DamageParticles.Add(new DamageParticle(subElement));
|
||||
DamageParticles.Add(new ParticleEmitter(subElement));
|
||||
break;
|
||||
case "deathparticle":
|
||||
DeathParticles.Add(new DamageParticle(subElement));
|
||||
DeathParticles.Add(new ParticleEmitter(subElement));
|
||||
break;
|
||||
case "targets":
|
||||
LoadTargets(subElement);
|
||||
@@ -131,29 +87,59 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDamageParticle(BallastFloraBranch branch, float damage)
|
||||
{
|
||||
Vector2 pos = GetWorldPosition() + branch.Position;
|
||||
int amount = (int)Math.Clamp(damage / 10f, 1, 10);
|
||||
for (int i = 0; i < amount; i++)
|
||||
partial void UpdateDamage(float deltaTime)
|
||||
{
|
||||
foreach (BallastFloraBranch branch in Branches)
|
||||
{
|
||||
foreach (DamageParticle particle in DamageParticles)
|
||||
if (branch.AccumulatedDamage > 0)
|
||||
{
|
||||
particle.Emit(pos);
|
||||
CreateDamageParticle(branch, branch.AccumulatedDamage);
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
var pos = (Parent?.Position ?? Vector2.Zero) + Offset + branch.Position;
|
||||
GUI.AddMessage($"{(int)branch.AccumulatedDamage}", GUIStyle.Red, pos, Vector2.UnitY * 10.0f, 3f, playSound: false, subId: Parent?.Submarine?.ID ?? -1);
|
||||
}
|
||||
}
|
||||
if (Character.Controlled != null && Character.Controlled.CurrentHull == branch.CurrentHull &&
|
||||
branch.IsRoot &&
|
||||
(branch.AccumulatedDamage > 0.0f || branch.AccumulatedDamage < -0.1f))
|
||||
{
|
||||
Character.Controlled.UpdateHUDProgressBar(this,
|
||||
GetWorldPosition() + branch.Position,
|
||||
branch.Health / branch.MaxHealth,
|
||||
emptyColor: GUIStyle.HealthBarColorLow,
|
||||
fullColor: GUIStyle.HealthBarColorHigh,
|
||||
textTag: Prefab.DisplayName.Value);
|
||||
}
|
||||
branch.AccumulatedDamage = 0f;
|
||||
if (branch.DamageVisualizationTimer > 0.0f)
|
||||
{
|
||||
branch.DamageVisualizationTimer -= deltaTime;
|
||||
float t1 = (float)Timing.TotalTime * 0.2f + branch.Position.X / 100.0f;
|
||||
float t2 = (float)Timing.TotalTime * 0.5f + branch.Position.Y / 100.0f;
|
||||
branch.ShakeAmount = new Vector2(
|
||||
PerlinNoise.GetPerlin(t1, t2) - 0.5f,
|
||||
PerlinNoise.GetPerlin(t2, t1) - 0.5f) * 10.0f * branch.DamageVisualizationTimer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDeathParticle(BallastFloraBranch branch)
|
||||
private void CreateDamageParticle(BallastFloraBranch branch, float deltaTime)
|
||||
{
|
||||
Vector2 pos = GetWorldPosition() + branch.Position;
|
||||
int amount = (int)Math.Clamp(branch.MaxHealth / 10f, 1, 10);
|
||||
for (int i = 0; i < amount; i++)
|
||||
foreach (var particleEmitter in DamageParticles)
|
||||
{
|
||||
foreach (DamageParticle particle in DeathParticles)
|
||||
{
|
||||
particle.Emit(pos);
|
||||
}
|
||||
particleEmitter.Emit(deltaTime, pos, branch.CurrentHull);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDeathParticle(BallastFloraBranch branch, float deltaTime)
|
||||
{
|
||||
Vector2 pos = GetWorldPosition() + branch.Position;
|
||||
foreach (var particleEmitter in DeathParticles)
|
||||
{
|
||||
particleEmitter.Emit(deltaTime, pos, branch.CurrentHull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,25 +155,25 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
{
|
||||
Vector2 pos = Parent.Submarine.DrawPosition + ConvertUnits.ToDisplayUnits(body.Position);
|
||||
pos.Y = -pos.Y;
|
||||
GUI.DrawRectangle(spriteBatch, pos, 32f, 32f, 0f, Color.Cyan, 0.1f, thickness: 1);
|
||||
GUI.DrawRectangle(spriteBatch, pos, 32f, 32f, 0f, body.UserData is BallastFloraBranch { IsRoot: true } ? Color.Magenta : Color.Cyan, 0.1f, thickness: 1);
|
||||
}
|
||||
|
||||
foreach (var (key, steps) in IgnoredTargets)
|
||||
{
|
||||
string label = $"Ignored \"{key.Name}\" for {steps} steps";
|
||||
var (sizeX, sizeY) = GUI.SubHeadingFont.MeasureString(label);
|
||||
var (sizeX, sizeY) = GUIStyle.SubHeadingFont.MeasureString(label);
|
||||
Vector2 targetPos = key.WorldPosition;
|
||||
targetPos.Y = -targetPos.Y;
|
||||
GUI.DrawString(spriteBatch, targetPos - new Vector2(sizeX / 2f, sizeY), label, GUI.Style.Red, font: GUI.SubHeadingFont);
|
||||
GUI.DrawString(spriteBatch, targetPos - new Vector2(sizeX / 2f, sizeY), label, GUIStyle.Red, font: GUIStyle.SubHeadingFont);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (BallastFloraBranch branch in Branches)
|
||||
{
|
||||
Vector2 pos = Parent.DrawPosition + Offset + branch.Position;
|
||||
Vector2 pos = Parent.DrawPosition + Offset + branch.Position + branch.ShakeAmount;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
float depth = BranchDepth;
|
||||
float depth = branch.IsRootGrowth ? 0.2f : BranchDepth;
|
||||
|
||||
float layer1 = depth + 0.01f,
|
||||
layer2 = depth + 0.02f,
|
||||
@@ -195,7 +181,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
VineSprite branchSprite = BranchSprites[branch.Type];
|
||||
|
||||
Color branchColor = Color.White;
|
||||
Color branchColor = (branch.IsRoot || branch.IsRootGrowth) ? RootColor : Color.White;
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
@@ -207,7 +193,13 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
pos1.Y = -pos1.Y;
|
||||
Vector2 pos2 = basePos - to;
|
||||
pos2.Y = -pos2.Y;
|
||||
GUI.DrawLine(spriteBatch, pos1, pos2, GUI.Style.Yellow * 0.8f, width: 4);
|
||||
GUI.DrawLine(spriteBatch, pos1, pos2, GUIStyle.Yellow * 0.8f, width: 4);
|
||||
}
|
||||
if (branch.ParentBranch != null)
|
||||
{
|
||||
Vector2 pos2 = Parent.DrawPosition + Offset + branch.ParentBranch.Position;
|
||||
pos2.Y = -pos2.Y;
|
||||
GUI.DrawLine(spriteBatch, pos, pos2, GUIStyle.Green * 0.8f, width: 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -235,8 +227,8 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
}
|
||||
}
|
||||
|
||||
var (sizeX, sizeY) = GUI.SubHeadingFont.MeasureString(label);
|
||||
GUI.DrawString(spriteBatch, pos - new Vector2(sizeX / 2f, branch.Rect.Height + sizeY), label, Color.White, font: GUI.SubHeadingFont);
|
||||
var (sizeX, sizeY) = GUIStyle.SubHeadingFont.MeasureString(label);
|
||||
GUI.DrawString(spriteBatch, pos - new Vector2(sizeX / 2f, branch.Rect.Height + sizeY), label, Color.White, font: GUIStyle.SubHeadingFont);
|
||||
}
|
||||
|
||||
bool isDamaged = branch.Health < branch.MaxHealth;
|
||||
@@ -340,7 +332,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
case NetworkHeader.BranchRemove:
|
||||
|
||||
int removedBranchId = msg.ReadInt32();
|
||||
BallastFloraBranch removedBranch = Branches.FirstOrDefault(b => b.ID == removedBranchId);
|
||||
BallastFloraBranch? removedBranch = Branches.FirstOrDefault(b => b.ID == removedBranchId);
|
||||
if (removedBranch != null)
|
||||
{
|
||||
RemoveBranch(removedBranch);
|
||||
@@ -352,14 +344,11 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
break;
|
||||
case NetworkHeader.BranchDamage:
|
||||
|
||||
int damageBranchId = msg.ReadInt32();
|
||||
float damage = msg.ReadSingle();
|
||||
float health = msg.ReadSingle();
|
||||
BallastFloraBranch damagedBranch = Branches.FirstOrDefault(b => b.ID == damageBranchId);
|
||||
BallastFloraBranch? damagedBranch = Branches.FirstOrDefault(b => b.ID == damageBranchId);
|
||||
if (damagedBranch != null)
|
||||
{
|
||||
CreateDamageParticle(damagedBranch, damage);
|
||||
damagedBranch.Health = health;
|
||||
}
|
||||
else
|
||||
@@ -370,6 +359,9 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
case NetworkHeader.Kill:
|
||||
Kill();
|
||||
break;
|
||||
case NetworkHeader.Remove:
|
||||
Remove();
|
||||
break;
|
||||
}
|
||||
|
||||
PowerConsumptionTimer = msg.ReadSingle();
|
||||
@@ -378,15 +370,18 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
private BallastFloraBranch ReadBranch(IReadMessage msg)
|
||||
{
|
||||
int id = msg.ReadInt32();
|
||||
byte type = (byte) msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
byte sides = (byte) msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
byte type = (byte)msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
byte sides = (byte)msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
int flowerConfig = msg.ReadRangedInteger(0, 0xFFF);
|
||||
int leafConfig = msg.ReadRangedInteger(0, 0xFFF);
|
||||
int maxHealth = msg.ReadUInt16();
|
||||
int posX = msg.ReadInt32(), posY = msg.ReadInt32();
|
||||
int parentBranchIndex = msg.ReadInt32();
|
||||
Vector2 pos = new Vector2(posX * VineTile.Size, posY * VineTile.Size);
|
||||
|
||||
return new BallastFloraBranch(this, pos, (VineTileType)type, FoliageConfig.Deserialize(flowerConfig), FoliageConfig.Deserialize(leafConfig))
|
||||
BallastFloraBranch? parentBranch = parentBranchIndex < 0 || parentBranchIndex >= Branches.Count ? null : Branches[parentBranchIndex];
|
||||
|
||||
return new BallastFloraBranch(this, parentBranch, pos, (VineTileType)type, FoliageConfig.Deserialize(flowerConfig), FoliageConfig.Deserialize(leafConfig))
|
||||
{
|
||||
ID = id,
|
||||
MaxHealth = maxHealth,
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
||||
|
||||
if (!editing || !ShowGaps || !SubEditorScreen.IsLayerVisible(this)) { return; }
|
||||
|
||||
Color clr = (open == 0.0f) ? GUI.Style.Red : Color.Cyan;
|
||||
Color clr = (open == 0.0f) ? GUIStyle.Red : Color.Cyan;
|
||||
if (IsHighlighted) { clr = Color.Gold; }
|
||||
|
||||
GUI.DrawRectangle(
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(sb,
|
||||
new Vector2(WorldRect.X - 5, -WorldRect.Y - 5),
|
||||
new Vector2(rect.Width + 10, rect.Height + 10),
|
||||
GUI.Style.Red,
|
||||
GUIStyle.Red,
|
||||
false,
|
||||
depth,
|
||||
(int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.MapCreatures.Behavior;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -107,7 +108,7 @@ namespace Barotrauma
|
||||
{
|
||||
CanTakeKeyBoardFocus = false
|
||||
};
|
||||
new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont);
|
||||
new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUIStyle.LargeFont);
|
||||
|
||||
PositionEditingHUD();
|
||||
|
||||
@@ -285,7 +286,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUI.Style.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUIStyle.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
}
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
@@ -295,34 +296,34 @@ namespace Barotrauma
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
|
||||
GUI.Style.Red * ((100.0f - OxygenPercentage) / 400.0f) * alpha, true, 0, (int)Math.Max(1.5f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
GUIStyle.Red * ((100.0f - OxygenPercentage) / 400.0f) * alpha, true, 0, (int)Math.Max(1.5f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Pressure: " + ((int)pressure - rect.Y).ToString() +
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, "Pressure: " + ((int)pressure - rect.Y).ToString() +
|
||||
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 5, -drawRect.Y + 5), Color.White);
|
||||
GUI.SmallFont.DrawString(spriteBatch, waterVolume + " / " + Volume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, waterVolume + " / " + Volume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * Math.Min(waterVolume / Volume, 1.0f))), Color.Cyan, true);
|
||||
if (WaterVolume > Volume)
|
||||
{
|
||||
float maxExcessWater = Volume * MaxCompress;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * (waterVolume - Volume) / maxExcessWater)), GUI.Style.Red, true);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * (waterVolume - Volume) / maxExcessWater)), GUIStyle.Red, true);
|
||||
}
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, 100), Color.Black);
|
||||
|
||||
foreach (FireSource fs in FireSources)
|
||||
{
|
||||
Rectangle fireSourceRect = new Rectangle((int)fs.WorldPosition.X, -(int)fs.WorldPosition.Y, (int)fs.Size.X, (int)fs.Size.Y);
|
||||
GUI.DrawRectangle(spriteBatch, fireSourceRect, GUI.Style.Red, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(fireSourceRect.X - (int)fs.DamageRange, fireSourceRect.Y, fireSourceRect.Width + (int)fs.DamageRange * 2, fireSourceRect.Height), GUI.Style.Orange, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, fireSourceRect, GUIStyle.Red, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(fireSourceRect.X - (int)fs.DamageRange, fireSourceRect.Y, fireSourceRect.Width + (int)fs.DamageRange * 2, fireSourceRect.Height), GUIStyle.Orange, false, 0, 5);
|
||||
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)fs.LastExtinguishPos.X, (int)-fs.LastExtinguishPos.Y, 5,5), Color.Yellow, true);
|
||||
}
|
||||
foreach (FireSource fs in FakeFireSources)
|
||||
{
|
||||
Rectangle fireSourceRect = new Rectangle((int)fs.WorldPosition.X, -(int)fs.WorldPosition.Y, (int)fs.Size.X, (int)fs.Size.Y);
|
||||
GUI.DrawRectangle(spriteBatch, fireSourceRect, GUI.Style.Red, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(fireSourceRect.X - (int)fs.DamageRange, fireSourceRect.Y, fireSourceRect.Width + (int)fs.DamageRange * 2, fireSourceRect.Height), GUI.Style.Orange, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, fireSourceRect, GUIStyle.Red, false, 0, 5);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(fireSourceRect.X - (int)fs.DamageRange, fireSourceRect.Y, fireSourceRect.Width + (int)fs.DamageRange * 2, fireSourceRect.Height), GUIStyle.Orange, false, 0, 5);
|
||||
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)fs.LastExtinguishPos.X, (int)-fs.LastExtinguishPos.Y, 5,5), Color.Yellow, true);
|
||||
}
|
||||
|
||||
@@ -358,7 +359,7 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(currentHullRect.X, -currentHullRect.Y),
|
||||
new Vector2(connectedHullRect.X, -connectedHullRect.Y),
|
||||
GUI.Style.Green, width: 2);
|
||||
GUIStyle.Green, width: 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,7 +377,7 @@ namespace Barotrauma
|
||||
|
||||
if (section.ColorStrength < 0.01f || section.Color.A < 1) { continue; }
|
||||
|
||||
if (GameMain.DecalManager.GrimeSprites.Count == 0)
|
||||
if (DecalManager.GrimeSprites.None())
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawOffset.X + rect.X + section.Rect.X, -(drawOffset.Y + rect.Y + section.Rect.Y)),
|
||||
@@ -387,7 +388,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 sectionPos = new Vector2(drawPos.X + section.Rect.Location.X, -(drawPos.Y + section.Rect.Location.Y));
|
||||
Vector2 randomOffset = new Vector2(section.Noise.X - 0.5f, section.Noise.Y - 0.5f) * 15.0f;
|
||||
var sprite = GameMain.DecalManager.GrimeSprites[i % GameMain.DecalManager.GrimeSprites.Count];
|
||||
var sprite = DecalManager.GrimeSprites[$"{nameof(GrimeSprite)}{i % DecalManager.GrimeSpriteCount}"].Sprite;
|
||||
sprite.Draw(spriteBatch, sectionPos + randomOffset, section.GetStrengthAdjustedColor(), scale: 1.25f);
|
||||
}
|
||||
}
|
||||
@@ -648,7 +649,7 @@ namespace Barotrauma
|
||||
BallastFloraBehavior.NetworkHeader header = (BallastFloraBehavior.NetworkHeader) message.ReadByte();
|
||||
if (header == BallastFloraBehavior.NetworkHeader.Spawn)
|
||||
{
|
||||
string identifier = message.ReadString();
|
||||
Identifier identifier = message.ReadIdentifier();
|
||||
float x = message.ReadSingle();
|
||||
float y = message.ReadSingle();
|
||||
BallastFlora = new BallastFloraBehavior(this, BallastFloraPrefab.Find(identifier), new Vector2(x, y), firstGrowth: true)
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class ItemAssemblyPrefab
|
||||
partial class ItemAssemblyPrefab : MapEntityPrefab
|
||||
{
|
||||
public void DrawIcon(SpriteBatch spriteBatch, GUICustomComponent guiComponent)
|
||||
{
|
||||
@@ -16,28 +16,28 @@ namespace Barotrauma
|
||||
|
||||
float scale = Math.Min(drawArea.Width / (float)Bounds.Width, drawArea.Height / (float)Bounds.Height) * 0.9f;
|
||||
|
||||
foreach (Pair<MapEntityPrefab, Rectangle> entity in DisplayEntities)
|
||||
foreach ((Identifier identifier, Rectangle rect) in DisplayEntities)
|
||||
{
|
||||
if (entity.First is CoreEntityPrefab) { continue; }
|
||||
Rectangle drawRect = entity.Second;
|
||||
drawRect = new Rectangle(
|
||||
(int)(drawRect.X * scale) + drawArea.Center.X, (int)((drawRect.Y) * scale) - drawArea.Center.Y,
|
||||
(int)(drawRect.Width * scale), (int)(drawRect.Height * scale));
|
||||
entity.First.DrawPlacing(spriteBatch, drawRect, entity.First.Scale * scale);
|
||||
var entityPrefab = MapEntityPrefab.FindByIdentifier(identifier);
|
||||
if (entityPrefab is CoreEntityPrefab) { continue; }
|
||||
var drawRect = new Rectangle(
|
||||
(int)(rect.X * scale) + drawArea.Center.X, (int)((rect.Y) * scale) - drawArea.Center.Y,
|
||||
(int)(rect.Width * scale), (int)(rect.Height * scale));
|
||||
entityPrefab.DrawPlacing(spriteBatch, drawRect, entityPrefab.Scale * scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
base.DrawPlacing(spriteBatch, cam);
|
||||
foreach (Pair<MapEntityPrefab, Rectangle> entity in DisplayEntities)
|
||||
foreach ((Identifier identifier, Rectangle rect) in DisplayEntities)
|
||||
{
|
||||
Rectangle drawRect = entity.Second;
|
||||
var entityPrefab = MapEntityPrefab.Find(p => p.Identifier == identifier);
|
||||
Rectangle drawRect = rect;
|
||||
|
||||
drawRect.Location += placePosition != Vector2.Zero ? placePosition.ToPoint() : Submarine.MouseToWorldGrid(cam, Submarine.MainSub).ToPoint();
|
||||
|
||||
entity.First.DrawPlacing(spriteBatch, drawRect, entity.First.Scale);
|
||||
entityPrefab.DrawPlacing(spriteBatch, drawRect, entityPrefab.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ namespace Barotrauma
|
||||
|
||||
checkWallsTimer = Rand.Range(0.0f, CheckWallsInterval, Rand.RandSync.ClientOnly);
|
||||
|
||||
foreach (XElement subElement in prefab.Config.Elements())
|
||||
foreach (var subElement in prefab.Config.Elements())
|
||||
{
|
||||
List<SpriteDeformation> deformationList = null;
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
|
||||
+16
-15
@@ -18,45 +18,46 @@ namespace Barotrauma
|
||||
private readonly List<BackgroundCreaturePrefab> prefabs = new List<BackgroundCreaturePrefab>();
|
||||
private readonly List<BackgroundCreature> creatures = new List<BackgroundCreature>();
|
||||
|
||||
public BackgroundCreatureManager(string configPath)
|
||||
{
|
||||
LoadConfig(new ContentFile(configPath, ContentType.BackgroundCreaturePrefabs));
|
||||
}
|
||||
|
||||
public BackgroundCreatureManager(IEnumerable<ContentFile> files)
|
||||
public BackgroundCreatureManager(IEnumerable<BackgroundCreaturePrefabsFile> files)
|
||||
{
|
||||
foreach(var file in files)
|
||||
{
|
||||
LoadConfig(file);
|
||||
LoadConfig(file.Path);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadConfig(ContentFile config)
|
||||
public BackgroundCreatureManager(string path)
|
||||
{
|
||||
DebugConsole.AddWarning($"Couldn't find any BackgroundCreaturePrefabs files, falling back to {path}");
|
||||
LoadConfig(ContentPath.FromRaw(null, path));
|
||||
}
|
||||
|
||||
private void LoadConfig(ContentPath configPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(config.Path);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configPath);
|
||||
if (doc == null) { return; }
|
||||
var mainElement = doc.Root;
|
||||
var mainElement = doc.Root.FromPackage(configPath.ContentPackage);
|
||||
if (mainElement.IsOverride())
|
||||
{
|
||||
mainElement = doc.Root.FirstElement();
|
||||
mainElement = mainElement.FirstElement();
|
||||
prefabs.Clear();
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{config.Path}'", Color.Yellow);
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.Yellow);
|
||||
}
|
||||
else if (prefabs.Any())
|
||||
{
|
||||
DebugConsole.NewMessage($"Loading additional background creatures from file '{config.Path}'");
|
||||
DebugConsole.NewMessage($"Loading additional background creatures from file '{configPath}'");
|
||||
}
|
||||
|
||||
foreach (XElement element in mainElement.Elements())
|
||||
foreach (var element in mainElement.Elements())
|
||||
{
|
||||
prefabs.Add(new BackgroundCreaturePrefab(element));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", config.Path), e);
|
||||
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", configPath), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-22
@@ -12,52 +12,52 @@ namespace Barotrauma
|
||||
|
||||
public readonly XElement Config;
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Speed { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float WanderAmount { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float WanderZAmount { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
[Serialize(1, IsPropertySaveable.Yes)]
|
||||
public int SwarmMin { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
[Serialize(1, IsPropertySaveable.Yes)]
|
||||
public int SwarmMax { get; private set; }
|
||||
|
||||
[Serialize(200.0f, true)]
|
||||
[Serialize(200.0f, IsPropertySaveable.Yes)]
|
||||
public float SwarmRadius { get; private set; }
|
||||
|
||||
[Serialize(0.2f, true)]
|
||||
[Serialize(0.2f, IsPropertySaveable.Yes)]
|
||||
public float SwarmCohesion { get; private set; }
|
||||
|
||||
[Serialize(10.0f, true)]
|
||||
[Serialize(10.0f, IsPropertySaveable.Yes)]
|
||||
public float MinDepth { get; private set; }
|
||||
|
||||
[Serialize(1000.0f, true)]
|
||||
[Serialize(1000.0f, IsPropertySaveable.Yes)]
|
||||
public float MaxDepth { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
public bool DisableRotation { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
public bool DisableFlipping { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Scale { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Commonness { get; private set; }
|
||||
|
||||
[Serialize(1000, true)]
|
||||
[Serialize(1000, IsPropertySaveable.Yes)]
|
||||
public int MaxCount { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float FlashInterval { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float FlashDuration { get; private set; }
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace Barotrauma
|
||||
/// Overrides the commonness of the object in a specific level type.
|
||||
/// Key = name of the level type, value = commonness in that level type.
|
||||
/// </summary>
|
||||
public Dictionary<string, float> OverrideCommonness = new Dictionary<string, float>();
|
||||
public Dictionary<Identifier, float> OverrideCommonness = new Dictionary<Identifier, float>();
|
||||
|
||||
public BackgroundCreaturePrefab(XElement element)
|
||||
public BackgroundCreaturePrefab(ContentXElement element)
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Barotrauma
|
||||
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace Barotrauma
|
||||
DeformableLightSprite = new DeformableSprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "overridecommonness":
|
||||
string levelType = subElement.GetAttributeString("leveltype", "").ToLowerInvariant();
|
||||
Identifier levelType = subElement.GetAttributeIdentifier("leveltype", Identifier.Empty);
|
||||
if (!OverrideCommonness.ContainsKey(levelType))
|
||||
{
|
||||
OverrideCommonness.Add(levelType, subElement.GetAttributeFloat("commonness", 1.0f));
|
||||
@@ -104,9 +104,10 @@ namespace Barotrauma
|
||||
|
||||
public float GetCommonness(LevelGenerationParams generationParams)
|
||||
{
|
||||
if (generationParams?.Identifier != null &&
|
||||
if (generationParams != null &&
|
||||
!generationParams.Identifier.IsEmpty &&
|
||||
(OverrideCommonness.TryGetValue(generationParams.Identifier, out float commonness) ||
|
||||
(generationParams.OldIdentifier != null && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
(!generationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
{
|
||||
return commonness;
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ namespace Barotrauma
|
||||
SoundTriggers = new LevelTrigger[Prefab.Sounds.Count];
|
||||
for (int i = 0; i < Prefab.Sounds.Count; i++)
|
||||
{
|
||||
Sounds[i] = Submarine.LoadRoundSound(Prefab.Sounds[i].SoundElement, false);
|
||||
Sounds[i] = RoundSound.Load(Prefab.Sounds[i].SoundElement, false);
|
||||
SoundTriggers[i] = Prefab.Sounds[i].TriggerIndex > -1 ? Triggers[Prefab.Sounds[i].TriggerIndex] : null;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
foreach (XElement subElement in Prefab.Config.Elements())
|
||||
foreach (var subElement in Prefab.Config.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("deformablesprite", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
foreach (XElement animationElement in subElement.Elements())
|
||||
@@ -151,7 +151,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
VisibleOnSonar = Prefab.SonarDisruption > 0.0f || Prefab.OverrideProperties.Any(p => p != null && p.SonarDisruption > 0.0f) ||
|
||||
(Triggers != null && Triggers.Any(t => !MathUtils.NearlyEqual(t.Force, Vector2.Zero) && t.ForceMode != LevelTrigger.TriggerForceMode.LimitVelocity || !string.IsNullOrWhiteSpace(t.InfectIdentifier)));
|
||||
(Triggers != null && Triggers.Any(t => !MathUtils.NearlyEqual(t.Force, Vector2.Zero) && t.ForceMode != LevelTrigger.TriggerForceMode.LimitVelocity || !t.InfectIdentifier.IsEmpty));
|
||||
if (VisibleOnSonar && Triggers.Any())
|
||||
{
|
||||
SonarRadius = Triggers.Select(t => t.ColliderRadius * 1.5f).Max();
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(obj.Position.X, -obj.Position.Y), new Vector2(10.0f, 10.0f), GUI.Style.Red, true);
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(obj.Position.X, -obj.Position.Y), new Vector2(10.0f, 10.0f), GUIStyle.Red, true);
|
||||
|
||||
if (obj.Triggers == null) { continue; }
|
||||
foreach (LevelTrigger trigger in obj.Triggers)
|
||||
@@ -218,7 +218,7 @@ namespace Barotrauma
|
||||
if (flowForce.LengthSquared() > 1)
|
||||
{
|
||||
flowForce.Y = -flowForce.Y;
|
||||
GUI.DrawLine(spriteBatch, new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y), new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y) + flowForce * 10, GUI.Style.Orange, 0, 5);
|
||||
GUI.DrawLine(spriteBatch, new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y), new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y) + flowForce * 10, GUIStyle.Orange, 0, 5);
|
||||
}
|
||||
trigger.PhysicsBody.UpdateDrawPosition();
|
||||
trigger.PhysicsBody.DebugDraw(spriteBatch, trigger.IsTriggered ? Color.Cyan : Color.DarkCyan);
|
||||
|
||||
+11
-11
@@ -9,15 +9,15 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class LevelObjectPrefab
|
||||
partial class LevelObjectPrefab : PrefabWithUintIdentifier, ISerializableEntity
|
||||
{
|
||||
public class SoundConfig
|
||||
{
|
||||
public readonly XElement SoundElement;
|
||||
public readonly ContentXElement SoundElement;
|
||||
public readonly Vector2 Position;
|
||||
public readonly int TriggerIndex;
|
||||
|
||||
public SoundConfig(XElement element, int triggerIndex)
|
||||
public SoundConfig(ContentXElement element, int triggerIndex)
|
||||
{
|
||||
SoundElement = element;
|
||||
Position = element.GetAttributeVector2("position", Vector2.Zero);
|
||||
@@ -67,14 +67,14 @@ namespace Barotrauma
|
||||
private set;
|
||||
} = new List<SpriteDeformation>();
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
LoadElementsProjSpecific(element, -1);
|
||||
}
|
||||
|
||||
private void LoadElementsProjSpecific(XElement element, int parentTriggerIndex)
|
||||
private void LoadElementsProjSpecific(ContentXElement element, int parentTriggerIndex)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -121,7 +121,7 @@ namespace Barotrauma
|
||||
|
||||
SerializableProperty.SerializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements().ToList())
|
||||
foreach (var subElement in element.Elements().ToList())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -144,7 +144,7 @@ namespace Barotrauma
|
||||
{
|
||||
int elementIndex = 0;
|
||||
bool wasSaved = false;
|
||||
foreach (XElement subElement in element.Elements().ToList())
|
||||
foreach (var subElement in element.Elements().ToList())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -175,13 +175,13 @@ namespace Barotrauma
|
||||
new XAttribute("maxcount", childObj.MaxCount)));
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, float> overrideCommonness in OverrideCommonness)
|
||||
foreach (KeyValuePair<Identifier, float> overrideCommonness in OverrideCommonness)
|
||||
{
|
||||
bool elementFound = false;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("overridecommonness", System.StringComparison.OrdinalIgnoreCase)
|
||||
&& subElement.GetAttributeString("leveltype", "").Equals(overrideCommonness.Key, System.StringComparison.OrdinalIgnoreCase))
|
||||
&& subElement.GetAttributeIdentifier("leveltype", Identifier.Empty) == overrideCommonness.Key)
|
||||
{
|
||||
subElement.Attribute("commonness").Value = overrideCommonness.Value.ToString("G", CultureInfo.InvariantCulture);
|
||||
elementFound = true;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(nodeList[i - 1].X, -nodeList[i - 1].Y),
|
||||
new Vector2(nodeList[i].X, -nodeList[i].Y),
|
||||
Color.Lerp(Color.Yellow, GUI.Style.Red, i / (float)nodeList.Count), 0, 10);
|
||||
Color.Lerp(Color.Yellow, GUIStyle.Red, i / (float)nodeList.Count), 0, 10);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace Barotrauma.Lights
|
||||
if (!BoundingBox.Contains(point)) { return false; }
|
||||
|
||||
Vector2 center = (vertices[0].Pos + vertices[1].Pos + vertices[2].Pos + vertices[3].Pos) * 0.25f;
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector2 segmentVector = vertices[(i + 1) % 4].Pos - vertices[i].Pos;
|
||||
Vector2 centerToVertex = center - vertices[i].Pos;
|
||||
@@ -695,7 +695,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
ShadowVertexCount = 0;
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (!backFacing[i]) { continue; }
|
||||
int currentIndex = i;
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
var pp = graphics.PresentationParameters;
|
||||
|
||||
currLightMapScale = GameMain.Config.LightMapScale;
|
||||
currLightMapScale = GameSettings.CurrentConfig.Graphics.LightMapScale;
|
||||
|
||||
LightMap?.Dispose();
|
||||
LightMap = CreateRenderTarget();
|
||||
@@ -120,15 +120,15 @@ namespace Barotrauma.Lights
|
||||
RenderTarget2D CreateRenderTarget()
|
||||
{
|
||||
return new RenderTarget2D(graphics,
|
||||
(int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false,
|
||||
(int)(GameMain.GraphicsWidth * GameSettings.CurrentConfig.Graphics.LightMapScale), (int)(GameMain.GraphicsHeight * GameSettings.CurrentConfig.Graphics.LightMapScale), false,
|
||||
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
|
||||
RenderTargetUsage.DiscardContents);
|
||||
}
|
||||
|
||||
LosTexture?.Dispose();
|
||||
LosTexture = new RenderTarget2D(graphics,
|
||||
(int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale),
|
||||
(int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, SurfaceFormat.Color, DepthFormat.None);
|
||||
(int)(GameMain.GraphicsWidth * GameSettings.CurrentConfig.Graphics.LightMapScale),
|
||||
(int)(GameMain.GraphicsHeight * GameSettings.CurrentConfig.Graphics.LightMapScale), false, SurfaceFormat.Color, DepthFormat.None);
|
||||
}
|
||||
|
||||
public void AddLight(LightSource light)
|
||||
@@ -165,13 +165,13 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (!LightingEnabled) { return; }
|
||||
|
||||
if (Math.Abs(currLightMapScale - GameMain.Config.LightMapScale) > 0.01f)
|
||||
if (Math.Abs(currLightMapScale - GameSettings.CurrentConfig.Graphics.LightMapScale) > 0.01f)
|
||||
{
|
||||
//lightmap scale has changed -> recreate render targets
|
||||
CreateRenderTargets(graphics);
|
||||
}
|
||||
|
||||
Matrix spriteBatchTransform = cam.Transform * Matrix.CreateScale(new Vector3(GameMain.Config.LightMapScale, GameMain.Config.LightMapScale, 1.0f));
|
||||
Matrix spriteBatchTransform = cam.Transform * Matrix.CreateScale(new Vector3(GameSettings.CurrentConfig.Graphics.LightMapScale, GameSettings.CurrentConfig.Graphics.LightMapScale, 1.0f));
|
||||
Matrix transform = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
@@ -187,6 +187,7 @@ namespace Barotrauma.Lights
|
||||
if ((light.Color.A < 1 || light.Range < 1.0f) && !light.LightSourceParams.OverrideLightSpriteAlpha.HasValue) { continue; }
|
||||
if (light.ParentBody != null)
|
||||
{
|
||||
light.ParentBody.UpdateDrawPosition();
|
||||
light.Position = light.ParentBody.DrawPosition;
|
||||
if (light.ParentSub != null) { light.Position -= light.ParentSub.DrawPosition; }
|
||||
}
|
||||
@@ -501,7 +502,7 @@ namespace Barotrauma.Lights
|
||||
private Dictionary<Hull, Rectangle> GetVisibleHulls(Camera cam)
|
||||
{
|
||||
visibleHulls.Clear();
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
foreach (Hull hull in Hull.HullList)
|
||||
{
|
||||
if (hull.HiddenInGame) { continue; }
|
||||
var drawRect =
|
||||
@@ -537,7 +538,7 @@ namespace Barotrauma.Lights
|
||||
Vector2 scale = new Vector2(
|
||||
MathHelper.Clamp(losOffset.Length() / 256.0f, 4.0f, 5.0f), 3.0f);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cam.Transform * Matrix.CreateScale(new Vector3(GameMain.Config.LightMapScale, GameMain.Config.LightMapScale, 1.0f)));
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cam.Transform * Matrix.CreateScale(new Vector3(GameSettings.CurrentConfig.Graphics.LightMapScale, GameSettings.CurrentConfig.Graphics.LightMapScale, 1.0f)));
|
||||
spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation,
|
||||
new Vector2(visionCircle.Width * 0.2f, visionCircle.Height / 2), scale, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Barotrauma.Lights
|
||||
|
||||
public bool Persistent;
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties { get; private set; } = new Dictionary<string, SerializableProperty>();
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties { get; private set; } = new Dictionary<Identifier, SerializableProperty>();
|
||||
|
||||
[Serialize("1.0,1.0,1.0,1.0", true, alwaysUseInstanceValues: true), Editable]
|
||||
[Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes, alwaysUseInstanceValues: true), Editable]
|
||||
public Color Color
|
||||
{
|
||||
get;
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
private float range;
|
||||
|
||||
[Serialize(100.0f, true, alwaysUseInstanceValues: true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f)]
|
||||
[Serialize(100.0f, IsPropertySaveable.Yes, alwaysUseInstanceValues: true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f)]
|
||||
public float Range
|
||||
{
|
||||
get { return range; }
|
||||
@@ -43,19 +43,19 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(1f, true), Editable(minValue: 0.01f, maxValue: 100f, ValueStep = 0.1f, DecimalCount = 2)]
|
||||
[Serialize(1f, IsPropertySaveable.Yes), Editable(minValue: 0.01f, maxValue: 100f, ValueStep = 0.1f, DecimalCount = 2)]
|
||||
public float Scale { get; set; }
|
||||
|
||||
[Serialize("0, 0", true), Editable(ValueStep = 1, DecimalCount = 1, MinValueFloat = -1000f, MaxValueFloat = 1000f)]
|
||||
[Serialize("0, 0", IsPropertySaveable.Yes), Editable(ValueStep = 1, DecimalCount = 1, MinValueFloat = -1000f, MaxValueFloat = 1000f)]
|
||||
public Vector2 Offset { get; set; }
|
||||
|
||||
[Serialize(0f, true), Editable(MinValueFloat = -360, MaxValueFloat = 360, ValueStep = 1, DecimalCount = 0)]
|
||||
[Serialize(0f, IsPropertySaveable.Yes), Editable(MinValueFloat = -360, MaxValueFloat = 360, ValueStep = 1, DecimalCount = 0)]
|
||||
public float Rotation { get; set; }
|
||||
|
||||
public Vector2 GetOffset() => Vector2.Transform(Offset, Matrix.CreateRotationZ(Rotation));
|
||||
|
||||
private float flicker;
|
||||
[Editable, Serialize(0.0f, false, description: "How heavily the light flickers. 0 = no flickering, 1 = the light will alternate between completely dark and full brightness.")]
|
||||
[Editable, Serialize(0.0f, IsPropertySaveable.No, description: "How heavily the light flickers. 0 = no flickering, 1 = the light will alternate between completely dark and full brightness.")]
|
||||
public float Flicker
|
||||
{
|
||||
get { return flicker; }
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
}
|
||||
|
||||
[Editable, Serialize(1.0f, false, description: "How fast the light flickers.")]
|
||||
[Editable, Serialize(1.0f, IsPropertySaveable.No, description: "How fast the light flickers.")]
|
||||
public float FlickerSpeed
|
||||
{
|
||||
get;
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
private float pulseFrequency;
|
||||
[Editable, Serialize(0.0f, true, description: "How rapidly the light pulsates (in Hz). 0 = no blinking.")]
|
||||
[Editable, Serialize(0.0f, IsPropertySaveable.Yes, description: "How rapidly the light pulsates (in Hz). 0 = no blinking.")]
|
||||
public float PulseFrequency
|
||||
{
|
||||
get { return pulseFrequency; }
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
private float pulseAmount;
|
||||
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 1.0f, DecimalCount = 2), Serialize(0.0f, true, description: "How much light pulsates (in Hz). 0 = not at all, 1 = alternates between full brightness and off.")]
|
||||
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 1.0f, DecimalCount = 2), Serialize(0.0f, IsPropertySaveable.Yes, description: "How much light pulsates (in Hz). 0 = not at all, 1 = alternates between full brightness and off.")]
|
||||
public float PulseAmount
|
||||
{
|
||||
get { return pulseAmount; }
|
||||
@@ -95,7 +95,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
private float blinkFrequency;
|
||||
[Editable, Serialize(0.0f, true, description: "How rapidly the light blinks on and off (in Hz). 0 = no blinking.")]
|
||||
[Editable, Serialize(0.0f, IsPropertySaveable.Yes, description: "How rapidly the light blinks on and off (in Hz). 0 = no blinking.")]
|
||||
public float BlinkFrequency
|
||||
{
|
||||
get { return blinkFrequency; }
|
||||
@@ -124,7 +124,7 @@ namespace Barotrauma.Lights
|
||||
private set;
|
||||
}
|
||||
|
||||
public XElement DeformableLightSpriteElement
|
||||
public ContentXElement DeformableLightSpriteElement
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
@@ -134,11 +134,11 @@ namespace Barotrauma.Lights
|
||||
//Can be used to make lamp sprites glow at full brightness even if the light itself is dim.
|
||||
public float? OverrideLightSpriteAlpha;
|
||||
|
||||
public LightSourceParams(XElement element)
|
||||
public LightSourceParams(ContentXElement element)
|
||||
{
|
||||
Deserialize(element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -427,7 +427,7 @@ namespace Barotrauma.Lights
|
||||
private readonly PropertyConditional.Comparison comparison;
|
||||
private readonly List<PropertyConditional> conditionals = new List<PropertyConditional>();
|
||||
|
||||
public LightSource (XElement element, ISerializableEntity conditionalTarget = null)
|
||||
public LightSource(ContentXElement element, ISerializableEntity conditionalTarget = null)
|
||||
: this(Vector2.Zero, 100.0f, Color.White, null)
|
||||
{
|
||||
lightSourceParams = new LightSourceParams(element);
|
||||
@@ -444,7 +444,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
this.conditionalTarget = conditionalTarget;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -1211,7 +1211,7 @@ namespace Barotrauma.Lights
|
||||
new SegmentPoint(new Vector2(drawPos.X - bounds, drawPos.Y + bounds), null)
|
||||
};
|
||||
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, boundaryCorners[i].Pos, boundaryCorners[(i + 1) % 4].Pos, Color.White, 0, 3);
|
||||
}
|
||||
@@ -1283,16 +1283,16 @@ namespace Barotrauma.Lights
|
||||
|
||||
if (CastShadows && Screen.Selected == GameMain.SubEditorScreen)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 20, Vector2.One * 40, GUI.Style.Orange, isFilled: false);
|
||||
GUI.DrawLine(spriteBatch, drawPos - Vector2.One * 20, drawPos + Vector2.One * 20, GUI.Style.Orange);
|
||||
GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * 20, drawPos + new Vector2(1.0f, -1.0f) * 20, GUI.Style.Orange);
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 20, Vector2.One * 40, GUIStyle.Orange, isFilled: false);
|
||||
GUI.DrawLine(spriteBatch, drawPos - Vector2.One * 20, drawPos + Vector2.One * 20, GUIStyle.Orange);
|
||||
GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * 20, drawPos + new Vector2(1.0f, -1.0f) * 20, GUIStyle.Orange);
|
||||
}
|
||||
|
||||
//visualize light recalculations
|
||||
float timeSinceRecalculation = (float)Timing.TotalTime - lastRecalculationTime;
|
||||
if (timeSinceRecalculation < 0.1f)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, GUI.Style.Red * (1.0f - timeSinceRecalculation * 10.0f), isFilled: true);
|
||||
GUI.DrawRectangle(spriteBatch, drawPos - Vector2.One * 10, Vector2.One * 20, GUIStyle.Red * (1.0f - timeSinceRecalculation * 10.0f), isFilled: true);
|
||||
GUI.DrawLine(spriteBatch, drawPos - Vector2.One * Range, drawPos + Vector2.One * Range, Color);
|
||||
GUI.DrawLine(spriteBatch, drawPos - new Vector2(1.0f, -1.0f) * Range, drawPos + new Vector2(1.0f, -1.0f) * Range, Color);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.IO;
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(WorldPosition.X, -WorldPosition.Y),
|
||||
new Vector2(e.WorldPosition.X, -e.WorldPosition.Y),
|
||||
isLinkAllowed ? GUI.Style.Green * 0.5f : GUI.Style.Red * 0.5f, width: 3);
|
||||
isLinkAllowed ? GUIStyle.Green * 0.5f : GUIStyle.Red * 0.5f, width: 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Vector2 drawPos, float alpha = 1.0f)
|
||||
{
|
||||
Color color = (IsHighlighted) ? GUI.Style.Orange : GUI.Style.Green;
|
||||
if (IsSelected) { color = GUI.Style.Red; }
|
||||
Color color = (IsHighlighted) ? GUIStyle.Orange : GUIStyle.Green;
|
||||
if (IsSelected) { color = GUIStyle.Red; }
|
||||
|
||||
Vector2 pos = drawPos;
|
||||
|
||||
@@ -98,16 +98,16 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("LinkedSub"), font: GUI.LargeFont);
|
||||
TextManager.Get("LinkedSub"), font: GUIStyle.LargeFont);
|
||||
|
||||
if (!inGame)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("LinkLinkedSub"), textColor: GUI.Style.Orange, font: GUI.SmallFont);
|
||||
TextManager.Get("LinkLinkedSub"), textColor: GUIStyle.Orange, font: GUIStyle.SmallFont);
|
||||
}
|
||||
|
||||
var pathContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), isHorizontal: true);
|
||||
var pathBox = new GUITextBox(new RectTransform(new Vector2(0.75f, 1.0f), pathContainer.RectTransform), filePath, font: GUI.SmallFont);
|
||||
var pathBox = new GUITextBox(new RectTransform(new Vector2(0.75f, 1.0f), pathContainer.RectTransform), filePath, font: GUIStyle.SmallFont);
|
||||
var reloadButton = new GUIButton(new RectTransform(new Vector2(0.25f / pathBox.RectTransform.RelativeSize.X, 1.0f), pathBox.RectTransform, Anchor.CenterRight, Pivot.CenterLeft),
|
||||
TextManager.Get("ReloadLinkedSub"), style: "GUIButtonSmall")
|
||||
{
|
||||
@@ -132,20 +132,21 @@ namespace Barotrauma
|
||||
if (!File.Exists(pathBox.Text))
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariable("ReloadLinkedSubError", "[file]", pathBox.Text));
|
||||
pathBox.Flash(GUI.Style.Red);
|
||||
pathBox.Flash(GUIStyle.Red);
|
||||
pathBox.Text = filePath;
|
||||
return false;
|
||||
}
|
||||
|
||||
XDocument doc = SubmarineInfo.OpenFile(pathBox.Text);
|
||||
if (doc == null || doc.Root == null) return false;
|
||||
if (doc == null || doc.Root == null) { return false; }
|
||||
doc.Root.SetAttributeValue("filepath", pathBox.Text);
|
||||
|
||||
pathBox.Flash(GUI.Style.Green);
|
||||
pathBox.Flash(GUIStyle.Green);
|
||||
|
||||
GenerateWallVertices(doc.Root);
|
||||
saveElement = doc.Root;
|
||||
saveElement.Name = "LinkedSubmarine";
|
||||
CargoCapacity = doc.Root.GetAttributeInt("cargocapacity", 0);
|
||||
|
||||
filePath = pathBox.Text;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
@@ -65,10 +66,7 @@ namespace Barotrauma
|
||||
|
||||
private float connectionHighlightState;
|
||||
|
||||
private (Rectangle targetArea, string tip)? tooltip;
|
||||
private string sanitizedTooltip;
|
||||
private List<RichTextData> tooltipRichTextData;
|
||||
private string prevTooltip;
|
||||
private (Rectangle targetArea, RichString tip)? tooltip;
|
||||
|
||||
private (SubmarineInfo pendingSub, float realWorldCrushDepth) pendingSubInfo;
|
||||
|
||||
@@ -136,7 +134,7 @@ namespace Barotrauma
|
||||
for (int y = 0; y < tilesY; y++)
|
||||
{
|
||||
var biome = GetBiome(x * tileSize.X);
|
||||
List<Sprite> tileList = null;
|
||||
ImmutableArray<Sprite> tileList;
|
||||
if (generationParams.MapTiles.ContainsKey(biome.Identifier))
|
||||
{
|
||||
tileList = generationParams.MapTiles[biome.Identifier];
|
||||
@@ -146,7 +144,7 @@ namespace Barotrauma
|
||||
tileList = generationParams.MapTiles.Values.First();
|
||||
missingBiomes.Add(biome);
|
||||
}
|
||||
mapTiles[x, y] = tileList[x % tileList.Count];
|
||||
mapTiles[x, y] = tileList[x % tileList.Length];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +206,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (location == null) { return; }
|
||||
|
||||
var mapTile = generationParams.MapTiles.Values.FirstOrDefault()?.FirstOrDefault();
|
||||
var mapTile = generationParams.MapTiles.Values.FirstOrDefault().FirstOrDefault();
|
||||
if (mapTile == null) { return; }
|
||||
|
||||
Vector2 mapTileSize = mapTile.size * generationParams.MapTileScale;
|
||||
@@ -253,12 +251,12 @@ namespace Barotrauma
|
||||
location.LastTypeChangeMessage = msg;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.AddChatMessage(msg, Networking.ChatMessageType.Default, TextManager.Get("RadioAnnouncerName"));
|
||||
GameMain.Client.AddChatMessage(msg, Networking.ChatMessageType.Default, TextManager.Get("RadioAnnouncerName").Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.GameSession?.GameMode.CrewManager.AddSinglePlayerChatMessage(
|
||||
TextManager.Get("RadioAnnouncerName"),
|
||||
TextManager.Get("RadioAnnouncerName").Value,
|
||||
msg,
|
||||
Networking.ChatMessageType.Default,
|
||||
sender: null);
|
||||
@@ -617,7 +615,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 typeChangeIconPos = pos + new Vector2(1.35f, -0.35f) * generationParams.LocationIconSize * 0.5f * zoom;
|
||||
float typeChangeIconScale = 18.0f / generationParams.TypeChangeIcon.SourceRect.Width;
|
||||
generationParams.TypeChangeIcon.Draw(spriteBatch, typeChangeIconPos, GUI.Style.Red, scale: typeChangeIconScale * zoom);
|
||||
generationParams.TypeChangeIcon.Draw(spriteBatch, typeChangeIconPos, GUIStyle.Red, scale: typeChangeIconScale * zoom);
|
||||
if (Vector2.Distance(PlayerInput.MousePosition, typeChangeIconPos) < generationParams.TypeChangeIcon.SourceRect.Width * zoom &&
|
||||
(tooltip == null || IsPreferredTooltip(typeChangeIconPos)))
|
||||
{
|
||||
@@ -646,8 +644,8 @@ namespace Barotrauma
|
||||
Vector2 dPos = pos;
|
||||
dPos.Y += 48;
|
||||
string name = $"Reputation: {location.Name}";
|
||||
Vector2 nameSize = GUI.SmallFont.MeasureString(name);
|
||||
GUI.DrawString(spriteBatch, dPos, name, Color.White, Color.Black * 0.8f, 4, font: GUI.SmallFont);
|
||||
Vector2 nameSize = GUIStyle.SmallFont.MeasureString(name);
|
||||
GUI.DrawString(spriteBatch, dPos, name, Color.White, Color.Black * 0.8f, 4, font: GUIStyle.SmallFont);
|
||||
dPos.Y += nameSize.Y + 16;
|
||||
|
||||
Rectangle bgRect = new Rectangle((int)dPos.X, (int)dPos.Y, 256, 32);
|
||||
@@ -656,8 +654,8 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, bgRect, Color.Black * 0.8f, isFilled: true);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)dPos.X, (int)dPos.Y, (int)(location.Reputation.NormalizedValue * 255), 32), barColor, isFilled: true);
|
||||
string reputationValue = ((int)location.Reputation.Value).ToString();
|
||||
Vector2 repValueSize = GUI.SubHeadingFont.MeasureString(reputationValue);
|
||||
GUI.DrawString(spriteBatch, dPos + (new Vector2(256, 32) / 2) - (repValueSize / 2), reputationValue, Color.White, Color.Black, font: GUI.SubHeadingFont);
|
||||
Vector2 repValueSize = GUIStyle.SubHeadingFont.MeasureString(reputationValue);
|
||||
GUI.DrawString(spriteBatch, dPos + (new Vector2(256, 32) / 2) - (repValueSize / 2), reputationValue, Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)dPos.X, (int)dPos.Y, 256, 32), Color.White);
|
||||
}
|
||||
}
|
||||
@@ -670,12 +668,7 @@ namespace Barotrauma
|
||||
|
||||
if (tooltip != null)
|
||||
{
|
||||
if (tooltip.Value.tip != prevTooltip)
|
||||
{
|
||||
prevTooltip = tooltip.Value.tip;
|
||||
tooltipRichTextData = RichTextData.GetRichTextData(tooltip.Value.tip, out sanitizedTooltip);
|
||||
}
|
||||
GUIComponent.DrawToolTip(spriteBatch, sanitizedTooltip, tooltip.Value.targetArea, tooltipRichTextData);
|
||||
GUIComponent.DrawToolTip(spriteBatch, tooltip.Value.tip, tooltip.Value.targetArea);
|
||||
drawRadiationTooltip = false;
|
||||
}
|
||||
else if (HighlightedLocation != null)
|
||||
@@ -685,35 +678,35 @@ namespace Barotrauma
|
||||
pos.X += 50 * zoom;
|
||||
pos.X = (int)pos.X;
|
||||
pos.Y = (int)pos.Y;
|
||||
Vector2 nameSize = GUI.LargeFont.MeasureString(HighlightedLocation.Name);
|
||||
Vector2 typeSize = string.IsNullOrEmpty(HighlightedLocation.Type.Name) ? Vector2.Zero : GUI.Font.MeasureString(HighlightedLocation.Type.Name);
|
||||
Vector2 nameSize = GUIStyle.LargeFont.MeasureString(HighlightedLocation.Name);
|
||||
Vector2 typeSize = HighlightedLocation.Type.Name.IsNullOrEmpty() ? Vector2.Zero : GUIStyle.Font.MeasureString(HighlightedLocation.Type.Name);
|
||||
Vector2 size = new Vector2(Math.Max(nameSize.X, typeSize.X), nameSize.Y + typeSize.Y);
|
||||
bool showReputation = hudVisibility > 0.0f && HighlightedLocation.Discovered && HighlightedLocation.Type.HasOutpost && HighlightedLocation.Reputation != null;
|
||||
string repLabelText = null, repValueText = null;
|
||||
LocalizedString repLabelText = null, repValueText = null;
|
||||
Vector2 repLabelSize = Vector2.Zero, repBarSize = Vector2.Zero;
|
||||
if (showReputation)
|
||||
{
|
||||
repLabelText = TextManager.Get("reputation");
|
||||
repLabelSize = GUI.Font.MeasureString(repLabelText);
|
||||
repLabelSize = GUIStyle.Font.MeasureString(repLabelText);
|
||||
repBarSize = new Vector2(GUI.IntScale(200), repLabelSize.Y);
|
||||
size.Y += 2 * repLabelSize.Y + GUI.IntScale(5) + repBarSize.Y;
|
||||
repValueText = HighlightedLocation.Reputation.GetFormattedReputationText(addColorTags: false);
|
||||
size.X = Math.Max(size.X, repBarSize.X + GUI.Font.MeasureString(repValueText).X + GUI.IntScale(10));
|
||||
size.X = Math.Max(size.X, repBarSize.X + GUIStyle.Font.MeasureString(repValueText).X + GUI.IntScale(10));
|
||||
}
|
||||
GUI.Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0].Draw(
|
||||
GUIStyle.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0].Draw(
|
||||
spriteBatch, new Rectangle((int)(pos.X - 60 * GUI.Scale), (int)(pos.Y - size.Y), (int)(size.X + 120 * GUI.Scale), (int)(size.Y * 2.2f)), Color.Black * hudVisibility);
|
||||
var topLeftPos = pos - new Vector2(0.0f, size.Y / 2);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, HighlightedLocation.Name, GUI.Style.TextColor * hudVisibility * 1.5f, font: GUI.LargeFont);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, HighlightedLocation.Name, GUIStyle.TextColorNormal * hudVisibility * 1.5f, font: GUIStyle.LargeFont);
|
||||
topLeftPos += new Vector2(0.0f, nameSize.Y);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, HighlightedLocation.Type.Name, GUI.Style.TextColor * hudVisibility * 1.5f);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, HighlightedLocation.Type.Name, GUIStyle.TextColorNormal * hudVisibility * 1.5f);
|
||||
if (showReputation)
|
||||
{
|
||||
topLeftPos += new Vector2(0.0f, typeSize.Y + repLabelSize.Y);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, repLabelText, GUI.Style.TextColor * hudVisibility * 1.5f);
|
||||
GUI.DrawString(spriteBatch, topLeftPos, repLabelText.Value, GUIStyle.TextColorNormal * hudVisibility * 1.5f);
|
||||
topLeftPos += new Vector2(0.0f, repLabelSize.Y + GUI.IntScale(10));
|
||||
Rectangle repBarRect = new Rectangle(new Point((int)topLeftPos.X, (int)topLeftPos.Y), new Point((int)repBarSize.X, (int)repBarSize.Y));
|
||||
RoundSummary.DrawReputationBar(spriteBatch, repBarRect, HighlightedLocation.Reputation.NormalizedValue);
|
||||
GUI.DrawString(spriteBatch, new Vector2(repBarRect.Right + GUI.IntScale(5), repBarRect.Top), repValueText, Reputation.GetReputationColor(HighlightedLocation.Reputation.NormalizedValue));
|
||||
GUI.DrawString(spriteBatch, new Vector2(repBarRect.Right + GUI.IntScale(5), repBarRect.Top), repValueText.Value, Reputation.GetReputationColor(HighlightedLocation.Reputation.NormalizedValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +756,7 @@ namespace Barotrauma
|
||||
generationParams.SmallLevelConnectionLength,
|
||||
generationParams.LargeLevelConnectionLength,
|
||||
connection.Length);
|
||||
connectionColor = ToolBox.GradientLerp(sizeFactor, Color.LightGreen, GUI.Style.Orange, GUI.Style.Red);
|
||||
connectionColor = ToolBox.GradientLerp(sizeFactor, Color.LightGreen, GUIStyle.Orange, GUIStyle.Red);
|
||||
}
|
||||
else if (overrideColor.HasValue)
|
||||
{
|
||||
@@ -894,14 +887,14 @@ namespace Barotrauma
|
||||
}
|
||||
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
|
||||
{
|
||||
var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth");
|
||||
var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth".ToIdentifier());
|
||||
if (hullUpgradePrefab != null)
|
||||
{
|
||||
int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
|
||||
int currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
|
||||
if (pendingLevel > currentLevel)
|
||||
{
|
||||
string updateValueStr = hullUpgradePrefab.SourceElement?.Element("Structure")?.GetAttributeString("crushdepth", null);
|
||||
string updateValueStr = hullUpgradePrefab.SourceElement?.GetChildElement("Structure")?.GetAttributeString("crushdepth", null);
|
||||
if (!string.IsNullOrEmpty(updateValueStr))
|
||||
{
|
||||
subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel - currentLevel, updateValueStr);
|
||||
@@ -934,8 +927,8 @@ namespace Barotrauma
|
||||
{
|
||||
var gateLocation = connection.Locations[0].IsGateBetweenBiomes ? connection.Locations[0] : connection.Locations[1];
|
||||
var unlockEvent =
|
||||
EventSet.PrefabList.Find(ep => ep.UnlockPathEvent && ep.BiomeIdentifier == gateLocation.LevelData.Biome.Identifier) ??
|
||||
EventSet.PrefabList.Find(ep => ep.UnlockPathEvent && string.IsNullOrEmpty(ep.BiomeIdentifier));
|
||||
EventPrefab.Prefabs.FirstOrDefault(ep => ep.UnlockPathEvent && ep.BiomeIdentifier == gateLocation.LevelData.Biome.Identifier) ??
|
||||
EventPrefab.Prefabs.FirstOrDefault(ep => ep.UnlockPathEvent && ep.BiomeIdentifier == Identifier.Empty);
|
||||
|
||||
if (unlockEvent != null)
|
||||
{
|
||||
@@ -943,15 +936,15 @@ namespace Barotrauma
|
||||
Faction unlockFaction = null;
|
||||
if (!string.IsNullOrEmpty(unlockEvent.UnlockPathFaction))
|
||||
{
|
||||
unlockFaction = GameMain.GameSession.Campaign.Factions.Find(f => f.Prefab.Identifier.Equals(unlockEvent.UnlockPathFaction, StringComparison.OrdinalIgnoreCase));
|
||||
unlockFaction = GameMain.GameSession.Campaign.Factions.Find(f => f.Prefab.Identifier == unlockEvent.UnlockPathFaction);
|
||||
unlockReputation = unlockFaction?.Reputation;
|
||||
}
|
||||
|
||||
DrawIcon(
|
||||
"LockedLocationConnection", (int)(28 * zoom),
|
||||
TextManager.GetWithVariables(unlockEvent.UnlockPathTooltip ?? "LockedPathTooltip",
|
||||
new string[] { "[requiredreputation]", "[currentreputation]" },
|
||||
new string[] { Reputation.GetFormattedReputationText(MathUtils.InverseLerp(unlockReputation.MinReputation, unlockReputation.MaxReputation, unlockEvent.UnlockPathReputation), unlockEvent.UnlockPathReputation, addColorTags: true), unlockReputation.GetFormattedReputationText(addColorTags: true) }));
|
||||
("[requiredreputation]", Reputation.GetFormattedReputationText(MathUtils.InverseLerp(unlockReputation.MinReputation, unlockReputation.MaxReputation, unlockEvent.UnlockPathReputation), unlockEvent.UnlockPathReputation, addColorTags: true)),
|
||||
("[currentreputation]", unlockReputation.GetFormattedReputationText(addColorTags: true))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -968,9 +961,9 @@ namespace Barotrauma
|
||||
if (crushDepthWarningIconStyle != null)
|
||||
{
|
||||
DrawIcon(crushDepthWarningIconStyle, (int)(32 * zoom),
|
||||
TextManager.Get(tooltip)
|
||||
.Replace("[initialdepth]", $"‖color:gui.orange‖{(int)(connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio)}‖end‖")
|
||||
.Replace("[submarinecrushdepth]", $"‖color:gui.orange‖{(int)subCrushDepth}‖end‖"));
|
||||
RichString.Rich(TextManager.GetWithVariables(tooltip,
|
||||
("[initialdepth]", $"‖color:gui.orange‖{(int)(connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio)}‖end‖"),
|
||||
("[submarinecrushdepth]", $"‖color:gui.orange‖{(int)subCrushDepth}‖end‖"))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,14 +976,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
void DrawIcon(string iconStyle, int iconSize, string tooltipText)
|
||||
void DrawIcon(string iconStyle, int iconSize, LocalizedString tooltipText)
|
||||
{
|
||||
Vector2 iconPos = (connectionStart.Value + connectionEnd.Value) / 2;
|
||||
Vector2 iconDiff = Vector2.Normalize(connectionEnd.Value - connectionStart.Value) * iconSize;
|
||||
|
||||
iconPos += (iconDiff * -(iconCount - 1) / 2.0f) + iconDiff * iconIndex;
|
||||
|
||||
var style = GUI.Style.GetComponentStyle(iconStyle);
|
||||
var style = GUIStyle.GetComponentStyle(iconStyle);
|
||||
bool mouseOn = Vector2.DistanceSquared(iconPos, PlayerInput.MousePosition) < iconSize * iconSize && IsPreferredTooltip(iconPos);
|
||||
Sprite iconSprite = style.GetDefaultSprite();
|
||||
iconSprite.Draw(spriteBatch, iconPos, (mouseOn ? style.HoverColor : style.Color) * 0.7f,
|
||||
@@ -1018,10 +1011,10 @@ namespace Barotrauma
|
||||
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(rect.Right - GUI.IntScale(170), rect.Y + GUI.IntScale(5)),
|
||||
"JOVIAN FLUX " + ((cameraNoiseStrength + Rand.Range(-0.02f, 0.02f)) * 500), generationParams.IndicatorColor * hudVisibility, font: GUI.SmallFont);
|
||||
"JOVIAN FLUX " + ((cameraNoiseStrength + Rand.Range(-0.02f, 0.02f)) * 500), generationParams.IndicatorColor * hudVisibility, font: GUIStyle.SmallFont);
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(rect.X + GUI.IntScale(15), rect.Bottom - GUI.IntScale(25)),
|
||||
"LAT " + (-DrawOffset.Y / 100.0f) + " LON " + (-DrawOffset.X / 100.0f), generationParams.IndicatorColor * hudVisibility, font: GUI.SmallFont);
|
||||
"LAT " + (-DrawOffset.Y / 100.0f) + " LON " + (-DrawOffset.X / 100.0f), generationParams.IndicatorColor * hudVisibility, font: GUIStyle.SmallFont);
|
||||
}
|
||||
|
||||
private void UpdateMapAnim(MapAnim anim, float deltaTime)
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Barotrauma
|
||||
{
|
||||
internal partial class Radiation
|
||||
{
|
||||
private static readonly string radiationTooltip = TextManager.Get("RadiationTooltip");
|
||||
private static readonly LocalizedString radiationTooltip = TextManager.Get("RadiationTooltip");
|
||||
private static float spriteIndex;
|
||||
private readonly SpriteSheet sheet = GUI.Style.RadiationAnimSpriteSheet;
|
||||
private readonly SpriteSheet sheet = GUIStyle.RadiationAnimSpriteSheet;
|
||||
private int maxFrames => sheet.FrameCount + 1;
|
||||
|
||||
private bool isHovingOver;
|
||||
@@ -18,7 +18,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Enabled) { return; }
|
||||
|
||||
UISprite uiSprite = GUI.Style.RadiationSprite;
|
||||
UISprite uiSprite = GUIStyle.Radiation;
|
||||
var (offsetX, offsetY) = Map.DrawOffset * zoom;
|
||||
var (centerX, centerY) = container.Center.ToVector2();
|
||||
var (halfSizeX, halfSizeY) = new Vector2(container.Width / 2f, container.Height / 2f) * zoom;
|
||||
|
||||
@@ -610,7 +610,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (MapEntity entity in highlightedEntities)
|
||||
{
|
||||
var tooltip = string.Empty;
|
||||
LocalizedString tooltip = string.Empty;
|
||||
|
||||
if (wiringMode && entity is Item item)
|
||||
{
|
||||
@@ -622,9 +622,9 @@ namespace Barotrauma
|
||||
var conn = wire.Connections[i];
|
||||
if (conn != null)
|
||||
{
|
||||
string[] tags = { "[item]", "[pin]" };
|
||||
string[] values = { conn.Item?.Name, conn.Name };
|
||||
tooltip += TextManager.GetWithVariables("wirelistformat",tags , values);
|
||||
tooltip += TextManager.GetWithVariables("wirelistformat",
|
||||
("[item]", conn.Item?.Name),
|
||||
("[pin]", conn.Name));
|
||||
}
|
||||
if (i != wire.Connections.Length - 1) { tooltip += '\n'; }
|
||||
}
|
||||
@@ -632,7 +632,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
var textBlock = new GUITextBlock(new RectTransform(new Point(highlightedListBox.Content.Rect.Width, 15), highlightedListBox.Content.RectTransform),
|
||||
ToolBox.LimitString(entity.Name, GUI.SmallFont, 140), font: GUI.SmallFont)
|
||||
ToolBox.LimitString(entity.Name, GUIStyle.SmallFont, 140), font: GUIStyle.SmallFont)
|
||||
{
|
||||
ToolTip = tooltip,
|
||||
UserData = entity
|
||||
@@ -803,7 +803,7 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
}
|
||||
e.prefab?.DrawPlacing(spriteBatch,
|
||||
e.Prefab?.DrawPlacing(spriteBatch,
|
||||
new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteEffects);
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(e.WorldRect.X, -e.WorldRect.Y) + moveAmount,
|
||||
@@ -830,7 +830,7 @@ namespace Barotrauma
|
||||
new Vector2(posX, posY + sizeY)
|
||||
};
|
||||
|
||||
Color selectionColor = GUI.Style.Blue;
|
||||
Color selectionColor = GUIStyle.Blue;
|
||||
float thickness = Math.Max(2f, 2f / Screen.Selected.Cam.Zoom);
|
||||
|
||||
GUI.DrawFilledRectangle(spriteBatch, corners[0], selectionSize, selectionColor * 0.1f);
|
||||
|
||||
@@ -5,15 +5,13 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
abstract partial class MapEntityPrefab : IPrefab, IDisposable
|
||||
abstract partial class MapEntityPrefab : PrefabWithUintIdentifier
|
||||
{
|
||||
public readonly Dictionary<string, List<DecorativeSprite>> UpgradeOverrideSprites = new Dictionary<string, List<DecorativeSprite>>();
|
||||
|
||||
public virtual void UpdatePlacing(Camera cam)
|
||||
{
|
||||
if (PlayerInput.SecondaryMouseButtonClicked())
|
||||
{
|
||||
selected = null;
|
||||
Selected = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +45,7 @@ namespace Barotrauma
|
||||
placePosition = Vector2.Zero;
|
||||
if (!PlayerInput.IsShiftDown())
|
||||
{
|
||||
selected = null;
|
||||
Selected = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +95,7 @@ namespace Barotrauma
|
||||
}
|
||||
public void DrawListLine(SpriteBatch spriteBatch, Vector2 pos, Color color)
|
||||
{
|
||||
GUI.Font.DrawString(spriteBatch, originalName, pos, color);
|
||||
GUIStyle.Font.DrawString(spriteBatch, OriginalName, pos, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Sounds;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class RoundSound
|
||||
{
|
||||
public Sound? Sound;
|
||||
public readonly float Volume;
|
||||
public readonly float Range;
|
||||
public readonly Vector2 FrequencyMultiplierRange;
|
||||
public readonly bool Stream;
|
||||
public readonly bool IgnoreMuffling;
|
||||
|
||||
public readonly string? Filename;
|
||||
|
||||
private RoundSound(ContentXElement element, Sound sound)
|
||||
{
|
||||
Filename = sound.Filename;
|
||||
Sound = sound;
|
||||
Stream = sound.Stream;
|
||||
Range = element.GetAttributeFloat("range", 1000.0f);
|
||||
Volume = element.GetAttributeFloat("volume", 1.0f);
|
||||
FrequencyMultiplierRange = new Vector2(1.0f);
|
||||
string freqMultAttr = element.GetAttributeString("frequencymultiplier", element.GetAttributeString("frequency", "1.0"))!;
|
||||
if (!freqMultAttr.Contains(','))
|
||||
{
|
||||
if (float.TryParse(freqMultAttr, NumberStyles.Any, CultureInfo.InvariantCulture, out float freqMult))
|
||||
{
|
||||
FrequencyMultiplierRange = new Vector2(freqMult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var freqMult = XMLExtensions.ParseVector2(freqMultAttr, false);
|
||||
if (freqMult.Y >= 0.25f)
|
||||
{
|
||||
FrequencyMultiplierRange = freqMult;
|
||||
}
|
||||
}
|
||||
if (FrequencyMultiplierRange.Y > 4.0f)
|
||||
{
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")");
|
||||
}
|
||||
IgnoreMuffling = element.GetAttributeBool("dontmuffle", false);
|
||||
}
|
||||
|
||||
public float GetRandomFrequencyMultiplier()
|
||||
{
|
||||
return Rand.Range(FrequencyMultiplierRange.X, FrequencyMultiplierRange.Y);
|
||||
}
|
||||
|
||||
private static readonly List<RoundSound> roundSounds = new List<RoundSound>();
|
||||
public static RoundSound? Load(ContentXElement element, bool stream = false)
|
||||
{
|
||||
if (GameMain.SoundManager?.Disabled ?? true) { return null; }
|
||||
|
||||
var filename = element.GetAttributeContentPath("file") ?? element.GetAttributeContentPath("sound");
|
||||
|
||||
if (filename is null)
|
||||
{
|
||||
string errorMsg = "Error when loading round sound (" + element + ") - file path not set";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FilePathEmpty" + element.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
|
||||
Sound? existingSound = roundSounds.Find(s => s.Filename == filename?.FullPath && s.Stream == stream && s.Sound is { Disposed: false })?.Sound;
|
||||
|
||||
if (existingSound is null)
|
||||
{
|
||||
try
|
||||
{
|
||||
existingSound = GameMain.SoundManager.LoadSound(filename?.FullPath, stream);
|
||||
if (existingSound == null) { return null; }
|
||||
}
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
RoundSound newSound = new RoundSound(element, existingSound);
|
||||
|
||||
roundSounds.Add(newSound);
|
||||
return newSound;
|
||||
}
|
||||
|
||||
public static void Reload(RoundSound roundSound)
|
||||
{
|
||||
Sound? existingSound = roundSounds.Find(s => s.Filename == roundSound.Filename && s.Stream == roundSound.Stream && s.Sound is { Disposed: false })?.Sound;
|
||||
if (existingSound == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
existingSound = GameMain.SoundManager.LoadSound(roundSound.Filename, roundSound.Stream);
|
||||
}
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + roundSound.Filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + roundSound.Filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
}
|
||||
roundSound.Sound = existingSound;
|
||||
}
|
||||
|
||||
private static void Remove(RoundSound roundSound)
|
||||
{
|
||||
#warning TODO: what is going on here????
|
||||
roundSound.Sound?.Dispose();
|
||||
|
||||
if (roundSounds.Contains(roundSound)) { roundSounds.Remove(roundSound); }
|
||||
foreach (RoundSound otherSound in roundSounds)
|
||||
{
|
||||
if (otherSound.Sound == roundSound.Sound) { otherSound.Sound = null; }
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveAllRoundSounds()
|
||||
{
|
||||
for (int i = roundSounds.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Remove(roundSounds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GameMain.SubEditorScreen.IsSubcategoryHidden(prefab.Subcategory))
|
||||
if (GameMain.SubEditorScreen.IsSubcategoryHidden(Prefab.Subcategory))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -38,9 +38,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
[Editable, Serialize("", true)]
|
||||
[Editable, Serialize("", IsPropertySaveable.Yes)]
|
||||
#else
|
||||
[Serialize("", true)]
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
#endif
|
||||
public string SpecialTag
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
Prefab.sprite?.EnsureLazyLoaded();
|
||||
Prefab.Sprite?.EnsureLazyLoaded();
|
||||
Prefab.BackgroundSprite?.EnsureLazyLoaded();
|
||||
|
||||
foreach (var decorativeSprite in Prefab.DecorativeSprites)
|
||||
@@ -120,13 +120,13 @@ namespace Barotrauma
|
||||
{
|
||||
CanTakeKeyBoardFocus = false
|
||||
};
|
||||
var editor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont) { UserData = this };
|
||||
var editor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUIStyle.LargeFont) { UserData = this };
|
||||
|
||||
if (Submarine.MainSub?.Info?.Type == SubmarineType.OutpostModule)
|
||||
{
|
||||
GUITickBox tickBox = new GUITickBox(new RectTransform(new Point(listBox.Content.Rect.Width, 10)), TextManager.Get("sp.structure.removeiflinkedoutpostdoorinuse.name"))
|
||||
{
|
||||
Font = GUI.SmallFont,
|
||||
Font = GUIStyle.SmallFont,
|
||||
Selected = RemoveIfLinkedOutpostDoorInUse,
|
||||
ToolTip = TextManager.Get("sp.structure.removeiflinkedoutpostdoorinuse.description"),
|
||||
OnSelected = (tickBox) =>
|
||||
@@ -246,7 +246,7 @@ namespace Barotrauma
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (prefab.sprite == null) { return; }
|
||||
if (Prefab.Sprite == null) { return; }
|
||||
|
||||
if (editing)
|
||||
{
|
||||
@@ -265,17 +265,17 @@ namespace Barotrauma
|
||||
|
||||
private float GetRealDepth()
|
||||
{
|
||||
return SpriteDepthOverrideIsSet ? SpriteOverrideDepth : prefab.sprite.Depth;
|
||||
return SpriteDepthOverrideIsSet ? SpriteOverrideDepth : Prefab.Sprite.Depth;
|
||||
}
|
||||
|
||||
public float GetDrawDepth()
|
||||
{
|
||||
return GetDrawDepth(GetRealDepth(), prefab.sprite);
|
||||
return GetDrawDepth(GetRealDepth(), Prefab.Sprite);
|
||||
}
|
||||
|
||||
private void Draw(SpriteBatch spriteBatch, bool editing, bool back = true, Effect damageEffect = null)
|
||||
{
|
||||
if (prefab.sprite == null) { return; }
|
||||
if (Prefab.Sprite == null) { return; }
|
||||
if (editing)
|
||||
{
|
||||
if (!SubEditorScreen.IsLayerVisible(this)) { return; }
|
||||
@@ -284,7 +284,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (HiddenInGame) { return; }
|
||||
|
||||
Color color = IsIncludedInSelection && editing ? GUI.Style.Blue : IsHighlighted ? GUI.Style.Orange * Math.Max(spriteColor.A / (float) byte.MaxValue, 0.1f) : spriteColor;
|
||||
Color color = IsIncludedInSelection && editing ? GUIStyle.Blue : IsHighlighted ? GUIStyle.Orange * Math.Max(spriteColor.A / (float) byte.MaxValue, 0.1f) : spriteColor;
|
||||
|
||||
if (IsSelected && editing)
|
||||
{
|
||||
@@ -371,8 +371,8 @@ namespace Barotrauma
|
||||
|
||||
if (back == GetRealDepth() > 0.5f)
|
||||
{
|
||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||
prefab.sprite.effects ^= SpriteEffects;
|
||||
SpriteEffects oldEffects = Prefab.Sprite.effects;
|
||||
Prefab.Sprite.effects ^= SpriteEffects;
|
||||
|
||||
for (int i = 0; i < Sections.Length; i++)
|
||||
{
|
||||
@@ -410,10 +410,10 @@ namespace Barotrauma
|
||||
if (FlippedX && IsHorizontal) { sectionOffset.X = drawSection.Right - rect.Right; }
|
||||
if (FlippedY && !IsHorizontal) { sectionOffset.Y = (rect.Y - rect.Height) - (drawSection.Y - drawSection.Height); }
|
||||
|
||||
sectionOffset.X += MathUtils.PositiveModulo((int)-textureOffset.X, prefab.sprite.SourceRect.Width);
|
||||
sectionOffset.Y += MathUtils.PositiveModulo((int)-textureOffset.Y, prefab.sprite.SourceRect.Height);
|
||||
sectionOffset.X += MathUtils.PositiveModulo((int)-textureOffset.X, Prefab.Sprite.SourceRect.Width);
|
||||
sectionOffset.Y += MathUtils.PositiveModulo((int)-textureOffset.Y, Prefab.Sprite.SourceRect.Height);
|
||||
|
||||
prefab.sprite.DrawTiled(
|
||||
Prefab.Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(drawSection.X + drawOffset.X, -(drawSection.Y + drawOffset.Y)),
|
||||
new Vector2(drawSection.Width, drawSection.Height),
|
||||
@@ -429,10 +429,10 @@ namespace Barotrauma
|
||||
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier) * Scale;
|
||||
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
|
||||
rotation, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, prefab.sprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.sprite.Depth), 0.999f));
|
||||
rotation, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, Prefab.Sprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - Prefab.Sprite.Depth), 0.999f));
|
||||
}
|
||||
prefab.sprite.effects = oldEffects;
|
||||
Prefab.Sprite.effects = oldEffects;
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw && Screen.Selected.Cam.Zoom > 0.5f)
|
||||
@@ -473,13 +473,13 @@ namespace Barotrauma
|
||||
DecorativeSprite.UpdateSpriteStates(Prefab.DecorativeSpriteGroups, spriteAnimState, ID, deltaTime, ConditionalMatches);
|
||||
foreach (int spriteGroup in Prefab.DecorativeSpriteGroups.Keys)
|
||||
{
|
||||
for (int i = 0; i < Prefab.DecorativeSpriteGroups[spriteGroup].Count; i++)
|
||||
for (int i = 0; i < Prefab.DecorativeSpriteGroups[spriteGroup].Length; i++)
|
||||
{
|
||||
var decorativeSprite = Prefab.DecorativeSpriteGroups[spriteGroup][i];
|
||||
if (decorativeSprite == null) { continue; }
|
||||
if (spriteGroup > 0)
|
||||
{
|
||||
int activeSpriteIndex = ID % Prefab.DecorativeSpriteGroups[spriteGroup].Count;
|
||||
int activeSpriteIndex = ID % Prefab.DecorativeSpriteGroups[spriteGroup].Length;
|
||||
if (i != activeSpriteIndex)
|
||||
{
|
||||
spriteAnimState[decorativeSprite].IsActive = false;
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class StructurePrefab : MapEntityPrefab
|
||||
{
|
||||
public Color BackgroundSpriteColor
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public readonly Color BackgroundSpriteColor;
|
||||
|
||||
public List<DecorativeSprite> DecorativeSprites = new List<DecorativeSprite>();
|
||||
public Dictionary<int, List<DecorativeSprite>> DecorativeSpriteGroups = new Dictionary<int, List<DecorativeSprite>>();
|
||||
public readonly ImmutableArray<DecorativeSprite> DecorativeSprites;
|
||||
public readonly ImmutableDictionary<int, ImmutableArray<DecorativeSprite>> DecorativeSpriteGroups;
|
||||
|
||||
public override void UpdatePlacing(Camera cam)
|
||||
{
|
||||
if (PlayerInput.SecondaryMouseButtonClicked())
|
||||
{
|
||||
selected = null;
|
||||
Selected = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +62,7 @@ namespace Barotrauma
|
||||
placePosition = Vector2.Zero;
|
||||
if (!PlayerInput.IsShiftDown())
|
||||
{
|
||||
selected = null;
|
||||
Selected = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -91,24 +88,24 @@ namespace Barotrauma
|
||||
newRect = Submarine.AbsRect(placePosition, placeSize);
|
||||
}
|
||||
|
||||
sprite.DrawTiled(spriteBatch, new Vector2(newRect.X, -newRect.Y), new Vector2(newRect.Width, newRect.Height), textureScale: TextureScale * Scale);
|
||||
Sprite.DrawTiled(spriteBatch, new Vector2(newRect.X, -newRect.Y), new Vector2(newRect.Width, newRect.Height), textureScale: TextureScale * Scale);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth * 2, newRect.Height), Color.White);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight * 2), Color.White);
|
||||
}
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
SpriteEffects oldEffects = sprite.effects;
|
||||
sprite.effects ^= spriteEffects;
|
||||
SpriteEffects oldEffects = Sprite.effects;
|
||||
Sprite.effects ^= spriteEffects;
|
||||
|
||||
sprite.DrawTiled(
|
||||
Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(placeRect.X, -placeRect.Y),
|
||||
new Vector2(placeRect.Width, placeRect.Height),
|
||||
color: Color.White * 0.8f,
|
||||
textureScale: TextureScale * scale);
|
||||
|
||||
sprite.effects = oldEffects;
|
||||
Sprite.effects = oldEffects;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,58 +12,9 @@ using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Items.Components;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class RoundSound
|
||||
{
|
||||
public Sound Sound;
|
||||
public readonly float Volume;
|
||||
public readonly float Range;
|
||||
public readonly Vector2 FrequencyMultiplierRange;
|
||||
public readonly bool Stream;
|
||||
public readonly bool IgnoreMuffling;
|
||||
|
||||
public readonly string Filename;
|
||||
|
||||
public RoundSound(XElement element, Sound sound)
|
||||
{
|
||||
Filename = sound?.Filename;
|
||||
Sound = sound;
|
||||
Stream = sound.Stream;
|
||||
Range = element.GetAttributeFloat("range", 1000.0f);
|
||||
Volume = element.GetAttributeFloat("volume", 1.0f);
|
||||
FrequencyMultiplierRange = new Vector2(1.0f);
|
||||
string freqMultAttr = element.GetAttributeString("frequencymultiplier", element.GetAttributeString("frequency", "1.0"));
|
||||
if (!freqMultAttr.Contains(','))
|
||||
{
|
||||
if (float.TryParse(freqMultAttr, NumberStyles.Any, CultureInfo.InvariantCulture, out float freqMult))
|
||||
{
|
||||
FrequencyMultiplierRange = new Vector2(freqMult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var freqMult = XMLExtensions.ParseVector2(freqMultAttr, false);
|
||||
if (freqMult.Y >= 0.25f)
|
||||
{
|
||||
FrequencyMultiplierRange = freqMult;
|
||||
}
|
||||
}
|
||||
if (FrequencyMultiplierRange.Y > 4.0f)
|
||||
{
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")");
|
||||
}
|
||||
IgnoreMuffling = element.GetAttributeBool("dontmuffle", false);
|
||||
}
|
||||
|
||||
public float GetRandomFrequencyMultiplier()
|
||||
{
|
||||
return Rand.Range(FrequencyMultiplierRange.X, FrequencyMultiplierRange.Y);
|
||||
}
|
||||
}
|
||||
|
||||
partial class Submarine : Entity, IServerSerializable
|
||||
{
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub)
|
||||
@@ -82,97 +33,6 @@ namespace Barotrauma
|
||||
return worldGridPos;
|
||||
}
|
||||
|
||||
|
||||
private static List<RoundSound> roundSounds = null;
|
||||
public static RoundSound LoadRoundSound(XElement element, bool stream = false)
|
||||
{
|
||||
if (GameMain.SoundManager?.Disabled ?? true) { return null; }
|
||||
|
||||
string filename = element.GetAttributeString("file", "");
|
||||
if (string.IsNullOrEmpty(filename)) filename = element.GetAttributeString("sound", "");
|
||||
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
string errorMsg = "Error when loading round sound (" + element + ") - file path not set";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Submarine.LoadRoundSound:FilePathEmpty" + element.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
|
||||
filename = Path.GetFullPath(filename.CleanUpPath()).CleanUpPath();
|
||||
Sound existingSound = null;
|
||||
if (roundSounds == null)
|
||||
{
|
||||
roundSounds = new List<RoundSound>();
|
||||
}
|
||||
else
|
||||
{
|
||||
existingSound = roundSounds.Find(s => s.Filename == filename && s.Stream == stream && !s.Sound.Disposed)?.Sound;
|
||||
}
|
||||
|
||||
if (existingSound == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
existingSound = GameMain.SoundManager.LoadSound(filename, stream);
|
||||
if (existingSound == null) { return null; }
|
||||
}
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Submarine.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
RoundSound newSound = new RoundSound(element, existingSound);
|
||||
|
||||
roundSounds.Add(newSound);
|
||||
return newSound;
|
||||
}
|
||||
|
||||
public static void ReloadRoundSound(RoundSound roundSound)
|
||||
{
|
||||
Sound existingSound = roundSounds?.Find(s => s.Filename == roundSound.Filename && s.Stream == roundSound.Stream && !s.Sound.Disposed)?.Sound;
|
||||
if (existingSound == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
existingSound = GameMain.SoundManager.LoadSound(roundSound.Filename, roundSound.Stream);
|
||||
}
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + roundSound.Filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Submarine.LoadRoundSound:FileNotFound" + roundSound.Filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
}
|
||||
roundSound.Sound = existingSound;
|
||||
}
|
||||
|
||||
private static void RemoveRoundSound(RoundSound roundSound)
|
||||
{
|
||||
roundSound.Sound?.Dispose();
|
||||
if (roundSounds == null) return;
|
||||
|
||||
if (roundSounds.Contains(roundSound)) roundSounds.Remove(roundSound);
|
||||
foreach (RoundSound otherSound in roundSounds)
|
||||
{
|
||||
if (otherSound.Sound == roundSound.Sound) otherSound.Sound = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveAllRoundSounds()
|
||||
{
|
||||
if (roundSounds == null) return;
|
||||
for (int i = roundSounds.Count - 1; i >= 0; i--)
|
||||
{
|
||||
RemoveRoundSound(roundSounds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//drawing ----------------------------------------------------
|
||||
private static readonly HashSet<Submarine> visibleSubs = new HashSet<Submarine>();
|
||||
public static void CullEntities(Camera cam)
|
||||
@@ -402,7 +262,7 @@ namespace Barotrauma
|
||||
|
||||
var connectedSubs = GetConnectedSubs();
|
||||
|
||||
HashSet<Hull> hullList = Hull.hullList.Where(hull => hull.Submarine == this || connectedSubs.Contains(hull.Submarine)).Where(hull => !ignoreOutpost || IsEntityFoundOnThisSub(hull, true)).ToHashSet();
|
||||
HashSet<Hull> hullList = Hull.HullList.Where(hull => hull.Submarine == this || connectedSubs.Contains(hull.Submarine)).Where(hull => !ignoreOutpost || IsEntityFoundOnThisSub(hull, true)).ToHashSet();
|
||||
|
||||
Dictionary<Hull, HashSet<Hull>> combinedHulls = new Dictionary<Hull, HashSet<Hull>>();
|
||||
|
||||
@@ -592,23 +452,23 @@ namespace Barotrauma
|
||||
List<string> errorMsgs = new List<string>();
|
||||
List<SubEditorScreen.WarningType> warnings = new List<SubEditorScreen.WarningType>();
|
||||
|
||||
if (!Hull.hullList.Any())
|
||||
if (!Hull.HullList.Any())
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NoWaypoints))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NoHullsWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NoHullsWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NoHulls);
|
||||
}
|
||||
}
|
||||
|
||||
if (Info.Type != SubmarineType.OutpostModule ||
|
||||
(Info.OutpostModuleInfo?.ModuleFlags.Any(f => !f.Equals("hallwayvertical", StringComparison.OrdinalIgnoreCase) && !f.Equals("hallwayhorizontal", StringComparison.OrdinalIgnoreCase)) ?? true))
|
||||
if (Info.Type != SubmarineType.OutpostModule ||
|
||||
(Info.OutpostModuleInfo?.ModuleFlags.Any(f => f != "hallwayvertical" && f != "hallwayhorizontal") ?? true))
|
||||
{
|
||||
if (!WayPoint.WayPointList.Any(wp => wp.ShouldBeSaved && wp.SpawnType == SpawnType.Path))
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NoWaypoints))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NoWaypointsWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NoWaypointsWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NoWaypoints);
|
||||
}
|
||||
}
|
||||
@@ -623,7 +483,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.DisconnectedVents))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("DisconnectedVentsWarning"));
|
||||
errorMsgs.Add(TextManager.Get("DisconnectedVentsWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.DisconnectedVents);
|
||||
}
|
||||
break;
|
||||
@@ -634,7 +494,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NoHumanSpawnpoints))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NoHumanSpawnpointWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NoHumanSpawnpointWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NoHumanSpawnpoints);
|
||||
}
|
||||
}
|
||||
@@ -642,7 +502,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NoCargoSpawnpoints))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NoCargoSpawnpointWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NoCargoSpawnpointWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NoCargoSpawnpoints);
|
||||
}
|
||||
}
|
||||
@@ -650,7 +510,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NoBallastTag))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NoBallastTagsWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NoBallastTagsWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NoBallastTag);
|
||||
}
|
||||
}
|
||||
@@ -670,8 +530,8 @@ namespace Barotrauma
|
||||
if (doorLinks + wireCount > item.Connections[i].MaxWires)
|
||||
{
|
||||
errorMsgs.Add(TextManager.GetWithVariables("InsufficientFreeConnectionsWarning",
|
||||
new string[] { "[doorcount]", "[freeconnectioncount]" },
|
||||
new string[] { doorLinks.ToString(), (item.Connections[i].MaxWires - wireCount).ToString() }));
|
||||
("[doorcount]", doorLinks.ToString()),
|
||||
("[freeconnectioncount]", (item.Connections[i].MaxWires - wireCount).ToString())).Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -682,7 +542,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.NonLinkedGaps))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NonLinkedGapsWarning"));
|
||||
errorMsgs.Add(TextManager.Get("NonLinkedGapsWarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.NonLinkedGaps);
|
||||
}
|
||||
}
|
||||
@@ -698,7 +558,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!IsWarningSuppressed(SubEditorScreen.WarningType.TooManyLights))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("subeditor.shadowcastinglightswarning"));
|
||||
errorMsgs.Add(TextManager.Get("subeditor.shadowcastinglightswarning").Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.TooManyLights);
|
||||
}
|
||||
}
|
||||
@@ -746,7 +606,7 @@ namespace Barotrauma
|
||||
var msgBox = new GUIMessageBox(
|
||||
TextManager.Get("Warning"),
|
||||
TextManager.Get("FarAwayEntitiesWarning"),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
new LocalizedString[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
|
||||
msgBox.Buttons[0].OnClicked += (btn, obj) =>
|
||||
{
|
||||
|
||||
@@ -83,31 +83,31 @@ namespace Barotrauma
|
||||
Spacing = 5
|
||||
};
|
||||
|
||||
ScalableFont font = parent.Rect.Width < 350 ? GUI.SmallFont : GUI.Font;
|
||||
GUIFont font = parent.Rect.Width < 350 ? GUIStyle.SmallFont : GUIStyle.Font;
|
||||
|
||||
CreateSpecsWindow(descriptionBox, font, includeDescription: true);
|
||||
}
|
||||
|
||||
public void CreateSpecsWindow(GUIListBox parent, ScalableFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
|
||||
public void CreateSpecsWindow(GUIListBox parent, GUIFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
|
||||
{
|
||||
float leftPanelWidth = 0.6f;
|
||||
float rightPanelWidth = 0.4f / leftPanelWidth;
|
||||
string className = !HasTag(SubmarineTag.Shuttle) ? TextManager.Get($"submarineclass.{SubmarineClass}") : TextManager.Get("shuttle");
|
||||
LocalizedString className = !HasTag(SubmarineTag.Shuttle) ? TextManager.Get($"submarineclass.{SubmarineClass}") : TextManager.Get("shuttle");
|
||||
|
||||
int classHeight = (int)GUI.SubHeadingFont.MeasureString(className).Y;
|
||||
int classHeight = (int)GUIStyle.SubHeadingFont.MeasureString(className).Y;
|
||||
int leftPanelWidthInt = (int)(parent.Rect.Width * leftPanelWidth);
|
||||
|
||||
GUITextBlock submarineNameText = null;
|
||||
GUITextBlock submarineClassText = null;
|
||||
if (includeTitle)
|
||||
{
|
||||
int nameHeight = (int)GUI.LargeFont.MeasureString(DisplayName, true).Y;
|
||||
submarineNameText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, nameHeight + HUDLayoutSettings.Padding / 2), parent.Content.RectTransform), DisplayName, textAlignment: Alignment.CenterLeft, font: GUI.LargeFont) { CanBeFocused = false };
|
||||
int nameHeight = (int)GUIStyle.LargeFont.MeasureString(DisplayName, true).Y;
|
||||
submarineNameText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, nameHeight + HUDLayoutSettings.Padding / 2), parent.Content.RectTransform), DisplayName, textAlignment: Alignment.CenterLeft, font: GUIStyle.LargeFont) { CanBeFocused = false };
|
||||
submarineNameText.RectTransform.MinSize = new Point(0, (int)submarineNameText.TextSize.Y);
|
||||
}
|
||||
if (includeClass)
|
||||
{
|
||||
submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont) { CanBeFocused = false };
|
||||
submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUIStyle.SubHeadingFont) { CanBeFocused = false };
|
||||
submarineClassText.RectTransform.MinSize = new Point(0, (int)submarineClassText.TextSize.Y);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Barotrauma
|
||||
Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;
|
||||
if (realWorldDimensions != Vector2.Zero)
|
||||
{
|
||||
string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] { "[width]", "[height]" }, new string[2] { ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString() });
|
||||
LocalizedString dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", ("[width]", ((int)realWorldDimensions.X).ToString()), ("[height]", ((int)realWorldDimensions.Y).ToString()));
|
||||
var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
|
||||
TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
|
||||
{ CanBeFocused = false };
|
||||
@@ -134,7 +134,7 @@ namespace Barotrauma
|
||||
dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
|
||||
}
|
||||
|
||||
string cargoCapacityStr = CargoCapacity < 0 ? TextManager.Get("unknown") : TextManager.GetWithVariables("cargocapacityformat", new string[1] { "[cratecount]" }, new string[1] {CargoCapacity.ToString() });
|
||||
var cargoCapacityStr = CargoCapacity < 0 ? TextManager.Get("unknown") : TextManager.GetWithVariable("cargocapacityformat", "[cratecount]", CargoCapacity.ToString());
|
||||
var cargoCapacityText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
|
||||
TextManager.Get("cargocapacity"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
|
||||
{ CanBeFocused = false };
|
||||
@@ -200,11 +200,11 @@ namespace Barotrauma
|
||||
//space
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), parent.Content.RectTransform), style: null);
|
||||
|
||||
if (!string.IsNullOrEmpty(Description))
|
||||
if (!Description.IsNullOrEmpty())
|
||||
{
|
||||
var wsItemDesc = new GUITextBlock(new RectTransform(new Vector2(1, 0), parent.Content.RectTransform),
|
||||
TextManager.Get("SaveSubDialogDescription", fallBackTag: "WorkshopItemDescription"), font: GUI.Font, wrap: true)
|
||||
{ CanBeFocused = false, ForceUpperCase = true };
|
||||
TextManager.Get("SaveSubDialogDescription", "WorkshopItemDescription"), font: GUIStyle.Font, wrap: true)
|
||||
{ CanBeFocused = false, ForceUpperCase = ForceUpperCase.Yes };
|
||||
|
||||
descBlock = new GUITextBlock(new RectTransform(new Vector2(1, 0), parent.Content.RectTransform), Description, font: font, wrap: true)
|
||||
{
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace Barotrauma
|
||||
private class HullCollection
|
||||
{
|
||||
public readonly List<Rectangle> Rects;
|
||||
public readonly string Name;
|
||||
public readonly LocalizedString Name;
|
||||
|
||||
public HullCollection(string identifier)
|
||||
public HullCollection(Identifier identifier)
|
||||
{
|
||||
Rects = new List<Rectangle>();
|
||||
Name = TextManager.Get(identifier, returnNull: true) ?? identifier;
|
||||
Name = TextManager.Get(identifier).Fallback(identifier.Value);
|
||||
}
|
||||
|
||||
public void AddRect(XElement element)
|
||||
@@ -53,10 +53,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, HullCollection> hullCollections;
|
||||
private readonly Dictionary<Identifier,HullCollection> hullCollections;
|
||||
private readonly List<Door> doors;
|
||||
|
||||
|
||||
private static SubmarinePreview instance = null;
|
||||
|
||||
public static void Create(SubmarineInfo submarineInfo)
|
||||
@@ -78,7 +77,7 @@ namespace Barotrauma
|
||||
isDisposed = false;
|
||||
loadTask = null;
|
||||
|
||||
hullCollections = new Dictionary<string, HullCollection>();
|
||||
hullCollections = new Dictionary<Identifier, HullCollection>();
|
||||
doors = new List<Door>();
|
||||
|
||||
previewFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null);
|
||||
@@ -133,7 +132,7 @@ namespace Barotrauma
|
||||
};
|
||||
var topLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.97f, 5f / 7f), topContainer.RectTransform, Anchor.Center), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
|
||||
titleText = new GUITextBlock(new RectTransform(new Vector2(0.95f, 1f), topLayout.RectTransform), subInfo.DisplayName, font: GUI.LargeFont);
|
||||
titleText = new GUITextBlock(new RectTransform(new Vector2(0.95f, 1f), topLayout.RectTransform), subInfo.DisplayName, font: GUIStyle.LargeFont);
|
||||
new GUIButton(new RectTransform(new Vector2(0.05f, 1f), topLayout.RectTransform), TextManager.Get("Close"))
|
||||
{
|
||||
OnClicked = (btn, obj) => { Dispose(); return false; }
|
||||
@@ -146,7 +145,7 @@ namespace Barotrauma
|
||||
ScrollBarVisible = false,
|
||||
Spacing = 5
|
||||
};
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUI.Font, includeTitle: false, includeDescription: true);
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUIStyle.Font, includeTitle: false, includeDescription: true);
|
||||
int width = specsContainer.Rect.Width;
|
||||
void recalculateSpecsContainerHeight()
|
||||
{
|
||||
@@ -242,8 +241,8 @@ namespace Barotrauma
|
||||
BakeMapEntity(subElement);
|
||||
break;
|
||||
case "hull":
|
||||
string identifier = subElement.GetAttributeString("roomname", "").ToLowerInvariant();
|
||||
if (!string.IsNullOrEmpty(identifier))
|
||||
Identifier identifier = subElement.GetAttributeIdentifier("roomname", "");
|
||||
if (!identifier.IsEmpty)
|
||||
{
|
||||
if (!hullCollections.TryGetValue(identifier, out HullCollection hullCollection))
|
||||
{
|
||||
@@ -309,11 +308,11 @@ namespace Barotrauma
|
||||
|
||||
float rotation = element.GetAttributeFloat("rotation", 0f);
|
||||
|
||||
MapEntityPrefab prefab = MapEntityPrefab.List.FirstOrDefault(p => p.Identifier.Equals(identifier, StringComparison.OrdinalIgnoreCase));
|
||||
MapEntityPrefab prefab = MapEntityPrefab.List.FirstOrDefault(p => p.Identifier == identifier);
|
||||
if (prefab == null) { return; }
|
||||
|
||||
var texture = prefab.sprite.Texture;
|
||||
var srcRect = prefab.sprite.SourceRect;
|
||||
var texture = prefab.Sprite.Texture;
|
||||
var srcRect = prefab.Sprite.SourceRect;
|
||||
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
if (flippedX && ((prefab as ItemPrefab)?.CanSpriteFlipX ?? true))
|
||||
@@ -325,8 +324,8 @@ namespace Barotrauma
|
||||
spriteEffects |= SpriteEffects.FlipVertically;
|
||||
}
|
||||
|
||||
var prevEffects = prefab.sprite.effects;
|
||||
prefab.sprite.effects ^= spriteEffects;
|
||||
var prevEffects = prefab.Sprite.effects;
|
||||
prefab.Sprite.effects ^= spriteEffects;
|
||||
|
||||
bool overrideSprite = false;
|
||||
ItemPrefab itemPrefab = prefab as ItemPrefab;
|
||||
@@ -359,10 +358,10 @@ namespace Barotrauma
|
||||
if (flippedY) { textureOffset.Y = -textureOffset.Y; }
|
||||
|
||||
backGroundOffset = new Vector2(
|
||||
MathUtils.PositiveModulo((int)-textureOffset.X, prefab.sprite.SourceRect.Width),
|
||||
MathUtils.PositiveModulo((int)-textureOffset.Y, prefab.sprite.SourceRect.Height));
|
||||
MathUtils.PositiveModulo((int)-textureOffset.X, prefab.Sprite.SourceRect.Width),
|
||||
MathUtils.PositiveModulo((int)-textureOffset.Y, prefab.Sprite.SourceRect.Height));
|
||||
|
||||
prefab.sprite.DrawTiled(
|
||||
prefab.Sprite.DrawTiled(
|
||||
spriteRecorder,
|
||||
rect.Location.ToVector2() * new Vector2(1f, -1f),
|
||||
rect.Size.ToVector2(),
|
||||
@@ -385,17 +384,17 @@ namespace Barotrauma
|
||||
{
|
||||
if (!prefab.ResizeHorizontal)
|
||||
{
|
||||
rect.Width = (int)(prefab.sprite.size.X * scale);
|
||||
rect.Width = (int)(prefab.Sprite.size.X * scale);
|
||||
}
|
||||
if (!prefab.ResizeVertical)
|
||||
{
|
||||
rect.Height = (int)(prefab.sprite.size.Y * scale);
|
||||
rect.Height = (int)(prefab.Sprite.size.Y * scale);
|
||||
}
|
||||
|
||||
var spritePos = rect.Center.ToVector2();
|
||||
//spritePos.Y = rect.Height - spritePos.Y;
|
||||
|
||||
prefab.sprite.DrawTiled(
|
||||
prefab.Sprite.DrawTiled(
|
||||
spriteRecorder,
|
||||
rect.Location.ToVector2() * new Vector2(1f, -1f),
|
||||
rect.Size.ToVector2(),
|
||||
@@ -413,7 +412,7 @@ namespace Barotrauma
|
||||
new Vector2(spritePos.X + offset.X - rect.Width / 2, -(spritePos.Y + offset.Y + rect.Height / 2)),
|
||||
rect.Size.ToVector2(), color: color,
|
||||
textureScale: Vector2.One * scale,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.sprite.Depth), 0.999f));
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.Sprite.Depth), 0.999f));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -425,14 +424,14 @@ namespace Barotrauma
|
||||
spritePos.Y -= rect.Height;
|
||||
//spritePos.Y = rect.Height - spritePos.Y;
|
||||
|
||||
prefab.sprite.Draw(
|
||||
prefab.Sprite.Draw(
|
||||
spriteRecorder,
|
||||
spritePos * new Vector2(1f, -1f),
|
||||
color,
|
||||
prefab.sprite.Origin,
|
||||
prefab.Sprite.Origin,
|
||||
rotation,
|
||||
scale,
|
||||
prefab.sprite.effects, depth);
|
||||
prefab.Sprite.effects, depth);
|
||||
|
||||
foreach (var decorativeSprite in itemPrefab.DecorativeSprites)
|
||||
{
|
||||
@@ -442,14 +441,14 @@ namespace Barotrauma
|
||||
if (flippedX && itemPrefab.CanSpriteFlipX) { offset.X = -offset.X; }
|
||||
if (flippedY && itemPrefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
|
||||
decorativeSprite.Sprite.Draw(spriteRecorder, new Vector2(spritePos.X + offset.X, -(spritePos.Y + offset.Y)), color,
|
||||
MathHelper.ToRadians(rotation) + rot, decorativeSprite.GetScale(0f) * scale, prefab.sprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.sprite.Depth), 0.999f));
|
||||
MathHelper.ToRadians(rotation) + rot, decorativeSprite.GetScale(0f) * scale, prefab.Sprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.Sprite.Depth), 0.999f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prefab.sprite.effects = prevEffects;
|
||||
prefab.Sprite.effects = prevEffects;
|
||||
}
|
||||
|
||||
private void BakeItemComponents(
|
||||
@@ -467,7 +466,7 @@ namespace Barotrauma
|
||||
case "turret":
|
||||
Sprite barrelSprite = null;
|
||||
Sprite railSprite = null;
|
||||
foreach (XElement turretSubElem in subElement.Elements())
|
||||
foreach (var turretSubElem in subElement.Elements())
|
||||
{
|
||||
switch (turretSubElem.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -494,13 +493,13 @@ namespace Barotrauma
|
||||
drawPos,
|
||||
color,
|
||||
rotation + MathHelper.PiOver2, scale,
|
||||
SpriteEffects.None, depth + (railSprite.Depth - prefab.sprite.Depth));
|
||||
SpriteEffects.None, depth + (railSprite.Depth - prefab.Sprite.Depth));
|
||||
|
||||
barrelSprite?.Draw(spriteRecorder,
|
||||
drawPos,
|
||||
color,
|
||||
rotation + MathHelper.PiOver2, scale,
|
||||
SpriteEffects.None, depth + (barrelSprite.Depth - prefab.sprite.Depth));
|
||||
SpriteEffects.None, depth + (barrelSprite.Depth - prefab.Sprite.Depth));
|
||||
|
||||
break;
|
||||
case "door":
|
||||
@@ -578,13 +577,13 @@ namespace Barotrauma
|
||||
|
||||
if (!spriteRecorder.ReadyToRender)
|
||||
{
|
||||
string waitText = !loadTask.IsCompleted ?
|
||||
TextManager.Get("generatingsubmarinepreview", fallBackTag: "loading") :
|
||||
LocalizedString waitText = !loadTask.IsCompleted ?
|
||||
TextManager.Get("generatingsubmarinepreview", "loading") :
|
||||
(loadTask.Exception?.ToString() ?? "Task completed without marking as ready to render");
|
||||
Vector2 origin = (GUI.Font.MeasureString(waitText) * 0.5f);
|
||||
Vector2 origin = (GUIStyle.Font.MeasureString(waitText) * 0.5f);
|
||||
origin.X = MathF.Round(origin.X);
|
||||
origin.Y = MathF.Round(origin.Y);
|
||||
GUI.Font.DrawString(
|
||||
GUIStyle.Font.DrawString(
|
||||
spriteBatch,
|
||||
waitText,
|
||||
scissorRectangle.Center.ToVector2(),
|
||||
@@ -629,18 +628,18 @@ namespace Barotrauma
|
||||
|
||||
if (mouseOver)
|
||||
{
|
||||
string str = hullCollection.Name;
|
||||
Vector2 strSize = GUI.Font.MeasureString(str) / camera.Zoom;
|
||||
LocalizedString str = hullCollection.Name;
|
||||
Vector2 strSize = GUIStyle.Font.MeasureString(str) / camera.Zoom;
|
||||
Vector2 padding = new Vector2(30, 30) / camera.Zoom;
|
||||
Vector2 shift = new Vector2(10, 0) / camera.Zoom;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, mousePos + shift, strSize + padding, Color.Black, isFilled: true, depth: 0.25f);
|
||||
GUI.Font.DrawString(spriteBatch, str, mousePos + shift + (strSize + padding) * 0.5f, Color.White, 0f, strSize * camera.Zoom * 0.5f, 1f / camera.Zoom, SpriteEffects.None, 0f);
|
||||
GUIStyle.Font.DrawString(spriteBatch, str, mousePos + shift + (strSize + padding) * 0.5f, Color.White, 0f, strSize * camera.Zoom * 0.5f, 1f / camera.Zoom, SpriteEffects.None, 0f);
|
||||
}
|
||||
}
|
||||
foreach (var door in doors)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, door.Rect, GUI.Style.Green * 0.5f, isFilled: true, depth: 0.4f);
|
||||
GUI.DrawRectangle(spriteBatch, door.Rect, GUIStyle.Green * 0.5f, isFilled: true, depth: 0.4f);
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Barotrauma
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, Vector2 drawPos)
|
||||
{
|
||||
Color clr = CurrentHull == null ? Color.DodgerBlue : GUI.Style.Green;
|
||||
Color clr = CurrentHull == null ? Color.DodgerBlue : GUIStyle.Green;
|
||||
if (spawnType != SpawnType.Path) { clr = Color.Gray; }
|
||||
if (isObstructed)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace Barotrauma
|
||||
if (IsSelected || IsHighlighted)
|
||||
{
|
||||
int glowSize = (int)(iconSize * 1.5f);
|
||||
GUI.Style.UIGlowCircular.Draw(spriteBatch,
|
||||
GUIStyle.UIGlowCircular.Draw(spriteBatch,
|
||||
new Rectangle((int)(drawPos.X - glowSize / 2), (int)(drawPos.Y - glowSize / 2), glowSize, glowSize),
|
||||
Color.White);
|
||||
}
|
||||
@@ -84,21 +84,21 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
|
||||
(isObstructed ? Color.Gray : GUI.Style.Green) * 0.7f, width: 5, depth: 0.002f);
|
||||
(isObstructed ? Color.Gray : GUIStyle.Green) * 0.7f, width: 5, depth: 0.002f);
|
||||
}
|
||||
if (ConnectedGap != null)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(ConnectedGap.DrawPosition.X, -ConnectedGap.DrawPosition.Y),
|
||||
GUI.Style.Green * 0.5f, width: 1);
|
||||
GUIStyle.Green * 0.5f, width: 1);
|
||||
}
|
||||
if (Ladders != null)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(Ladders.Item.DrawPosition.X, -Ladders.Item.DrawPosition.Y),
|
||||
GUI.Style.Green * 0.5f, width: 1);
|
||||
GUIStyle.Green * 0.5f, width: 1);
|
||||
}
|
||||
|
||||
var color = Color.WhiteSmoke;
|
||||
@@ -123,13 +123,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
GUI.SmallFont.DrawString(spriteBatch,
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch,
|
||||
ID.ToString(),
|
||||
new Vector2(DrawPosition.X - 10, -DrawPosition.Y - 30),
|
||||
color);
|
||||
if (Tunnel?.Type != null)
|
||||
{
|
||||
GUI.SmallFont.DrawString(spriteBatch,
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch,
|
||||
Tunnel.Type.ToString(),
|
||||
new Vector2(DrawPosition.X - 10, -DrawPosition.Y - 45),
|
||||
color);
|
||||
@@ -289,13 +289,13 @@ namespace Barotrauma
|
||||
|
||||
if (spawnType == SpawnType.Path)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("Waypoint"), font: GUI.LargeFont);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("Waypoint"), font: GUIStyle.LargeFont);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("LinkWaypoint"));
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("Spawnpoint"), font: GUI.LargeFont);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("Spawnpoint"), font: GUIStyle.LargeFont);
|
||||
|
||||
var spawnTypeContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -318,8 +318,8 @@ namespace Barotrauma
|
||||
OnClicked = ChangeSpawnType
|
||||
};
|
||||
|
||||
var descText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("IDCardDescription"), font: GUI.SmallFont)
|
||||
var descText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("IDCardDescription"), font: GUIStyle.SmallFont)
|
||||
{
|
||||
ToolTip = TextManager.Get("IDCardDescriptionTooltip")
|
||||
};
|
||||
@@ -336,17 +336,17 @@ namespace Barotrauma
|
||||
propertyBox.OnEnterPressed += (textBox, text) =>
|
||||
{
|
||||
IdCardDesc = text;
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
return true;
|
||||
};
|
||||
propertyBox.OnDeselected += (textBox, keys) =>
|
||||
{
|
||||
IdCardDesc = textBox.Text;
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
};
|
||||
|
||||
var idCardTagsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("IDCardTags"), font: GUI.SmallFont)
|
||||
TextManager.Get("IDCardTags"), font: GUIStyle.SmallFont)
|
||||
{
|
||||
ToolTip = TextManager.Get("IDCardTagsTooltip")
|
||||
};
|
||||
@@ -363,17 +363,17 @@ namespace Barotrauma
|
||||
propertyBox.OnEnterPressed += (textBox, text) =>
|
||||
{
|
||||
textBox.Text = string.Join(",", IdCardTags);
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
return true;
|
||||
};
|
||||
propertyBox.OnDeselected += (textBox, keys) =>
|
||||
{
|
||||
textBox.Text = string.Join(",", IdCardTags);
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
};
|
||||
|
||||
var jobsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("SpawnpointJobs"), font: GUI.SmallFont)
|
||||
TextManager.Get("SpawnpointJobs"), font: GUIStyle.SmallFont)
|
||||
{
|
||||
ToolTip = TextManager.Get("SpawnpointJobsTooltip")
|
||||
};
|
||||
@@ -394,7 +394,7 @@ namespace Barotrauma
|
||||
jobDropDown.SelectItem(AssignedJob);
|
||||
|
||||
var tagsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("spawnpointtags"), font: GUI.SmallFont);
|
||||
TextManager.Get("spawnpointtags"), font: GUIStyle.SmallFont);
|
||||
propertyBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), tagsText.RectTransform, Anchor.CenterRight), string.Join(", ", tags))
|
||||
{
|
||||
MaxTextLength = 60,
|
||||
@@ -402,19 +402,19 @@ namespace Barotrauma
|
||||
};
|
||||
propertyBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
tags = text.Split(',').ToList();
|
||||
tags = text.Split(',').ToIdentifiers().ToHashSet();
|
||||
return true;
|
||||
};
|
||||
propertyBox.OnEnterPressed += (textBox, text) =>
|
||||
{
|
||||
textBox.Text = string.Join(",", tags);
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
return true;
|
||||
};
|
||||
propertyBox.OnDeselected += (textBox, keys) =>
|
||||
{
|
||||
textBox.Text = string.Join(",", tags);
|
||||
textBox.Flash(GUI.Style.Green);
|
||||
textBox.Flash(GUIStyle.Green);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user