Unstable 0.1300.0.4
This commit is contained in:
@@ -251,7 +251,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool Freeze { get; set; }
|
||||
|
||||
public void MoveCamera(float deltaTime, bool allowMove = true, bool allowZoom = true)
|
||||
public void MoveCamera(float deltaTime, bool allowMove = true, bool allowZoom = true, bool? followSub = null)
|
||||
{
|
||||
prevPosition = position;
|
||||
prevZoom = zoom;
|
||||
@@ -278,7 +278,7 @@ namespace Barotrauma
|
||||
velocity = Vector2.Lerp(velocity, moveInput, deltaTime * 10.0f);
|
||||
moveCam = velocity * moveSpeed * deltaTime * FreeCamMoveSpeed * 60.0f;
|
||||
|
||||
if (Screen.Selected == GameMain.GameScreen && FollowSub)
|
||||
if (Screen.Selected == GameMain.GameScreen && (followSub ?? FollowSub))
|
||||
{
|
||||
var closestSub = Submarine.FindClosest(WorldViewCenter);
|
||||
if (closestSub != null)
|
||||
@@ -313,9 +313,10 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 mousePos = PlayerInput.MousePosition;
|
||||
Vector2 offset = mousePos - Resolution.ToVector2() / 2;
|
||||
offset.X = offset.X / (Resolution.X * 0.6f);
|
||||
offset.Y = -offset.Y / (Resolution.Y * 0.6f);
|
||||
offset.X = offset.X / (Resolution.X * 0.4f);
|
||||
offset.Y = -offset.Y / (Resolution.Y * 0.3f);
|
||||
if (offset.LengthSquared() > 1.0f) offset.Normalize();
|
||||
float offsetUnscaledLen = offset.Length();
|
||||
offset *= OffsetAmount;
|
||||
// Freeze the camera movement by default, when the cursor is on top of an ui element.
|
||||
// Setting a positive value to the OffsetAmount, will override this behaviour.
|
||||
@@ -330,21 +331,20 @@ namespace Barotrauma
|
||||
}
|
||||
if (Freeze)
|
||||
{
|
||||
offset = previousOffset;
|
||||
if (offset.LengthSquared() > 0.001f) { offset = previousOffset; }
|
||||
}
|
||||
else
|
||||
{
|
||||
previousOffset = offset;
|
||||
}
|
||||
|
||||
//TODO: remove magic numbers
|
||||
float minMultiplier = OffsetAmount > 0f ? ((DefaultZoom * 8f * 250f) / OffsetAmount) : 15f;
|
||||
|
||||
//how much to zoom out (0.0 = Default zoom, 1.0 = zoom completely out)
|
||||
//how much to zoom out (zoom completely out when offset is 1000)
|
||||
float zoomOutAmount = GetZoomAmount(offset);
|
||||
float newZoom = MathHelper.Lerp(DefaultZoom, MinZoom * minMultiplier, zoomOutAmount) * globalZoomScale;
|
||||
//scaled zoom amount
|
||||
float scaledZoom = MathHelper.Lerp(DefaultZoom, MinZoom, zoomOutAmount) * globalZoomScale;
|
||||
//zoom in further if zoomOutAmount is low and resolution is lower than reference
|
||||
newZoom *= MathHelper.Lerp(0.5f * (1f - Math.Min(globalZoomScale, 1f)), 0f, zoomOutAmount) + 1f;
|
||||
float newZoom = scaledZoom * (MathHelper.Lerp(0.3f * (1f - Math.Min(globalZoomScale, 1f)), 0f,
|
||||
(GameMain.Config == null || GameMain.Config.EnableMouseLook) ? (float)Math.Sqrt(offsetUnscaledLen) : 0.3f) + 1f);
|
||||
|
||||
Zoom += (newZoom - zoom) / ZoomSmoothness;
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace Barotrauma
|
||||
|
||||
private float GetZoomAmount(Vector2 offset)
|
||||
{
|
||||
return Math.Min(offset.Length() / Math.Max(1f, OffsetAmount), 1.0f);
|
||||
return Math.Min(offset.Length() / 1000.0f, 1.0f);
|
||||
}
|
||||
|
||||
public float GetZoomAmountFromPrevious()
|
||||
|
||||
@@ -55,6 +55,11 @@ namespace Barotrauma
|
||||
set
|
||||
{
|
||||
if (controlled == value) return;
|
||||
if ((!(controlled is null)) && (!(Screen.Selected?.Cam is null)) && value is null)
|
||||
{
|
||||
Screen.Selected.Cam.TargetPos = Vector2.Zero;
|
||||
Lights.LightManager.ViewTarget = null;
|
||||
}
|
||||
controlled = value;
|
||||
if (controlled != null) controlled.Enabled = true;
|
||||
CharacterHealth.OpenHealthWindow = null;
|
||||
@@ -122,6 +127,9 @@ namespace Barotrauma
|
||||
get { return gibEmitters; }
|
||||
}
|
||||
|
||||
public static bool IsMouseOnUI => GUI.MouseOn != null ||
|
||||
(CharacterInventory.IsMouseOnInventory() && !CharacterInventory.DraggingItemToWorld);
|
||||
|
||||
public class ObjectiveEntity
|
||||
{
|
||||
public Entity Entity;
|
||||
@@ -291,6 +299,10 @@ namespace Barotrauma
|
||||
cam.OffsetAmount = targetOffsetAmount = 0.0f;
|
||||
}
|
||||
}
|
||||
else if (IsMouseOnUI)
|
||||
{
|
||||
targetOffsetAmount = cam.OffsetAmount;
|
||||
}
|
||||
else if (Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||
{
|
||||
Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||
@@ -417,6 +429,11 @@ namespace Barotrauma
|
||||
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
controlled = null;
|
||||
if (!(Screen.Selected?.Cam is null))
|
||||
{
|
||||
Screen.Selected.Cam.TargetPos = Vector2.Zero;
|
||||
Lights.LightManager.ViewTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
PlaySound(CharacterSound.SoundType.Die);
|
||||
@@ -424,7 +441,15 @@ namespace Barotrauma
|
||||
|
||||
partial void DisposeProjSpecific()
|
||||
{
|
||||
if (controlled == this) controlled = null;
|
||||
if (controlled == this)
|
||||
{
|
||||
controlled = null;
|
||||
if (!(Screen.Selected?.Cam is null))
|
||||
{
|
||||
Screen.Selected.Cam.TargetPos = Vector2.Zero;
|
||||
Lights.LightManager.ViewTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.GameSession?.CrewManager != null &&
|
||||
GameMain.GameSession.CrewManager.GetCharacters().Contains(this))
|
||||
|
||||
@@ -12,6 +12,40 @@ namespace Barotrauma
|
||||
{
|
||||
class CharacterHUD
|
||||
{
|
||||
const float BossHealthBarDuration = 30.0f;
|
||||
class BossHealthBar
|
||||
{
|
||||
public readonly Character Character;
|
||||
public float FadeTimer;
|
||||
|
||||
public readonly GUIComponent TopContainer;
|
||||
public readonly GUIComponent SideContainer;
|
||||
|
||||
public readonly GUIProgressBar TopHealthBar;
|
||||
public readonly GUIProgressBar SideHealthBar;
|
||||
|
||||
public BossHealthBar(Character character)
|
||||
{
|
||||
Character = character;
|
||||
FadeTimer = BossHealthBarDuration;
|
||||
|
||||
TopContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.18f, 0.03f), HUDFrame.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
MinSize = new Point(100, 50),
|
||||
RelativeOffset = new Vector2(0.0f, 0.01f)
|
||||
}, isHorizontal: false, childAnchor: Anchor.TopCenter);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), TopContainer.RectTransform), character.DisplayName, textAlignment: Alignment.Center, textColor: GUI.Style.Red);
|
||||
TopHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.6f), TopContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBarCentered");
|
||||
|
||||
SideContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), bossHealthContainer.RectTransform)
|
||||
{
|
||||
MinSize = new Point(80, 60)
|
||||
}, isHorizontal: false, childAnchor: Anchor.TopRight);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), SideContainer.RectTransform), character.DisplayName, textAlignment: Alignment.CenterRight, textColor: GUI.Style.Red);
|
||||
SideHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar");
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<ISpatialEntity, int> orderIndicatorCount = new Dictionary<ISpatialEntity, int>();
|
||||
const float ItemOverlayDelay = 1.0f;
|
||||
private static Item focusedItem;
|
||||
@@ -20,8 +54,12 @@ namespace Barotrauma
|
||||
private static readonly List<Item> brokenItems = new List<Item>();
|
||||
private static float brokenItemsCheckTimer;
|
||||
|
||||
private static readonly List<BossHealthBar> bossHealthBars = new List<BossHealthBar>();
|
||||
|
||||
private static readonly Dictionary<string, string> cachedHudTexts = new Dictionary<string, string>();
|
||||
|
||||
private static GUILayoutGroup bossHealthContainer;
|
||||
|
||||
private static GUIFrame hudFrame;
|
||||
public static GUIFrame HUDFrame
|
||||
{
|
||||
@@ -34,6 +72,13 @@ namespace Barotrauma
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
bossHealthContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.15f, 0.5f), hudFrame.RectTransform, Anchor.CenterRight)
|
||||
{
|
||||
RelativeOffset = new Vector2(0.005f, 0.0f)
|
||||
})
|
||||
{
|
||||
AbsoluteSpacing = GUI.IntScale(10)
|
||||
};
|
||||
}
|
||||
return hudFrame;
|
||||
}
|
||||
@@ -71,7 +116,7 @@ namespace Barotrauma
|
||||
|
||||
public static void AddToGUIUpdateList(Character character)
|
||||
{
|
||||
if (GUI.DisableHUD) return;
|
||||
if (GUI.DisableHUD) { return; }
|
||||
|
||||
if (!character.IsIncapacitated && character.Stun <= 0.0f && !IsCampaignInterfaceOpen)
|
||||
{
|
||||
@@ -84,7 +129,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (ItemComponent ic in item.Components)
|
||||
{
|
||||
if (ic.DrawHudWhenEquipped) ic.AddToGUIUpdateList();
|
||||
if (ic.DrawHudWhenEquipped) { ic.AddToGUIUpdateList(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,13 +145,14 @@ namespace Barotrauma
|
||||
|
||||
public static void Update(float deltaTime, Character character, Camera cam)
|
||||
{
|
||||
UpdateBossHealthBars(deltaTime);
|
||||
|
||||
if (GUI.DisableHUD)
|
||||
{
|
||||
if (character.Inventory != null && !LockInventory(character))
|
||||
{
|
||||
character.Inventory.UpdateSlotInput();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -489,6 +535,92 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowBossHealthBar(Character character)
|
||||
{
|
||||
var existingBar = bossHealthBars.Find(b => b.Character == character);
|
||||
if (existingBar != null)
|
||||
{
|
||||
existingBar.FadeTimer = BossHealthBarDuration;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bossHealthBars.Count > 5)
|
||||
{
|
||||
BossHealthBar oldestHealthBar = bossHealthBars.First();
|
||||
foreach (var bar in bossHealthBars)
|
||||
{
|
||||
if (bar.TopHealthBar.BarSize < oldestHealthBar.TopHealthBar.BarSize)
|
||||
{
|
||||
oldestHealthBar = bar;
|
||||
}
|
||||
}
|
||||
oldestHealthBar.FadeTimer = Math.Min(oldestHealthBar.FadeTimer, 1.0f);
|
||||
}
|
||||
|
||||
bossHealthBars.Add(new BossHealthBar(character));
|
||||
}
|
||||
|
||||
public static void UpdateBossHealthBars(float deltaTime)
|
||||
{
|
||||
for (int i = 0; i < bossHealthBars.Count; i++)
|
||||
{
|
||||
var bossHealthBar = bossHealthBars[i];
|
||||
|
||||
bool showTopBar = i == 0;
|
||||
if (showTopBar != bossHealthBar.TopContainer.Visible)
|
||||
{
|
||||
bossHealthContainer.Recalculate();
|
||||
}
|
||||
|
||||
bossHealthBar.TopContainer.Visible = showTopBar;
|
||||
bossHealthBar.SideContainer.Visible = !bossHealthBar.TopContainer.Visible;
|
||||
|
||||
float health = bossHealthBar.Character.Vitality / bossHealthBar.Character.MaxVitality;
|
||||
|
||||
float alpha = Math.Min(bossHealthBar.FadeTimer, 1.0f);
|
||||
foreach (var c in bossHealthBar.TopContainer.GetAllChildren())
|
||||
{
|
||||
c.Color = new Color(c.Color, (byte)(alpha * 255));
|
||||
if (c is GUITextBlock textBlock)
|
||||
{
|
||||
textBlock.TextColor = new Color(textBlock.TextColor, (byte)(alpha * 255));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var c in bossHealthBar.SideContainer.GetAllChildren())
|
||||
{
|
||||
c.Color = new Color(c.Color, (byte)(alpha * 255));
|
||||
if (c is GUITextBlock textBlock)
|
||||
{
|
||||
textBlock.TextColor = new Color(textBlock.TextColor, (byte)(alpha * 255));
|
||||
}
|
||||
}
|
||||
|
||||
bossHealthBar.TopHealthBar.BarSize = bossHealthBar.SideHealthBar.BarSize = health;
|
||||
|
||||
bossHealthBar.TopHealthBar.Color = bossHealthBar.SideHealthBar.Color =
|
||||
ToolBox.GradientLerp(health, GUI.Style.HealthBarColorLow, GUI.Style.HealthBarColorMedium, GUI.Style.HealthBarColorHigh) * alpha;
|
||||
|
||||
if (bossHealthBar.Character.IsDead || bossHealthBar.Character.Removed)
|
||||
{
|
||||
bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 1.0f);
|
||||
}
|
||||
bossHealthBar.FadeTimer -= deltaTime;
|
||||
}
|
||||
|
||||
for (int i = bossHealthBars.Count - 1; i >= 0 ; i--)
|
||||
{
|
||||
var bossHealthBar = bossHealthBars[i];
|
||||
if (bossHealthBar.FadeTimer <= 0)
|
||||
{
|
||||
bossHealthBar.SideContainer.Parent?.RemoveChild(bossHealthBar.SideContainer);
|
||||
bossHealthBar.TopContainer.Parent?.RemoveChild(bossHealthBar.TopContainer);
|
||||
bossHealthBars.RemoveAt(i);
|
||||
bossHealthContainer.Recalculate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool LockInventory(Character character)
|
||||
{
|
||||
if (character?.Inventory == null || !character.AllowInput || character.LockHands || IsCampaignInterfaceOpen) { return true; }
|
||||
|
||||
@@ -297,6 +297,7 @@ namespace Barotrauma
|
||||
barSize: 1.0f, color: GUI.Style.HealthBarColorHigh, style: horizontal ? "CharacterHealthBar" : "GUIProgressBarVertical")
|
||||
{
|
||||
HoverCursor = CursorState.Hand,
|
||||
ToolTip = TextManager.GetWithVariable("hudbutton.healthinterface", "[key]", GameMain.Config.KeyBindText(InputType.Health)),
|
||||
Enabled = true,
|
||||
IsHorizontal = horizontal
|
||||
};
|
||||
|
||||
@@ -383,8 +383,20 @@ namespace Barotrauma
|
||||
color: ((chatBox.Content.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f, parseRichText: true)
|
||||
{
|
||||
UserData = message.SenderName,
|
||||
CanBeFocused = true
|
||||
CanBeFocused = false
|
||||
};
|
||||
msgText.CalculateHeightFromText();
|
||||
if (msgText.RichTextData != null)
|
||||
{
|
||||
foreach (var data in msgText.RichTextData)
|
||||
{
|
||||
msgText.ClickableAreas.Add(new GUITextBlock.ClickableArea()
|
||||
{
|
||||
Data = data,
|
||||
OnClick = GameMain.NetLobbyScreen.SelectPlayer
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (message is OrderChatMessage orderChatMsg &&
|
||||
Character.Controlled != null &&
|
||||
|
||||
@@ -539,52 +539,42 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<string> strings;
|
||||
if (MouseOn != null)
|
||||
{
|
||||
RectTransform mouseOnRect = MouseOn.RectTransform;
|
||||
bool isAbsoluteOffsetInUse = mouseOnRect.AbsoluteOffset != Point.Zero || mouseOnRect.RelativeOffset == Vector2.Zero;
|
||||
|
||||
string selectedString = $"Selected UI Element: {MouseOn.GetType().Name} ({ MouseOn.Style?.Element.Name.LocalName ?? "no style" }, {MouseOn.Rect}";
|
||||
string offsetString = $"Relative Offset: {mouseOnRect.RelativeOffset} | Absolute Offset: {(isAbsoluteOffsetInUse ? mouseOnRect.AbsoluteOffset : mouseOnRect.ParentRect.MultiplySize(mouseOnRect.RelativeOffset))}{(isAbsoluteOffsetInUse ? "" : " (Calculated from RelativeOffset)")}";
|
||||
string anchorPivotString = $"Anchor: {mouseOnRect.Anchor} | Pivot: {mouseOnRect.Pivot}";
|
||||
Vector2 selectedStringSize = SmallFont.MeasureString(selectedString);
|
||||
Vector2 offsetStringSize = SmallFont.MeasureString(offsetString);
|
||||
Vector2 anchorPivotStringSize = SmallFont.MeasureString(anchorPivotString);
|
||||
|
||||
int padding = IntScale(10);
|
||||
int yPos = padding;
|
||||
|
||||
DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - (int)selectedStringSize.X - padding, yPos), selectedString, Color.LightGreen, Color.Black, 0, SmallFont);
|
||||
yPos += (int)selectedStringSize.Y + padding / 2;
|
||||
|
||||
DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - (int)offsetStringSize.X - padding, yPos), offsetString, Color.LightGreen, Color.Black, 0, SmallFont);
|
||||
yPos += (int)offsetStringSize.Y + padding / 2;
|
||||
|
||||
DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - (int)anchorPivotStringSize.X - padding, yPos), anchorPivotString, Color.LightGreen, Color.Black, 0, SmallFont);
|
||||
yPos += (int)anchorPivotStringSize.Y + padding / 2;
|
||||
strings = new string[]
|
||||
{
|
||||
$"Selected UI Element: {MouseOn.GetType().Name} ({ MouseOn.Style?.Element.Name.LocalName ?? "no style" }, {MouseOn.Rect}",
|
||||
$"Relative Offset: {mouseOnRect.RelativeOffset} | Absolute Offset: {(isAbsoluteOffsetInUse ? mouseOnRect.AbsoluteOffset : mouseOnRect.ParentRect.MultiplySize(mouseOnRect.RelativeOffset))}{(isAbsoluteOffsetInUse ? "" : " (Calculated from RelativeOffset)")}",
|
||||
$"Anchor: {mouseOnRect.Anchor} | Pivot: {mouseOnRect.Pivot}"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] strings = new string[]
|
||||
strings = new string[]
|
||||
{
|
||||
$"GUI.Scale: {Scale}",
|
||||
$"GUI.xScale: {xScale}",
|
||||
$"GUI.yScale: {yScale}",
|
||||
$"RelativeHorizontalAspectRatio: {RelativeHorizontalAspectRatio}",
|
||||
$"RelativeVerticalAspectRatio: {RelativeVerticalAspectRatio}",
|
||||
$"Cam.Zoom: {Screen.Selected.Cam?.Zoom ?? 0f}",
|
||||
};
|
||||
}
|
||||
|
||||
int padding = IntScale(10);
|
||||
int yPos = padding;
|
||||
strings = strings.Concat(new string[] { $"Cam.Zoom: {Screen.Selected.Cam?.Zoom ?? 0f}" });
|
||||
|
||||
foreach (string str in strings)
|
||||
{
|
||||
Vector2 stringSize = SmallFont.MeasureString(str);
|
||||
int padding = IntScale(10);
|
||||
int yPos = padding;
|
||||
|
||||
DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - (int)stringSize.X - padding, yPos), str, Color.LightGreen, Color.Black, 0, SmallFont);
|
||||
yPos += (int)stringSize.Y + padding / 2;
|
||||
}
|
||||
foreach (string str in strings)
|
||||
{
|
||||
Vector2 stringSize = SmallFont.MeasureString(str);
|
||||
|
||||
DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - (int)stringSize.X - padding, yPos), str, Color.LightGreen, Color.Black, 0, SmallFont);
|
||||
yPos += (int)stringSize.Y + padding / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,7 +1027,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
if (parent != null && parent.CanBeFocused)
|
||||
{
|
||||
if (!parent.Rect.Equals(monitorRect)) { return parent.HoverCursor; }
|
||||
}
|
||||
|
||||
@@ -573,8 +573,9 @@ namespace Barotrauma
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
if (ClickableAreas.Any() && (GUI.MouseOn?.IsParentOf(this) ?? true) && Rect.Contains(PlayerInput.MousePosition))
|
||||
if (ClickableAreas.Any() && (GUI.MouseOn?.IsParentOf(this) ?? true))
|
||||
{
|
||||
if (!Rect.Contains(PlayerInput.MousePosition)) { return; }
|
||||
int index = GetCaretIndexFromScreenPos(PlayerInput.MousePosition);
|
||||
foreach (ClickableArea clickableArea in ClickableAreas)
|
||||
{
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace Barotrauma
|
||||
public GUITextBlock submarineFee;
|
||||
public GUIButton selectSubmarineButton;
|
||||
public GUITextBlock middleTextBlock;
|
||||
public GUIButton previewButton;
|
||||
}
|
||||
|
||||
public SubmarineSelection(bool transfer, Action closeAction, RectTransform parent)
|
||||
@@ -191,6 +192,12 @@ namespace Barotrauma
|
||||
submarineDisplayElement.submarineClass = new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), submarineDisplayElement.background.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, HUDLayoutSettings.Padding + (int)GUI.Font.MeasureString(submarineDisplayElement.submarineName.Text).Y) }, string.Empty, textAlignment: Alignment.Center);
|
||||
submarineDisplayElement.submarineFee = new GUITextBlock(new RectTransform(new Vector2(1f, 0.1f), submarineDisplayElement.background.RectTransform, Anchor.BottomCenter, Pivot.BottomCenter) { AbsoluteOffset = new Point(0, HUDLayoutSettings.Padding) }, string.Empty, textAlignment: Alignment.Center, font: GUI.SubHeadingFont);
|
||||
submarineDisplayElement.selectSubmarineButton = new GUIButton(new RectTransform(Vector2.One, submarineDisplayElement.background.RectTransform), style: null);
|
||||
submarineDisplayElement.previewButton = new GUIButton(new RectTransform(Vector2.One * 0.12f, submarineDisplayElement.background.RectTransform, anchor: Anchor.BottomRight, pivot: Pivot.BottomRight, scaleBasis: ScaleBasis.BothHeight) { AbsoluteOffset = new Point((int)(0.03f * background.Rect.Height)) }, style: "ExpandButton")
|
||||
{
|
||||
Color = Color.White,
|
||||
HoverColor = Color.White,
|
||||
PressedColor = Color.White
|
||||
};
|
||||
submarineDisplays[i] = submarineDisplayElement;
|
||||
}
|
||||
|
||||
@@ -299,6 +306,7 @@ namespace Barotrauma
|
||||
submarineDisplays[i].selectSubmarineButton.OnClicked = null;
|
||||
submarineDisplays[i].displayedSubmarine = null;
|
||||
submarineDisplays[i].middleTextBlock.AutoDraw = false;
|
||||
submarineDisplays[i].previewButton.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -369,6 +377,13 @@ namespace Barotrauma
|
||||
{
|
||||
SelectSubmarine(subToDisplay, submarineDisplays[i].background.Rect);
|
||||
}
|
||||
|
||||
submarineDisplays[i].previewButton.Visible = true;
|
||||
submarineDisplays[i].previewButton.OnClicked = (btn, obj) =>
|
||||
{
|
||||
SubmarinePreview.Create(subToDisplay);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
submarineIndex++;
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Barotrauma
|
||||
contentFrameSize = new Vector2(0.45f, 0.667f);
|
||||
break;
|
||||
}
|
||||
contentFrame = new GUIFrame(new RectTransform(contentFrameSize, infoFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { RelativeOffset = new Vector2(0.025f, 0.12f) });
|
||||
contentFrame = new GUIFrame(new RectTransform(contentFrameSize, infoFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.12f) });
|
||||
|
||||
var horizontalLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.958f, 0.943f), contentFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter) { AbsoluteOffset = new Point(0, GUI.IntScale(25f)) }, isHorizontal: true)
|
||||
{
|
||||
@@ -234,8 +234,6 @@ namespace Barotrauma
|
||||
{
|
||||
var reputationButton = createTabButton(InfoFrameTab.Reputation, "reputation");
|
||||
|
||||
var submarineButton = createTabButton(InfoFrameTab.Submarine, "submarine");
|
||||
|
||||
var balanceFrame = new GUIFrame(new RectTransform(new Point(innerLayoutGroup.Rect.Width, innerLayoutGroup.Rect.Height - infoFrameHolderHeight), parent: innerLayoutGroup.RectTransform), style: "InnerFrame");
|
||||
new GUITextBlock(new RectTransform(Vector2.One, balanceFrame.RectTransform), "", textAlignment: Alignment.Right, parseRichText: true)
|
||||
{
|
||||
@@ -251,6 +249,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var submarineButton = createTabButton(InfoFrameTab.Submarine, "submarine");
|
||||
|
||||
if (GameMain.NetworkMember != null)
|
||||
{
|
||||
var myCharacterButton = createTabButton(InfoFrameTab.MyCharacter, "tabmenu.character");
|
||||
@@ -722,7 +722,7 @@ namespace Barotrauma
|
||||
GUIComponent existingPreview = infoFrameHolder.FindChild("SelectedCharacter");
|
||||
if (existingPreview != null) infoFrameHolder.RemoveChild(existingPreview);
|
||||
|
||||
GUIFrame background = new GUIFrame(new RectTransform(new Vector2(0.543f, 0.717f), infoFrameHolder.RectTransform, Anchor.TopLeft, Pivot.TopRight) { RelativeOffset = new Vector2(-0.061f, 0) })
|
||||
GUIFrame background = new GUIFrame(new RectTransform(new Vector2(0.543f, 0.717f), infoFrameHolder.RectTransform, Anchor.TopLeft, Pivot.TopRight) { RelativeOffset = new Vector2(-0.145f, 0) })
|
||||
{
|
||||
UserData = "SelectedCharacter"
|
||||
};
|
||||
@@ -1106,7 +1106,11 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GameSession?.GameMode is CampaignMode campaign)
|
||||
{
|
||||
var upgradeRootLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.57f), paddedFrame.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft), true);
|
||||
GUILayoutGroup headerLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.09f), paddedFrame.RectTransform) { RelativeOffset = new Vector2(0f, 0.43f) }, isHorizontal: true) { Stretch = true };
|
||||
GUIImage headerIcon = new GUIImage(new RectTransform(Vector2.One, headerLayout.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "SubmarineIcon");
|
||||
new GUITextBlock(new RectTransform(Vector2.One, headerLayout.RectTransform), TextManager.Get("uicategory.upgrades"), font: GUI.LargeFont);
|
||||
|
||||
var upgradeRootLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.48f), paddedFrame.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft), isHorizontal: true);
|
||||
|
||||
var upgradeCategoryPanel = UpgradeStore.CreateUpgradeCategoryList(new RectTransform(new Vector2(0.4f, 1f), upgradeRootLayout.RectTransform));
|
||||
upgradeCategoryPanel.HideChildrenOutsideFrame = true;
|
||||
@@ -1129,6 +1133,11 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var specsListBox = new GUIListBox(new RectTransform(new Vector2(1f, 0.57f), paddedFrame.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft));
|
||||
sub.Info.CreateSpecsWindow(specsListBox, GUI.Font, includeTitle: false, includeClass: false, includeDescription: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,6 +767,10 @@ namespace Barotrauma
|
||||
else if (orderInfo.MatchesOrder(order, option))
|
||||
{
|
||||
icon.UserData = new OrderInfo(order, option, priority);
|
||||
if (icon is GUIImage image)
|
||||
{
|
||||
image.Sprite = GetOrderIconSprite(order, option);
|
||||
}
|
||||
updatedExistingIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace Barotrauma
|
||||
{
|
||||
chatBox.ToggleOpen = wasChatBoxOpen;
|
||||
}
|
||||
if (!value && CampaignUI?.SelectedTab == InteractionType.PurchaseSub)
|
||||
{
|
||||
SubmarinePreview.Close();
|
||||
}
|
||||
showCampaignUI = value;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -533,7 +533,7 @@ namespace Barotrauma
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
Map?.Radiation.UpdateRadiation(deltaTime);
|
||||
Map?.Radiation?.UpdateRadiation(deltaTime);
|
||||
|
||||
if (PlayerInput.SecondaryMouseButtonClicked() ||
|
||||
PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape))
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Barotrauma
|
||||
|
||||
CheckIsInteracting();
|
||||
CheckIfDivingGearOutOfOxygen();
|
||||
CheckAdjacentHulls();
|
||||
CheckHulls();
|
||||
CheckReminders();
|
||||
}
|
||||
|
||||
@@ -503,6 +503,19 @@ namespace Barotrauma
|
||||
DisplayHint("onrepairfailed");
|
||||
}
|
||||
|
||||
public static void OnActiveOrderAdded(Order order)
|
||||
{
|
||||
if (!CanDisplayHints()) { return; }
|
||||
if (order == null) { return; }
|
||||
|
||||
if (order.Identifier == "reportballastflora" &&
|
||||
order.TargetEntity is Hull h &&
|
||||
h.Submarine?.TeamID == Character.Controlled.TeamID)
|
||||
{
|
||||
DisplayHint("onballastflorainfected");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckIfDivingGearOutOfOxygen()
|
||||
{
|
||||
if (!CanDisplayHints()) { return; }
|
||||
@@ -520,10 +533,14 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
private static void CheckAdjacentHulls()
|
||||
private static void CheckHulls()
|
||||
{
|
||||
if (!CanDisplayHints()) { return; }
|
||||
if (Character.Controlled.CurrentHull == null) { return; }
|
||||
if (HumanAIController.IsBallastFloraNoticeable(Character.Controlled, Character.Controlled.CurrentHull))
|
||||
{
|
||||
if (DisplayHint("onballastflorainfected")) { return; }
|
||||
}
|
||||
foreach (var gap in Character.Controlled.CurrentHull.ConnectedGaps)
|
||||
{
|
||||
if (gap.ConnectedDoor == null || gap.ConnectedDoor.Impassable) { continue; }
|
||||
|
||||
@@ -705,6 +705,7 @@ namespace Barotrauma.Items.Components
|
||||
if (c.Params.HideInSonar) { continue; }
|
||||
|
||||
if (!c.IsUnconscious && c.Params.DistantSonarRange > 0.0f &&
|
||||
c.AIController is EnemyAIController enemyAI && enemyAI.IsTargetingPlayer &&
|
||||
((c.WorldPosition - transducerCenter) * displayScale).LengthSquared() > DisplayRadius * DisplayRadius)
|
||||
{
|
||||
float dist = Vector2.Distance(c.WorldPosition, transducerCenter);
|
||||
@@ -1099,6 +1100,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Level.Loaded != null && dockingPort.Item.Submarine.WorldPosition.Y > Level.Loaded.Size.Y) { continue; }
|
||||
if (dockingPort.Item.Submarine == null) { continue; }
|
||||
if (dockingPort.Item.Submarine.Info.IsWreck) { continue; }
|
||||
if (!dockingPort.Item.Submarine.ShowSonarMarker && !dockingPort.Item.Submarine.Info.IsOutpost) { continue; }
|
||||
|
||||
//don't show the docking ports of the opposing team on the sonar
|
||||
if (item.Submarine != null)
|
||||
|
||||
@@ -238,7 +238,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (!PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
if (GameMain.NetworkMember != null || panel.CheckCharacterSuccess(Character.Controlled))
|
||||
if ((GameMain.NetworkMember != null || panel.CheckCharacterSuccess(Character.Controlled)) &&
|
||||
Wires.Count(w => w != null) < MaxPlayerConnectableWires)
|
||||
{
|
||||
//find an empty cell for the new connection
|
||||
int index = FindEmptyIndex();
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace Barotrauma.Items.Components
|
||||
var textBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), layoutGroup.RectTransform), ciElement.Signal, style: "GUITextBoxNoIcon")
|
||||
{
|
||||
OverflowClip = true,
|
||||
UserData = ciElement
|
||||
UserData = ciElement,
|
||||
MaxTextLength = ciElement.MaxTextLength
|
||||
};
|
||||
//reset size restrictions set by the Style to make sure the elements can fit the interface
|
||||
textBox.RectTransform.MinSize = textBox.Frame.RectTransform.MinSize = new Point(0, 0);
|
||||
|
||||
@@ -130,12 +130,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
powerIndicator = new GUIProgressBar(new RectTransform(new Vector2(0.18f, 0.03f), GUI.Canvas, Anchor.TopCenter)
|
||||
powerIndicator = new GUIProgressBar(new RectTransform(new Vector2(0.18f, 0.03f), GUI.Canvas, Anchor.BottomCenter)
|
||||
{
|
||||
MinSize = new Point(100,20),
|
||||
MinSize = new Point(100, 20),
|
||||
RelativeOffset = new Vector2(0.0f, 0.01f)
|
||||
},
|
||||
barSize: 0.0f, style: "DeviceProgressBar");
|
||||
},
|
||||
barSize: 0.0f, style: "DeviceProgressBar")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
@@ -497,9 +500,15 @@ namespace Barotrauma.Items.Components
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
if (!(e is Item linkedItem)) { continue; }
|
||||
availableAmmo.AddRange(linkedItem.ContainedItems);
|
||||
}
|
||||
|
||||
var itemContainer = linkedItem.GetComponent<ItemContainer>();
|
||||
if (itemContainer == null) { continue; }
|
||||
availableAmmo.AddRange(itemContainer.Inventory.AllItems);
|
||||
for (int i = 0; i < itemContainer.Inventory.Capacity - itemContainer.Inventory.AllItems.Count(); i++)
|
||||
{
|
||||
availableAmmo.Add(null);
|
||||
}
|
||||
}
|
||||
|
||||
float chargeRate =
|
||||
powerConsumption <= 0.0f ?
|
||||
1.0f :
|
||||
@@ -534,7 +543,7 @@ namespace Barotrauma.Items.Components
|
||||
int spacing = 5;
|
||||
int slotsPerRow = Math.Min(availableAmmo.Count, 6);
|
||||
int totalWidth = slotSize.X * slotsPerRow + spacing * (slotsPerRow - 1);
|
||||
Point invSlotPos = new Point(GameMain.GraphicsWidth / 2 - totalWidth / 2, (int)(60 * GUI.Scale));
|
||||
Point invSlotPos = new Point(GameMain.GraphicsWidth / 2 - totalWidth / 2, powerIndicator.Rect.Y - (int)(75 * GUI.Scale));
|
||||
for (int i = 0; i < availableAmmo.Count; i++)
|
||||
{
|
||||
// TODO: Optimize? Creates multiple new objects per frame?
|
||||
|
||||
@@ -319,10 +319,10 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return DraggingItems.Any() &&
|
||||
Character.Controlled != null &&
|
||||
return Character.Controlled != null &&
|
||||
Character.Controlled.SelectedConstruction == null &&
|
||||
CharacterHealth.OpenHealthWindow == null;
|
||||
CharacterHealth.OpenHealthWindow == null &&
|
||||
DraggingItems.Any();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -496,8 +496,6 @@ namespace Barotrauma.Lights
|
||||
if ((!LosEnabled || LosMode == LosMode.None) && !ObstructVision) return;
|
||||
if (ViewTarget == null) return;
|
||||
|
||||
if (Character.Controlled == null) { DebugConsole.NewMessage("aaa", Color.Orange); }
|
||||
|
||||
graphics.SetRenderTarget(LosTexture);
|
||||
|
||||
if (ObstructVision)
|
||||
|
||||
@@ -103,13 +103,6 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
#endif
|
||||
public Location CurrentDisplayLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return GameMain.GameSession.Campaign.CurrentDisplayLocation;
|
||||
}
|
||||
}
|
||||
|
||||
partial void InitProjectSpecific()
|
||||
{
|
||||
@@ -263,24 +256,26 @@ namespace Barotrauma
|
||||
{
|
||||
Rectangle rect = mapContainer.Rect;
|
||||
|
||||
if (CurrentDisplayLocation != null)
|
||||
var currentDisplayLocation = GameMain.GameSession?.Campaign?.GetCurrentDisplayLocation();
|
||||
|
||||
if (currentDisplayLocation != null)
|
||||
{
|
||||
if (!CurrentDisplayLocation.Discovered)
|
||||
if (!currentDisplayLocation.Discovered)
|
||||
{
|
||||
RemoveFogOfWar(CurrentDisplayLocation);
|
||||
CurrentDisplayLocation.Discovered = true;
|
||||
if (CurrentDisplayLocation.MapPosition.X > furthestDiscoveredLocation.MapPosition.X)
|
||||
RemoveFogOfWar(currentDisplayLocation);
|
||||
currentDisplayLocation.Discovered = true;
|
||||
if (currentDisplayLocation.MapPosition.X > furthestDiscoveredLocation.MapPosition.X)
|
||||
{
|
||||
furthestDiscoveredLocation = CurrentDisplayLocation;
|
||||
furthestDiscoveredLocation = currentDisplayLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 currentPosition = CurrentDisplayLocation.MapPosition;
|
||||
Vector2 currentPosition = currentDisplayLocation.MapPosition;
|
||||
if (Level.Loaded?.Type == LevelData.LevelType.LocationConnection && Level.Loaded.StartLocation != null && Level.Loaded.EndLocation != null)
|
||||
{
|
||||
Vector2 startPos = CurrentDisplayLocation == Level.Loaded.StartLocation ? Level.Loaded.StartLocation.MapPosition : Level.Loaded.EndLocation.MapPosition;
|
||||
int moveDir = CurrentDisplayLocation == Level.Loaded.StartLocation ? 1 : -1;
|
||||
Vector2 startPos = currentDisplayLocation == Level.Loaded.StartLocation ? Level.Loaded.StartLocation.MapPosition : Level.Loaded.EndLocation.MapPosition;
|
||||
int moveDir = currentDisplayLocation == Level.Loaded.StartLocation ? 1 : -1;
|
||||
|
||||
Vector2 diff = Level.Loaded.EndLocation.MapPosition - Level.Loaded.StartLocation.MapPosition;
|
||||
currentPosition = startPos +
|
||||
@@ -330,14 +325,14 @@ namespace Barotrauma
|
||||
for (int i = 0; i < Locations.Count; i++)
|
||||
{
|
||||
Location location = Locations[i];
|
||||
if (IsInFogOfWar(location) && !(CurrentDisplayLocation?.Connections.Any(c => c.Locations.Contains(location)) ?? false) && !GameMain.DebugDraw) { continue; }
|
||||
if (IsInFogOfWar(location) && !(currentDisplayLocation?.Connections.Any(c => c.Locations.Contains(location)) ?? false) && !GameMain.DebugDraw) { continue; }
|
||||
|
||||
Vector2 pos = rectCenter + (location.MapPosition + viewOffset) * zoom;
|
||||
if (!rect.Contains(pos)) { continue; }
|
||||
|
||||
Sprite locationSprite = location.IsCriticallyRadiated() ? location.Type.RadiationSprite ?? location.Type.Sprite : location.Type.Sprite;
|
||||
float iconScale = generationParams.LocationIconSize / locationSprite.size.X;
|
||||
if (location == CurrentDisplayLocation) { iconScale *= 1.2f; }
|
||||
if (location == currentDisplayLocation) { iconScale *= 1.2f; }
|
||||
|
||||
Rectangle drawRect = locationSprite.SourceRect;
|
||||
drawRect.Width = (int)(drawRect.Width * iconScale * zoom * 1.4f);
|
||||
@@ -383,9 +378,9 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
if (HighlightedLocation != CurrentDisplayLocation &&
|
||||
if (HighlightedLocation != currentDisplayLocation &&
|
||||
connection.Locations.Contains(HighlightedLocation) &&
|
||||
connection.Locations.Contains(CurrentDisplayLocation))
|
||||
connection.Locations.Contains(currentDisplayLocation))
|
||||
{
|
||||
if (PlayerInput.PrimaryMouseButtonClicked() &&
|
||||
SelectedLocation != HighlightedLocation && HighlightedLocation != null)
|
||||
@@ -418,13 +413,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (PlayerInput.DoubleClicked() && HighlightedLocation != null)
|
||||
{
|
||||
var passedConnection = CurrentDisplayLocation.Connections.Find(c => c.OtherLocation(CurrentDisplayLocation) == HighlightedLocation);
|
||||
var passedConnection = currentDisplayLocation.Connections.Find(c => c.OtherLocation(currentDisplayLocation) == HighlightedLocation);
|
||||
if (passedConnection != null)
|
||||
{
|
||||
passedConnection.Passed = true;
|
||||
}
|
||||
|
||||
Location prevLocation = CurrentDisplayLocation;
|
||||
Location prevLocation = currentDisplayLocation;
|
||||
CurrentLocation = HighlightedLocation;
|
||||
Level.Loaded.DebugSetStartLocation(CurrentLocation);
|
||||
Level.Loaded.DebugSetEndLocation(null);
|
||||
@@ -436,7 +431,7 @@ namespace Barotrauma
|
||||
{
|
||||
CurrentLocation.CreateStore();
|
||||
ProgressWorld();
|
||||
Radiation.OnStep(1);
|
||||
Radiation?.OnStep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -461,6 +456,7 @@ namespace Barotrauma
|
||||
public void Draw(SpriteBatch spriteBatch, GUICustomComponent mapContainer)
|
||||
{
|
||||
tooltip = null;
|
||||
var currentDisplayLocation = GameMain.GameSession?.Campaign?.GetCurrentDisplayLocation();
|
||||
|
||||
Rectangle rect = mapContainer.Rect;
|
||||
|
||||
@@ -531,14 +527,14 @@ namespace Barotrauma
|
||||
float rawNoiseScale = 1.0f + PerlinNoise.GetPerlin((int)(Timing.TotalTime * 1 - 1), (int)(Timing.TotalTime * 1 - 1));
|
||||
DrawNoise(spriteBatch, rect, rawNoiseScale);
|
||||
|
||||
Radiation.Draw(spriteBatch, rect, zoom);
|
||||
Radiation?.Draw(spriteBatch, rect, zoom);
|
||||
|
||||
if (generationParams.ShowLocations)
|
||||
{
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
if (IsInFogOfWar(connection.Locations[0]) && IsInFogOfWar(connection.Locations[1])) { continue; }
|
||||
DrawConnection(spriteBatch, connection, rect, viewOffset);
|
||||
DrawConnection(spriteBatch, connection, rect, viewOffset, currentDisplayLocation);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Locations.Count; i++)
|
||||
@@ -557,12 +553,12 @@ namespace Barotrauma
|
||||
|
||||
Color color = location.Type.SpriteColor;
|
||||
if (!location.Discovered) { color = Color.White; }
|
||||
if (location.Connections.Find(c => c.Locations.Contains(CurrentDisplayLocation)) == null)
|
||||
if (location.Connections.Find(c => c.Locations.Contains(currentDisplayLocation)) == null)
|
||||
{
|
||||
color *= 0.5f;
|
||||
}
|
||||
|
||||
float iconScale = location == CurrentDisplayLocation ? 1.2f : 1.0f;
|
||||
float iconScale = location == currentDisplayLocation ? 1.2f : 1.0f;
|
||||
if (location == HighlightedLocation)
|
||||
{
|
||||
iconScale *= 1.2f;
|
||||
@@ -571,7 +567,7 @@ namespace Barotrauma
|
||||
locationSprite.Draw(spriteBatch, pos, color,
|
||||
scale: generationParams.LocationIconSize / locationSprite.size.X * iconScale * zoom);
|
||||
|
||||
if (location == CurrentDisplayLocation)
|
||||
if (location == currentDisplayLocation)
|
||||
{
|
||||
if (SelectedLocation != null)
|
||||
{
|
||||
@@ -701,7 +697,7 @@ namespace Barotrauma
|
||||
|
||||
if (drawRadiationTooltip)
|
||||
{
|
||||
Radiation.DrawFront(spriteBatch);
|
||||
Radiation?.DrawFront(spriteBatch);
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
@@ -736,7 +732,7 @@ namespace Barotrauma
|
||||
|
||||
private static float GetPerlinNoise() => PerlinNoise.GetPerlin((int)(Timing.TotalTime * 1 - 1), (int)(Timing.TotalTime * 1 - 1));
|
||||
|
||||
private void DrawConnection(SpriteBatch spriteBatch, LocationConnection connection, Rectangle viewArea, Vector2 viewOffset, Color? overrideColor = null)
|
||||
private void DrawConnection(SpriteBatch spriteBatch, LocationConnection connection, Rectangle viewArea, Vector2 viewOffset, Location currentDisplayLocation, Color? overrideColor = null)
|
||||
{
|
||||
Color connectionColor;
|
||||
if (GameMain.DebugDraw)
|
||||
@@ -765,15 +761,15 @@ namespace Barotrauma
|
||||
width = (int)(width * 1.5f);
|
||||
}
|
||||
//selected connection
|
||||
if (SelectedLocation != CurrentDisplayLocation &&
|
||||
connection.Locations.Contains(SelectedLocation) && connection.Locations.Contains(CurrentDisplayLocation))
|
||||
if (SelectedLocation != currentDisplayLocation &&
|
||||
connection.Locations.Contains(SelectedLocation) && connection.Locations.Contains(currentDisplayLocation))
|
||||
{
|
||||
connectionColor = generationParams.HighlightedConnectionColor;
|
||||
width *= 2;
|
||||
}
|
||||
//highlighted connection
|
||||
else if (HighlightedLocation != CurrentDisplayLocation &&
|
||||
connection.Locations.Contains(HighlightedLocation) && connection.Locations.Contains(CurrentDisplayLocation))
|
||||
else if (HighlightedLocation != currentDisplayLocation &&
|
||||
connection.Locations.Contains(HighlightedLocation) && connection.Locations.Contains(currentDisplayLocation))
|
||||
{
|
||||
connectionColor = generationParams.HighlightedConnectionColor;
|
||||
width *= 2;
|
||||
@@ -834,7 +830,7 @@ namespace Barotrauma
|
||||
if (connection == SelectedConnection)
|
||||
{
|
||||
float t = (i - startIndex) / (float)(endIndex - startIndex - 1);
|
||||
if (CurrentDisplayLocation == connection.Locations[1]) { t = 1.0f - t; }
|
||||
if (currentDisplayLocation == connection.Locations[1]) { t = 1.0f - t; }
|
||||
if (t > connectionHighlightState)
|
||||
{
|
||||
segmentWidth /= 2;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma
|
||||
{
|
||||
var texture = TextureLoader.FromStream(mem, path: FilePath, compress: false);
|
||||
if (texture == null) { throw new Exception("PreviewImage texture returned null"); }
|
||||
PreviewImage = new Sprite(texture, null, null);
|
||||
PreviewImage = new Sprite(texture, sourceRectangle: null, newOffset: null, path: FilePath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -39,6 +39,7 @@ namespace Barotrauma
|
||||
|
||||
var previewButton = new GUIButton(new RectTransform(new Vector2(1f, 0.5f), content.RectTransform), style: null)
|
||||
{
|
||||
CanBeFocused = SubmarineElement != null,
|
||||
OnClicked = (btn, obj) => { SubmarinePreview.Create(this); return false; },
|
||||
};
|
||||
|
||||
@@ -61,16 +62,19 @@ namespace Barotrauma
|
||||
new GUIFrame(new RectTransform(Vector2.One, submarinePreviewBackground.RectTransform), "InnerGlow", color: Color.Black) { CanBeFocused = false };
|
||||
}
|
||||
|
||||
new GUIFrame(new RectTransform(Vector2.One * 0.12f, previewButton.RectTransform, anchor: Anchor.BottomRight, pivot: Pivot.BottomRight, scaleBasis: ScaleBasis.BothHeight)
|
||||
if (SubmarineElement != null)
|
||||
{
|
||||
AbsoluteOffset = new Point((int)(0.03f * previewButton.Rect.Height))
|
||||
},
|
||||
"ExpandButton", Color.White)
|
||||
{
|
||||
Color = Color.White,
|
||||
HoverColor = Color.White,
|
||||
PressedColor = Color.White
|
||||
};
|
||||
new GUIFrame(new RectTransform(Vector2.One * 0.12f, previewButton.RectTransform, anchor: Anchor.BottomRight, pivot: Pivot.BottomRight, scaleBasis: ScaleBasis.BothHeight)
|
||||
{
|
||||
AbsoluteOffset = new Point((int)(0.03f * previewButton.Rect.Height))
|
||||
},
|
||||
"ExpandButton", Color.White)
|
||||
{
|
||||
Color = Color.White,
|
||||
HoverColor = Color.White,
|
||||
PressedColor = Color.White
|
||||
};
|
||||
}
|
||||
|
||||
var descriptionBox = new GUIListBox(new RectTransform(new Vector2(1, 0.5f), content.RectTransform, Anchor.BottomCenter))
|
||||
{
|
||||
@@ -81,10 +85,10 @@ namespace Barotrauma
|
||||
|
||||
ScalableFont font = parent.Rect.Width < 350 ? GUI.SmallFont : GUI.Font;
|
||||
|
||||
CreateSpecsWindow(descriptionBox, font, includesDescription: true);
|
||||
CreateSpecsWindow(descriptionBox, font, includeDescription: true);
|
||||
}
|
||||
|
||||
public void CreateSpecsWindow(GUIListBox parent, ScalableFont font, bool includeTitle = true, bool includesDescription = false)
|
||||
public void CreateSpecsWindow(GUIListBox parent, ScalableFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
|
||||
{
|
||||
float leftPanelWidth = 0.6f;
|
||||
float rightPanelWidth = 0.4f;
|
||||
@@ -94,15 +98,18 @@ namespace Barotrauma
|
||||
int leftPanelWidthInt = (int)(parent.Rect.Width * leftPanelWidth);
|
||||
|
||||
GUITextBlock submarineNameText = null;
|
||||
GUITextBlock submarineClassText = null;
|
||||
if (includeTitle)
|
||||
{
|
||||
int nameHeight = (int)GUI.LargeFont.MeasureString(DisplayName, true).Y;
|
||||
submarineNameText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, nameHeight + HUDLayoutSettings.Padding / 2), parent.Content.RectTransform), DisplayName, textAlignment: Alignment.CenterLeft, font: GUI.LargeFont) { CanBeFocused = false };
|
||||
submarineNameText.RectTransform.MinSize = new Point(0, (int)submarineNameText.TextSize.Y);
|
||||
}
|
||||
var submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont) { CanBeFocused = false };
|
||||
submarineClassText.RectTransform.MinSize = new Point(0, (int)submarineClassText.TextSize.Y);
|
||||
|
||||
if (includeClass)
|
||||
{
|
||||
submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont) { CanBeFocused = false };
|
||||
submarineClassText.RectTransform.MinSize = new Point(0, (int)submarineClassText.TextSize.Y);
|
||||
}
|
||||
Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;
|
||||
if (realWorldDimensions != Vector2.Zero)
|
||||
{
|
||||
@@ -169,7 +176,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
GUITextBlock descBlock = null;
|
||||
if (includesDescription)
|
||||
if (includeDescription)
|
||||
{
|
||||
//space
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), parent.Content.RectTransform), style: null);
|
||||
|
||||
@@ -60,10 +60,15 @@ namespace Barotrauma
|
||||
|
||||
public static void Create(SubmarineInfo submarineInfo)
|
||||
{
|
||||
instance?.Dispose();
|
||||
Close();
|
||||
instance = new SubmarinePreview(submarineInfo);
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
instance?.Dispose();
|
||||
}
|
||||
|
||||
private SubmarinePreview(SubmarineInfo subInfo)
|
||||
{
|
||||
camera = new Camera();
|
||||
@@ -102,7 +107,7 @@ namespace Barotrauma
|
||||
},
|
||||
(deltaTime, component) => {
|
||||
bool isMouseOnComponent = GUI.MouseOn == component;
|
||||
camera.MoveCamera(deltaTime, allowZoom: isMouseOnComponent);
|
||||
camera.MoveCamera(deltaTime, allowZoom: isMouseOnComponent, followSub: false);
|
||||
if (isMouseOnComponent &&
|
||||
(PlayerInput.MidButtonHeld() || PlayerInput.LeftButtonHeld()))
|
||||
{
|
||||
@@ -136,7 +141,7 @@ namespace Barotrauma
|
||||
ScrollBarVisible = false,
|
||||
Spacing = 5
|
||||
};
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUI.Font, includeTitle: false, includesDescription: true);
|
||||
subInfo.CreateSpecsWindow(specsContainer, GUI.Font, includeTitle: false, includeDescription: true);
|
||||
int width = specsContainer.Rect.Width;
|
||||
void recalculateSpecsContainerHeight()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,14 @@ namespace Barotrauma.Networking
|
||||
|
||||
string senderName = msg.ReadString();
|
||||
Character senderCharacter = null;
|
||||
Client senderClient = null;
|
||||
bool hasSenderClient = msg.ReadBoolean();
|
||||
if (hasSenderClient)
|
||||
{
|
||||
UInt64 clientId = msg.ReadUInt64();
|
||||
senderClient = GameMain.Client.ConnectedClients.Find(c => c.SteamID == clientId || c.ID == clientId);
|
||||
if (senderClient != null) { senderName = senderClient.Name; }
|
||||
}
|
||||
bool hasSenderCharacter = msg.ReadBoolean();
|
||||
if (hasSenderCharacter)
|
||||
{
|
||||
@@ -38,6 +46,7 @@ namespace Barotrauma.Networking
|
||||
senderName = senderCharacter.Name;
|
||||
}
|
||||
}
|
||||
msg.ReadPadBits();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -197,7 +206,7 @@ namespace Barotrauma.Networking
|
||||
GameMain.Client.ServerSettings.ServerLog?.WriteLine(txt, messageType);
|
||||
break;
|
||||
default:
|
||||
GameMain.Client.AddChatMessage(txt, type, senderName, senderCharacter, changeType);
|
||||
GameMain.Client.AddChatMessage(txt, type, senderName, senderClient, senderCharacter, changeType);
|
||||
break;
|
||||
}
|
||||
LastID = id;
|
||||
|
||||
@@ -1805,8 +1805,10 @@ namespace Barotrauma.Networking
|
||||
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.Hash == subHash);
|
||||
if (matchingSub == null)
|
||||
{
|
||||
matchingSub = new SubmarineInfo(Path.Combine(SubmarineInfo.SavePath, subName) + ".sub", subHash, tryLoad: false);
|
||||
matchingSub.SubmarineClass = (SubmarineClass)subClass;
|
||||
matchingSub = new SubmarineInfo(Path.Combine(SubmarineInfo.SavePath, subName) + ".sub", subHash, tryLoad: false)
|
||||
{
|
||||
SubmarineClass = (SubmarineClass)subClass
|
||||
};
|
||||
}
|
||||
matchingSub.RequiredContentPackagesInstalled = requiredContentPackagesInstalled;
|
||||
ServerSubmarines.Add(matchingSub);
|
||||
@@ -3578,6 +3580,10 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
errorLines.Add("Submarine: " + GameMain.GameSession.Submarine.Info.Name);
|
||||
}
|
||||
if (GameMain.NetworkMember?.RespawnManager?.RespawnShuttle != null)
|
||||
{
|
||||
errorLines.Add("Respawn shuttle: " + GameMain.NetworkMember.RespawnManager.RespawnShuttle.Info.Name);
|
||||
}
|
||||
if (Level.Loaded != null)
|
||||
{
|
||||
errorLines.Add("Level: " + Level.Loaded.Seed + ", " + string.Join(", ", Level.Loaded.EqualityCheckValues.Select(cv => cv.ToString("X"))));
|
||||
|
||||
@@ -648,7 +648,14 @@ namespace Barotrauma.Networking
|
||||
|
||||
foreach (ItemPrefab ip in ItemPrefab.Prefabs)
|
||||
{
|
||||
if (!ip.CanBeBought && !ip.Tags.Contains("smallitem")) continue;
|
||||
if (ip.AllowAsExtraCargo.HasValue)
|
||||
{
|
||||
if (!ip.AllowAsExtraCargo.Value) { continue; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ip.CanBeBought) { continue; }
|
||||
}
|
||||
|
||||
var itemFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), cargoFrame.Content.RectTransform) { MinSize = new Point(0, 30) }, isHorizontal: true)
|
||||
{
|
||||
|
||||
@@ -112,14 +112,17 @@ namespace Barotrauma
|
||||
|
||||
switch (voteType)
|
||||
{
|
||||
case VoteType.Sub:
|
||||
SubmarineInfo sub = data as SubmarineInfo;
|
||||
if (sub == null) { return; }
|
||||
case VoteType.Sub:
|
||||
if (!(data is SubmarineInfo sub)) { return; }
|
||||
msg.Write(sub.EqualityCheckVal);
|
||||
if (sub.EqualityCheckVal == 0)
|
||||
{
|
||||
//sub doesn't exist client-side, use hash to let the server know which one we voted for
|
||||
msg.Write(sub.MD5Hash.Hash);
|
||||
}
|
||||
break;
|
||||
case VoteType.Mode:
|
||||
GameModePreset gameMode = data as GameModePreset;
|
||||
if (gameMode == null) { return; }
|
||||
if (!(data is GameModePreset gameMode)) { return; }
|
||||
msg.Write(gameMode.Identifier);
|
||||
break;
|
||||
case VoteType.EndRound:
|
||||
@@ -127,8 +130,7 @@ namespace Barotrauma
|
||||
msg.Write((bool)data);
|
||||
break;
|
||||
case VoteType.Kick:
|
||||
Client votedClient = data as Client;
|
||||
if (votedClient == null) return;
|
||||
if (!(data is Client votedClient)) { return; }
|
||||
|
||||
msg.Write(votedClient.ID);
|
||||
break;
|
||||
|
||||
@@ -173,7 +173,15 @@ namespace Barotrauma
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
bool hasRequiredContentPackages = selectedSub.RequiredContentPackagesInstalled;
|
||||
|
||||
CampaignSettings settings = new CampaignSettings { RadiationEnabled = EnableRadiationToggle?.Selected ?? GameMain.NetLobbyScreen.IsRadiationEnabled() };
|
||||
CampaignSettings settings = new CampaignSettings();
|
||||
if (isMultiplayer)
|
||||
{
|
||||
settings.RadiationEnabled = GameMain.NetLobbyScreen.IsRadiationEnabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.RadiationEnabled = EnableRadiationToggle?.Selected ?? false;
|
||||
}
|
||||
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages)
|
||||
{
|
||||
@@ -257,11 +265,14 @@ namespace Barotrauma
|
||||
|
||||
if (!isMultiplayer)
|
||||
{
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 1f), buttonContainer.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
Selected = true,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 1f), buttonContainer.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
{
|
||||
Selected = true,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
}
|
||||
|
||||
var disclaimerBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.8f), rightColumn.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(5) }, style: "GUINotificationButton")
|
||||
{
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Barotrauma
|
||||
{
|
||||
var map = GameMain.GameSession?.Map;
|
||||
if (map == null) { return; }
|
||||
if (selectedLocation != null && selectedLocation == map.CurrentDisplayLocation)
|
||||
if (selectedLocation != null && selectedLocation == GameMain.GameSession.Campaign.GetCurrentDisplayLocation())
|
||||
{
|
||||
map.SelectLocation(-1);
|
||||
}
|
||||
@@ -438,7 +438,7 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
SelectedLevel = connection?.LevelData;
|
||||
Location currentDisplayLocation = Campaign.CurrentDisplayLocation;
|
||||
Location currentDisplayLocation = Campaign.GetCurrentDisplayLocation();
|
||||
if (connection != null && connection.Locations.Contains(currentDisplayLocation))
|
||||
{
|
||||
List<Mission> availableMissions = currentDisplayLocation.GetMissionsInConnection(connection).ToList();
|
||||
|
||||
+1
-1
@@ -711,7 +711,7 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
// Camera
|
||||
Cam.MoveCamera((float)deltaTime, allowMove: false);
|
||||
Cam.MoveCamera((float)deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null);
|
||||
Vector2 targetPos = character.WorldPosition;
|
||||
if (PlayerInput.MidButtonHeld())
|
||||
{
|
||||
|
||||
@@ -953,7 +953,7 @@ namespace Barotrauma
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
Cam.MoveCamera((float) deltaTime, true, true);
|
||||
Cam.MoveCamera((float) deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
Vector2 mousePos = Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
mousePos.Y = -mousePos.Y;
|
||||
|
||||
|
||||
@@ -843,7 +843,7 @@ namespace Barotrauma
|
||||
pointerLightSource.Position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pointerLightSource.Enabled = cursorLightEnabled.Selected;
|
||||
pointerLightSource.IsBackground = true;
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null);
|
||||
cam.UpdateTransform();
|
||||
Level.Loaded?.Update((float)deltaTime, cam);
|
||||
|
||||
|
||||
@@ -1173,7 +1173,10 @@ namespace Barotrauma
|
||||
(int)(campaignSetupUI.StartButton.TextBlock.TextSize.X * 1.5f),
|
||||
campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
startButtonContainer.RectTransform.MinSize = new Point(0, campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
campaignSetupUI.EnableRadiationToggle.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
if (campaignSetupUI.EnableRadiationToggle != null)
|
||||
{
|
||||
campaignSetupUI.EnableRadiationToggle.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
campaignSetupUI.InitialMoneyText.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
|
||||
|
||||
@@ -485,6 +485,7 @@ namespace Barotrauma
|
||||
if (socialHolder != null) { socialHolder.Visible = false; }
|
||||
if (!(serverLogHolder?.Visible ?? true))
|
||||
{
|
||||
if (GameMain.Client?.ServerSettings?.ServerLog == null) { return false; }
|
||||
serverLogHolder.Visible = true;
|
||||
GameMain.Client.ServerSettings.ServerLog.AssignLogFrame(serverLogReverseButton, serverLogBox, serverLogFilterTicks.Content, serverLogFilter);
|
||||
}
|
||||
@@ -1134,15 +1135,19 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
radiationEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
Selected = true,
|
||||
OnSelected = box =>
|
||||
radiationEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, radiationEnabled: box.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Selected = true,
|
||||
OnSelected = box =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, radiationEnabled: box.Selected);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
List<GUIComponent> settingsElements = settingsContent.Children.ToList();
|
||||
for (int i = 0; i < settingsElements.Count; i++)
|
||||
@@ -1292,7 +1297,10 @@ namespace Barotrauma
|
||||
}
|
||||
SeedBox.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
levelDifficultyScrollBar.Enabled = !CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
radiationEnabledTickBox.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
if (radiationEnabledTickBox != null)
|
||||
{
|
||||
radiationEnabledTickBox.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
}
|
||||
traitorProbabilityButtons[0].Enabled = traitorProbabilityButtons[1].Enabled = traitorProbabilityText.Enabled =
|
||||
!CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
botCountButtons[0].Enabled = botCountButtons[1].Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
@@ -2611,6 +2619,18 @@ namespace Barotrauma
|
||||
UserData = message,
|
||||
CanBeFocused = false
|
||||
};
|
||||
msg.CalculateHeightFromText();
|
||||
if (msg.RichTextData != null)
|
||||
{
|
||||
foreach (var data in msg.RichTextData)
|
||||
{
|
||||
msg.ClickableAreas.Add(new GUITextBlock.ClickableArea()
|
||||
{
|
||||
Data = data,
|
||||
OnClick = GameMain.NetLobbyScreen.SelectPlayer
|
||||
});
|
||||
}
|
||||
}
|
||||
msg.RectTransform.SizeChanged += Recalculate;
|
||||
void Recalculate()
|
||||
{
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Barotrauma
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
cam.MoveCamera((float)deltaTime, true);
|
||||
cam.MoveCamera((float)deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
|
||||
if (selectedPrefab != null)
|
||||
{
|
||||
|
||||
@@ -4291,7 +4291,7 @@ namespace Barotrauma
|
||||
|
||||
if (PlayerInput.IsCtrlDown() && MapEntity.StartMovingPos == Vector2.Zero)
|
||||
{
|
||||
cam.MoveCamera((float) deltaTime, allowMove: false);
|
||||
cam.MoveCamera((float) deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null);
|
||||
// Save menu
|
||||
if (PlayerInput.KeyHit(Keys.S))
|
||||
{
|
||||
@@ -4330,12 +4330,12 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
cam.MoveCamera((float) deltaTime, allowMove: true);
|
||||
cam.MoveCamera((float) deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cam.MoveCamera((float) deltaTime, allowMove: false);
|
||||
cam.MoveCamera((float) deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null);
|
||||
}
|
||||
|
||||
if (PlayerInput.MidButtonHeld())
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Barotrauma.Sounds
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! " + Al.GetErrorString(alError));
|
||||
throw new Exception("Failed to set regular buffer data for non-streamed audio! " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
MuffleBuffer(floatBuffer, SampleRate, reader.Channels);
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma.Sounds
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! " + Al.GetErrorString(alError));
|
||||
throw new Exception("Failed to set muffled buffer data for non-streamed audio! " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
reader.Dispose(); reader = null;
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
bufferPool.ForEach(b => Al.DeleteBuffer(b));
|
||||
bufferPool.Clear();
|
||||
BuffersGenerated = 0;
|
||||
}
|
||||
|
||||
public bool RequestAlBuffers()
|
||||
@@ -81,10 +82,37 @@ namespace Barotrauma.Sounds
|
||||
if (otherSound.IsPlaying()) { continue; }
|
||||
if (otherSound.Buffers == null) { continue; }
|
||||
if (otherSound.Buffers.AlBuffer == 0) { continue; }
|
||||
|
||||
// Dispose all channels that are holding
|
||||
// a reference to these buffers, otherwise
|
||||
// an INVALID_OPERATION error will be thrown
|
||||
// when attempting to set the buffer data later.
|
||||
// Having the sources not play is not enough,
|
||||
// as OpenAL assumes that you may want to call
|
||||
// alSourcePlay without reassigning the buffer.
|
||||
otherSound.Owner.KillChannels(otherSound);
|
||||
|
||||
AlBuffer = otherSound.Buffers.AlBuffer;
|
||||
AlMuffledBuffer = otherSound.Buffers.AlMuffledBuffer;
|
||||
otherSound.Buffers.AlBuffer = 0;
|
||||
otherSound.Buffers.AlMuffledBuffer = 0;
|
||||
|
||||
// For performance reasons, sift the current sound to
|
||||
// the end of the loadedSounds list, that way it'll
|
||||
// be less likely to have its buffers stolen, which
|
||||
// means less reuploads for frequently played sounds.
|
||||
sound.Owner.MoveSoundToPosition(sound, sound.Owner.LoadedSoundCount-1);
|
||||
|
||||
if (!Al.IsBuffer(AlBuffer))
|
||||
{
|
||||
throw new Exception(sound.Filename + " has an invalid buffer!");
|
||||
}
|
||||
if (!Al.IsBuffer(AlMuffledBuffer))
|
||||
{
|
||||
throw new Exception(sound.Filename + " has an invalid muffled buffer!");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -491,8 +491,10 @@ namespace Barotrauma.Sounds
|
||||
mutex = new object();
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if (mutex != null) { Monitor.Enter(mutex); }
|
||||
if (sound.Owner.CountPlayingInstances(sound) < sound.MaxSimultaneousInstances)
|
||||
{
|
||||
@@ -515,15 +517,6 @@ namespace Barotrauma.Sounds
|
||||
Sound.FillBuffers();
|
||||
}
|
||||
|
||||
if (!Al.IsBuffer(sound.Buffers.AlBuffer))
|
||||
{
|
||||
throw new Exception(sound.Filename + " has an invalid buffer!");
|
||||
}
|
||||
if (!Al.IsBuffer(sound.Buffers.AlMuffledBuffer))
|
||||
{
|
||||
throw new Exception(sound.Filename + " has an invalid muffled buffer!");
|
||||
}
|
||||
|
||||
uint alBuffer = sound.Owner.GetCategoryMuffle(category) || muffled ? Sound.Buffers.AlMuffledBuffer : Sound.Buffers.AlBuffer;
|
||||
Al.Sourcei(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Buffer, (int)alBuffer);
|
||||
alError = Al.GetError();
|
||||
@@ -587,6 +580,7 @@ namespace Barotrauma.Sounds
|
||||
this.Near = near;
|
||||
this.Far = far;
|
||||
this.Category = category;
|
||||
#if !DEBUG
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -594,8 +588,11 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
finally
|
||||
{
|
||||
#endif
|
||||
if (mutex != null) { Monitor.Exit(mutex); }
|
||||
#if !DEBUG
|
||||
}
|
||||
#endif
|
||||
|
||||
Sound.Owner.Update();
|
||||
}
|
||||
|
||||
@@ -514,6 +514,18 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveSoundToPosition(Sound sound, int pos)
|
||||
{
|
||||
lock (loadedSounds)
|
||||
{
|
||||
int index = loadedSounds.IndexOf(sound);
|
||||
if (index >= 0)
|
||||
{
|
||||
loadedSounds.SiftElement(index, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCategoryGainMultiplier(string category, float gain, int index=0)
|
||||
{
|
||||
if (Disabled) { return; }
|
||||
|
||||
@@ -29,7 +29,16 @@ namespace Barotrauma
|
||||
get { return texture != null && !cannotBeLoaded; }
|
||||
}
|
||||
|
||||
public Sprite(Texture2D texture, Rectangle? sourceRectangle, Vector2? newOffset, float newRotation = 0.0f)
|
||||
public Sprite(Sprite other) : this(other.texture, other.sourceRect, other.offset, other.rotation)
|
||||
{
|
||||
FilePath = other.FilePath;
|
||||
FullPath = other.FullPath;
|
||||
Compress = other.Compress;
|
||||
size = other.size;
|
||||
effects = other.effects;
|
||||
}
|
||||
|
||||
public Sprite(Texture2D texture, Rectangle? sourceRectangle, Vector2? newOffset, float newRotation = 0.0f, string path = null)
|
||||
{
|
||||
this.texture = texture;
|
||||
|
||||
@@ -45,6 +54,8 @@ namespace Barotrauma
|
||||
|
||||
rotation = newRotation;
|
||||
|
||||
FilePath = path;
|
||||
|
||||
AddToList(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user