Unstable 0.1400.7.0 (Coronavirus edition)

This commit is contained in:
Markus Isberg
2021-07-23 21:01:17 +03:00
parent ee5308b39f
commit 47707c824a
133 changed files with 1310 additions and 533 deletions
@@ -167,6 +167,13 @@ namespace Barotrauma.Items.Components
private set;
}
[Serialize(0, false)]
public int HudLayer
{
get;
private set;
}
private bool useAlternativeLayout;
public bool UseAlternativeLayout
{
@@ -443,6 +450,8 @@ namespace Barotrauma.Items.Components
public virtual void UpdateHUD(Character character, float deltaTime, Camera cam) { }
public virtual void UpdateEditing(float deltaTime) { }
public virtual void CreateEditingHUD(SerializableEntityEditor editor)
{
}
@@ -44,20 +44,6 @@ namespace Barotrauma.Items.Components
private set;
}
#if DEBUG
[Editable]
#endif
[Serialize("0.0,0.0", false, description: "The position where the contained items get drawn at (offset from the upper left corner of the sprite in pixels).")]
public Vector2 ItemPos { get; set; }
#if DEBUG
[Editable]
#endif
[Serialize("0.0,0.0", false, description: "The interval at which the contained items are spaced apart from each other (in pixels).")]
public Vector2 ItemInterval { get; set; }
[Serialize(100, false, description: "How many items are placed in a row before starting a new row.")]
public int ItemsPerRow { get; set; }
/// <summary>
/// Depth at which the contained sprites are drawn. If not set, the original depth of the item sprites is used.
/// </summary>
@@ -291,7 +277,6 @@ namespace Barotrauma.Items.Components
transformedItemPos = Vector2.Transform(transformedItemPos, transform);
transformedItemInterval = Vector2.Transform(transformedItemInterval, transform);
transformedItemIntervalHorizontal = Vector2.Transform(transformedItemIntervalHorizontal, transform);
transformedItemPos += item.DrawPosition;
}
@@ -21,6 +21,10 @@ namespace Barotrauma.Items.Components
private float[] charWidths;
private float prevScale;
private Rectangle prevRect;
private StringBuilder sb;
private Vector4 padding;
[Serialize("0,0,0,0", true, description: "The amount of padding around the text in pixels (left,top,right,bottom).")]
@@ -49,7 +53,8 @@ namespace Barotrauma.Items.Components
}
text = value;
SetDisplayText(value);
SetDisplayText(value);
UpdateScrollingText();
}
}
@@ -205,9 +210,16 @@ namespace Barotrauma.Items.Components
if (!needsScrolling) { return; }
scrollAmount -= deltaTime * ScrollSpeed;
UpdateScrollingText();
}
private void UpdateScrollingText()
{
if (!scrollable || !needsScrolling) { return; }
float currLength = 0;
StringBuilder sb = new StringBuilder();
sb ??= new StringBuilder();
sb.Clear();
float textAreaWidth = textBlock.Rect.Width - textBlock.Padding.X - textBlock.Padding.Z;
for (int i = scrollIndex; i < scrollingText.Length; i++)
{
@@ -246,10 +258,7 @@ namespace Barotrauma.Items.Components
prevScale = item.Scale;
prevRect = item.Rect;
}
private float prevScale;
private Rectangle prevRect;
public void Draw(SpriteBatch spriteBatch, bool editing = false, float itemDepth = -1)
{
if (editing)
@@ -267,15 +276,6 @@ namespace Barotrauma.Items.Components
item.DrawPosition.X - item.Rect.Width / 2.0f,
-(item.DrawPosition.Y + item.Rect.Height / 2.0f));
Rectangle worldRect = item.WorldRect;
if (worldRect.X > Screen.Selected.Cam.WorldView.Right ||
worldRect.Right < Screen.Selected.Cam.WorldView.X ||
worldRect.Y < Screen.Selected.Cam.WorldView.Y - Screen.Selected.Cam.WorldView.Height ||
worldRect.Y - worldRect.Height > Screen.Selected.Cam.WorldView.Y)
{
return;
}
textBlock.TextDepth = item.SpriteDepth - 0.0001f;
textBlock.TextOffset = drawPos - textBlock.Rect.Location.ToVector2() + (editing ? Vector2.Zero : new Vector2(scrollAmount + scrollPadding, 0.0f));
textBlock.DrawManually(spriteBatch);
@@ -561,7 +561,8 @@ namespace Barotrauma.Items.Components
private bool StartButtonClicked(GUIButton button, object obj)
{
if (selectedItem == null) { return false; }
if (fabricatedItem == null && !outputContainer.Inventory.CanBePut(selectedItem.TargetItem))
if (fabricatedItem == null &&
!outputContainer.Inventory.CanBePut(selectedItem.TargetItem, selectedItem.OutCondition))
{
outputSlot.Flash(GUI.Style.Red);
return false;
@@ -23,6 +23,10 @@ namespace Barotrauma.Items.Components
public static void DrawConnections(SpriteBatch spriteBatch, ConnectionPanel panel, Character character)
{
if (DraggingConnected?.Item.Removed ?? false)
{
DraggingConnected = null;
}
Rectangle panelRect = panel.GuiFrame.Rect;
int x = panelRect.X, y = panelRect.Y;
int width = panelRect.Width, height = panelRect.Height;
@@ -304,6 +304,21 @@ namespace Barotrauma.Items.Components
}
}
public override void UpdateEditing(float deltaTime)
{
if (Screen.Selected == GameMain.SubEditorScreen && item.IsSelected)
{
if (widgets.ContainsKey("maxrotation"))
{
widgets["maxrotation"].Update(deltaTime);
}
if (widgets.ContainsKey("minrotation"))
{
widgets["minrotation"].Update(deltaTime);
}
}
}
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
{
if (crosshairSprite != null)
@@ -469,7 +484,6 @@ namespace Barotrauma.Items.Components
{
widget.tooltip = "Min: " + (int)MathHelper.ToDegrees(minRotation);
widget.DrawPos = GetDrawPos() + new Vector2((float)Math.Cos(minRotation), (float)Math.Sin(minRotation)) * coneRadius / Screen.Selected.Cam.Zoom * GUI.Scale;
widget.Update(deltaTime);
};
});
@@ -1104,6 +1104,8 @@ namespace Barotrauma
public static void UpdateDragging()
{
DraggingItems.RemoveAll(it => !Character.Controlled.CanInteractWith(it));
if (DraggingItems.Any() && PlayerInput.PrimaryMouseButtonReleased())
{
Character.Controlled.ClearInputs();
@@ -22,6 +22,8 @@ namespace Barotrauma
private readonly List<ItemComponent> activeHUDs = new List<ItemComponent>();
private readonly List<SerializableEntityEditor> activeEditors = new List<SerializableEntityEditor>();
public GUIComponentStyle IconStyle { get; private set; } = null;
partial void AssignCampaignInteractionTypeProjSpecific(CampaignMode.InteractionType interactionType)
{
@@ -40,7 +42,6 @@ namespace Barotrauma
public float LastImpactSoundTime;
public const float ImpactSoundInterval = 0.2f;
private bool editingHUDRefreshPending;
private float editingHUDRefreshTimer;
private ContainedItemSprite activeContainedSprite;
@@ -581,14 +582,18 @@ namespace Barotrauma
}
}
public override void UpdateEditing(Camera cam)
public override void UpdateEditing(Camera cam, float deltaTime)
{
if (editingHUD == null || editingHUD.UserData as Item != this ||
(editingHUDRefreshPending && editingHUDRefreshTimer <= 0.0f))
if (editingHUD == null || editingHUD.UserData as Item != this)
{
editingHUD = CreateEditingHUD(Screen.Selected != GameMain.SubEditorScreen);
editingHUDRefreshTimer = 1.0f;
}
if (editingHUDRefreshTimer <= 0.0f)
{
activeEditors.ForEach(e => e?.RefreshValues());
editingHUDRefreshTimer = 1.0f;
}
if (Screen.Selected != GameMain.SubEditorScreen) { return; }
@@ -606,6 +611,11 @@ namespace Barotrauma
if (Character.Controlled == null) { activeHUDs.Clear(); }
foreach (ItemComponent ic in components)
{
ic.UpdateEditing(deltaTime);
}
if (!Linkable) { return; }
if (!PlayerInput.KeyDown(Keys.Space)) { return; }
@@ -632,7 +642,7 @@ namespace Barotrauma
public GUIComponent CreateEditingHUD(bool inGame = false)
{
editingHUDRefreshPending = false;
activeEditors.Clear();
int heightScaled = (int)(20 * GUI.Scale);
editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) }) { UserData = this };
@@ -643,6 +653,7 @@ namespace Barotrauma
};
var itemEditor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont) { UserData = this };
activeEditors.Add(itemEditor);
itemEditor.Children.First().Color = Color.Black * 0.7f;
if (!inGame)
{
@@ -782,6 +793,7 @@ namespace Barotrauma
var componentEditor = new SerializableEntityEditor(listBox.Content.RectTransform, ic, inGame, showName: !inGame, titleFont: GUI.SubHeadingFont) { UserData = ic };
componentEditor.Children.First().Color = Color.Black * 0.7f;
activeEditors.Add(componentEditor);
if (inGame)
{
@@ -976,7 +988,7 @@ namespace Barotrauma
Screen.Selected == GameMain.SubEditorScreen)
{
GUIComponent prevEditingHUD = editingHUD;
UpdateEditing(cam);
UpdateEditing(cam, deltaTime);
editingHUDCreated = editingHUD != null && editingHUD != prevEditingHUD;
}
@@ -996,7 +1008,7 @@ namespace Barotrauma
{
if (prefab.IsLinkAllowed(entity.prefab) && entity is Item i)
{
if (!i.DisplaySideBySideWhenLinked) continue;
if (!i.DisplaySideBySideWhenLinked) { continue; }
activeComponents.AddRange(i.components);
}
}
@@ -1030,6 +1042,8 @@ namespace Barotrauma
}
}
activeHUDs.Sort((h1, h2) => { return h2.HudLayer.CompareTo(h1.HudLayer); });
//active HUDs have changed, need to reposition
if (!prevActiveHUDs.SequenceEqual(activeHUDs) || editingHUDCreated)
{
@@ -1132,8 +1146,6 @@ namespace Barotrauma
}
texts.Add(new ColoredText(nameText, GUI.Style.TextColor, false, false));
bool noComponentText = true;
if (CampaignInteractionType != CampaignMode.InteractionType.None)
{
texts.Add(new ColoredText(TextManager.GetWithVariable($"CampaignInteraction.{CampaignInteractionType}", "[key]", GameMain.Config.KeyBindText(InputType.Use)), Color.Cyan, false, false));
@@ -1159,7 +1171,6 @@ namespace Barotrauma
}
}
texts.Add(new ColoredText(ic.DisplayMsg, color, false, false));
noComponentText = false;
}
}
if (PlayerInput.IsShiftDown() && CrewManager.DoesItemHaveContextualOrders(this))
@@ -1295,7 +1306,6 @@ namespace Barotrauma
break;
case NetEntityEvent.Type.ChangeProperty:
ReadPropertyChange(msg, false);
editingHUDRefreshPending = true;
break;
case NetEntityEvent.Type.Upgrade:
string identifier = msg.ReadString();