diff --git a/Barotrauma/BarotraumaClient/ClientCode.projitems b/Barotrauma/BarotraumaClient/ClientCode.projitems
index 37b214100..8f73c6fd8 100644
--- a/Barotrauma/BarotraumaClient/ClientCode.projitems
+++ b/Barotrauma/BarotraumaClient/ClientCode.projitems
@@ -219,6 +219,7 @@
+
diff --git a/Barotrauma/BarotraumaClient/ClientCode.shproj.user b/Barotrauma/BarotraumaClient/ClientCode.shproj.user
index 0b0f24d53..966b4ffb6 100644
--- a/Barotrauma/BarotraumaClient/ClientCode.shproj.user
+++ b/Barotrauma/BarotraumaClient/ClientCode.shproj.user
@@ -1,5 +1,5 @@
-
+
true
diff --git a/Barotrauma/BarotraumaClient/Properties/AssemblyInfo.cs b/Barotrauma/BarotraumaClient/Properties/AssemblyInfo.cs
index c89a88b51..7e4c3bedf 100644
--- a/Barotrauma/BarotraumaClient/Properties/AssemblyInfo.cs
+++ b/Barotrauma/BarotraumaClient/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.9.4.0")]
-[assembly: AssemblyFileVersion("0.9.4.0")]
+[assembly: AssemblyVersion("0.9.5.1")]
+[assembly: AssemblyFileVersion("0.9.5.1")]
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
index 4d6c90904..d190e07af 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/AI/EnemyAIController.cs
@@ -14,10 +14,27 @@ namespace Barotrauma
Vector2 pos = Character.WorldPosition;
pos.Y = -pos.Y;
- if (SelectedAiTarget?.Entity != null)
+ if (State == AIState.Idle && PreviousState == AIState.Attack)
{
- GUI.DrawLine(spriteBatch, pos, new Vector2(SelectedAiTarget.WorldPosition.X, -SelectedAiTarget.WorldPosition.Y), Color.Red * 0.5f, 0, 4);
-
+ var target = _selectedAiTarget ?? _lastAiTarget;
+ if (target != null)
+ {
+ var memory = GetTargetMemory(target);
+ Vector2 targetPos = memory.Location;
+ targetPos.Y = -targetPos.Y;
+ GUI.DrawLine(spriteBatch, pos, targetPos, Color.White * 0.5f, 0, 4);
+ GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{target.Entity.ToString()} ({memory.Priority.FormatZeroDecimal()})", Color.White, Color.Black);
+ }
+ }
+ else if (SelectedAiTarget?.Entity != null)
+ {
+ Vector2 targetPos = SelectedAiTarget.WorldPosition;
+ if (State == AIState.Attack)
+ {
+ targetPos = attackWorldPos;
+ }
+ targetPos.Y = -targetPos.Y;
+ GUI.DrawLine(spriteBatch, pos, targetPos, Color.Red * 0.5f, 0, 4);
if (wallTarget != null)
{
Vector2 wallTargetPos = wallTarget.Position;
@@ -26,7 +43,8 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, wallTargetPos - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Orange, false);
GUI.DrawLine(spriteBatch, pos, wallTargetPos, Color.Orange * 0.5f, 0, 5);
}
- GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity.ToString()} ({targetValue.FormatZeroDecimal()})", Color.Red, Color.Black);
+ GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity.ToString()} ({GetTargetMemory(SelectedAiTarget).Priority.FormatZeroDecimal()})", Color.Red, Color.Black);
+ GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 40.0f, $"({targetValue.FormatZeroDecimal()})", Color.Red, Color.Black);
}
/*GUI.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red);
@@ -42,6 +60,9 @@ namespace Barotrauma
case AIState.Escape:
stateColor = Color.LightBlue;
break;
+ case AIState.Flee:
+ stateColor = Color.White;
+ break;
case AIState.Eat:
stateColor = Color.Brown;
break;
@@ -59,8 +80,8 @@ namespace Barotrauma
if (LatchOntoAI.WallAttachPos.HasValue)
{
- GUI.DrawLine(spriteBatch, pos,
- ConvertUnits.ToDisplayUnits(new Vector2(LatchOntoAI.WallAttachPos.Value.X, -LatchOntoAI.WallAttachPos.Value.Y)), Color.Green, 0, 3);
+ //GUI.DrawLine(spriteBatch, pos,
+ // ConvertUnits.ToDisplayUnits(new Vector2(LatchOntoAI.WallAttachPos.Value.X, -LatchOntoAI.WallAttachPos.Value.Y)), Color.Green, 0, 3);
}
}
@@ -93,6 +114,17 @@ namespace Barotrauma
}
}
}
+ else
+ {
+ if (steeringManager.AvoidDir.LengthSquared() > 0.0001f)
+ {
+ Vector2 hitPos = ConvertUnits.ToDisplayUnits(steeringManager.AvoidRayCastHitPosition);
+ hitPos.Y = -hitPos.Y;
+
+ GUI.DrawLine(spriteBatch, hitPos, hitPos + new Vector2(steeringManager.AvoidDir.X, -steeringManager.AvoidDir.Y) * 100, Color.Red, width: 5);
+ //GUI.DrawLine(spriteBatch, pos, ConvertUnits.ToDisplayUnits(steeringManager.AvoidLookAheadPos.X, -steeringManager.AvoidLookAheadPos.Y), Color.Orange, width: 4);
+ }
+ }
GUI.DrawLine(spriteBatch, pos, pos + ConvertUnits.ToDisplayUnits(new Vector2(Character.AnimController.TargetMovement.X, -Character.AnimController.TargetMovement.Y)), Color.SteelBlue, width: 2);
GUI.DrawLine(spriteBatch, pos, pos + ConvertUnits.ToDisplayUnits(new Vector2(Steering.X, -Steering.Y)), Color.Blue, width: 3);
}
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaClient/Source/Characters/AI/HumanAIController.cs
index 613bf9d15..3e90775da 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/AI/HumanAIController.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/AI/HumanAIController.cs
@@ -25,7 +25,7 @@ namespace Barotrauma
{
Vector2 pos = Character.WorldPosition;
pos.Y = -pos.Y;
- Vector2 textOffset = new Vector2(-40, -120);
+ Vector2 textOffset = new Vector2(-40, -160);
if (SelectedAiTarget?.Entity != null)
{
@@ -33,26 +33,36 @@ namespace Barotrauma
//GUI.DrawString(spriteBatch, pos + textOffset, $"AI TARGET: {SelectedAiTarget.Entity.ToString()}", Color.White, Color.Black);
}
+ GUI.DrawString(spriteBatch, pos + textOffset, Character.Name, Color.White, Color.Black);
+
if (ObjectiveManager != null)
{
var currentOrder = ObjectiveManager.CurrentOrder;
if (currentOrder != null)
{
- GUI.DrawString(spriteBatch, pos + textOffset, $"ORDER: {currentOrder.DebugTag} ({currentOrder.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
+ GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 20), $"ORDER: {currentOrder.DebugTag} ({currentOrder.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
}
else if (ObjectiveManager.WaitTimer > 0)
{
- GUI.DrawString(spriteBatch, pos + textOffset, $"Waiting... {ObjectiveManager.WaitTimer.FormatZeroDecimal()}", Color.White, Color.Black);
+ GUI.DrawString(spriteBatch, pos + new Vector2(0, 20), $"Waiting... {ObjectiveManager.WaitTimer.FormatZeroDecimal()}", Color.White, Color.Black);
}
var currentObjective = ObjectiveManager.CurrentObjective;
if (currentObjective != null)
{
- GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 20), $"OBJECTIVE: {currentObjective.DebugTag} ({currentObjective.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
+ if (currentOrder == null)
+ {
+ GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 20), $"MAIN OBJECTIVE: {currentObjective.DebugTag} ({currentObjective.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
+ }
var subObjective = currentObjective.SubObjectives.FirstOrDefault();
if (subObjective != null)
{
GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 40), $"SUBOBJECTIVE: {subObjective.DebugTag} ({subObjective.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
}
+ var activeObjective = ObjectiveManager.GetActiveObjective();
+ if (activeObjective != null)
+ {
+ GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 60), $"ACTIVE OBJECTIVE: {activeObjective.DebugTag} ({activeObjective.GetPriority().FormatZeroDecimal()})", Color.White, Color.Black);
+ }
}
}
@@ -81,7 +91,7 @@ namespace Barotrauma
new Vector2(path.CurrentNode.DrawPosition.X, -path.CurrentNode.DrawPosition.Y),
Color.BlueViolet, 0, 3);
- GUI.DrawString(spriteBatch, pos + textOffset - new Vector2(0, 20), "Path cost: " + path.Cost.FormatZeroDecimal(), Color.White, Color.Black * 0.5f);
+ GUI.DrawString(spriteBatch, pos + textOffset + new Vector2(0, 80), "Path cost: " + path.Cost.FormatZeroDecimal(), Color.White, Color.Black * 0.5f);
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
index c42fb71fb..ef4034a8b 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs
@@ -24,7 +24,7 @@ namespace Barotrauma
partial void UpdateNetPlayerPositionProjSpecific(float deltaTime, float lowestSubPos)
{
- if (character != GameMain.Client.Character || !character.AllowInput)
+ if (character != GameMain.Client.Character || !character.CanMove)
{
//remove states without a timestamp (there may still be ID-based states
//in the list when the controlled character switches to timestamp-based interpolation)
@@ -92,10 +92,10 @@ namespace Barotrauma
Collider.AngularVelocity = newAngularVelocity;
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
- float errorTolerance = character.AllowInput ? 0.01f : 0.2f;
+ float errorTolerance = character.CanMove ? 0.01f : 0.2f;
if (distSqrd > errorTolerance)
{
- if (distSqrd > 10.0f || !character.AllowInput)
+ if (distSqrd > 10.0f || !character.CanMove)
{
Collider.TargetRotation = newRotation;
SetPosition(newPosition, lerp: distSqrd < 5.0f, ignorePlatforms: false);
@@ -108,9 +108,9 @@ namespace Barotrauma
}
}
- //unconscious/dead characters can't correct their position using AnimController movement
+ //immobilized characters can't correct their position using AnimController movement
// -> we need to correct it manually
- if (!character.AllowInput)
+ if (!character.CanMove)
{
float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition);
float mainLimbErrorTolerance = 0.1f;
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
index cf53dd16f..e855ea88c 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs
@@ -343,7 +343,7 @@ namespace Barotrauma
partial void OnAttackedProjSpecific(Character attacker, AttackResult attackResult)
{
- if (attackResult.Damage <= 1.0f) { return; }
+ if (attackResult.Damage <= 1.0f || IsDead) { return; }
if (soundTimer < soundInterval * 0.5f)
{
PlaySound(CharacterSound.SoundType.Damage);
@@ -524,6 +524,8 @@ namespace Barotrauma
partial void UpdateProjSpecific(float deltaTime, Camera cam)
{
+ if (!enabled) { return; }
+
if (!IsDead && !IsUnconscious)
{
if (soundTimer > 0)
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs
index 0e7a8ad34..49fc72c13 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterInfo.cs
@@ -50,7 +50,7 @@ namespace Barotrauma
Job.Name, textColor: Job.Prefab.UIColor, font: font);
}
- if (personalityTrait != null && TextManager.Language == "English")
+ if (personalityTrait != null)
{
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform),
TextManager.AddPunctuation(':', TextManager.Get("PersonalityTrait"), TextManager.Get("personalitytrait." + personalityTrait.Name.Replace(" ", ""))), font: font);
@@ -125,7 +125,7 @@ namespace Barotrauma
}
}
- partial void LoadAttachmentSprites()
+ partial void LoadAttachmentSprites(bool omitJob)
{
if (attachmentSprites == null)
{
@@ -139,7 +139,25 @@ namespace Barotrauma
BeardElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Beard)));
MoustacheElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Moustache)));
HairElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Hair)));
- Job?.Prefab.ClothingElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
+ if (omitJob)
+ {
+ JobPrefab.NoJobElement?.Element("PortraitClothing")?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
+ }
+ else
+ {
+ Job?.Prefab.ClothingElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
+ }
+ }
+
+ // Doesn't work if the head's source rect does not start at 0,0.
+ public static Point CalculateOffset(Sprite sprite, Point offset) => sprite.SourceRect.Size * offset;
+
+ public void CalculateHeadPosition(Sprite sprite)
+ {
+ if (sprite == null) { return; }
+ if (Head.SheetIndex == null) { return; }
+ Point location = CalculateOffset(sprite, Head.SheetIndex.Value.ToPoint());
+ sprite.SourceRect = new Rectangle(location, sprite.SourceRect.Size);
}
public void DrawPortrait(SpriteBatch spriteBatch, Vector2 screenPos, float targetWidth)
@@ -155,6 +173,10 @@ namespace Barotrauma
// Scale down the head sprite 10%
float scale = targetWidth * 0.9f / Portrait.size.X;
Vector2 offset = Portrait.size * backgroundScale / 4;
+ if (Head.SheetIndex.HasValue)
+ {
+ Portrait.SourceRect = new Rectangle(CalculateOffset(Portrait, Head.SheetIndex.Value.ToPoint()), Portrait.SourceRect.Size);
+ }
Portrait.Draw(spriteBatch, screenPos + offset, scale: scale, spriteEffect: SpriteEffects.FlipHorizontally);
if (AttachmentSprites != null)
{
@@ -170,16 +192,21 @@ namespace Barotrauma
public void DrawIcon(SpriteBatch spriteBatch, Vector2 screenPos, Vector2 targetAreaSize)
{
- if (HeadSprite != null)
+ var headSprite = HeadSprite;
+ if (headSprite != null)
{
- float scale = Math.Min(targetAreaSize.X / HeadSprite.size.X, targetAreaSize.Y / HeadSprite.size.Y);
- HeadSprite.Draw(spriteBatch, screenPos, scale: scale);
+ float scale = Math.Min(targetAreaSize.X / headSprite.size.X, targetAreaSize.Y / headSprite.size.Y);
+ if (Head.SheetIndex.HasValue)
+ {
+ headSprite.SourceRect = new Rectangle(CalculateOffset(headSprite, Head.SheetIndex.Value.ToPoint()), headSprite.SourceRect.Size);
+ }
+ headSprite.Draw(spriteBatch, screenPos, scale: scale);
if (AttachmentSprites != null)
{
float depthStep = 0.000001f;
foreach (var attachment in AttachmentSprites)
{
- DrawAttachmentSprite(spriteBatch, attachment, HeadSprite, screenPos, scale, depthStep);
+ DrawAttachmentSprite(spriteBatch, attachment, headSprite, screenPos, scale, depthStep);
depthStep += depthStep;
}
}
@@ -188,13 +215,15 @@ namespace Barotrauma
private void DrawAttachmentSprite(SpriteBatch spriteBatch, WearableSprite attachment, Sprite head, Vector2 drawPos, float scale, float depthStep, SpriteEffects spriteEffects = SpriteEffects.None)
{
- var list = AttachmentSprites.ToList();
if (attachment.InheritSourceRect)
{
if (attachment.SheetIndex.HasValue)
{
- Point location = (head.SourceRect.Location + head.SourceRect.Size) * attachment.SheetIndex.Value;
- attachment.Sprite.SourceRect = new Rectangle(location, head.SourceRect.Size);
+ attachment.Sprite.SourceRect = new Rectangle(CalculateOffset(head, attachment.SheetIndex.Value), head.SourceRect.Size);
+ }
+ else if (Head.SheetIndex.HasValue)
+ {
+ attachment.Sprite.SourceRect = new Rectangle(CalculateOffset(head, Head.SheetIndex.Value.ToPoint()), head.SourceRect.Size);
}
else
{
@@ -219,7 +248,6 @@ namespace Barotrauma
attachment.Sprite.Draw(spriteBatch, drawPos, Color.White, origin, rotate: 0, scale: scale, depth: depth, spriteEffect: spriteEffects);
}
-
public static CharacterInfo ClientRead(string speciesName, IReadMessage inc)
{
ushort infoID = inc.ReadUInt16();
@@ -234,6 +262,8 @@ namespace Barotrauma
string ragdollFile = inc.ReadString();
string jobIdentifier = inc.ReadString();
+ int variant = inc.ReadByte();
+
JobPrefab jobPrefab = null;
Dictionary skillLevels = new Dictionary();
if (!string.IsNullOrEmpty(jobIdentifier))
@@ -249,7 +279,7 @@ namespace Barotrauma
}
// TODO: animations
- CharacterInfo ch = new CharacterInfo(speciesName, newName, jobPrefab, ragdollFile)
+ CharacterInfo ch = new CharacterInfo(speciesName, newName, jobPrefab, ragdollFile, variant)
{
ID = infoID,
};
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs
index f0e3a3aff..c8957a3b2 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs
@@ -249,7 +249,7 @@ namespace Barotrauma
msg.ReadPadBits();
int index = 0;
- if (GameMain.Client.Character == this && AllowInput)
+ if (GameMain.Client.Character == this && CanMove)
{
var posInfo = new CharacterStateInfo(
pos, rotation,
@@ -309,7 +309,7 @@ namespace Barotrauma
LastNetworkUpdateID = controlled.LastNetworkUpdateID;
}
- Controlled = this;
+ if (!IsDead) { Controlled = this; }
IsRemotePlayer = false;
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = this;
@@ -342,7 +342,7 @@ namespace Barotrauma
}
}
- public static Character ReadSpawnData(IReadMessage inc, bool spawn = true)
+ public static Character ReadSpawnData(IReadMessage inc)
{
DebugConsole.Log("Reading character spawn data");
@@ -362,10 +362,9 @@ namespace Barotrauma
Character character = null;
if (noInfo)
{
- if (!spawn) return null;
-
character = Create(speciesName, position, seed, null, true);
character.ID = id;
+ character.ReadStatus(inc);
}
else
{
@@ -375,15 +374,14 @@ namespace Barotrauma
bool hasAi = inc.ReadBoolean();
string infoSpeciesName = inc.ReadString();
- if (!spawn) return null;
-
CharacterInfo info = CharacterInfo.ClientRead(infoSpeciesName, inc);
- character = Create(infoSpeciesName, position, seed, info, GameMain.Client.ID != ownerId, hasAi);
+ character = Create(speciesName, position, seed, info, GameMain.Client.ID != ownerId, hasAi);
character.ID = id;
character.TeamID = (TeamType)teamID;
+ character.ReadStatus(inc);
- if (character.IsHuman && character.TeamID != TeamType.FriendlyNPC)
+ if (character.IsHuman && character.TeamID != TeamType.FriendlyNPC && !character.IsDead)
{
CharacterInfo duplicateCharacterInfo = GameMain.GameSession.CrewManager.GetCharacterInfos().FirstOrDefault(c => c.ID == info.ID);
GameMain.GameSession.CrewManager.RemoveCharacterInfo(duplicateCharacterInfo);
@@ -394,7 +392,7 @@ namespace Barotrauma
{
GameMain.Client.HasSpawned = true;
GameMain.Client.Character = character;
- Controlled = character;
+ if (!character.IsDead) { Controlled = character; }
GameMain.LightManager.LosEnabled = true;
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
index 2789f2703..4c98b4691 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs
@@ -13,7 +13,7 @@ namespace Barotrauma
{
private static bool toggledThisFrame;
- private static Sprite damageOverlay;
+ public static Sprite DamageOverlay;
private static string[] strengthTexts;
@@ -153,12 +153,7 @@ namespace Barotrauma
get { return healthBarPulsateTimer; }
set { healthBarPulsateTimer = MathHelper.Clamp(value, 0.0f, 10.0f); }
}
-
- static CharacterHealth()
- {
- damageOverlay = new Sprite("Content/UI/damageOverlay.png", Vector2.Zero);
- }
-
+
partial void InitProjSpecific(XElement element, Character character)
{
DisplayedVitality = MaxVitality;
@@ -837,8 +832,8 @@ namespace Barotrauma
if (damageOverlayAlpha > 0.0f)
{
- damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayAlpha, Vector2.Zero, 0.0f,
- new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y));
+ DamageOverlay?.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayAlpha, Vector2.Zero, 0.0f,
+ new Vector2(GameMain.GraphicsWidth / DamageOverlay.size.X, GameMain.GraphicsHeight / DamageOverlay.size.Y));
}
if (Character.Inventory != null)
@@ -997,30 +992,7 @@ namespace Barotrauma
//key = item identifier
//float = suitability
Dictionary treatmentSuitability = new Dictionary();
- float minSuitability = -10, maxSuitability = 10;
- foreach (Affliction affliction in afflictions)
- {
- foreach (KeyValuePair treatment in affliction.Prefab.TreatmentSuitability)
- {
- if (!treatmentSuitability.ContainsKey(treatment.Key))
- {
- treatmentSuitability[treatment.Key] = treatment.Value * affliction.Strength;
- }
- else
- {
- treatmentSuitability[treatment.Key] += treatment.Value * affliction.Strength;
- }
- minSuitability = Math.Min(treatmentSuitability[treatment.Key], minSuitability);
- maxSuitability = Math.Max(treatmentSuitability[treatment.Key], maxSuitability);
- }
- }
- //normalize the suitabilities to a range of 0 to 1
- foreach (string treatment in treatmentSuitability.Keys.ToList())
- {
- treatmentSuitability[treatment] = (treatmentSuitability[treatment] - minSuitability) / (maxSuitability - minSuitability);
- //lerp towards a random value if the medical skill is low
- treatmentSuitability[treatment] = MathHelper.Lerp(treatmentSuitability[treatment], Rand.Range(0.0f, 1.0f), randomVariance);
- }
+ GetSuitableTreatments(treatmentSuitability, normalize: true, randomization: randomVariance);
foreach (Affliction affliction in afflictions)
{
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/DamageModifier.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/DamageModifier.cs
index 316872df3..c9258a8a0 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Health/DamageModifier.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/DamageModifier.cs
@@ -2,7 +2,7 @@
{
partial class DamageModifier
{
- [Serialize("", false)]
+ [Serialize("", false), Editable]
public string DamageSound
{
get;
diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs
index 1b0f04fa5..36cbc1b1e 100644
--- a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs
+++ b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs
@@ -119,7 +119,24 @@ namespace Barotrauma
public List Deformations { get; private set; } = new List();
public Sprite Sprite { get; protected set; }
- public DeformableSprite DeformSprite { get; protected set; }
+
+ protected DeformableSprite _deformSprite;
+
+ public DeformableSprite DeformSprite
+ {
+ get
+ {
+ var conditionalSprite = ConditionalSprites.FirstOrDefault(c => c.IsActive && c.DeformableSprite != null);
+ if (conditionalSprite != null)
+ {
+ return conditionalSprite.DeformableSprite;
+ }
+ else
+ {
+ return _deformSprite;
+ }
+ }
+ }
public List DecorativeSprites { get; private set; } = new List();
@@ -127,15 +144,14 @@ namespace Barotrauma
{
get
{
- // TODO: should we optimize this? No need to check all the conditionals each time the property is accessed.
- var conditionalSprite = ConditionalSprites.FirstOrDefault(c => c.IsActive);
+ var conditionalSprite = ConditionalSprites.FirstOrDefault(c => c.IsActive && c.ActiveSprite != null);
if (conditionalSprite != null)
{
- return conditionalSprite;
+ return conditionalSprite.ActiveSprite;
}
else
{
- return DeformSprite != null ? DeformSprite.Sprite : Sprite;
+ return _deformSprite != null ? _deformSprite.Sprite : Sprite;
}
}
}
@@ -215,40 +231,53 @@ namespace Barotrauma
DamagedSprite = new Sprite(subElement, file: GetSpritePath(subElement, Params.damagedSpriteParams));
break;
case "conditionalsprite":
- ConditionalSprites.Add(new ConditionalSprite(subElement, character, file: GetSpritePath(subElement, null)));
+ var conditionalSprite = new ConditionalSprite(subElement, character, file: GetSpritePath(subElement, null));
+ ConditionalSprites.Add(conditionalSprite);
+ if (conditionalSprite.DeformableSprite != null)
+ {
+ CreateDeformations(subElement.GetChildElement("deformablesprite"));
+ }
break;
case "deformablesprite":
- DeformSprite = new DeformableSprite(subElement, filePath: GetSpritePath(subElement, Params.deformSpriteParams));
- foreach (XElement animationElement in subElement.Elements())
- {
- int sync = animationElement.GetAttributeInt("sync", -1);
- SpriteDeformation deformation = null;
- if (sync > -1)
- {
- // if the element is marked with the sync attribute, use a deformation of the same type with the same sync value, if there is one already.
- string typeName = animationElement.GetAttributeString("type", "").ToLowerInvariant();
- deformation = ragdoll.Limbs
- .Where(l => l != null)
- .SelectMany(l => l.Deformations)
- .Where(d => d.TypeName == typeName && d.Sync == sync)
- .FirstOrDefault();
- }
- if (deformation == null)
- {
- deformation = SpriteDeformation.Load(animationElement, character.SpeciesName);
- if (deformation != null)
- {
- ragdoll.SpriteDeformations.Add(deformation);
- }
- }
- if (deformation != null) Deformations.Add(deformation);
- }
+ _deformSprite = new DeformableSprite(subElement, filePath: GetSpritePath(subElement, Params.deformSpriteParams));
+ CreateDeformations(subElement);
break;
case "lightsource":
LightSource = new LightSource(subElement);
InitialLightSourceColor = LightSource.Color;
break;
}
+
+ void CreateDeformations(XElement e)
+ {
+ foreach (XElement animationElement in e.GetChildElements("spritedeformation"))
+ {
+ int sync = animationElement.GetAttributeInt("sync", -1);
+ SpriteDeformation deformation = null;
+ if (sync > -1)
+ {
+ // if the element is marked with the sync attribute, use a deformation of the same type with the same sync value, if there is one already.
+ string typeName = animationElement.GetAttributeString("type", "").ToLowerInvariant();
+ deformation = ragdoll.Limbs
+ .Where(l => l != null)
+ .SelectMany(l => l.Deformations)
+ .Where(d => d.TypeName == typeName && d.Sync == sync)
+ .FirstOrDefault();
+ }
+ if (deformation == null)
+ {
+ deformation = SpriteDeformation.Load(animationElement, character.SpeciesName);
+ if (deformation != null)
+ {
+ ragdoll.SpriteDeformations.Add(deformation);
+ }
+ }
+ if (deformation != null)
+ {
+ Deformations.Add(deformation);
+ }
+ }
+ }
}
}
@@ -260,11 +289,11 @@ namespace Barotrauma
var source = Sprite.SourceElement;
Sprite = new Sprite(source, file: GetSpritePath(source, Params.normalSpriteParams));
}
- if (DeformSprite != null)
+ if (_deformSprite != null)
{
- DeformSprite.Remove();
- var source = DeformSprite.Sprite.SourceElement;
- DeformSprite = new DeformableSprite(source, filePath: GetSpritePath(source, Params.deformSpriteParams));
+ _deformSprite.Remove();
+ var source = _deformSprite.Sprite.SourceElement;
+ _deformSprite = new DeformableSprite(source, filePath: GetSpritePath(source, Params.deformSpriteParams));
}
if (DamagedSprite != null)
{
@@ -275,9 +304,8 @@ namespace Barotrauma
for (int i = 0; i < ConditionalSprites.Count; i++)
{
var conditionalSprite = ConditionalSprites[i];
+ var source = conditionalSprite.ActiveSprite.SourceElement;
conditionalSprite.Remove();
- var source = conditionalSprite.SourceElement;
- // TODO: lazy load?
ConditionalSprites[i] = new ConditionalSprite(source, character, file: GetSpritePath(source, null));
}
for (int i = 0; i < DecorativeSprites.Count; i++)
@@ -289,6 +317,12 @@ namespace Barotrauma
}
}
+ private void CalculateHeadPosition(Sprite sprite)
+ {
+ if (type != LimbType.Head) { return; }
+ character.Info?.CalculateHeadPosition(sprite);
+ }
+
private string GetSpritePath(XElement element, SpriteParams spriteParams)
{
string texturePath = element.GetAttributeString("texture", null);
@@ -330,7 +364,7 @@ namespace Barotrauma
bool isFlipped = dir == Direction.Left;
Sprite?.LoadParams(Params.normalSpriteParams, isFlipped);
DamagedSprite?.LoadParams(Params.damagedSpriteParams, isFlipped);
- DeformSprite?.Sprite.LoadParams(Params.deformSpriteParams, isFlipped);
+ _deformSprite?.Sprite.LoadParams(Params.deformSpriteParams, isFlipped);
for (int i = 0; i < DecorativeSprites.Count; i++)
{
DecorativeSprites[i].Sprite?.LoadParams(Params.decorativeSpriteParams[i], isFlipped);
@@ -461,24 +495,31 @@ namespace Barotrauma
enableHuskSprite && HuskSprite != null && HuskSprite.HideLimb ||
OtherWearables.Any(w => w.HideLimb) ||
wearingItems.Any(w => w != null && w.HideLimb);
+
+ var activeSprite = ActiveSprite;
+ if (type == LimbType.Head)
+ {
+ CalculateHeadPosition(activeSprite);
+ }
+
// TODO: there's now two calls to this, because body.Draw() method calls this too -> is this an issue?
body.UpdateDrawPosition();
if (!hideLimb)
{
- var activeSprite = ActiveSprite;
- if (DeformSprite != null && activeSprite == DeformSprite.Sprite)
+ var deformSprite = DeformSprite;
+ if (deformSprite != null)
{
if (Deformations != null && Deformations.Any())
{
- var deformation = SpriteDeformation.GetDeformation(Deformations, DeformSprite.Size);
- DeformSprite.Deform(deformation);
+ var deformation = SpriteDeformation.GetDeformation(Deformations, deformSprite.Size);
+ deformSprite.Deform(deformation);
}
else
{
- DeformSprite.Reset();
+ deformSprite.Reset();
}
- body.Draw(DeformSprite, cam, Vector2.One * Scale * TextureScale, color, Params.MirrorHorizontally);
+ body.Draw(deformSprite, cam, Vector2.One * Scale * TextureScale, color, Params.MirrorHorizontally);
}
else
{
@@ -489,15 +530,16 @@ namespace Barotrauma
if (LightSource != null)
{
LightSource.Position = body.DrawPosition;
+ if (LightSource.ParentSub != null) { LightSource.Position -= LightSource.ParentSub.DrawPosition; }
LightSource.LightSpriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipVertically;
}
if (damageOverlayStrength > 0.0f && DamagedSprite != null && !hideLimb)
{
DamagedSprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
- color * Math.Min(damageOverlayStrength, 1.0f), ActiveSprite.Origin,
+ color * Math.Min(damageOverlayStrength, 1.0f), activeSprite.Origin,
-body.DrawRotation,
- Scale, spriteEffect, ActiveSprite.Depth - 0.0000015f);
+ Scale, spriteEffect, activeSprite.Depth - 0.0000015f);
}
foreach (var decorativeSprite in DecorativeSprites)
{
@@ -636,48 +678,58 @@ namespace Barotrauma
{
foreach (var modifier in damageModifiers)
{
- float rotation = -body.TransformedRotation + GetArmorSectorRotationOffset(modifier.ArmorSectorInRadians) * Dir;
- Vector2 forward = VectorExtensions.Forward(rotation);
+ //Vector2 up = VectorExtensions.Backward(-body.TransformedRotation + Params.GetSpriteOrientation() * Dir);
+ //int width = 4;
+ //if (!isScreenSpace)
+ //{
+ // width = (int)Math.Round(width / cam.Zoom);
+ //}
+ //GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(up) * size, Color.Red, width: width);
+ Color color = modifier.DamageMultiplier > 1 ? Color.Red : Color.GreenYellow;
float size = ConvertUnits.ToDisplayUnits(body.GetSize().Length() / 2);
if (isScreenSpace)
{
size *= cam.Zoom;
}
- Color color = modifier.DamageMultiplier > 1 ? Color.Red : Color.GreenYellow;
- int width = 4;
- if (!isScreenSpace)
- {
- width = (int)Math.Round(width / cam.Zoom);
- }
- GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(forward) * size, color, width: width);
int thickness = 2;
if (!isScreenSpace)
{
thickness = (int)Math.Round(thickness / cam.Zoom);
}
- ShapeExtensions.DrawSector(spriteBatch, startPos, size, GetArmorSectorSize(modifier.ArmorSectorInRadians) * Dir, 40, color, rotation + MathHelper.Pi, thickness);
+ float bodyRotation = -body.Rotation;
+ float constantOffset = -MathHelper.PiOver2;
+ Vector2 armorSector = modifier.ArmorSectorInRadians;
+ float armorSectorSize = Math.Abs(armorSector.X - armorSector.Y);
+ float radians = armorSectorSize * Dir;
+ float armorSectorOffset = armorSector.X * Dir;
+ float finalOffset = bodyRotation + constantOffset + armorSectorOffset;
+ ShapeExtensions.DrawSector(spriteBatch, startPos, size, radians, 40, color, finalOffset, thickness);
}
}
private void DrawWearable(WearableSprite wearable, float depthStep, SpriteBatch spriteBatch, Color color, SpriteEffects spriteEffect)
{
+ var sprite = ActiveSprite;
if (wearable.InheritSourceRect)
{
if (wearable.SheetIndex.HasValue)
{
- Point location = (ActiveSprite.SourceRect.Location + ActiveSprite.SourceRect.Size) * wearable.SheetIndex.Value;
- wearable.Sprite.SourceRect = new Rectangle(location, ActiveSprite.SourceRect.Size);
+ wearable.Sprite.SourceRect = new Rectangle(CharacterInfo.CalculateOffset(sprite, wearable.SheetIndex.Value), sprite.SourceRect.Size);
+ }
+ else if (type == LimbType.Head && character.Info != null && character.Info.Head.SheetIndex.HasValue)
+ {
+ wearable.Sprite.SourceRect = new Rectangle(CharacterInfo.CalculateOffset(sprite, character.Info.Head.SheetIndex.Value.ToPoint()), sprite.SourceRect.Size);
}
else
{
- wearable.Sprite.SourceRect = ActiveSprite.SourceRect;
+ wearable.Sprite.SourceRect = sprite.SourceRect;
}
}
Vector2 origin = wearable.Sprite.Origin;
if (wearable.InheritOrigin)
{
- origin = ActiveSprite.Origin;
+ origin = sprite.Origin;
wearable.Sprite.Origin = origin;
}
else
@@ -694,7 +746,7 @@ namespace Barotrauma
if (wearable.InheritLimbDepth)
{
- depth = ActiveSprite.Depth - depthStep;
+ depth = sprite.Depth - depthStep;
Limb depthLimb = (wearable.DepthLimb == LimbType.None) ? this : character.AnimController.GetLimb(wearable.DepthLimb);
if (depthLimb != null)
{
@@ -728,11 +780,11 @@ namespace Barotrauma
XElement element;
if (random)
{
- element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.FirstOrDefault();
+ element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.GetRandom(Rand.RandSync.ClientOnly);
}
else
{
- element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.GetRandom(Rand.RandSync.ClientOnly);
+ element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.FirstOrDefault();
}
if (element != null)
{
@@ -749,8 +801,8 @@ namespace Barotrauma
DamagedSprite?.Remove();
DamagedSprite = null;
- DeformSprite?.Sprite?.Remove();
- DeformSprite = null;
+ _deformSprite?.Sprite?.Remove();
+ _deformSprite = null;
DecorativeSprites.ForEach(s => s.Remove());
ConditionalSprites.Clear();
diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
index 81c38ada9..4acb4a66a 100644
--- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
+++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs
@@ -10,6 +10,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Globalization;
+using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -56,6 +57,7 @@ namespace Barotrauma
private static GUIFrame frame;
private static GUIListBox listBox;
private static GUITextBox textBox;
+ private const int maxLength = 1000;
public static GUITextBox TextBox => textBox;
@@ -92,6 +94,7 @@ namespace Barotrauma
{
IsFixedSize = false
});
+ textBox.MaxTextLength = maxLength;
textBox.OnKeyHit += (sender, key) =>
{
if (key != Keys.Tab)
@@ -109,7 +112,7 @@ namespace Barotrauma
}
}
- public static void Update(GameMain game, float deltaTime)
+ public static void Update(float deltaTime)
{
lock (queuedMessages)
{
@@ -162,6 +165,16 @@ namespace Barotrauma
textBox.Text = AutoComplete(textBox.Text, increment: string.IsNullOrEmpty(currentAutoCompletedCommand) ? 0 : 1 );
}
+ if (PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl))
+ {
+ if ((PlayerInput.KeyDown(Keys.C) || PlayerInput.KeyDown(Keys.D) || PlayerInput.KeyDown(Keys.Z)) && activeQuestionCallback != null)
+ {
+ activeQuestionCallback = null;
+ activeQuestionText = null;
+ NewMessage(PlayerInput.KeyDown(Keys.C) ? "^C" : PlayerInput.KeyDown(Keys.D) ? "^D" : "^Z", Color.White, true);
+ }
+ }
+
if (PlayerInput.KeyHit(Keys.Enter))
{
ExecuteCommand(textBox.Text);
@@ -185,41 +198,6 @@ namespace Barotrauma
}
}
- public static void Draw(SpriteBatch spriteBatch)
- {
- if (!isOpen) return;
-
- frame.DrawManually(spriteBatch);
- }
-
- private static bool IsCommandPermitted(string command, GameClient client)
- {
- switch (command)
- {
- case "kick":
- return client.HasPermission(ClientPermissions.Kick);
- case "ban":
- case "banip":
- case "banendpoint":
- return client.HasPermission(ClientPermissions.Ban);
- case "unban":
- case "unbanip":
- return client.HasPermission(ClientPermissions.Unban);
- case "netstats":
- case "help":
- case "dumpids":
- case "admin":
- case "entitylist":
- case "togglehud":
- case "toggleupperhud":
- case "togglecharacternames":
- case "fpscounter":
- return true;
- default:
- return client.HasConsoleCommandPermission(command);
- }
- }
-
public static void DequeueMessages()
{
while (queuedMessages.Count > 0)
@@ -294,7 +272,7 @@ namespace Barotrauma
};
textContainer.RectTransform.NonScaledSize = new Point(textContainer.RectTransform.NonScaledSize.X, textBlock.RectTransform.NonScaledSize.Y + 5);
textBlock.SetTextPos();
- var nameBlock = new GUITextBlock(new RectTransform(new Point(150, textContainer.Rect.Height), textContainer.RectTransform),
+ new GUITextBlock(new RectTransform(new Point(150, textContainer.Rect.Height), textContainer.RectTransform),
command.names[0], textAlignment: Alignment.TopLeft);
listBox.UpdateScrollBarSize();
@@ -509,14 +487,22 @@ namespace Barotrauma
AssignOnExecute("los", (string[] args) =>
{
- GameMain.LightManager.LosEnabled = !GameMain.LightManager.LosEnabled;
+ if (args.None() || !bool.TryParse(args[0], out bool state))
+ {
+ state = !GameMain.LightManager.LosEnabled;
+ }
+ GameMain.LightManager.LosEnabled = state;
NewMessage("Line of sight effect " + (GameMain.LightManager.LosEnabled ? "enabled" : "disabled"), Color.White);
});
AssignRelayToServer("los", false);
AssignOnExecute("lighting|lights", (string[] args) =>
{
- GameMain.LightManager.LightingEnabled = !GameMain.LightManager.LightingEnabled;
+ if (args.None() || !bool.TryParse(args[0], out bool state))
+ {
+ state = !GameMain.LightManager.LightingEnabled;
+ }
+ GameMain.LightManager.LightingEnabled = state;
NewMessage("Lighting " + (GameMain.LightManager.LightingEnabled ? "enabled" : "disabled"), Color.White);
});
AssignRelayToServer("lighting|lights", false);
@@ -635,10 +621,61 @@ namespace Barotrauma
}
}));
+ commands.Add(new Command("resetentitiesbyidentifier", "resetentitiesbyidentifier [tag/identifier]: Reset items and structures with the given tag/identifier to prefabs. Only applicable in the subeditor.", args =>
+ {
+ if (args.Length == 0) { return; }
+ if (Screen.Selected == GameMain.SubEditorScreen)
+ {
+ bool entityFound = false;
+ foreach (MapEntity entity in MapEntity.mapEntityList)
+ {
+ if (entity is Item item)
+ {
+ if (item.prefab.Identifier != args[0] && !item.Tags.Contains(args[0])) { continue; }
+ item.Reset();
+ if (MapEntity.SelectedList.Contains(item)) { item.CreateEditingHUD(); }
+ entityFound = true;
+ }
+ else if (entity is Structure structure)
+ {
+ if (structure.prefab.Identifier != args[0] && !structure.Tags.Contains(args[0])) { continue; }
+ structure.Reset();
+ if (MapEntity.SelectedList.Contains(structure)) { structure.CreateEditingHUD(); }
+ entityFound = true;
+ }
+ else
+ {
+ continue;
+ }
+ NewMessage($"Reset {entity.Name}.");
+ }
+ if (!entityFound)
+ {
+ if (MapEntity.SelectedList.Count == 0)
+ {
+ NewMessage("No entities selected.");
+ return;
+ }
+ }
+ }
+ }, () =>
+ {
+ return new string[][]
+ {
+ MapEntityPrefab.List.Select(me => me.Identifier).ToArray()
+ };
+ }));
+
commands.Add(new Command("resetselected", "Reset selected items and structures to prefabs. Only applicable in the subeditor.", args =>
{
if (Screen.Selected == GameMain.SubEditorScreen)
{
+ if (MapEntity.SelectedList.Count == 0)
+ {
+ NewMessage("No entities selected.");
+ return;
+ }
+
foreach (MapEntity entity in MapEntity.SelectedList)
{
if (entity is Item item)
@@ -649,6 +686,11 @@ namespace Barotrauma
{
structure.Reset();
}
+ else
+ {
+ continue;
+ }
+ NewMessage($"Reset {entity.Name}.");
}
foreach (MapEntity entity in MapEntity.SelectedList)
{
@@ -787,7 +829,11 @@ namespace Barotrauma
AssignOnExecute("debugdraw", (string[] args) =>
{
- GameMain.DebugDraw = !GameMain.DebugDraw;
+ if (args.None() || !bool.TryParse(args[0], out bool state))
+ {
+ state = !GameMain.DebugDraw;
+ }
+ GameMain.DebugDraw = state;
NewMessage("Debug draw mode " + (GameMain.DebugDraw ? "enabled" : "disabled"), Color.White);
});
AssignRelayToServer("debugdraw", false);
@@ -1012,22 +1058,38 @@ namespace Barotrauma
commands.Add(new Command("checkmissingloca", "", (string[] args) =>
{
- foreach (MapEntityPrefab me in MapEntityPrefab.List)
+ //key = text tag, value = list of languages the tag is missing from
+ Dictionary> missingTags = new Dictionary>();
+ Dictionary> tags = new Dictionary>();
+ foreach (string language in TextManager.AvailableLanguages)
{
- string name = TextManager.Get("entityname." + me.Identifier, returnNull: true);
- if (!string.IsNullOrEmpty(name)) { continue; }
+ TextManager.Language = language;
+ tags.Add(language, new HashSet(TextManager.GetAllTagTextPairs().Select(t => t.Key)));
+ }
- if (me is ItemPrefab itemPrefab)
+ foreach (string englishTag in tags["English"])
+ {
+ if (englishTag == "entitydescription.reinforceddoor")
{
- string nameIdentifier = itemPrefab.ConfigElement?.GetAttributeString("nameidentifier", "");
- if (nameIdentifier != null)
+ int asdfsdf = 1;
+ }
+ foreach (string language in TextManager.AvailableLanguages)
+ {
+ if (language == "English") { continue; }
+ if (!tags[language].Contains(englishTag))
{
- name = TextManager.Get("entityname." + nameIdentifier, returnNull: true);
- if (!string.IsNullOrEmpty(name)) { continue; }
+ if (!missingTags.ContainsKey(englishTag))
+ {
+ missingTags[englishTag] = new List();
+ }
+ missingTags[englishTag].Add(language);
}
}
- NewMessage("Entity name not translated (" + me.Name + ", " + me.Identifier + ")!", me is ItemPrefab ? Color.Red : Color.Yellow);
}
+ string filePath = "missingloca.txt";
+ File.WriteAllLines(filePath, missingTags.Select(t => "\""+t.Key + "\"\n missing from " + string.Join(", ", t.Value)));
+ System.Diagnostics.Process.Start(Path.GetFullPath(filePath));
+ TextManager.Language = "English";
}));
commands.Add(new Command("spamchatmessages", "", (string[] args) =>
@@ -1107,21 +1169,32 @@ namespace Barotrauma
{
if (!structure.ResizeHorizontal)
{
- structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y,
+ structure.Rect = structure.DefaultRect = new Rectangle(structure.Rect.X, structure.Rect.Y,
(int)structure.Prefab.ScaledSize.X,
structure.Rect.Height);
}
if (!structure.ResizeVertical)
{
- structure.Rect = new Rectangle(structure.Rect.X, structure.Rect.Y,
+ structure.Rect = structure.DefaultRect = new Rectangle(structure.Rect.X, structure.Rect.Y,
structure.Rect.Width,
(int)structure.Prefab.ScaledSize.Y);
}
+
}
}
}
}
}, isCheat: false));
+
+ commands.Add(new Command("flip", "Flip the currently controlled character.", (string[] args) =>
+ {
+ Character.Controlled?.AnimController.Flip();
+ }, isCheat: false));
+ commands.Add(new Command("mirror", "Mirror the currently controlled character.", (string[] args) =>
+ {
+ (Character.Controlled?.AnimController as FishAnimController)?.Mirror(lerp: false);
+ }, isCheat: false));
+
#endif
commands.Add(new Command("dumptexts", "dumptexts [filepath]: Extracts all the texts from the given text xml and writes them into a file (using the same filename, but with the .txt extension). If the filepath is omitted, the EnglishVanilla.xml file is used.", (string[] args) =>
@@ -1237,21 +1310,53 @@ namespace Barotrauma
{
Dictionary typeNames = new Dictionary
{
- { "Single", "float"},
- { "Int32", "integer"},
- { "Boolean", "true/false"},
- { "String", "text"},
+ { "Single", "Float"},
+ { "Int32", "Integer"},
+ { "Boolean", "True/False"},
+ { "String", "Text"},
};
- var itemComponentTypes = typeof(ItemComponent).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ItemComponent)));
+ var itemComponentTypes = typeof(ItemComponent).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ItemComponent))).ToList();
+ itemComponentTypes.Sort((i1, i2) => { return i1.Name.CompareTo(i2.Name); });
+
+ itemComponentTypes.Insert(0, typeof(ItemComponent));
+
string filePath = args.Length > 0 ? args[0] : "ItemComponentDocumentation.txt";
List lines = new List();
foreach (Type t in itemComponentTypes)
{
- lines.Add($"[b]{t.Name}[/b]");
+
+ lines.Add($"[h1]{t.Name}[/h1]");
lines.Add("");
- var properties = t.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);//.Cast();
+ var properties = t.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly).ToList();//.Cast();
+ Type baseType = t.BaseType;
+ while (baseType != null && baseType != typeof(ItemComponent))
+ {
+ properties.AddRange(baseType.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly));
+ baseType = baseType.BaseType;
+ }
+
+ if (!properties.Any(p => p.GetCustomAttributes(true).Any(a => a is Serialize)))
+ {
+ lines.Add("No editable properties.");
+ lines.Add("");
+ continue;
+ }
+
+ lines.Add("[table]");
+ lines.Add(" [tr]");
+
+ lines.Add(" [th]Name[/th]");
+ lines.Add(" [th]Type[/th]");
+ lines.Add(" [th]Default value[/th]");
+ //lines.Add(" [th]Range[/th]");
+ lines.Add(" [th]Description[/th]");
+
+ lines.Add(" [/tr]");
+
+
+
Dictionary dictionary = new Dictionary();
foreach (var property in properties)
{
@@ -1273,29 +1378,41 @@ namespace Barotrauma
}
propertyTypeName = string.Join("/", valueNames);
}
-
- lines.Add($"{property.Name} ({propertyTypeName})");
-
- if (!string.IsNullOrEmpty(serialize.Description))
+ string defaultValueString = serialize.defaultValue?.ToString() ?? "";
+ if (property.PropertyType == typeof(float))
{
- lines.Add(serialize.Description);
+ defaultValueString = ((float)serialize.defaultValue).ToString(CultureInfo.InvariantCulture);
}
+
+ lines.Add(" [tr]");
+
+ lines.Add($" [td]{property.Name}[/td]");
+ lines.Add($" [td]{propertyTypeName}[/td]");
+ lines.Add($" [td]{defaultValueString}[/td]");
+
Editable editable = attributes.FirstOrDefault(a => a is Editable) as Editable;
+ string rangeText = "-";
if (editable != null)
{
if (editable.MinValueFloat > float.MinValue || editable.MaxValueFloat < float.MaxValue)
{
- lines.Add("Range: " + editable.MinValueFloat+"-"+editable.MaxValueFloat);
+ rangeText = editable.MinValueFloat + "-" + editable.MaxValueFloat;
}
else if (editable.MinValueInt > int.MinValue || editable.MaxValueInt < int.MaxValue)
{
- lines.Add("Range: " + editable.MinValueInt + "-" + editable.MaxValueInt);
+ rangeText = editable.MinValueInt + "-" + editable.MaxValueInt;
}
}
+ //lines.Add($" [td]{rangeText}[/td]");
- lines.Add("Default value: " + serialize.defaultValue);
- lines.Add("");
+ if (!string.IsNullOrEmpty(serialize.Description))
+ {
+ lines.Add($" [td]{serialize.Description}[/td]");
+ }
+
+ lines.Add(" [/tr]");
}
+ lines.Add("[/table]");
lines.Add("");
}
File.WriteAllLines(filePath, lines);
@@ -1546,10 +1663,12 @@ namespace Barotrauma
(string[] args) =>
{
if (GameMain.Client == null || args.Length == 0) return;
- ShowQuestionPrompt("Reason for banning the endpoint \"" + args[0] + "\"?", (reason) =>
+ ShowQuestionPrompt("Reason for banning the endpoint \"" + args[0] + "\"? (Enter c to cancel)", (reason) =>
{
- ShowQuestionPrompt("Enter the duration of the ban (leave empty to ban permanently, or use the format \"[days] d [hours] h\")", (duration) =>
+ if (reason == "c" || reason == "C") { return; }
+ ShowQuestionPrompt("Enter the duration of the ban (leave empty to ban permanently, or use the format \"[days] d [hours] h\") (Enter c to cancel)", (duration) =>
{
+ if (duration == "c" || duration == "C") { return; }
TimeSpan? banDuration = null;
if (!string.IsNullOrWhiteSpace(duration))
{
@@ -1866,10 +1985,17 @@ namespace Barotrauma
{
character.Info.Race = race;
character.ReloadHead();
+ foreach (var limb in character.AnimController.Limbs)
+ {
+ if (limb.type != LimbType.Head)
+ {
+ limb.RecreateSprites();
+ }
+ }
}
}, isCheat: true));
- commands.Add(new Command("loadhead|head", "Load head sprite(s). Required argument: head id. Optional arguments: hair index, beard index, moustache index, face attachment index.", args =>
+ commands.Add(new Command("head", "Load the head sprite and the wearables (hair etc). Required argument: head id. Optional arguments: hair index, beard index, moustache index, face attachment index.", args =>
{
var character = Character.Controlled;
if (character == null)
@@ -1903,6 +2029,13 @@ namespace Barotrauma
int.TryParse(args[4], out faceAttachmentIndex);
}
character.ReloadHead(id, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
+ foreach (var limb in character.AnimController.Limbs)
+ {
+ if (limb.type != LimbType.Head)
+ {
+ limb.RecreateSprites();
+ }
+ }
}
}, isCheat: true));
@@ -1948,13 +2081,13 @@ namespace Barotrauma
{
wearable.Variant = variant;
}
- wearable.RefreshPath();
+ wearable.ParsePath(true);
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
foreach (var wearable in limb.OtherWearables)
{
- wearable.RefreshPath();
+ wearable.ParsePath(true);
wearable.Sprite.ReloadXML();
wearable.Sprite.ReloadTexture();
}
diff --git a/Barotrauma/BarotraumaClient/Source/Events/Missions/Mission.cs b/Barotrauma/BarotraumaClient/Source/Events/Missions/Mission.cs
index 907f11bb5..6d839a784 100644
--- a/Barotrauma/BarotraumaClient/Source/Events/Missions/Mission.cs
+++ b/Barotrauma/BarotraumaClient/Source/Events/Missions/Mission.cs
@@ -1,4 +1,6 @@
-namespace Barotrauma
+using Barotrauma.Networking;
+
+namespace Barotrauma
{
partial class Mission
{
@@ -14,5 +16,10 @@
IconColor = Prefab.IconColor
};
}
+
+ public void ClientRead(IReadMessage msg)
+ {
+ State = msg.ReadInt16();
+ }
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
index b4c7d5308..b93ad97c1 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs
@@ -1,4 +1,5 @@
-using Barotrauma.Items.Components;
+using Barotrauma.Extensions;
+using Barotrauma.Items.Components;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -52,6 +53,8 @@ namespace Barotrauma
public GUIButton ToggleButton { get; private set; }
+ private GUIButton showNewMessagesButton;
+
public ChatBox(GUIComponent parent, bool isSinglePlayer)
{
this.IsSinglePlayer = isSinglePlayer;
@@ -65,8 +68,9 @@ namespace Barotrauma
int toggleButtonWidth = (int)(30 * GUI.Scale);
GUIFrame = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.ChatBoxArea, parent.RectTransform), style: null);
- var chatBoxHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), GUIFrame.RectTransform), style: "ChatBox");
+ var chatBoxHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.875f), GUIFrame.RectTransform), style: "ChatBox");
chatBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.95f), chatBoxHolder.RectTransform, Anchor.CenterRight), style: null);
+
ToggleButton = new GUIButton(new RectTransform(new Point(toggleButtonWidth, HUDLayoutSettings.ChatBoxArea.Height), parent.RectTransform),
style: "UIToggleButton");
@@ -76,7 +80,7 @@ namespace Barotrauma
return true;
};
- InputBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.1f), GUIFrame.RectTransform, Anchor.BottomCenter),
+ InputBox = new GUITextBox(new RectTransform(new Vector2(0.925f, 0.125f), GUIFrame.RectTransform, Anchor.BottomLeft),
style: "ChatTextBox")
{
Font = GUI.SmallFont,
@@ -84,9 +88,25 @@ namespace Barotrauma
};
InputBox.OnDeselected += (gui, Keys) =>
{
- gui.Text = "";
+ //gui.Text = "";
};
-
+
+ var chatSendButton = new GUIButton(new RectTransform(new Vector2(0.075f, 0.125f), GUIFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.0f, -0.01f) }, ">");
+ chatSendButton.OnClicked += (GUIButton btn, object userdata) =>
+ {
+ InputBox.OnEnterPressed(InputBox, InputBox.Text);
+ return true;
+ };
+
+ showNewMessagesButton = new GUIButton(new RectTransform(new Vector2(1f, 0.125f), GUIFrame.RectTransform, Anchor.BottomCenter) { RelativeOffset = new Vector2(0.0f, -0.125f) }, TextManager.Get("chat.shownewmessages"));
+ showNewMessagesButton.OnClicked += (GUIButton btn, object userdata) =>
+ {
+ chatBox.ScrollBar.BarScrollValue = 1f;
+ showNewMessagesButton.Visible = false;
+ return true;
+ };
+
+ showNewMessagesButton.Visible = false;
ToggleOpen = GameMain.Config.ChatOpen;
}
@@ -133,7 +153,7 @@ namespace Barotrauma
public void AddMessage(ChatMessage message)
{
- while (chatBox.Content.CountChildren > 20)
+ while (chatBox.Content.CountChildren > 60)
{
chatBox.RemoveChild(chatBox.Content.Children.First());
}
@@ -155,18 +175,21 @@ namespace Barotrauma
var msgHolder = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.0f), chatBox.Content.RectTransform, Anchor.TopCenter), style: null,
color: ((chatBox.Content.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f);
- GUITextBlock senderNameBlock = null;
+ GUITextBlock senderNameBlock = new GUITextBlock(new RectTransform(new Vector2(0.98f, 0.0f), msgHolder.RectTransform) { AbsoluteOffset = new Point((int)(5 * GUI.Scale), 0) },
+ ChatMessage.GetTimeStamp(), textColor: Color.LightGray, font: GUI.SmallFont, textAlignment: Alignment.TopLeft, style: null)
+ {
+ CanBeFocused = true
+ };
if (!string.IsNullOrEmpty(senderName))
{
- senderNameBlock = new GUITextBlock(new RectTransform(new Vector2(0.98f, 0.0f), msgHolder.RectTransform)
- { AbsoluteOffset = new Point((int)(5 * GUI.Scale), 0) },
+ new GUITextBlock(new RectTransform(new Vector2(0.8f, 1.0f), senderNameBlock.RectTransform) { AbsoluteOffset = new Point((int)(senderNameBlock.TextSize.X), 0) },
senderName, textColor: senderColor, font: GUI.SmallFont, textAlignment: Alignment.TopLeft, style: null)
{
CanBeFocused = true
};
}
- new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), msgHolder.RectTransform)
+ var msgText =new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), msgHolder.RectTransform)
{ AbsoluteOffset = new Point((int)(10 * GUI.Scale), senderNameBlock == null ? 0 : senderNameBlock.Rect.Height) },
displayedText, textColor: message.Color, font: GUI.SmallFont, textAlignment: Alignment.TopLeft, style: null, wrap: true,
color: ((chatBox.Content.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f)
@@ -185,12 +208,28 @@ namespace Barotrauma
{
msgHolder.Flash(Color.Yellow * 0.6f);
}
- //resize the holder to match the size of the message and add some spacing
- msgHolder.RectTransform.Resize(new Point(msgHolder.Rect.Width, msgHolder.Children.Sum(c => c.Rect.Height) + (int)(10 * GUI.Scale)), resizeChildren: false);
+ msgHolder.RectTransform.SizeChanged += Recalculate;
+ Recalculate();
+ void Recalculate()
+ {
+ msgHolder.RectTransform.SizeChanged -= Recalculate;
+ //resize the holder to match the size of the message and add some spacing
+ msgText.RectTransform.MaxSize = new Point(msgHolder.Rect.Width - msgText.RectTransform.AbsoluteOffset.X, int.MaxValue);
+ senderNameBlock.RectTransform.MaxSize = new Point(msgHolder.Rect.Width - senderNameBlock.RectTransform.AbsoluteOffset.X, int.MaxValue);
+ msgHolder.Children.ForEach(c => (c as GUITextBlock)?.CalculateHeightFromText());
+ msgHolder.RectTransform.Resize(new Point(msgHolder.Rect.Width, msgHolder.Children.Sum(c => c.Rect.Height) + (int)(10 * GUI.Scale)), resizeChildren: false);
+ msgHolder.RectTransform.SizeChanged += Recalculate;
+ chatBox.RecalculateChildren();
+ }
CoroutineManager.StartCoroutine(UpdateMessageAnimation(msgHolder, 0.5f));
chatBox.UpdateScrollBarSize();
+
+ if (chatBox.ScrollBar.Visible && chatBox.ScrollBar.BarScroll < 1f)
+ {
+ showNewMessagesButton.Visible = true;
+ }
if (!ToggleOpen)
{
@@ -203,16 +242,16 @@ namespace Barotrauma
{
CanBeFocused = false
};
- var msgText = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.0f), popupMsg.RectTransform, Anchor.TopRight)
+ var msgPopupText = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.0f), popupMsg.RectTransform, Anchor.TopRight)
{ AbsoluteOffset = new Point(0, senderText.Rect.Height) },
displayedText, textColor: message.Color, font: GUI.SmallFont, textAlignment: Alignment.TopRight, style: null, wrap: true)
{
CanBeFocused = false
};
int textWidth = (int)Math.Max(
- msgText.Font.MeasureString(msgText.WrappedText).X,
+ msgPopupText.Font.MeasureString(msgPopupText.WrappedText).X,
senderText.Font.MeasureString(senderText.WrappedText).X);
- popupMsg.RectTransform.Resize(new Point(textWidth + 20, msgText.Rect.Bottom - senderText.Rect.Y), resizeChildren: false);
+ popupMsg.RectTransform.Resize(new Point(textWidth + 20, msgPopupText.Rect.Bottom - senderText.Rect.Y), resizeChildren: false);
popupMessages.Enqueue(popupMsg);
}
@@ -277,6 +316,11 @@ namespace Barotrauma
prevUIScale = GUI.Scale;
}
+ if (showNewMessagesButton.Visible && chatBox.ScrollBar.BarScroll == 1f)
+ {
+ showNewMessagesButton.Visible = false;
+ }
+
if (ToggleOpen || (InputBox != null && InputBox.Selected))
{
openState += deltaTime * 5.0f;
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/ComponentStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/ComponentStyle.cs
index 565460059..09d15b36d 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/ComponentStyle.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/ComponentStyle.cs
@@ -19,12 +19,16 @@ namespace Barotrauma
public readonly Color OutlineColor;
+ public readonly XElement Element;
+
public readonly Dictionary> Sprites;
public Dictionary ChildStyles;
public GUIComponentStyle(XElement element)
{
+ Element = element;
+
Sprites = new Dictionary>();
foreach (GUIComponent.ComponentState state in Enum.GetValues(typeof(GUIComponent.ComponentState)))
{
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
index c87231d3d..19b88d3cd 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs
@@ -29,6 +29,35 @@ namespace Barotrauma
{
public static GUICanvas Canvas => GUICanvas.Instance;
+ public static readonly SamplerState SamplerState = new SamplerState()
+ {
+ Filter = TextureFilter.Linear,
+ AddressU = TextureAddressMode.Wrap,
+ AddressV = TextureAddressMode.Wrap,
+ AddressW = TextureAddressMode.Wrap,
+ BorderColor = Color.White,
+ MaxAnisotropy = 4,
+ MaxMipLevel = 0,
+ MipMapLevelOfDetailBias = -0.8f,
+ ComparisonFunction = CompareFunction.Never,
+ FilterMode = TextureFilterMode.Default,
+ };
+
+ public static readonly SamplerState SamplerStateClamp = new SamplerState()
+ {
+ Filter = TextureFilter.Linear,
+ AddressU = TextureAddressMode.Clamp,
+ AddressV = TextureAddressMode.Clamp,
+ AddressW = TextureAddressMode.Clamp,
+ BorderColor = Color.White,
+ MaxAnisotropy = 4,
+ MaxMipLevel = 0,
+ MipMapLevelOfDetailBias = -0.8f,
+ ComparisonFunction = CompareFunction.Never,
+ FilterMode = TextureFilterMode.Default,
+ };
+
+
public static readonly string[] vectorComponentLabels = { "X", "Y", "Z", "W" };
public static readonly string[] rectComponentLabels = { "X", "Y", "W", "H" };
public static readonly string[] colorComponentLabels = { "R", "G", "B", "A" };
@@ -455,7 +484,11 @@ namespace Barotrauma
if (GameMain.WindowActive)
{
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerStateClamp, rasterizerState: GameMain.ScissorTestEnable);
Cursor.Draw(spriteBatch, PlayerInput.LatestMousePosition, 0, Scale / 2f);
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
}
@@ -664,6 +697,7 @@ namespace Barotrauma
///
public static GUIComponent UpdateMouseOn()
{
+ GUIComponent prevMouseOn = MouseOn;
MouseOn = null;
int inventoryIndex = -1;
if (Inventory.IsMouseOnInventory())
@@ -673,9 +707,13 @@ namespace Barotrauma
for (int i = updateList.Count - 1; i > inventoryIndex; i--)
{
GUIComponent c = updateList[i];
+ if (!c.CanBeFocused) { continue; }
if (c.MouseRect.Contains(PlayerInput.MousePosition))
{
- MouseOn = c;
+ if ((!PlayerInput.LeftButtonHeld() && !PlayerInput.LeftButtonClicked()) || c == prevMouseOn)
+ {
+ MouseOn = c;
+ }
break;
}
}
@@ -1629,42 +1667,9 @@ namespace Barotrauma
return true;
}
- private static bool QuitClicked(GUIButton button, object obj)
+ public static bool QuitClicked(GUIButton button, object obj)
{
- bool save = button.UserData as string == "save";
- if (save)
- {
- SaveUtil.SaveGame(GameMain.GameSession.SavePath);
- }
-
- if (GameMain.Client != null)
- {
- GameMain.Client.Disconnect();
- GameMain.Client = null;
- }
-
- CoroutineManager.StopCoroutines("EndCinematic");
-
- if (GameMain.GameSession != null)
- {
- if (Tutorial.Initialized)
- {
- ((TutorialMode)GameMain.GameSession.GameMode).Tutorial.Stop();
- }
-
- if (GameSettings.SendUserStatistics)
- {
- Mission mission = GameMain.GameSession.Mission;
- GameAnalyticsManager.AddDesignEvent("QuitRound:" + (save ? "Save" : "NoSave"));
- GameAnalyticsManager.AddDesignEvent("EndRound:" + (mission == null ? "NoMission" : (mission.Completed ? "MissionCompleted" : "MissionFailed")));
- }
- GameMain.GameSession = null;
- }
-
- GUIMessageBox.CloseAll();
-
- GameMain.MainMenuScreen.Select();
-
+ GameMain.QuitToMainMenu(button.UserData as string == "save");
return true;
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIButton.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIButton.cs
index 79282e4bd..bdb6b4627 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIButton.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIButton.cs
@@ -153,15 +153,18 @@ namespace Barotrauma
public GUIButton(RectTransform rectT, string text = "", Alignment textAlignment = Alignment.Center, string style = "", Color? color = null) : base(style, rectT)
{
+ CanBeFocused = true;
+
if (color.HasValue)
{
this.color = color.Value;
}
- frame = new GUIFrame(new RectTransform(Vector2.One, rectT), style);
+ frame = new GUIFrame(new RectTransform(Vector2.One, rectT), style) { CanBeFocused = false };
if (style != null) GUI.Style.Apply(frame, style == "" ? "GUIButton" : style);
textBlock = new GUITextBlock(new RectTransform(Vector2.One, rectT), text, textAlignment: textAlignment, style: null)
{
- TextColor = this.style == null ? Color.Black : this.style.textColor
+ TextColor = this.style == null ? Color.Black : this.style.textColor,
+ CanBeFocused = false
};
if (rectT.Rect.Height == 0 && !string.IsNullOrEmpty(text))
{
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
index cad4abb24..cb6ed0528 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs
@@ -106,11 +106,21 @@ namespace Barotrauma
return Children.Where(c => c.userData == userData);
}
+ public IEnumerable FindChildren(Func predicate)
+ {
+ return Children.Where(c => predicate(c));
+ }
+
public virtual void ClearChildren()
{
RectTransform.ClearChildren();
}
+ public void SetAsFirstChild()
+ {
+ RectTransform.SetAsFirstChild();
+ }
+
public void SetAsLastChild()
{
RectTransform.SetAsLastChild();
@@ -319,7 +329,7 @@ namespace Barotrauma
Font = GUI.Font;
- CanBeFocused = true;
+ CanBeFocused = true; //TODO: change default to false?
if (style != null)
GUI.Style.Apply(this, style);
@@ -729,9 +739,10 @@ namespace Barotrauma
private static GUITextBlock LoadGUITextBlock(XElement element, RectTransform parent, string overrideText = null, Anchor? anchor = null)
{
- string text = element.Attribute("text") == null ?
- element.ElementInnerText() :
- element.GetAttributeString("text", "");
+ string text = overrideText ??
+ (element.Attribute("text") == null ?
+ element.ElementInnerText() :
+ element.GetAttributeString("text", ""));
text = text.Replace(@"\n", "\n");
string style = element.GetAttributeString("style", "");
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUICustomComponent.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUICustomComponent.cs
index 2fd27cc60..6289aba4e 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUICustomComponent.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUICustomComponent.cs
@@ -29,7 +29,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, Rect);
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
OnDraw?.Invoke(spriteBatch, this);
@@ -38,7 +38,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs
index 4ff2c0079..151b31ec9 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs
@@ -16,7 +16,7 @@ namespace Barotrauma
private GUIButton button;
private GUIListBox listBox;
- private RectTransform currentListBoxParent;
+ private RectTransform currentHighestParent;
private List parentHierarchy = new List();
private bool selectMultiple;
@@ -141,6 +141,8 @@ namespace Barotrauma
public GUIDropDown(RectTransform rectT, string text = "", int elementCount = 4, string style = "", bool selectMultiple = false) : base(style, rectT)
{
+ CanBeFocused = true;
+
this.selectMultiple = selectMultiple;
button = new GUIButton(new RectTransform(Vector2.One, rectT), text, Alignment.CenterLeft, style: "GUIDropDown")
@@ -149,7 +151,7 @@ namespace Barotrauma
};
GUI.Style.Apply(button, "", this);
- listBox = new GUIListBox(new RectTransform(new Point(Rect.Width, Rect.Height * MathHelper.Clamp(elementCount, 2, 10)), rectT, Anchor.BottomLeft, Pivot.TopLeft)
+ listBox = new GUIListBox(new RectTransform(new Point(Rect.Width, Rect.Height * MathHelper.Clamp(elementCount, 2, 10)), rectT, Anchor.BottomCenter, Pivot.TopCenter)
{ IsFixedSize = false }, style: null)
{
Enabled = !selectMultiple,
@@ -157,48 +159,55 @@ namespace Barotrauma
};
GUI.Style.Apply(listBox.Content, "GUIListBox", this);
- currentListBoxParent = FindListBoxParent();
- currentListBoxParent.GUIComponent.OnAddedToGUIUpdateList += AddListBoxToGUIUpdateList;
+ currentHighestParent = FindHighestParent();
+ currentHighestParent.GUIComponent.OnAddedToGUIUpdateList += AddListBoxToGUIUpdateList;
rectT.ParentChanged += (RectTransform newParent) =>
{
- currentListBoxParent.GUIComponent.OnAddedToGUIUpdateList -= AddListBoxToGUIUpdateList;
+ currentHighestParent.GUIComponent.OnAddedToGUIUpdateList -= AddListBoxToGUIUpdateList;
if (newParent != null)
{
- currentListBoxParent = FindListBoxParent();
- currentListBoxParent.GUIComponent.OnAddedToGUIUpdateList += AddListBoxToGUIUpdateList;
+ currentHighestParent = FindHighestParent();
+ currentHighestParent.GUIComponent.OnAddedToGUIUpdateList += AddListBoxToGUIUpdateList;
}
};
}
///
- /// Finds the component after which the listbox should be drawn. Usually the parent of the dropdown, but if the dropdown
- /// is the child of another GUIListBox, we need to draw our listbox after that because listboxes clip everything outside their rect.
+ /// Finds the component after which the listbox should be drawn
+ /// //(= the component highest in the hierarchy, to get the listbox
+ /// //to be rendered on top of all of it's children)
///
- private RectTransform FindListBoxParent()
+ private RectTransform FindHighestParent()
{
parentHierarchy.Clear();
+
+ //collect entire parent hierarchy to a list
parentHierarchy = new List() { RectTransform.Parent };
- while (parentHierarchy.Last().Parent != null)
+ RectTransform parent = parentHierarchy.Last();
+ while (parent?.Parent != null)
{
- parentHierarchy.Add(parentHierarchy.Last().Parent);
+ parentHierarchy.Add(parent.Parent);
+ parent = parent.Parent;
}
- //find the parent GUIListBox highest in the hierarchy
- for (int i = parentHierarchy.Count - 1; i >= 0; i--)
+
+ //find the highest parent that has a guicomponent with a style
+ //(and so should be rendered and not just some empty parent/root element used for constructing a layout)
+ for (int i = parentHierarchy.Count - 1; i > 0; i--)
{
- if (parentHierarchy[i].GUIComponent is GUIListBox)
+ if (parentHierarchy[i] is GUICanvas ||
+ parentHierarchy[i].GUIComponent == null ||
+ parentHierarchy[i].GUIComponent.Style == null ||
+ parentHierarchy[i].GUIComponent == Screen.Selected?.Frame)
{
- if (parentHierarchy[i].Parent != null && parentHierarchy[i].Parent.GUIComponent != null)
- {
- return parentHierarchy[i].Parent;
- }
- return parentHierarchy[i];
+ parentHierarchy.RemoveAt(i);
+ }
+ else
+ {
+ break;
}
}
- //or just go with the direct parent if there are no listboxes in the hierarchy
- parentHierarchy.Clear();
- parentHierarchy.Add(RectTransform.Parent);
- return RectTransform.Parent;
+ return parentHierarchy.Last();
}
public void AddItem(string text, object userData = null, string toolTip = "")
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIFrame.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIFrame.cs
index eccf78a2f..582eb986f 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIFrame.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIFrame.cs
@@ -20,7 +20,7 @@ namespace Barotrauma
Color currColor = GetCurrentColor(state);
- if (sprites == null || !sprites.Any()) GUI.DrawRectangle(spriteBatch, Rect, currColor * (currColor.A/255.0f), true);
+ if (sprites == null || !sprites.Any(s => s.Value.Any())) GUI.DrawRectangle(spriteBatch, Rect, currColor * (currColor.A/255.0f), true);
base.Draw(spriteBatch);
if (OutlineColor != Color.Transparent)
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIImage.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIImage.cs
index 9817060fd..1f1d54575 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIImage.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIImage.cs
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
+using System.Linq;
namespace Barotrauma
{
@@ -57,6 +58,10 @@ namespace Barotrauma
}
}
+ public BlendState BlendState;
+
+ public ComponentState? OverrideState = null;
+
public GUIImage(RectTransform rectT, string style, bool scaleToFit = false)
: this(rectT, null, null, scaleToFit, style)
{
@@ -82,9 +87,7 @@ namespace Barotrauma
}
if (style == null)
{
- color = Color.White;
- hoverColor = Color.White;
- selectedColor = Color.White;
+ color = hoverColor = selectedColor = pressedColor = Color.White;
}
if (!scaleToFit)
{
@@ -99,7 +102,17 @@ namespace Barotrauma
protected override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
+
+ if (Parent != null) { state = Parent.State; }
+ if (OverrideState != null) { state = OverrideState.Value; }
Color currColor = GetCurrentColor(state);
+
+ if (BlendState != null)
+ {
+ spriteBatch.End();
+ spriteBatch.Begin(blendState: BlendState, samplerState: GUI.SamplerState);
+ }
+
if (style != null)
{
foreach (UISprite uiSprite in style.Sprites[state])
@@ -121,6 +134,12 @@ namespace Barotrauma
spriteBatch.Draw(sprite.Texture, Rect.Center.ToVector2(), sourceRect, currColor * (currColor.A / 255.0f), Rotation, sprite.size / 2,
Scale, SpriteEffects, 0.0f);
}
+
+ if (BlendState != null)
+ {
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
+ }
}
private void RecalculateScale()
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUILayoutGroup.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUILayoutGroup.cs
index e797b022a..96bc0edd8 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUILayoutGroup.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUILayoutGroup.cs
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
+using System;
using System.Linq;
namespace Barotrauma
@@ -71,6 +72,8 @@ namespace Barotrauma
public GUILayoutGroup(RectTransform rectT, bool isHorizontal = false, Anchor childAnchor = Anchor.TopLeft) : base(null, rectT)
{
+ CanBeFocused = false;
+
this.isHorizontal = isHorizontal;
this.childAnchor = childAnchor;
rectT.ChildrenChanged += (child) => needsToRecalculate = true;
@@ -83,17 +86,25 @@ namespace Barotrauma
float stretchFactor = 1.0f;
if (stretch && RectTransform.Children.Count() > 0)
{
+ float minSize = RectTransform.Children
+ .Where(c => !c.GUIComponent.IgnoreLayoutGroups)
+ .Sum(c => isHorizontal ? c.MinSize.X : c.MinSize.Y);
+
float totalSize = RectTransform.Children
.Where(c => !c.GUIComponent.IgnoreLayoutGroups)
.Sum(c => isHorizontal ?
MathHelper.Clamp(c.Rect.Width, c.MinSize.X, c.MaxSize.X) :
MathHelper.Clamp(c.Rect.Height, c.MinSize.Y, c.MaxSize.Y));
+ float thisSize = (isHorizontal ? Rect.Width : Rect.Height);
+
totalSize +=
(RectTransform.Children.Count() - 1) *
- (absoluteSpacing + relativeSpacing * (isHorizontal ? Rect.Width : Rect.Height));
+ (absoluteSpacing + relativeSpacing * thisSize);
- stretchFactor = totalSize <= 0.0f ? 1.0f : (isHorizontal ? Rect.Width: Rect.Height) / totalSize;
+ stretchFactor = totalSize <= 0.0f || minSize >= thisSize ?
+ 1.0f :
+ (thisSize - minSize) / (totalSize - minSize);
}
int absPos = 0;
@@ -106,7 +117,7 @@ namespace Barotrauma
{
child.RelativeOffset = new Vector2(relPos, child.RelativeOffset.Y);
child.AbsoluteOffset = new Point(absPos, child.AbsoluteOffset.Y);
- absPos += (int)((child.Rect.Width + absoluteSpacing) * stretchFactor);
+ absPos += (int)Math.Max((child.Rect.Width + absoluteSpacing) * stretchFactor, child.MinSize.X);
if (stretch)
{
child.RelativeSize = new Vector2(child.RelativeSize.X * stretchFactor, child.RelativeSize.Y);
@@ -116,7 +127,7 @@ namespace Barotrauma
{
child.RelativeOffset = new Vector2(child.RelativeOffset.X, relPos);
child.AbsoluteOffset = new Point(child.AbsoluteOffset.X, absPos);
- absPos += (int)((child.Rect.Height + absoluteSpacing) * stretchFactor);
+ absPos += (int)Math.Max((child.Rect.Height + absoluteSpacing) * stretchFactor, child.MinSize.Y);
if (stretch)
{
child.RelativeSize = new Vector2(child.RelativeSize.X, child.RelativeSize.Y * stretchFactor);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
index ed822aa59..586663afe 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs
@@ -135,6 +135,8 @@ namespace Barotrauma
public GUIListBox(RectTransform rectT, bool isHorizontal = false, Color? color = null, string style = "") : base(style, rectT)
{
+ CanBeFocused = true;
+
selected = new List();
Point frameSize = isHorizontal ?
@@ -176,7 +178,7 @@ namespace Barotrauma
private void UpdateDimensions()
{
- if (!ScrollBarEnabled)
+ if (!ScrollBar.Visible)
{
Content.RectTransform.NonScaledSize = Rect.Size;
}
@@ -295,7 +297,7 @@ namespace Barotrauma
if (child == null) continue;
// selecting
- if (Enabled && child.CanBeFocused && (GUI.IsMouseOn(child)) && child.Rect.Contains(PlayerInput.MousePosition))
+ if (Enabled && CanBeFocused && child.CanBeFocused && (GUI.IsMouseOn(child)) && child.Rect.Contains(PlayerInput.MousePosition))
{
child.State = ComponentState.Hover;
if (PlayerInput.LeftButtonClicked())
@@ -322,6 +324,15 @@ namespace Barotrauma
public override void AddToGUIUpdateList(bool ignoreChildren = false, int order = 0)
{
if (!Visible) { return; }
+
+ if (!ignoreChildren)
+ {
+ foreach (GUIComponent child in Children)
+ {
+ if (child == Content || child == ScrollBar) { continue; }
+ child.AddToGUIUpdateList(ignoreChildren, order);
+ }
+ }
foreach (GUIComponent child in Content.Children)
{
@@ -406,12 +417,16 @@ namespace Barotrauma
scrollBarNeedsRecalculation = false;
}
+ bool prevScrollBarVisible = ScrollBar.Visible;
+
ScrollBar.Enabled = ScrollBarEnabled && ScrollBar.BarSize < 1.0f;
if (AutoHideScrollBar)
{
ScrollBar.Visible = ScrollBar.BarSize < 1.0f;
}
+ if (ScrollBar.Visible != prevScrollBarVisible) { UpdateDimensions(); }
+
if ((GUI.IsMouseOn(this) || GUI.IsMouseOn(ScrollBar)) && PlayerInput.ScrollWheelSpeed != 0)
{
ScrollBar.BarScroll -= (PlayerInput.ScrollWheelSpeed / 500.0f) * BarSize;
@@ -594,7 +609,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, Content.Rect);
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
var children = Content.Children;
@@ -618,7 +633,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: prevRasterizerState);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: prevRasterizerState);
}
if (ScrollBar.Visible) ScrollBar.DrawManually(spriteBatch, alsoChildren: true, recursive: true);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUINumberInput.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUINumberInput.cs
index ca436e624..b456de7ec 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUINumberInput.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUINumberInput.cs
@@ -119,6 +119,19 @@ namespace Barotrauma
}
}
+ public override ScalableFont Font
+ {
+ get
+ {
+ return base.Font;
+ }
+ set
+ {
+ base.Font = value;
+ if (TextBox != null) { TextBox.Font = value; }
+ }
+ }
+
public GUILayoutGroup LayoutGroup
{
get;
@@ -147,11 +160,11 @@ namespace Barotrauma
};
TextBox.OnTextChanged += TextChanged;
var buttonArea = new GUIFrame(new RectTransform(new Vector2(_relativeButtonAreaWidth, 1.0f), LayoutGroup.RectTransform, Anchor.CenterRight), style: null);
- if (!relativeButtonAreaWidth.HasValue)
+ /*if (!relativeButtonAreaWidth.HasValue)
{
// Not sure what's the point of this
buttonArea.RectTransform.MinSize = new Point(Rect.Height, 0);
- }
+ }*/
PlusButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.5f), buttonArea.RectTransform), "+");
PlusButton.OnButtonDown += () =>
{
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIProgressBar.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIProgressBar.cs
index f982c05f3..b8ea1f87d 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIProgressBar.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIProgressBar.cs
@@ -94,7 +94,7 @@ namespace Barotrauma
{
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, sliderRect);
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
Color currColor = GetCurrentColor(state);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIRadioButtonGroup.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIRadioButtonGroup.cs
index f9ee629cb..1ca22acf1 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIRadioButtonGroup.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIRadioButtonGroup.cs
@@ -9,11 +9,12 @@ namespace Barotrauma
{
public class GUIRadioButtonGroup : GUIComponent
{
- private Dictionary radioButtons; //TODO: use children list instead?
+ private Dictionary radioButtons; //TODO: use children list instead?
- public GUIRadioButtonGroup() : base("GUIFrame")
+ public GUIRadioButtonGroup() : base(null)
{
- radioButtons = new Dictionary();
+ radioButtons = new Dictionary();
+ selected = null;
}
public override bool Enabled
@@ -22,28 +23,28 @@ namespace Barotrauma
set
{
base.Enabled = value;
- foreach(KeyValuePair rbPair in radioButtons)
+ foreach(KeyValuePair rbPair in radioButtons)
{
rbPair.Value.Enabled = value;
}
}
}
- public void AddRadioButton(Enum key, GUITickBox radioButton)
+ public void AddRadioButton(int key, GUITickBox radioButton)
{
if (selected == key) radioButton.Selected = true;
else if (radioButton.Selected) selected = key;
radioButton.SetRadioButtonGroup(this);
- radioButtons.Add(key, radioButton);
+ radioButtons.Add((int)key, radioButton);
}
- public delegate void RadioButtonGroupDelegate(GUIRadioButtonGroup rbg, Enum val);
+ public delegate void RadioButtonGroupDelegate(GUIRadioButtonGroup rbg, int? val);
public RadioButtonGroupDelegate OnSelect = null;
public void SelectRadioButton(GUITickBox radioButton)
{
- foreach (KeyValuePair rbPair in radioButtons)
+ foreach (KeyValuePair rbPair in radioButtons)
{
if (radioButton == rbPair.Value)
{
@@ -53,8 +54,8 @@ namespace Barotrauma
}
}
- private Enum selected;
- public Enum Selected
+ private int? selected;
+ public int? Selected
{
get
{
@@ -63,11 +64,11 @@ namespace Barotrauma
set
{
OnSelect?.Invoke(this, value);
- if (selected != null && selected.Equals((Enum)value)) return;
+ if (selected != null && selected.Equals(value)) return;
selected = value;
- foreach (KeyValuePair radioButton in radioButtons)
+ foreach (KeyValuePair radioButton in radioButtons)
{
- if (radioButton.Key.Equals((Enum)value))
+ if (radioButton.Key.Equals(value))
{
radioButton.Value.Selected = true;
}
@@ -80,7 +81,7 @@ namespace Barotrauma
{
get
{
- return radioButtons[selected];
+ return selected.HasValue ? radioButtons[selected.Value] : null;
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIScrollBar.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIScrollBar.cs
index 5f6f443c8..42a24b06c 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUIScrollBar.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIScrollBar.cs
@@ -17,6 +17,8 @@ namespace Barotrauma
private float barScroll;
private float step;
+
+ private Vector2? dragStartPos;
public delegate bool OnMovedHandler(GUIScrollBar scrollBar, float barScroll);
public OnMovedHandler OnMoved;
@@ -162,6 +164,18 @@ namespace Barotrauma
}
}
+ public float StepValue
+ {
+ get
+ {
+ return step * (Range.Y - Range.X);
+ }
+ set
+ {
+ Step = value / (Range.Y - Range.X);
+ }
+ }
+
public float BarSize
{
get { return barSize; }
@@ -174,6 +188,8 @@ namespace Barotrauma
public GUIScrollBar(RectTransform rectT, float barSize = 1, Color? color = null, string style = "", bool? isHorizontal = null) : base(style, rectT)
{
+ CanBeFocused = true;
+
this.isHorizontal = isHorizontal ?? (Rect.Width > Rect.Height);
Frame = new GUIFrame(new RectTransform(Vector2.One, rectT));
GUI.Style.Apply(Frame, IsHorizontal ? "GUIFrameHorizontal" : "GUIFrameVertical", this);
@@ -201,11 +217,11 @@ namespace Barotrauma
protected override void Update(float deltaTime)
{
- if (!Visible) return;
+ if (!Visible) { return; }
base.Update(deltaTime);
- if (!enabled) return;
+ if (!enabled) { return; }
if (IsBooleanSwitch &&
(!PlayerInput.LeftButtonHeld() || (GUI.MouseOn != this && !IsParentOf(GUI.MouseOn))))
@@ -221,10 +237,19 @@ namespace Barotrauma
if (draggingBar == this)
{
+ if (dragStartPos == null) { dragStartPos = PlayerInput.MousePosition; }
+
if (!PlayerInput.LeftButtonHeld())
{
+ if (IsBooleanSwitch && GUI.MouseOn == Bar && Vector2.Distance(dragStartPos.Value, PlayerInput.MousePosition) < 5)
+ {
+ BarScroll = BarScroll > 0.5f ? 0.0f : 1.0f;
+ OnMoved?.Invoke(this, BarScroll);
+ }
OnReleased?.Invoke(this, BarScroll);
draggingBar = null;
+ dragStartPos = null;
+
}
if ((isHorizontal && PlayerInput.MousePosition.X > Rect.X && PlayerInput.MousePosition.X < Rect.Right) ||
(!isHorizontal && PlayerInput.MousePosition.Y > Rect.Y && PlayerInput.MousePosition.Y < Rect.Bottom))
@@ -237,9 +262,18 @@ namespace Barotrauma
if (PlayerInput.LeftButtonClicked())
{
draggingBar?.OnReleased?.Invoke(draggingBar, draggingBar.BarScroll);
- MoveButton(new Vector2(
- Math.Sign(PlayerInput.MousePosition.X - Bar.Rect.Center.X) * Bar.Rect.Width,
- Math.Sign(PlayerInput.MousePosition.Y - Bar.Rect.Center.Y) * Bar.Rect.Height));
+ if (IsBooleanSwitch)
+ {
+ MoveButton(new Vector2(
+ Math.Sign(PlayerInput.MousePosition.X - Bar.Rect.Center.X) * Rect.Width,
+ Math.Sign(PlayerInput.MousePosition.Y - Bar.Rect.Center.Y) * Rect.Height));
+ }
+ else
+ {
+ MoveButton(new Vector2(
+ Math.Sign(PlayerInput.MousePosition.X - Bar.Rect.Center.X) * Bar.Rect.Width,
+ Math.Sign(PlayerInput.MousePosition.Y - Bar.Rect.Center.Y) * Bar.Rect.Height));
+ }
}
}
}
@@ -270,7 +304,7 @@ namespace Barotrauma
BarScroll = newScroll;
- if (moveAmount != Vector2.Zero && OnMoved != null) OnMoved(this, BarScroll);
+ if (moveAmount != Vector2.Zero && OnMoved != null) { OnMoved(this, BarScroll); }
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
index c54a3db71..18a5cd3e6 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs
@@ -242,10 +242,10 @@ namespace Barotrauma
Censor = false;
}
- public void CalculateHeightFromText()
+ public void CalculateHeightFromText(int padding = 0)
{
if (wrappedText == null) { return; }
- RectTransform.Resize(new Point(RectTransform.Rect.Width, (int)Font.MeasureString(wrappedText).Y));
+ RectTransform.Resize(new Point(RectTransform.Rect.Width, (int)Font.MeasureString(wrappedText).Y + padding));
}
public override void ApplyStyle(GUIComponentStyle style)
@@ -262,7 +262,7 @@ namespace Barotrauma
if (text == null) return;
censoredText = "";
- for (int i=0;i 0.0f) GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (currColor.A / 255.0f), false);
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
index 94e83bef0..6db251444 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBox.cs
@@ -9,9 +9,9 @@ using System.Linq;
namespace Barotrauma
{
- delegate void TextBoxEvent(GUITextBox sender, Keys key);
+ public delegate void TextBoxEvent(GUITextBox sender, Keys key);
- class GUITextBox : GUIComponent, IKeyboardSubscriber
+ public class GUITextBox : GUIComponent, IKeyboardSubscriber
{
public event TextBoxEvent OnSelected;
public event TextBoxEvent OnDeselected;
@@ -38,6 +38,7 @@ namespace Barotrauma
public bool CaretEnabled { get; set; }
public Color? CaretColor { get; set; }
+ public bool DeselectAfterMessage = true;
private int? maxTextLength;
@@ -232,6 +233,8 @@ namespace Barotrauma
Alignment textAlignment = Alignment.Left, bool wrap = false, string style = "", Color? color = null)
: base(style, rectT)
{
+ CanBeFocused = true;
+
Enabled = true;
this.color = color ?? Color.White;
frame = new GUIFrame(new RectTransform(Vector2.One, rectT, Anchor.Center), style, color);
@@ -477,7 +480,7 @@ namespace Barotrauma
}
else
{
- if (PlayerInput.LeftButtonClicked() && selected) Deselect();
+ if ((PlayerInput.LeftButtonClicked() || PlayerInput.RightButtonClicked()) && selected) Deselect();
isSelecting = false;
state = ComponentState.None;
}
@@ -656,7 +659,12 @@ namespace Barotrauma
switch (command)
{
case '\b': //backspace
- if (selectedCharacters > 0)
+ if (PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl))
+ {
+ SetText(string.Empty, false);
+ CaretIndex = Text.Length;
+ }
+ else if (selectedCharacters > 0)
{
RemoveSelectedText();
}
@@ -692,6 +700,7 @@ namespace Barotrauma
text = memento.Undo();
if (text != Text)
{
+ ClearSelection();
SetText(text, false);
CaretIndex = Text.Length;
OnTextChanged?.Invoke(this, Text);
@@ -701,6 +710,7 @@ namespace Barotrauma
text = memento.Redo();
if (text != Text)
{
+ ClearSelection();
SetText(text, false);
CaretIndex = Text.Length;
OnTextChanged?.Invoke(this, Text);
@@ -860,16 +870,12 @@ namespace Barotrauma
private void RemoveSelectedText()
{
if (selectedText.Length == 0) { return; }
- if (IsLeftToRight)
- {
- SetText(Text.Remove(selectionStartIndex, selectedText.Length));
- CaretIndex = Math.Min(Text.Length, selectionStartIndex);
- }
- else
- {
- SetText(Text.Remove(selectionEndIndex, selectedText.Length));
- CaretIndex = Math.Min(Text.Length, selectionEndIndex);
- }
+
+ selectionStartIndex = Math.Max(0, Math.Min(selectionEndIndex, Math.Min(selectionStartIndex, Text.Length - 1)));
+ int selectionLength = Math.Min(Text.Length - selectionStartIndex, selectedText.Length);
+ SetText(Text.Remove(selectionStartIndex, selectionLength));
+ CaretIndex = Math.Min(Text.Length, selectionStartIndex);
+
ClearSelection();
OnTextChanged?.Invoke(this, Text);
}
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITickBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITickBox.cs
index dd572c229..5d0c06360 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/GUITickBox.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITickBox.cs
@@ -1,11 +1,13 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using System;
using System.Collections.Generic;
namespace Barotrauma
{
public class GUITickBox : GUIComponent
{
+ private GUILayoutGroup layoutGroup;
private GUIFrame box;
private GUITextBlock text;
@@ -69,14 +71,19 @@ namespace Barotrauma
set { text.TextColor = value; }
}
- public override Rectangle MouseRect
+ /*public override Rectangle MouseRect
{
get
{
if (!CanBeFocused) return Rectangle.Empty;
- return ClampMouseRectToParent ? ClampRect(box.Rect) : box.Rect;
+ Rectangle union = Rectangle.Union(box.Rect, TextBlock.Rect);
+ Vector2 textPos = TextBlock.Rect.Location.ToVector2() + TextBlock.TextPos + TextBlock.TextOffset;
+ Vector2 textSize = TextBlock.Font.MeasureString(TextBlock.Text);
+ union = Rectangle.Union(union, new Rectangle(textPos.ToPoint(), textSize.ToPoint()));
+ union = Rectangle.Union(union, Rect);
+ return ClampMouseRectToParent ? ClampRect(union) : union;
}
- }
+ }*/
public override ScalableFont Font
{
@@ -121,7 +128,11 @@ namespace Barotrauma
public GUITickBox(RectTransform rectT, string label, ScalableFont font = null, string style = "") : base(null, rectT)
{
- box = new GUIFrame(new RectTransform(new Point(rectT.Rect.Height, rectT.Rect.Height), rectT, Anchor.CenterLeft)
+ CanBeFocused = true;
+
+ layoutGroup = new GUILayoutGroup(new RectTransform(Vector2.One, rectT), true);
+
+ box = new GUIFrame(new RectTransform(Vector2.One, layoutGroup.RectTransform, scaleBasis: ScaleBasis.BothHeight)
{
IsFixedSize = false
}, string.Empty, Color.DarkGray)
@@ -131,7 +142,11 @@ namespace Barotrauma
CanBeFocused = false
};
GUI.Style.Apply(box, style == "" ? "GUITickBox" : style);
- text = new GUITextBlock(new RectTransform(Vector2.One, rectT, Anchor.CenterLeft) { AbsoluteOffset = new Point(box.Rect.Width, 0) }, label, font: font, textAlignment: Alignment.CenterLeft);
+ Vector2 textBlockScale = new Vector2((float)(Rect.Width - Rect.Height) / (float)Math.Max(Rect.Width, 1.0), 1.0f);
+ text = new GUITextBlock(new RectTransform(textBlockScale, layoutGroup.RectTransform), label, font: font, textAlignment: Alignment.CenterLeft)
+ {
+ CanBeFocused = false
+ };
GUI.Style.Apply(text, "GUIButtonHorizontal", this);
Enabled = true;
@@ -148,9 +163,9 @@ namespace Barotrauma
private void ResizeBox()
{
- box.RectTransform.NonScaledSize = new Point(RectTransform.NonScaledSize.Y);
- text.RectTransform.NonScaledSize = new Point(Rect.Width - box.Rect.Width, text.Rect.Height);
- text.RectTransform.AbsoluteOffset = new Point(box.Rect.Width, 0);
+ Vector2 textBlockScale = new Vector2(Math.Max(Rect.Width - box.Rect.Width, 0.0f) / Math.Max(Rect.Width, 1.0f), 1.0f);
+ text.RectTransform.RelativeSize = textBlockScale;
+ text.SetTextPos();
}
protected override void Update(float deltaTime)
diff --git a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs
index 52b571a7c..a9afef032 100644
--- a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs
+++ b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs
@@ -21,11 +21,11 @@ namespace Barotrauma
private Video currSplashScreen;
private DateTime videoStartTime;
- private Queue> pendingSplashScreens = new Queue>();
+ private Queue> pendingSplashScreens = new Queue>();
///
- /// Pair.first = filepath, Pair.second = resolution
+ /// Triplet.first = filepath, Triplet.second = resolution, Triplet.third = audio gain
///
- public Queue> PendingSplashScreens
+ public Queue> PendingSplashScreens
{
get
{
@@ -49,7 +49,7 @@ namespace Barotrauma
{
lock (loadMutex)
{
- return currSplashScreen != null;
+ return currSplashScreen != null || pendingSplashScreens.Count > 0;
}
}
}
@@ -149,7 +149,7 @@ namespace Barotrauma
TitlePosition = new Vector2(GameMain.GraphicsWidth * 0.5f, GameMain.GraphicsHeight * 0.45f);
}
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, samplerState: GUI.SamplerState);
graphics.Clear(Color.Black);
spriteBatch.Draw(backgroundTexture, BackgroundPosition, null, Color.White * Math.Min(state / 5.0f, 1.0f), 0.0f,
@@ -168,7 +168,7 @@ namespace Barotrauma
WaterRenderer.Instance.RenderWater(spriteBatch, renderTarget, null);
}
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, samplerState: GUI.SamplerState);
titleSprite?.Draw(spriteBatch, TitlePosition, Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), scale: titleScale);
@@ -280,6 +280,7 @@ namespace Barotrauma
try
{
currSplashScreen = new Video(graphics, GameMain.SoundManager, fileName, (uint)resolution.X, (uint)resolution.Y);
+ currSplashScreen.AudioGain = newSplashScreen.Third;
videoStartTime = DateTime.Now;
}
catch (Exception e)
diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs
index 1199a63eb..fff5b55ee 100644
--- a/Barotrauma/BarotraumaClient/Source/GameMain.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs
@@ -166,6 +166,8 @@ namespace Barotrauma
get { return loadingScreenOpen; }
}
+ private const GraphicsProfile GfxProfile = GraphicsProfile.Reach;
+
public GameMain(string[] args)
{
Content.RootDirectory = "Content";
@@ -173,6 +175,7 @@ namespace Barotrauma
GraphicsDeviceManager = new GraphicsDeviceManager(this);
GraphicsDeviceManager.IsFullScreen = false;
+ GraphicsDeviceManager.GraphicsProfile = GfxProfile;
GraphicsDeviceManager.ApplyChanges();
Window.Title = "Barotrauma";
@@ -222,7 +225,7 @@ namespace Barotrauma
GraphicsHeight = Math.Min(GraphicsDevice.DisplayMode.Height, GraphicsHeight);
break;
}
- GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.Reach;
+ GraphicsDeviceManager.GraphicsProfile = GfxProfile;
GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color;
GraphicsDeviceManager.PreferMultiSampling = false;
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
@@ -292,6 +295,8 @@ namespace Barotrauma
GraphicsWidth = GraphicsDevice.Viewport.Width;
GraphicsHeight = GraphicsDevice.Viewport.Height;
+ ApplyGraphicsSettings();
+
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
spriteBatch = new SpriteBatch(GraphicsDevice);
@@ -308,8 +313,6 @@ namespace Barotrauma
bool canLoadInSeparateThread = true;
- ApplyGraphicsSettings();
-
loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "Load", canLoadInSeparateThread);
}
@@ -382,9 +385,10 @@ namespace Barotrauma
if (Config.EnableSplashScreen)
{
var pendingSplashScreens = TitleScreen.PendingSplashScreens;
- pendingSplashScreens?.Enqueue(new Pair("Content/Splash_UTG.mp4", new Point(1280, 720)));
- pendingSplashScreens?.Enqueue(new Pair("Content/Splash_FF.mp4", new Point(1280, 720)));
- pendingSplashScreens?.Enqueue(new Pair("Content/Splash_Daedalic.mp4", new Point(1920, 1080)));
+ float baseVolume = MathHelper.Clamp(Config.SoundVolume * 2.0f, 0.0f, 1.0f);
+ pendingSplashScreens?.Enqueue(new Triplet("Content/Splash_UTG.mp4", new Point(1280, 720), baseVolume * 0.5f));
+ pendingSplashScreens?.Enqueue(new Triplet("Content/Splash_FF.mp4", new Point(1280, 720), baseVolume));
+ pendingSplashScreens?.Enqueue(new Triplet("Content/Splash_Daedalic.mp4", new Point(1920, 1080), baseVolume * 0.15f));
}
//if not loading in a separate thread, wait for the splash screens to finish before continuing the loading
@@ -477,11 +481,6 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs));
- // Add any missing jobs from the prefab into Config.JobNamePreferences.
- foreach (string job in JobPrefab.List.Keys)
- {
- if (!Config.JobPreferences.Contains(job)) { Config.JobPreferences.Add(job); }
- }
NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations));
@@ -779,7 +778,17 @@ namespace Barotrauma
}
}
- GUI.ClearUpdateList();
+#if DEBUG
+ if (GameMain.NetworkMember == null)
+ {
+ if (PlayerInput.KeyHit(Keys.P) && !(GUI.KeyboardDispatcher.Subscriber is GUITextBox))
+ {
+ DebugConsole.Paused = !DebugConsole.Paused;
+ }
+ }
+#endif
+
+ GUI.ClearUpdateList();
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen || Tutorial.ContentRunning || DebugConsole.Paused) &&
(NetworkMember == null || !NetworkMember.GameStarted);
@@ -800,7 +809,7 @@ namespace Barotrauma
DebugConsole.AddToGUIUpdateList();
- DebugConsole.Update(this, (float)Timing.Step);
+ DebugConsole.Update((float)Timing.Step);
paused = paused || (DebugConsole.IsOpen && (NetworkMember == null || !NetworkMember.GameStarted));
if (!paused)
@@ -878,6 +887,7 @@ namespace Barotrauma
{
spriteBatch.Begin();
GUI.DrawRectangle(spriteBatch, GUI.MouseOn.MouseRect, Color.Lime);
+ GUI.DrawRectangle(spriteBatch, GUI.MouseOn.Rect, Color.Cyan);
spriteBatch.End();
}
@@ -887,6 +897,61 @@ namespace Barotrauma
PerformanceCounter.DrawTimeGraph.Update(sw.ElapsedTicks / (float)TimeSpan.TicksPerMillisecond);
}
+
+ public static void QuitToMainMenu(bool save, bool showVerificationPrompt)
+ {
+ if (showVerificationPrompt)
+ {
+ string text = (Screen.Selected is CharacterEditor.CharacterEditorScreen || Screen.Selected is SubEditorScreen) ? "PauseMenuQuitVerificationEditor" : "PauseMenuQuitVerification";
+ var msgBox = new GUIMessageBox("", TextManager.Get(text), new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
+ {
+ UserData = "verificationprompt"
+ };
+ msgBox.Buttons[0].OnClicked = (yesBtn, userdata) =>
+ {
+ QuitToMainMenu(save);
+ return true;
+ };
+ msgBox.Buttons[0].OnClicked += msgBox.Close;
+ msgBox.Buttons[1].OnClicked += msgBox.Close;
+ }
+
+ }
+
+ public static void QuitToMainMenu(bool save)
+ {
+ if (save)
+ {
+ SaveUtil.SaveGame(GameMain.GameSession.SavePath);
+ }
+
+ if (GameMain.Client != null)
+ {
+ GameMain.Client.Disconnect();
+ GameMain.Client = null;
+ }
+
+ CoroutineManager.StopCoroutines("EndCinematic");
+
+ if (GameMain.GameSession != null)
+ {
+ if (Tutorial.Initialized)
+ {
+ ((TutorialMode)GameMain.GameSession.GameMode).Tutorial?.Stop();
+ }
+
+ if (GameSettings.SendUserStatistics)
+ {
+ Mission mission = GameMain.GameSession.Mission;
+ GameAnalyticsManager.AddDesignEvent("QuitRound:" + (save ? "Save" : "NoSave"));
+ GameAnalyticsManager.AddDesignEvent("EndRound:" + (mission == null ? "NoMission" : (mission.Completed ? "MissionCompleted" : "MissionFailed")));
+ }
+ GameMain.GameSession = null;
+ }
+ GUIMessageBox.CloseAll();
+ GameMain.MainMenuScreen.Select();
+ }
+
public void ShowCampaignDisclaimer(Action onContinue = null)
{
var msgBox = new GUIMessageBox(TextManager.Get("CampaignDisclaimerTitle"), TextManager.Get("CampaignDisclaimerText"),
@@ -986,8 +1051,19 @@ namespace Barotrauma
{
if (NetworkMember != null) NetworkMember.Disconnect();
SteamManager.ShutDown();
- if (GameSettings.SendUserStatistics) GameAnalytics.OnQuit();
- if (GameSettings.SaveDebugConsoleLogs) DebugConsole.SaveLogs();
+
+ try
+ {
+ SaveUtil.CleanUnnecessarySaveFiles();
+ }
+ catch (Exception e)
+ {
+ DebugConsole.ThrowError("Error while cleaning unnecessary save files", e);
+ }
+
+ if (GameSettings.SendUserStatistics){ GameAnalytics.OnQuit(); }
+ if (GameSettings.SaveDebugConsoleLogs) { DebugConsole.SaveLogs(); }
+
base.OnExiting(sender, args);
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
index a853eaeda..dd7f32d52 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs
@@ -116,7 +116,8 @@ namespace Barotrauma
//Spacing = (int)(3 * GUI.Scale),
ScrollBarEnabled = false,
ScrollBarVisible = false,
- CanBeFocused = false
+ CanBeFocused = true,
+ OnSelected = (component, userdata) => false
};
scrollButtonUp = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.TopLeft, Pivot.TopLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
@@ -443,6 +444,13 @@ namespace Barotrauma
ToolTip = characterToolTip
};
+
+ if (GameMain.GameSession?.GameMode?.Mission is CombatMission combatMission)
+ {
+ new GUIFrame(new RectTransform(Vector2.One, characterArea.RectTransform), style: "InnerGlow",
+ color: character.TeamID == Character.TeamType.Team1 ? Color.SteelBlue : Color.OrangeRed);
+ }
+
var characterName = new GUITextBlock(new RectTransform(new Point(characterArea.Rect.Width - characterImage.Rect.Width - soundIcon.Rect.Width - 10, characterArea.Rect.Height),
characterArea.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(soundIcon.Rect.Width + 10, 0) },
character.Name, textColor: frame.Color, font: GUI.SmallFont, wrap: true)
@@ -1016,7 +1024,7 @@ namespace Barotrauma
ToggleCrewAreaOpen = true;
var characterElement = characterListBox.Content.FindChild(character);
GUIButton orderBtn = characterElement.FindChild(order, recursive: true) as GUIButton;
- if (orderBtn.Frame.FlashTimer <= 0)
+ if (orderBtn.FlashTimer <= 0)
{
orderBtn.Flash(color, 1.5f, false, flashRectInflate);
}
@@ -1360,7 +1368,7 @@ namespace Barotrauma
public void UpdateReports(float deltaTime)
{
bool canIssueOrders = false;
- if (Character.Controlled?.CurrentHull != null && Character.Controlled.SpeechImpediment < 100.0f)
+ if (Character.Controlled?.CurrentHull?.Submarine != null && Character.Controlled.SpeechImpediment < 100.0f)
{
WifiComponent radio = GetHeadset(Character.Controlled, true);
canIssueOrders = radio != null && radio.CanTransmit();
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs
index 26b195c90..73c7dd7a0 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/MultiPlayerCampaign.cs
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
+using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -13,25 +14,24 @@ namespace Barotrauma
private UInt16 startWatchmanID, endWatchmanID;
- public static GUIComponent StartCampaignSetup( IEnumerable submarines, IEnumerable saveFiles)
+ public static void StartCampaignSetup(IEnumerable saveFiles)
{
- GUIFrame background = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker");
+ var parent = GameMain.NetLobbyScreen.CampaignSetupFrame;
+ parent.ClearChildren();
+ parent.Visible = true;
+ GameMain.NetLobbyScreen.HighlightMode(2);
- GUIFrame setupBox = new GUIFrame(new RectTransform(new Vector2(0.25f, 0.45f), background.RectTransform, Anchor.Center) { MinSize = new Point(500, 550) });
- var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), setupBox.RectTransform, Anchor.Center))
+ var layout = new GUILayoutGroup(new RectTransform(Vector2.One, parent.RectTransform, Anchor.Center))
{
Stretch = true
};
- new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform,Anchor.TopCenter),
- TextManager.Get("CampaignSetup"), font: GUI.LargeFont);
-
- var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), paddedFrame.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.1f) }, isHorizontal: true)
+ var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), layout.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.1f) }, isHorizontal: true)
{
RelativeSpacing = 0.02f
};
- var campaignContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), paddedFrame.RectTransform, Anchor.BottomLeft), style: "InnerFrame")
+ var campaignContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), layout.RectTransform, Anchor.BottomLeft), style: "InnerFrame")
{
CanBeFocused = false
};
@@ -39,9 +39,9 @@ namespace Barotrauma
var newCampaignContainer = new GUIFrame(new RectTransform(Vector2.One, campaignContainer.RectTransform, Anchor.BottomLeft), style: null);
var loadCampaignContainer = new GUIFrame(new RectTransform(Vector2.One, campaignContainer.RectTransform, Anchor.BottomLeft), style: null);
- var campaignSetupUI = new CampaignSetupUI(true, newCampaignContainer, loadCampaignContainer, submarines, saveFiles);
+ var campaignSetupUI = new CampaignSetupUI(true, newCampaignContainer, loadCampaignContainer, null, saveFiles);
- var newCampaignButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonContainer.RectTransform),
+ var newCampaignButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), buttonContainer.RectTransform),
TextManager.Get("NewCampaign"), style: "GUITabButton")
{
OnClicked = (btn, obj) =>
@@ -52,7 +52,7 @@ namespace Barotrauma
}
};
- var loadCampaignButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.00f), buttonContainer.RectTransform),
+ var loadCampaignButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.00f), buttonContainer.RectTransform),
TextManager.Get("LoadCampaign"), style: "GUITabButton")
{
OnClicked = (btn, obj) =>
@@ -67,20 +67,6 @@ namespace Barotrauma
campaignSetupUI.StartNewGame = GameMain.Client.SetupNewCampaign;
campaignSetupUI.LoadGame = GameMain.Client.SetupLoadCampaign;
-
- var cancelButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.1f), paddedFrame.RectTransform, Anchor.BottomLeft),
- TextManager.Get("Cancel"), style: "GUIButtonLarge")
- {
- IgnoreLayoutGroups = true,
- OnClicked = (btn, obj) =>
- {
- background.Visible = false;
-
- return true;
- }
- };
-
- return background;
}
public override void Update(float deltaTime)
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs
index 73e18c6f2..a9b4039af 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/CaptainTutorial.cs
@@ -255,9 +255,9 @@ namespace Barotrauma.Tutorials
}
if (order.Options[orderIndex] == option)
{
- if (GameMain.GameSession.CrewManager.OrderOptionButtons[i].Frame.FlashTimer <= 0)
+ if (GameMain.GameSession.CrewManager.OrderOptionButtons[i].FlashTimer <= 0)
{
- GameMain.GameSession.CrewManager.OrderOptionButtons[i].Frame.Flash(highlightColor);
+ GameMain.GameSession.CrewManager.OrderOptionButtons[i].Flash(highlightColor);
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/EngineerTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/EngineerTutorial.cs
index 87188c524..a458bb670 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/EngineerTutorial.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/EngineerTutorial.cs
@@ -370,9 +370,9 @@ namespace Barotrauma.Tutorials
}
else if (IsSelectedItem(engineer_brokenJunctionBox) && repairableJunctionBoxComponent.CurrentFixer == null)
{
- if (repairableJunctionBoxComponent.RepairButton.Frame.FlashTimer <= 0)
+ if (repairableJunctionBoxComponent.RepairButton.FlashTimer <= 0)
{
- repairableJunctionBoxComponent.RepairButton.Frame.Flash();
+ repairableJunctionBoxComponent.RepairButton.Flash();
}
}
yield return null;
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs
index db5d5f16f..4f58acb60 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/MechanicTutorial.cs
@@ -416,9 +416,9 @@ namespace Barotrauma.Tutorials
if (mechanic_deconstructor.InputContainer.Inventory.FindItemByIdentifier("oxygentank") != null && !mechanic_deconstructor.IsActive)
{
- if (mechanic_deconstructor.ActivateButton.Frame.FlashTimer <= 0)
+ if (mechanic_deconstructor.ActivateButton.FlashTimer <= 0)
{
- mechanic_deconstructor.ActivateButton.Frame.Flash(highlightColor, 1.5f, false);
+ mechanic_deconstructor.ActivateButton.Flash(highlightColor, 1.5f, false);
}
}
}
@@ -452,9 +452,9 @@ namespace Barotrauma.Tutorials
}
else if (mechanic_fabricator.InputContainer.Inventory.FindItemByIdentifier("aluminium") != null && mechanic_fabricator.InputContainer.Inventory.FindItemByIdentifier("sodium") != null && !mechanic_fabricator.IsActive)
{
- if (mechanic_fabricator.ActivateButton.Frame.FlashTimer <= 0)
+ if (mechanic_fabricator.ActivateButton.FlashTimer <= 0)
{
- mechanic_fabricator.ActivateButton.Frame.Flash(highlightColor, 1.5f, false);
+ mechanic_fabricator.ActivateButton.Flash(highlightColor, 1.5f, false);
}
}
else if (mechanic.Inventory.FindItemByIdentifier("aluminium") != null || mechanic.Inventory.FindItemByIdentifier("sodium") != null)
@@ -544,9 +544,9 @@ namespace Barotrauma.Tutorials
}
else if (IsSelectedItem(mechanic_brokenPump.Item) && repairablePumpComponent.CurrentFixer == null)
{
- if (repairablePumpComponent.RepairButton.Frame.FlashTimer <= 0)
+ if (repairablePumpComponent.RepairButton.FlashTimer <= 0)
{
- repairablePumpComponent.RepairButton.Frame.Flash();
+ repairablePumpComponent.RepairButton.Flash();
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs
index 81b5040f3..6816e6f26 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameSession.cs
@@ -18,6 +18,11 @@ namespace Barotrauma
private bool ToggleInfoFrame()
{
+ if (GameMain.NetworkMember != null && GameMain.NetLobbyScreen != null)
+ {
+ if (GameMain.NetLobbyScreen.HeadSelectionList != null) { GameMain.NetLobbyScreen.HeadSelectionList.Visible = false; }
+ if (GameMain.NetLobbyScreen.JobSelectionFrame != null) { GameMain.NetLobbyScreen.JobSelectionFrame.Visible = false; }
+ }
if (infoFrame == null)
{
CreateInfoFrame();
@@ -37,7 +42,7 @@ namespace Barotrauma
infoFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker");
- var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), infoFrame.RectTransform, Anchor.Center) { MinSize = new Point(width, height) });
+ var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.35f), infoFrame.RectTransform, Anchor.Center) { MinSize = new Point(width, height), RelativeOffset = new Vector2(0.0f, 0.033f) });
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), innerFrame.RectTransform, Anchor.Center), style: null);
var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedFrame.RectTransform), isHorizontal: true)
@@ -144,6 +149,12 @@ namespace Barotrauma
if (GUI.DisableHUD) return;
GameMode?.AddToGUIUpdateList();
infoFrame?.AddToGUIUpdateList();
+
+ if (GameMain.NetworkMember != null)
+ {
+ GameMain.NetLobbyScreen?.HeadSelectionList?.AddToGUIUpdateList();
+ GameMain.NetLobbyScreen?.JobSelectionFrame?.AddToGUIUpdateList();
+ }
}
partial void UpdateProjSpecific(float deltaTime)
@@ -163,7 +174,24 @@ namespace Barotrauma
ToggleInfoFrame();
}
- infoFrame?.UpdateManually(deltaTime);
+ if (GameMain.NetworkMember != null)
+ {
+ if (GameMain.NetLobbyScreen?.HeadSelectionList != null)
+ {
+ if (PlayerInput.LeftButtonDown() && !GUI.IsMouseOn(GameMain.NetLobbyScreen.HeadSelectionList))
+ {
+ if (GameMain.NetLobbyScreen.HeadSelectionList != null) { GameMain.NetLobbyScreen.HeadSelectionList.Visible = false; }
+ }
+ }
+ if (GameMain.NetLobbyScreen?.JobSelectionFrame != null)
+ {
+ if (PlayerInput.LeftButtonDown() && !GUI.IsMouseOn(GameMain.NetLobbyScreen.JobSelectionFrame))
+ {
+ GameMain.NetLobbyScreen.JobList.Deselect();
+ if (GameMain.NetLobbyScreen.JobSelectionFrame != null) { GameMain.NetLobbyScreen.JobSelectionFrame.Visible = false; }
+ }
+ }
+ }
}
public void Draw(SpriteBatch spriteBatch)
@@ -171,7 +199,7 @@ namespace Barotrauma
if (GUI.DisableHUD) return;
GameMode?.Draw(spriteBatch);
- infoFrame?.DrawManually(spriteBatch);
+ //infoFrame?.DrawManually(spriteBatch);
}
}
}
diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs
index b4b7e2a49..064f183c0 100644
--- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs
+++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs
@@ -152,8 +152,7 @@ namespace Barotrauma
var languageDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.045f), generalLayoutGroup.RectTransform));
foreach (string language in TextManager.AvailableLanguages)
{
- //TODO: display the name of the language in the target language?
- languageDD.AddItem(language, language);
+ languageDD.AddItem(TextManager.GetTranslatedLanguageName(language), language);
}
languageDD.SelectItem(TextManager.Language);
languageDD.OnSelected = (guiComponent, obj) =>
@@ -356,7 +355,7 @@ namespace Barotrauma
};
lightScrollBar.OnMoved(lightScrollBar, lightScrollBar.BarScroll);
- new GUITickBox(new RectTransform(tickBoxScale, rightColumn.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get("SpecularLighting"))
+ /*new GUITickBox(new RectTransform(tickBoxScale, rightColumn.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get("SpecularLighting"))
{
ToolTip = TextManager.Get("SpecularLightingToolTip"),
Selected = SpecularityEnabled,
@@ -366,7 +365,7 @@ namespace Barotrauma
UnsavedSettings = true;
return true;
}
- };
+ };*/
new GUITickBox(new RectTransform(tickBoxScale, rightColumn.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get("ChromaticAberration"))
{
@@ -508,8 +507,8 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), voipSettings.RectTransform), TextManager.Get("VoiceChat"));
- IList deviceNames = Alc.GetStringList((IntPtr)null, Alc.CaptureDeviceSpecifier);
- foreach (string name in deviceNames)
+ CaptureDeviceNames = Alc.GetStringList((IntPtr)null, Alc.CaptureDeviceSpecifier);
+ foreach (string name in CaptureDeviceNames)
{
DebugConsole.NewMessage(name + " " + name.Length.ToString(), Color.Lime);
}
@@ -524,19 +523,19 @@ namespace Barotrauma
return true;
};
- if (string.IsNullOrWhiteSpace(VoiceCaptureDevice) || !(deviceNames?.Contains(VoiceCaptureDevice) ?? false))
+ if (string.IsNullOrWhiteSpace(VoiceCaptureDevice) || !(CaptureDeviceNames?.Contains(VoiceCaptureDevice) ?? false))
{
- VoiceCaptureDevice = deviceNames?.Count > 0 ? deviceNames[0] : null;
+ VoiceCaptureDevice = CaptureDeviceNames?.Count > 0 ? CaptureDeviceNames[0] : null;
}
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
{
VoiceSetting = VoiceMode.Disabled;
}
#if (!OSX)
- var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.15f), voipSettings.RectTransform), TrimAudioDeviceName(VoiceCaptureDevice), deviceNames.Count);
- if (deviceNames?.Count > 0)
+ var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.15f), voipSettings.RectTransform), TrimAudioDeviceName(VoiceCaptureDevice), CaptureDeviceNames.Count);
+ if (CaptureDeviceNames?.Count > 0)
{
- foreach (string name in deviceNames)
+ foreach (string name in CaptureDeviceNames)
{
deviceList.AddItem(TrimAudioDeviceName(name), name);
}
@@ -571,12 +570,12 @@ namespace Barotrauma
ToolTip = TextManager.Get("RefreshDefaultDeviceToolTip"),
OnClicked = (bt, userdata) =>
{
- deviceNames = Alc.GetStringList((IntPtr)null, Alc.CaptureDeviceSpecifier);
- if (deviceNames?.Count > 0)
+ CaptureDeviceNames = Alc.GetStringList((IntPtr)null, Alc.CaptureDeviceSpecifier);
+ if (CaptureDeviceNames?.Count > 0)
{
- if (VoiceCaptureDevice == deviceNames[0]) return true;
+ if (VoiceCaptureDevice == CaptureDeviceNames[0]) return true;
- VoipCapture.ChangeCaptureDevice(deviceNames[0]);
+ VoipCapture.ChangeCaptureDevice(CaptureDeviceNames[0]);
currentDeviceTextBlock.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice));
currentDeviceTextBlock.Flash(Color.Blue);
}
@@ -598,12 +597,12 @@ namespace Barotrauma
for (int i = 0; i < 3; i++)
{
string langStr = "VoiceMode." + ((VoiceMode)i).ToString();
- var tick = new GUITickBox(new RectTransform(tickBoxScale / 0.4f, voipSettings.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get(langStr))
+ var tick = new GUITickBox(new RectTransform(tickBoxScale / 0.4f, voipSettings.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get(langStr), style: "GUIRadioButton")
{
ToolTip = TextManager.Get(langStr + "ToolTip")
};
- voiceMode.AddRadioButton((VoiceMode)i, tick);
+ voiceMode.AddRadioButton(i, tick);
}
var micVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), voipSettings.RectTransform), TextManager.Get("MicrophoneVolume"));
@@ -611,10 +610,10 @@ namespace Barotrauma
barSize: 0.05f)
{
UserData = micVolumeText,
- BarScroll = (float)Math.Sqrt(MathUtils.InverseLerp(0.2f, 5.0f, MicrophoneVolume)),
+ BarScroll = (float)Math.Sqrt(MathUtils.InverseLerp(0.2f, MaxMicrophoneVolume, MicrophoneVolume)),
OnMoved = (scrollBar, scroll) =>
{
- MicrophoneVolume = MathHelper.Lerp(0.2f, 10.0f, scroll * scroll);
+ MicrophoneVolume = MathHelper.Lerp(0.2f, MaxMicrophoneVolume, scroll * scroll);
MicrophoneVolume = (float)Math.Round(MicrophoneVolume, 1);
ChangeSliderText(scrollBar, MicrophoneVolume);
scrollBar.Step = 0.05f;
@@ -667,7 +666,7 @@ namespace Barotrauma
return true;
};
- voiceMode.OnSelect = (GUIRadioButtonGroup rbg, Enum value) =>
+ voiceMode.OnSelect = (GUIRadioButtonGroup rbg, int? value) =>
{
if (rbg.Selected != null && rbg.Selected.Equals(value)) return;
try
@@ -708,7 +707,7 @@ namespace Barotrauma
VoiceSetting = VoiceMode.Disabled;
}
};
- voiceMode.Selected = VoiceSetting;
+ voiceMode.Selected = (int)VoiceSetting;
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
{
voiceMode.Enabled = false;
@@ -1157,7 +1156,7 @@ namespace Barotrauma
{
ApplySettings();
if (Screen.Selected != GameMain.MainMenuScreen) GUI.SettingsMenuOpen = false;
- if (contentPackageSelectionDirty)
+ if (contentPackageSelectionDirty || ContentPackage.List.Any(cp => cp.NeedsRestart))
{
new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredGeneric"));
}
diff --git a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs
index 4f2a5eb2d..c8f6b7e9d 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs
@@ -718,11 +718,11 @@ namespace Barotrauma
if (item.ParentInventory != this)
{
- //in another inventory -> attempt to place in the character's inventory
- if (item.ParentInventory.Locked || item.ParentInventory == null)
+ if (item.ParentInventory == null || item.ParentInventory.Locked)
{
return QuickUseAction.None;
}
+ //in another inventory -> attempt to place in the character's inventory
else if (allowInventorySwap)
{
if (item.Container == null || character.Inventory.FindIndex(item.Container) == -1) // Not a subinventory in the character's inventory
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemContainer.cs
index 5fafa9498..8f1972c6d 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemContainer.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemContainer.cs
@@ -64,6 +64,10 @@ namespace Barotrauma.Items.Components
[Serialize(null, false, description: "An optional text displayed above the item's inventory.")]
public string UILabel { get; set; }
+ [Serialize(true, false, description: "Should an indicator displaying the state of the contained items be displayed on this item's inventory slot. "+
+ "If this item can only contain one item, the indicator will display the condition of the contained item, otherwise it will indicate how full the item is.")]
+ public bool ShowContainedStateIndicator { get; set; }
+
[Serialize(false, false, description: "If enabled, the condition of this item is displayed in the indicator that would normally show the state of the contained items." +
" May be useful for items such as ammo boxes and magazines that spawn projectiles as needed," +
" and use the condition to determine how many projectiles can be spawned in total.")]
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Controller.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Controller.cs
index e4547a6c2..f6ffb5e1d 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Controller.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Controller.cs
@@ -38,7 +38,7 @@ namespace Barotrauma.Items.Components
private void ToggleCrewArea(bool value, bool storeOriginalState)
{
- var crewManager = GameMain.GameSession.CrewManager;
+ var crewManager = GameMain.GameSession?.CrewManager;
if (crewManager == null) { return; }
if (storeOriginalState)
@@ -50,7 +50,7 @@ namespace Barotrauma.Items.Components
private void ToggleChatBox(bool value, bool storeOriginalState)
{
- var crewManager = GameMain.GameSession.CrewManager;
+ var crewManager = GameMain.GameSession?.CrewManager;
if (crewManager == null) { return; }
if (crewManager.IsSinglePlayer)
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs
index b9f7fc697..1ccba72ca 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs
@@ -114,7 +114,7 @@ namespace Barotrauma.Items.Components
private void DrawHUDFront(SpriteBatch spriteBatch, GUICustomComponent container)
{
- if (voltage < minVoltage)
+ if (Voltage < MinVoltage)
{
Vector2 textSize = GUI.Font.MeasureString(noPowerTip);
Vector2 textPos = GuiFrame.Rect.Center.ToVector2();
@@ -164,7 +164,7 @@ namespace Barotrauma.Items.Components
}
}
- if (voltage < minVoltage)
+ if (Voltage < MinVoltage)
{
return;
}
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs
index 59be09f8d..6b7797bb0 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs
@@ -128,6 +128,7 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
+ base.OnItemLoaded();
if (pumpSpeedSlider != null)
{
pumpSpeedSlider.BarScroll = (flowPercentage + 100.0f) / 200.0f;
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Reactor.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Reactor.cs
index b64362833..5d725464e 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Reactor.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Reactor.cs
@@ -290,6 +290,7 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
+ base.OnItemLoaded();
turbineOutputScrollBar.BarScroll = targetTurbineOutput / 100.0f;
fissionRateScrollBar.BarScroll = targetFissionRate / 100.0f;
var itemContainer = item.GetComponent();
@@ -604,14 +605,15 @@ namespace Barotrauma.Items.Components
protected override void RemoveComponentSpecific()
{
- graphLine.Remove();
- fissionRateMeter.Remove();
- turbineOutputMeter.Remove();
- meterPointer.Remove();
- sectorSprite.Remove();
- tempMeterFrame.Remove();
- tempMeterBar.Remove();
- tempRangeIndicator.Remove();
+ base.RemoveComponentSpecific();
+ graphLine?.Remove();
+ fissionRateMeter?.Remove();
+ turbineOutputMeter?.Remove();
+ meterPointer?.Remove();
+ sectorSprite?.Remove();
+ tempMeterFrame?.Remove();
+ tempMeterBar?.Remove();
+ tempRangeIndicator?.Remove();
}
public void ClientWrite(IWriteMessage msg, object[] extraData = null)
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs
index 330ef05df..e85555c7b 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs
@@ -54,7 +54,7 @@ namespace Barotrauma.Items.Components
//float = strength of the disruption, between 0-1
List> disruptedDirections = new List>();
- private static Color[] blipColorGradient =
+ private static readonly Color[] blipColorGradient =
{
Color.TransparentBlack,
new Color(0, 50, 160),
@@ -162,9 +162,9 @@ namespace Barotrauma.Items.Components
signalWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedControlContainer.RectTransform), "", Color.Orange, textAlignment: Alignment.Center);
GUIRadioButtonGroup sonarMode = new GUIRadioButtonGroup();
- sonarMode.AddRadioButton(Mode.Active, activeTickBox);
- sonarMode.AddRadioButton(Mode.Passive, passiveTickBox);
- sonarMode.Selected = Mode.Passive;
+ sonarMode.AddRadioButton((int)Mode.Active, activeTickBox);
+ sonarMode.AddRadioButton((int)Mode.Passive, passiveTickBox);
+ sonarMode.Selected = (int)Mode.Passive;
GuiFrame.CanBeFocused = false;
@@ -226,6 +226,7 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
+ base.OnItemLoaded();
zoomSlider.BarScroll = MathUtils.InverseLerp(MinZoom, MaxZoom, zoom);
//make the sonarView customcomponent render the steering view so it gets drawn in front of the sonar
item.GetComponent()?.AttachToSonarHUD(sonarView);
@@ -434,7 +435,7 @@ namespace Barotrauma.Items.Components
if (distSqr > t.SoundRange * t.SoundRange * 2) { continue; }
float dist = (float)Math.Sqrt(distSqr);
- if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range)
+ if (dist > prevPassivePingRadius * Range && dist <= passivePingRadius * Range && Rand.Int(sonarBlips.Count) < 500)
{
Ping(t.WorldPosition, transducerCenter,
Math.Min(t.SoundRange, range * 0.5f) * displayScale, 0, displayScale, Math.Min(t.SoundRange, range * 0.5f),
@@ -675,14 +676,14 @@ namespace Barotrauma.Items.Components
}
else if (startOutside)
{
- if (MathUtils.GetLineCircleIntersections(Vector2.Zero, DisplayRadius, end, start, true, out Vector2? intersection1, out Vector2? intersection2) == 1)
+ if (MathUtils.GetLineCircleIntersections(Vector2.Zero, DisplayRadius, end, start, true, out Vector2? intersection1, out _) == 1)
{
DrawLineSprite(spriteBatch, center + intersection1.Value, center + end, color, width: width);
}
}
else if (endOutside)
{
- if (MathUtils.GetLineCircleIntersections(Vector2.Zero, DisplayRadius, start, end, true, out Vector2? intersection1, out Vector2? intersection2) == 1)
+ if (MathUtils.GetLineCircleIntersections(Vector2.Zero, DisplayRadius, start, end, true, out Vector2? intersection1, out _) == 1)
{
DrawLineSprite(spriteBatch, center + start, center + intersection1.Value, color, width: width);
}
@@ -750,7 +751,7 @@ namespace Barotrauma.Items.Components
{
size.Y = 0.0f;
}
- GUI.DrawLine(spriteBatch, center + offset - size, center + offset + size, Color.LightGreen, width: (int)(zoom * 2.5f));
+ GUI.DrawLine(spriteBatch, center + offset - size, center + offset + size, Color.LightGreen * signalStrength, width: (int)(zoom * 2.5f));
}
}
@@ -769,8 +770,6 @@ namespace Barotrauma.Items.Components
Vector2 targetPortDiff = (steering.DockingTarget.Item.WorldPosition - transducerCenter) * scale;
Vector2 targetPortPos = new Vector2(targetPortDiff.X, -targetPortDiff.Y);
- Vector2 midPos = (sourcePortPos + targetPortPos) / 2.0f;
-
System.Diagnostics.Debug.Assert(steering.ActiveDockingSource.IsHorizontal == steering.DockingTarget.IsHorizontal);
Vector2 diff = steering.DockingTarget.Item.WorldPosition - steering.ActiveDockingSource.Item.WorldPosition;
float dist = diff.Length();
@@ -851,7 +850,6 @@ namespace Barotrauma.Items.Components
private void UpdateDisruptions(Vector2 pingSource, float worldPingRadius, float worldPrevPingRadius)
{
float worldPingRadiusSqr = worldPingRadius * worldPingRadius;
- float worldPrevPingRadiusSqr = worldPrevPingRadius * worldPrevPingRadius;
disruptedDirections.Clear();
if (Level.Loaded == null) { return; }
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs
index 595592103..f0dc6be87 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Steering.cs
@@ -159,9 +159,9 @@ namespace Barotrauma.Items.Components
};
GUIRadioButtonGroup modes = new GUIRadioButtonGroup();
- modes.AddRadioButton(Mode.AutoPilot, autopilotTickBox);
- modes.AddRadioButton(Mode.Manual, manualTickBox);
- modes.Selected = Mode.Manual;
+ modes.AddRadioButton((int)Mode.AutoPilot, autopilotTickBox);
+ modes.AddRadioButton((int)Mode.Manual, manualTickBox);
+ modes.Selected = (int)Mode.Manual;
var autoPilotControls = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f), paddedControlContainer.RectTransform), "InnerFrame");
var paddedAutoPilotControls = new GUILayoutGroup(new RectTransform(new Vector2(0.8f), autoPilotControls.RectTransform, Anchor.Center))
@@ -171,7 +171,7 @@ namespace Barotrauma.Items.Components
};
maintainPosTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
- TextManager.Get("SteeringMaintainPos"), font: GUI.SmallFont)
+ TextManager.Get("SteeringMaintainPos"), font: GUI.SmallFont, style: "GUIRadioButton")
{
Enabled = false,
Selected = maintainPos,
@@ -208,7 +208,7 @@ namespace Barotrauma.Items.Components
levelStartTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
GameMain.GameSession?.StartLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, 20),
- font: GUI.SmallFont)
+ font: GUI.SmallFont, style: "GUIRadioButton")
{
Enabled = false,
Selected = levelStartSelected,
@@ -235,7 +235,7 @@ namespace Barotrauma.Items.Components
levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), paddedAutoPilotControls.RectTransform),
GameMain.GameSession?.EndLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, 20),
- font: GUI.SmallFont)
+ font: GUI.SmallFont, style: "GUIRadioButton")
{
Enabled = false,
Selected = levelEndSelected,
@@ -263,11 +263,11 @@ namespace Barotrauma.Items.Components
autoPilotControlsDisabler = new GUIFrame(new RectTransform(Vector2.One, autoPilotControls.RectTransform), "InnerFrame");
GUIRadioButtonGroup destinations = new GUIRadioButtonGroup();
- destinations.AddRadioButton(Destination.MaintainPos, maintainPosTickBox);
- destinations.AddRadioButton(Destination.LevelStart, levelStartTickBox);
- destinations.AddRadioButton(Destination.LevelEnd, levelEndTickBox);
- destinations.Selected = maintainPos ? Destination.MaintainPos :
- levelStartSelected ? Destination.LevelStart : Destination.LevelEnd;
+ destinations.AddRadioButton((int)Destination.MaintainPos, maintainPosTickBox);
+ destinations.AddRadioButton((int)Destination.LevelStart, levelStartTickBox);
+ destinations.AddRadioButton((int)Destination.LevelEnd, levelEndTickBox);
+ destinations.Selected = (int)(maintainPos ? Destination.MaintainPos :
+ levelStartSelected ? Destination.LevelStart : Destination.LevelEnd);
string steeringVelX = TextManager.Get("SteeringVelocityX");
string steeringVelY = TextManager.Get("SteeringVelocityY");
@@ -442,7 +442,7 @@ namespace Barotrauma.Items.Components
int x = rect.X;
int y = rect.Y;
- if (voltage < minVoltage && currPowerConsumption > 0.0f) return;
+ if (Voltage < MinVoltage) { return; }
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
Vector2 displaySubPos = (-sonar.DisplayOffset * sonar.Zoom) / sonar.Range * sonar.DisplayRadius * sonar.Zoom;
@@ -649,7 +649,7 @@ namespace Barotrauma.Items.Components
autoPilotControlsDisabler.Visible = !AutoPilot;
- if (voltage < minVoltage && currPowerConsumption > 0.0f)
+ if (Voltage < MinVoltage)
{
tipContainer.Visible = true;
tipContainer.Text = noPowerTip;
@@ -819,6 +819,7 @@ namespace Barotrauma.Items.Components
protected override void RemoveComponentSpecific()
{
+ base.RemoveComponentSpecific();
maintainPosIndicator?.Remove();
maintainPosOriginIndicator?.Remove();
steeringIndicator?.Remove();
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs
index 3c2f9a3e2..cb6f22c5b 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs
@@ -80,6 +80,7 @@ namespace Barotrauma.Items.Components
public override void OnItemLoaded()
{
+ base.OnItemLoaded();
if (rechargeSpeedSlider != null)
{
rechargeSpeedSlider.BarScroll = rechargeSpeed / MaxRechargeSpeed;
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs
index 272dfe94f..78abdac83 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using System;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -46,19 +47,26 @@ namespace Barotrauma.Items.Components
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), textContainer.RectTransform), "", textColor: Color.LightGreen)
{
ToolTip = TextManager.Get("PowerTransferTipPower"),
- TextGetter = () => { return powerStr.Replace("[power]", ((int)(-currPowerConsumption)).ToString()); }
+ TextGetter = () => { return powerStr.Replace("[power]", ((int)Math.Round(-currPowerConsumption)).ToString()); }
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), textContainer.RectTransform),
TextManager.Get("PowerTransferLoadLabel"), font: GUI.LargeFont)
{
ToolTip = TextManager.Get("PowerTransferTipLoad")
+
};
string loadStr = TextManager.Get("PowerTransferLoad");
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), textContainer.RectTransform), "", textColor: Color.LightBlue)
{
ToolTip = TextManager.Get("PowerTransferTipLoad"),
- TextGetter = () => { return loadStr.Replace("[load]", ((int)(powerLoad)).ToString()); }
+ TextGetter = () =>
+ {
+ return loadStr.Replace("[load]",
+ this is RelayComponent relay ?
+ ((int)Math.Round(relay.DisplayLoad)).ToString() :
+ ((int)Math.Round(powerLoad)).ToString());
+ }
};
}
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs
index 0f47fbbf6..cddda1212 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Wire.cs
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
@@ -12,32 +13,34 @@ namespace Barotrauma.Items.Components
{
partial class WireSection
{
- public void Draw(SpriteBatch spriteBatch, Color color, Vector2 offset, float depth, float width = 0.3f)
+ public void Draw(SpriteBatch spriteBatch, Wire wire, Color color, Vector2 offset, float depth, float width = 0.3f)
{
- spriteBatch.Draw(wireSprite.Texture,
+ spriteBatch.Draw(wire.wireSprite.Texture,
new Vector2(start.X + offset.X, -(start.Y + offset.Y)), null, color,
-angle,
- new Vector2(0.0f, wireSprite.size.Y / 2.0f),
- new Vector2(length / wireSprite.Texture.Width, width),
+ new Vector2(0.0f, wire.wireSprite.size.Y / 2.0f),
+ new Vector2(length / wire.wireSprite.Texture.Width, width),
SpriteEffects.None,
depth);
}
- public static void Draw(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color, float depth, float width = 0.3f)
+ public static void Draw(SpriteBatch spriteBatch, Wire wire, Vector2 start, Vector2 end, Color color, float depth, float width = 0.3f)
{
start.Y = -start.Y;
end.Y = -end.Y;
-
- spriteBatch.Draw(wireSprite.Texture,
+
+ spriteBatch.Draw(wire.wireSprite.Texture,
start, null, color,
MathUtils.VectorToAngle(end - start),
- new Vector2(0.0f, wireSprite.size.Y / 2.0f),
- new Vector2((Vector2.Distance(start, end)) / wireSprite.Texture.Width, width),
+ new Vector2(0.0f, wire.wireSprite.size.Y / 2.0f),
+ new Vector2((Vector2.Distance(start, end)) / wire.wireSprite.Texture.Width, width),
SpriteEffects.None,
depth);
}
}
- private static Sprite wireSprite;
+ private static Sprite defaultWireSprite;
+ private Sprite overrideSprite;
+ private Sprite wireSprite;
private static Wire draggingWire;
private static int? selectedNodeIndex;
@@ -48,6 +51,28 @@ namespace Barotrauma.Items.Components
get { return sectionExtents; }
}
+ partial void InitProjSpecific(XElement element)
+ {
+ if (defaultWireSprite == null)
+ {
+ defaultWireSprite = new Sprite("Content/Items/wireHorizontal.png", new Vector2(0.5f, 0.5f))
+ {
+ Depth = 0.85f
+ };
+ }
+
+ foreach (XElement subElement in element.Elements())
+ {
+ if (subElement.Name.ToString().ToLowerInvariant() == "wiresprite")
+ {
+ overrideSprite = new Sprite(subElement);
+ break;
+ }
+ }
+
+ wireSprite = overrideSprite ?? defaultWireSprite;
+ }
+
public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
{
if (sections.Count == 0 && !IsActive || Hidden)
@@ -75,20 +100,20 @@ namespace Barotrauma.Items.Components
{
foreach (WireSection section in sections)
{
- section.Draw(spriteBatch, Color.Gold, drawOffset, depth + 0.00001f, 0.7f);
+ section.Draw(spriteBatch, this, Color.Gold, drawOffset, depth + 0.00001f, 0.7f);
}
}
else if (item.IsSelected)
{
foreach (WireSection section in sections)
{
- section.Draw(spriteBatch, Color.Red, drawOffset, depth + 0.00001f, 0.7f);
+ section.Draw(spriteBatch, this, Color.Red, drawOffset, depth + 0.00001f, 0.7f);
}
}
foreach (WireSection section in sections)
{
- section.Draw(spriteBatch, item.Color, drawOffset, depth, 0.3f);
+ section.Draw(spriteBatch, this, item.Color, drawOffset, depth, 0.3f);
}
if (nodes.Count > 0)
@@ -101,7 +126,8 @@ namespace Barotrauma.Items.Components
if (IsActive && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
{
WireSection.Draw(
- spriteBatch,
+ spriteBatch,
+ this,
new Vector2(nodes[nodes.Count - 1].X, nodes[nodes.Count - 1].Y) + drawOffset,
new Vector2(newNodePos.X, newNodePos.Y) + drawOffset,
item.Color * 0.5f,
@@ -141,12 +167,12 @@ namespace Barotrauma.Items.Components
Vector2 endPos = start + new Vector2((float)Math.Sin(angle), -(float)Math.Cos(angle)) * 50.0f;
WireSection.Draw(
- spriteBatch,
+ spriteBatch, this,
start, endPos,
Color.Orange, depth + 0.00001f, 0.2f);
WireSection.Draw(
- spriteBatch,
+ spriteBatch, this,
start, start + (endPos - start) * 0.7f,
item.Color, depth, 0.3f);
}
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs
index 2ca75ce47..9f5425e5b 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs
@@ -993,7 +993,7 @@ namespace Barotrauma
Color.Lerp(Color.Red, Color.Green, item.Condition / item.MaxCondition) * 0.8f, true);
}
- if (itemContainer != null)
+ if (itemContainer != null && itemContainer.ShowContainedStateIndicator)
{
float containedState = 0.0f;
if (itemContainer.ShowConditionInContainedStateIndicator)
@@ -1156,7 +1156,7 @@ namespace Barotrauma
private void ApplyReceivedState()
{
- if (receivedItemIDs == null) return;
+ if (receivedItemIDs == null || (Owner != null && Owner.Removed)) { return; }
for (int i = 0; i < capacity; i++)
{
@@ -1171,7 +1171,7 @@ namespace Barotrauma
{
if (receivedItemIDs[i] > 0)
{
- if (!(Entity.FindEntityByID(receivedItemIDs[i]) is Item item) || Items[i] == item) continue;
+ if (!(Entity.FindEntityByID(receivedItemIDs[i]) is Item item) || Items[i] == item) { continue; }
TryPutItem(item, i, true, true, null, false);
for (int j = 0; j < capacity; j++)
diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs
index 13a582b24..7af86c154 100644
--- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs
+++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs
@@ -19,7 +19,7 @@ namespace Barotrauma
private readonly List positionBuffer = new List();
- private List activeHUDs = new List();
+ private readonly List activeHUDs = new List();
public IEnumerable ActiveHUDs => activeHUDs;
@@ -230,9 +230,6 @@ namespace Barotrauma
if (body == null)
{
- bool flipHorizontal = (SpriteEffects & SpriteEffects.FlipHorizontally) != 0;
- bool flipVertical = (SpriteEffects & SpriteEffects.FlipVertically) != 0;
-
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
{
activeSprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), color: color,
@@ -570,7 +567,7 @@ namespace Barotrauma
}
else
{
- if (ic.requiredItems.Count == 0 && SerializableProperty.GetProperties(ic).Count == 0) continue;
+ if (ic.requiredItems.Count == 0 && ic.DisabledRequiredItems.Count == 0 && SerializableProperty.GetProperties(ic).Count == 0) continue;
}
var componentEditor = new SerializableEntityEditor(listBox.Content.RectTransform, ic, inGame, showName: !inGame);
@@ -582,37 +579,44 @@ namespace Barotrauma
continue;
}
+ List requiredItems = new List();
foreach (var kvp in ic.requiredItems)
{
foreach (RelatedItem relatedItem in kvp.Value)
{
- var textBlock = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, heightScaled)),
- relatedItem.Type.ToString() + " required", font: GUI.SmallFont)
- {
- Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f)
- };
- componentEditor.AddCustomContent(textBlock, 1);
-
- GUITextBox namesBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight))
- {
- Font = GUI.SmallFont,
- Text = relatedItem.JoinedIdentifiers
- };
-
- namesBox.OnDeselected += (textBox, key) =>
- {
- relatedItem.JoinedIdentifiers = textBox.Text;
- textBox.Text = relatedItem.JoinedIdentifiers;
- };
-
- namesBox.OnEnterPressed += (textBox, text) =>
- {
- relatedItem.JoinedIdentifiers = text;
- textBox.Text = relatedItem.JoinedIdentifiers;
- return true;
- };
+ requiredItems.Add(relatedItem);
}
}
+ requiredItems.AddRange(ic.DisabledRequiredItems);
+
+ foreach (RelatedItem relatedItem in requiredItems)
+ {
+ var textBlock = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, heightScaled)),
+ relatedItem.Type.ToString() + " required", font: GUI.SmallFont)
+ {
+ Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f)
+ };
+ componentEditor.AddCustomContent(textBlock, 1);
+
+ GUITextBox namesBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight))
+ {
+ Font = GUI.SmallFont,
+ Text = relatedItem.JoinedIdentifiers
+ };
+
+ namesBox.OnDeselected += (textBox, key) =>
+ {
+ relatedItem.JoinedIdentifiers = textBox.Text;
+ textBox.Text = relatedItem.JoinedIdentifiers;
+ };
+
+ namesBox.OnEnterPressed += (textBox, text) =>
+ {
+ relatedItem.JoinedIdentifiers = text;
+ textBox.Text = relatedItem.JoinedIdentifiers;
+ return true;
+ };
+ }
ic.CreateEditingHUD(componentEditor);
componentEditor.Recalculate();
@@ -782,7 +786,7 @@ namespace Barotrauma
}
}
- List texts = new List();
+ readonly List texts = new List();
public List GetHUDTexts(Character character)
{
texts.Clear();
diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs
index 97146d94a..40acaf548 100644
--- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs
+++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs
@@ -216,7 +216,7 @@ namespace Barotrauma.Lights
if (GameMain.Config.SpecularityEnabled)
{
- UpdateSpecularMap(graphics, spriteBatch, spriteBatchTransform, cam, backgroundObstructor);
+ //UpdateSpecularMap(graphics, spriteBatch, spriteBatchTransform, cam, backgroundObstructor);
}
graphics.SetRenderTarget(LightMap);
@@ -302,19 +302,38 @@ namespace Barotrauma.Lights
//draw characters to obstruct the highlighted items/characters and light sprites
//---------------------------------------------------------------------------------------------------
- spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, transformMatrix: spriteBatchTransform);
+
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
foreach (Character character in Character.CharacterList)
{
if (character.CurrentHull == null || !character.Enabled) continue;
- if (Character.Controlled?.FocusedCharacter == character) continue;
+ if (Character.Controlled?.FocusedCharacter == character) continue;
foreach (Limb limb in character.AnimController.Limbs)
{
+ if (limb.DeformSprite != null) continue;
limb.Draw(spriteBatch, cam, Color.Black);
}
}
spriteBatch.End();
- graphics.BlendState = BlendState.Additive;
+ DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShaderSolidColor"];
+ DeformableSprite.Effect.Parameters["solidColor"].SetValue(Color.Black.ToVector4());
+ DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, transformMatrix: spriteBatchTransform);
+ foreach (Character character in Character.CharacterList)
+ {
+ if (character.CurrentHull == null || !character.Enabled) continue;
+ if (Character.Controlled?.FocusedCharacter == character) continue;
+ foreach (Limb limb in character.AnimController.Limbs)
+ {
+ if (limb.DeformSprite == null) continue;
+ limb.Draw(spriteBatch, cam, Color.Black);
+ }
+ }
+ spriteBatch.End();
+ DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShader"];
+ graphics.BlendState = BlendState.Additive;
+
//draw the actual light volumes, additive particles, hull ambient lights and the halo around the player
//---------------------------------------------------------------------------------------------------
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, transformMatrix: spriteBatchTransform);
@@ -372,10 +391,10 @@ namespace Barotrauma.Lights
if (GameMain.Config.SpecularityEnabled)
{
- spriteBatch.Begin(blendState: CustomBlendStates.Multiplicative);
+ /*spriteBatch.Begin(blendState: CustomBlendStates.Multiplicative);
spriteBatch.Draw(SpecularMap, Vector2.Zero, Color.White);
//spriteBatch.Draw(SpecularMap, Vector2.Zero, Color.White);
- spriteBatch.End();
+ spriteBatch.End();*/
}
//draw the actual light volumes, additive particles, hull ambient lights and the halo around the player
diff --git a/Barotrauma/BarotraumaClient/Source/Map/Map/Map.cs b/Barotrauma/BarotraumaClient/Source/Map/Map/Map.cs
index 270dfe590..e62c283e7 100644
--- a/Barotrauma/BarotraumaClient/Source/Map/Map/Map.cs
+++ b/Barotrauma/BarotraumaClient/Source/Map/Map/Map.cs
@@ -47,6 +47,7 @@ namespace Barotrauma
private Vector2 drawOffset;
private Vector2 drawOffsetNoise;
+
private float subReticleAnimState;
private float targetReticleAnimState;
private Vector2 subReticlePosition;
@@ -57,6 +58,9 @@ namespace Barotrauma
private MapTile[,] mapTiles;
private bool messageBoxOpen;
+
+ public Vector2 CenterOffset;
+
#if DEBUG
private GUIComponent editor;
@@ -316,7 +320,7 @@ namespace Barotrauma
hudOpenState = Math.Min(hudOpenState + deltaTime, 0.75f + (float)Math.Sin(Timing.TotalTime * 3.0f) * 0.25f);
- Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
+ Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y) + CenterOffset;
float closestDist = 0.0f;
highlightedLocation = null;
@@ -327,7 +331,7 @@ namespace Barotrauma
Location location = Locations[i];
Vector2 pos = rectCenter + (location.MapPosition + drawOffset) * zoom;
- if (!rect.Contains(pos)) continue;
+ if (!rect.Contains(pos)) { continue; }
float iconScale = MapGenerationParams.Instance.LocationIconSize / location.Type.Sprite.size.X;
@@ -348,28 +352,6 @@ namespace Barotrauma
}
}
- foreach (LocationConnection connection in connections)
- {
- if (highlightedLocation != CurrentLocation &&
- connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(CurrentLocation))
- {
- if (PlayerInput.LeftButtonClicked() &&
- SelectedLocation != highlightedLocation && highlightedLocation != null)
- {
- //clients aren't allowed to select the location without a permission
- if (GameMain.Client == null || GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign))
- {
- SelectedConnection = connection;
- SelectedLocation = highlightedLocation;
- targetReticleAnimState = 0.0f;
-
- OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
- GameMain.Client?.SendCampaignState();
- }
- }
- }
- }
-
if (GUI.KeyboardDispatcher.Subscriber == null)
{
float moveSpeed = 1000.0f;
@@ -383,6 +365,28 @@ namespace Barotrauma
if (GUI.MouseOn == mapContainer)
{
+ foreach (LocationConnection connection in connections)
+ {
+ if (highlightedLocation != CurrentLocation &&
+ connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(CurrentLocation))
+ {
+ if (PlayerInput.LeftButtonClicked() &&
+ SelectedLocation != highlightedLocation && highlightedLocation != null)
+ {
+ //clients aren't allowed to select the location without a permission
+ if (GameMain.Client == null || GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign))
+ {
+ SelectedConnection = connection;
+ SelectedLocation = highlightedLocation;
+ targetReticleAnimState = 0.0f;
+
+ OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
+ GameMain.Client?.SendCampaignState();
+ }
+ }
+ }
+ }
+
zoom += PlayerInput.ScrollWheelSpeed / 1000.0f;
zoom = MathHelper.Clamp(zoom, 1.0f, 4.0f);
@@ -425,12 +429,12 @@ namespace Barotrauma
Vector2 viewOffset = drawOffset + drawOffsetNoise;
- Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
+ Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y) + CenterOffset;
Rectangle prevScissorRect = GameMain.Instance.GraphicsDevice.ScissorRectangle;
spriteBatch.End();
spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, rect);
- spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
for (int x = 0; x < mapTiles.GetLength(0); x++)
{
@@ -662,15 +666,15 @@ namespace Barotrauma
Vector2 size = GUI.LargeFont.MeasureString(location.Name);
GUI.Style.GetComponentStyle("OuterGlow").Sprites[GUIComponent.ComponentState.None][0].Draw(
spriteBatch, new Rectangle((int)pos.X - 30, (int)pos.Y, (int)size.X + 60, (int)(size.Y + 25 * GUI.Scale)), Color.Black * hudOpenState * 0.7f);
- GUI.DrawString(spriteBatch, pos,
+ GUI.DrawString(spriteBatch, pos,
location.Name, Color.White * hudOpenState * 1.5f, font: GUI.LargeFont);
- GUI.DrawString(spriteBatch, pos + Vector2.UnitY * 25 * GUI.Scale,
+ GUI.DrawString(spriteBatch, pos + Vector2.UnitY * 25 * GUI.Scale,
location.Type.Name, Color.White * hudOpenState * 1.5f);
}
-
- GameMain.Instance.GraphicsDevice.ScissorRectangle = prevScissorRect;
+
spriteBatch.End();
- spriteBatch.Begin(SpriteSortMode.Deferred);
+ GameMain.Instance.GraphicsDevice.ScissorRectangle = prevScissorRect;
+ spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
private IEnumerable