Unstable 0.1300.0.7

This commit is contained in:
Markus Isberg
2021-04-07 15:24:22 +03:00
parent 96b2184811
commit 538c3dbfc3
47 changed files with 246 additions and 103 deletions
@@ -55,6 +55,10 @@ namespace Barotrauma
};
TopContainer.Visible = SideContainer.Visible = false;
TopContainer.CanBeFocused = false;
TopContainer.Children.ForEach(c => c.CanBeFocused = false);
SideContainer.CanBeFocused = false;
SideContainer.Children.ForEach(c => c.CanBeFocused = false);
}
}
@@ -465,7 +465,7 @@ namespace Barotrauma
if (currentRichTextData != null && currentRichTextData.StartIndex + lineNum <= i + rtdOffset && i + rtdOffset <= currentRichTextData.EndIndex + lineNum)
{
currentTextColor = currentRichTextData.Color ?? color;
currentTextColor = currentRichTextData.Color * currentRichTextData.Alpha ?? color;
if (!string.IsNullOrEmpty(currentRichTextData.Metadata))
{
currentTextColor = Color.Lerp(currentTextColor, Color.White, 0.5f);
@@ -584,6 +584,7 @@ namespace Barotrauma
if (ToggleOpen)
{
GUIFrame.CanBeFocused = true;
openState += deltaTime * 5.0f;
//delete all popup messages when the chatbox is open
foreach (var popupMsg in popupMessages)
@@ -594,6 +595,7 @@ namespace Barotrauma
}
else
{
GUIFrame.CanBeFocused = false;
openState -= deltaTime * 5.0f;
int yOffset = 0;
@@ -263,6 +263,8 @@ namespace Barotrauma
public bool HasColorHighlight => RichTextData != null;
public bool OverrideRichTextDataAlpha = true;
public struct ClickableArea
{
public RichTextData Data;
@@ -645,10 +647,13 @@ namespace Barotrauma
}
Font.DrawString(spriteBatch, textToShow, pos, colorToShow, 0.0f, origin, TextScale, SpriteEffects.None, textDepth);
}
else
{
if (OverrideRichTextDataAlpha)
{
RichTextData.ForEach(rt => rt.Alpha = currentTextColor.A / 255.0f);
}
Font.DrawStringWithColors(spriteBatch, Censor ? censoredText : (Wrap ? wrappedText : text), pos,
currentTextColor * (currentTextColor.A / 255.0f), 0.0f, origin, TextScale, SpriteEffects.None, textDepth, RichTextData);
}
@@ -626,6 +626,9 @@ namespace Barotrauma
{
if (Text == null) Text = "";
// Prevent alt gr from triggering any of these as that combination is often needed for special characters
if (PlayerInput.IsAltDown()) return;
switch (command)
{
case '\b' when !Readonly: //backspace
@@ -667,7 +670,10 @@ namespace Barotrauma
}
break;
case (char)0x1: // ctrl-a
SelectAll();
if (PlayerInput.IsCtrlDown())
{
SelectAll();
}
break;
case (char)0x1A when !Readonly && !SubEditorScreen.IsSubEditor(): // ctrl-z
text = memento.Undo();
@@ -917,6 +917,13 @@ namespace Barotrauma
var orderInfo = (OrderInfo)userData;
SetCharacterOrder(character, orderInfo.Order, orderInfo.OrderOption, CharacterInfo.HighestManualOrderPriority, Character.Controlled);
return true;
},
OnSecondaryClicked = (button, userData) =>
{
if (previousOrderIconGroup == null) { return false; }
previousOrderIconGroup.RemoveChild(button);
previousOrderIconGroup.Recalculate();
return true;
}
};
prevOrderFrame.RectTransform.IsFixedSize = true;
@@ -695,6 +695,7 @@ namespace Barotrauma
if (firstItem != null && !DraggingItems.Contains(firstItem) && Character.Controlled?.Inventory == this &&
GUI.KeyboardDispatcher.Subscriber == null && !CrewManager.IsCommandInterfaceOpen && PlayerInput.InventoryKeyHit(visualSlots[i].InventoryKeyIndex))
{
if (SubEditorScreen.IsSubEditor() && SubEditorScreen.SkipInventorySlotUpdate) { continue; }
#if LINUX
// some window managers on Linux use windows key + number to change workspaces or perform other actions
if (PlayerInput.KeyDown(Keys.RightWindows) || PlayerInput.KeyDown(Keys.LeftWindows)) { continue; }
@@ -587,7 +587,7 @@ namespace Barotrauma.Items.Components
//ID ushort.MaxValue = launched without a projectile
if (projectileID == ushort.MaxValue)
{
Launch(null);
Launch(null, user);
}
else
{
@@ -596,7 +596,7 @@ namespace Barotrauma.Items.Components
DebugConsole.ThrowError("Failed to launch a projectile - item with the ID \"" + projectileID + " not found");
return;
}
Launch(projectile, launchRotation: newTargetRotation);
Launch(projectile, user, launchRotation: newTargetRotation);
}
}
}
@@ -134,6 +134,7 @@ namespace Barotrauma.Networking
HasPassword = incMsg.ReadBoolean();
IsPublic = incMsg.ReadBoolean();
GameMain.NetLobbyScreen.SetPublic(IsPublic);
AllowFileTransfers = incMsg.ReadBoolean();
incMsg.ReadPadBits();
TickRate = incMsg.ReadRangedInteger(1, 60);
GameMain.NetworkMember.TickRate = TickRate;
@@ -27,7 +27,8 @@ namespace Barotrauma.Particles
private float angularVelocity;
private Vector2 dragVec = Vector2.Zero;
private int dragWait = 0;
private float dragWait = 0;
private float collisionIgnoreTimer = 0;
private Vector2 size;
private Vector2 sizeChange;
@@ -103,7 +104,7 @@ namespace Barotrauma.Particles
return debugName;
}
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false)
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f)
{
this.prefab = prefab;
debugName = $"Particle ({prefab.Name})";
@@ -174,14 +175,22 @@ namespace Barotrauma.Particles
}
DrawOnTop = drawOnTop;
this.collisionIgnoreTimer = collisionIgnoreTimer;
}
public bool Update(float deltaTime)
public enum UpdateResult
{
Normal,
Delete
}
public UpdateResult Update(float deltaTime)
{
if (startDelay > 0.0f)
{
startDelay -= deltaTime;
return true;
return UpdateResult.Normal;
}
prevPosition = position;
@@ -251,7 +260,7 @@ namespace Barotrauma.Particles
}
lifeTime -= deltaTime;
if (lifeTime <= 0.0f || color.A <= 0 || size.X <= 0.0f || size.Y <= 0.0f) { return false; }
if (lifeTime <= 0.0f || color.A <= 0 || size.X <= 0.0f || size.Y <= 0.0f) { return UpdateResult.Delete; }
if (hasSubEmitters)
{
@@ -261,7 +270,13 @@ namespace Barotrauma.Particles
}
}
if (!prefab.UseCollision) { return true; }
if (collisionIgnoreTimer > 0f)
{
collisionIgnoreTimer -= deltaTime;
if (collisionIgnoreTimer <= 0f) { currentHull ??= Hull.FindHull(position); }
return UpdateResult.Normal;
}
if (!prefab.UseCollision) { return UpdateResult.Normal; }
if (HighQualityCollisionDetection)
{
@@ -278,17 +293,17 @@ namespace Barotrauma.Particles
}
}
return true;
return UpdateResult.Normal;
}
private bool CollisionUpdate()
private UpdateResult CollisionUpdate()
{
if (currentHull == null)
{
Hull collidedHull = Hull.FindHull(position);
if (collidedHull != null)
{
if (prefab.DeleteOnCollision) return false;
if (prefab.DeleteOnCollision) return UpdateResult.Delete;
OnWallCollisionOutside(collidedHull);
}
}
@@ -298,12 +313,12 @@ namespace Barotrauma.Particles
Vector2 collisionNormal = Vector2.Zero;
if (velocity.Y < 0.0f && position.Y - prefab.CollisionRadius * size.Y < hullRect.Y - hullRect.Height)
{
if (prefab.DeleteOnCollision) { return false; }
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
collisionNormal = new Vector2(0.0f, 1.0f);
}
else if (velocity.Y > 0.0f && position.Y + prefab.CollisionRadius * size.Y > hullRect.Y)
{
if (prefab.DeleteOnCollision) { return false; }
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
collisionNormal = new Vector2(0.0f, -1.0f);
}
@@ -328,12 +343,12 @@ namespace Barotrauma.Particles
if (velocity.X < 0.0f && position.X - prefab.CollisionRadius * size.X < hullRect.X)
{
if (prefab.DeleteOnCollision) { return false; }
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
collisionNormal = new Vector2(1.0f, 0.0f);
}
else if (velocity.X > 0.0f && position.X + prefab.CollisionRadius * size.X > hullRect.Right)
{
if (prefab.DeleteOnCollision) { return false; }
if (prefab.DeleteOnCollision) { return UpdateResult.Delete; }
collisionNormal = new Vector2(-1.0f, 0.0f);
}
@@ -374,7 +389,7 @@ namespace Barotrauma.Particles
}
}
return true;
return UpdateResult.Normal;
}
private void ApplyDrag(float dragCoefficient, float deltaTime)
@@ -389,10 +404,10 @@ namespace Barotrauma.Particles
//TODO: some better way to handle particle drag
//this doesn't work that well because the drag vector is only updated every 0.5 seconds, allowing the particle to accelerate way more than it should
//(e.g. a falling particle can freely accelerate for 0.5 seconds before the drag takes effect)
dragWait--;
if (dragWait <= 0)
dragWait-=deltaTime;
if (dragWait <= 0f)
{
dragWait = 30;
dragWait = 0.5f;
float speed = velocity.Length();
@@ -115,12 +115,12 @@ namespace Barotrauma.Particles
Prefabs.RemoveByFile(configFile);
}
public Particle CreateParticle(string prefabName, Vector2 position, float angle, float speed, Hull hullGuess = null)
public Particle CreateParticle(string prefabName, Vector2 position, float angle, float speed, Hull hullGuess = null, float collisionIgnoreTimer = 0f)
{
return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)-Math.Sin(angle)) * speed, angle, hullGuess);
return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)-Math.Sin(angle)) * speed, angle, hullGuess, collisionIgnoreTimer);
}
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null)
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, float collisionIgnoreTimer = 0f)
{
ParticlePrefab prefab = FindPrefab(prefabName);
@@ -130,10 +130,10 @@ namespace Barotrauma.Particles
return null;
}
return CreateParticle(prefab, position, velocity, rotation, hullGuess);
return CreateParticle(prefab, position, velocity, rotation, hullGuess, collisionIgnoreTimer: collisionIgnoreTimer);
}
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false)
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f)
{
if (particleCount >= MaxParticles || prefab == null || prefab.Sprites.Count == 0) { return null; }
@@ -149,7 +149,7 @@ namespace Barotrauma.Particles
if (particles[particleCount] == null) particles[particleCount] = new Particle();
particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop);
particles[particleCount].Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer);
particleCount++;
@@ -181,10 +181,10 @@ namespace Barotrauma.Particles
for (int i = 0; i < particleCount; i++)
{
bool remove = false;
bool remove;
try
{
remove = !particles[i].Update(deltaTime);
remove = particles[i].Update(deltaTime) == Particle.UpdateResult.Delete;
}
catch (Exception e)
{
@@ -476,6 +476,11 @@ namespace Barotrauma
#endif
}
public static bool IsAltDown()
{
return KeyDown(Keys.LeftAlt) || KeyDown(Keys.RightAlt);
}
public static void Update(double deltaTime)
{
timeSinceClick += deltaTime;
@@ -111,6 +111,8 @@ namespace Barotrauma
public static bool TransparentWiringMode = true;
public static bool SkipInventorySlotUpdate;
private static object bulkItemBufferinUse;
public static object BulkItemBufferInUse
@@ -4109,6 +4111,7 @@ namespace Barotrauma
/// </summary>
public override void Update(double deltaTime)
{
SkipInventorySlotUpdate = false;
ImageManager.Update((float) deltaTime);
if (GameMain.GraphicsWidth != screenResolution.X || GameMain.GraphicsHeight != screenResolution.Y)
@@ -4222,11 +4225,15 @@ namespace Barotrauma
}
List<Keys> numberKeys = PlayerInput.NumberKeys;
if (numberKeys.Find(PlayerInput.KeyHit) is { } key)
if (numberKeys.Find(PlayerInput.KeyHit) is { } key && key != Keys.None)
{
// treat 0 as the last key instead of first
int index = key == Keys.D0 ? numberKeys.Count : numberKeys.IndexOf(key) - 1;
listBox.Select(index, force: false, autoScroll: true, takeKeyBoardFocus: false);
if (index > -1 && index < listBox.Content.CountChildren)
{
listBox.Select(index, force: false, autoScroll: true, takeKeyBoardFocus: false);
SkipInventorySlotUpdate = true;
}
}
}
}