Build 0.17.14.0

This commit is contained in:
Markus Isberg
2022-04-27 07:44:37 +09:00
parent 7a09cf3260
commit 6e38444fc4
47 changed files with 560 additions and 280 deletions
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using PlayerBalanceElement = Barotrauma.CampaignUI.PlayerBalanceElement;
namespace Barotrauma
{
@@ -21,6 +22,8 @@ namespace Barotrauma
private GUIButton validateHiresButton;
private GUIButton clearAllButton;
private PlayerBalanceElement? playerBalanceElement;
private List<CharacterInfo> PendingHires => campaign.Map?.CurrentLocation?.HireManager?.PendingHires;
private bool HasPermission => campaignUI.Campaign.AllowedToManageCampaign(ClientPermissions.ManageHires);
@@ -157,23 +160,7 @@ namespace Barotrauma
RelativeSpacing = 0.02f
};
var playerBalanceContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.75f / 14.0f), pendingAndCrewMainGroup.RectTransform), childAnchor: Anchor.TopRight)
{
RelativeSpacing = 0.005f
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), playerBalanceContainer.RectTransform),
TextManager.Get("campaignstore.balance"), font: GUIStyle.Font, textAlignment: Alignment.BottomRight)
{
AutoScaleVertical = true,
ForceUpperCase = ForceUpperCase.Yes
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), playerBalanceContainer.RectTransform),
"", font: GUIStyle.SubHeadingFont, textAlignment: Alignment.TopRight)
{
AutoScaleVertical = true,
TextScale = 1.1f,
TextGetter = () => TextManager.FormatCurrency(campaign.GetBalance())
};
playerBalanceElement = CampaignUI.AddBalanceElement(pendingAndCrewMainGroup, new Vector2(1.0f, 0.75f / 14.0f));
var pendingAndCrewGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), anchor: Anchor.Center,
parent: new GUIFrame(new RectTransform(new Vector2(1.0f, 13.25f / 14.0f), pendingAndCrewMainGroup.RectTransform)
@@ -792,6 +779,10 @@ namespace Barotrauma
CreateUI();
UpdateLocationView(campaign.Map.CurrentLocation, false);
}
else
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
}
(GUIComponent highlightedFrame, CharacterInfo highlightedInfo) = FindHighlightedCharacter(GUI.MouseOn);
if (highlightedFrame != null && highlightedInfo != null)
@@ -567,9 +567,9 @@ namespace Barotrauma
GameMain.GameSession?.EventManager?.DrawPinnedEvent(spriteBatch);
if (HUDLayoutSettings.DebugDraw) HUDLayoutSettings.Draw(spriteBatch);
if (HUDLayoutSettings.DebugDraw) { HUDLayoutSettings.Draw(spriteBatch); }
if (GameMain.Client != null) GameMain.Client.Draw(spriteBatch);
GameMain.Client?.Draw(spriteBatch);
if (Character.Controlled?.Inventory != null)
{
@@ -616,28 +616,46 @@ namespace Barotrauma
}
DrawSavingIndicator(spriteBatch);
if (GameMain.WindowActive && !HideCursor)
{
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerStateClamp, rasterizerState: GameMain.ScissorTestEnable);
if (GameMain.GameSession?.CrewManager is { DraggedOrderPrefab: { SymbolSprite: { } orderSprite, Color: var color }, DragOrder: true })
{
float spriteSize = Math.Max(orderSprite.size.X, orderSprite.size.Y);
orderSprite.Draw(spriteBatch, PlayerInput.LatestMousePosition, color, orderSprite.size / 2f, scale: 32f / spriteSize * Scale);
}
var sprite = MouseCursorSprites[MouseCursor] ?? MouseCursorSprites[CursorState.Default];
sprite.Draw(spriteBatch, PlayerInput.LatestMousePosition, Color.White, sprite.Origin, 0f, Scale / 1.5f);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
DrawCursor(spriteBatch);
HideCursor = false;
}
}
public static void DrawMessageBoxesOnly(SpriteBatch spriteBatch)
{
bool anyDrawn = false;
foreach (var component in updateList)
{
component.DrawAuto(spriteBatch);
anyDrawn = true;
}
if (anyDrawn)
{
DrawCursor(spriteBatch);
}
}
private static void DrawCursor(SpriteBatch spriteBatch)
{
if (GameMain.WindowActive && !HideCursor && MouseCursorSprites.Prefabs.Any())
{
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerStateClamp, rasterizerState: GameMain.ScissorTestEnable);
if (GameMain.GameSession?.CrewManager is { DraggedOrderPrefab: { SymbolSprite: { } orderSprite, Color: var color }, DragOrder: true })
{
float spriteSize = Math.Max(orderSprite.size.X, orderSprite.size.Y);
orderSprite.Draw(spriteBatch, PlayerInput.LatestMousePosition, color, orderSprite.size / 2f, scale: 32f / spriteSize * Scale);
}
var sprite = MouseCursorSprites[MouseCursor] ?? MouseCursorSprites[CursorState.Default];
sprite.Draw(spriteBatch, PlayerInput.LatestMousePosition, Color.White, sprite.Origin, 0f, Scale / 1.5f);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: SamplerState, rasterizerState: GameMain.ScissorTestEnable);
}
}
public static void DrawBackgroundSprite(SpriteBatch spriteBatch, Sprite backgroundSprite, float aberrationStrength = 1.0f)
{
double aberrationT = (Timing.TotalTime * 0.5f);
@@ -1204,6 +1222,17 @@ namespace Barotrauma
}
}
public static void UpdateGUIMessageBoxesOnly(float deltaTime)
{
GUIMessageBox.AddActiveToGUIUpdateList();
RefreshUpdateList();
UpdateMouseOn();
foreach (var c in updateList)
{
c.UpdateAuto(deltaTime);
}
}
private static void UpdateMessages(float deltaTime)
{
lock (mutex)
@@ -36,6 +36,8 @@ namespace Barotrauma
public string Tag { get; private set; }
public bool Closed { get; private set; }
public bool DisplayInLoadingScreens;
public GUIImage Icon
{
get;
@@ -451,6 +453,10 @@ namespace Barotrauma
continue;
}
if (messageBox.type != type) { continue; }
if (!messageBox.DisplayInLoadingScreens && GameMain.Instance.LoadingScreenOpen)
{
continue;
}
// These are handled separately in GUI.HandlePersistingElements()
if (MessageBoxes[i].UserData as string == "verificationprompt") { continue; }
@@ -1,13 +1,11 @@
using Microsoft.Xna.Framework;
using Barotrauma.Extensions;
using Barotrauma.Media;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Barotrauma.Media;
using System.Linq;
using Barotrauma.Extensions;
using System.Collections.Immutable;
namespace Barotrauma
{
@@ -16,7 +14,7 @@ namespace Barotrauma
private readonly Texture2D defaultBackgroundTexture, overlay;
private readonly SpriteSheet decorativeGraph, decorativeMap;
private Texture2D currentBackgroundTexture;
private Sprite noiseSprite;
private readonly Sprite noiseSprite;
private string randText = "";
@@ -250,8 +248,8 @@ namespace Barotrauma
}
}
}
}
GUI.DrawMessageBoxesOnly(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(blendState: BlendState.Additive);
@@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
using PlayerBalanceElement = Barotrauma.CampaignUI.PlayerBalanceElement;
namespace Barotrauma
{
@@ -180,6 +181,8 @@ namespace Barotrauma
private const float refreshTimerMax = 3f;
private float refreshTimer = 0;
private PlayerBalanceElement? playerBalanceElement;
public MedicalClinicUI(MedicalClinic clinic, GUIComponent parent)
{
medicalClinic = clinic;
@@ -428,6 +431,7 @@ namespace Barotrauma
{
container.ClearChildren();
pendingHealList = null;
playerBalanceElement = null;
int panelMaxWidth = (int)(GUI.xScale * (GUI.HorizontalAspectRatio < 1.4f ? 650 : 560));
GUIFrame paddedParent = new GUIFrame(new RectTransform(new Vector2(0.95f), container.RectTransform, Anchor.Center), style: null);
@@ -458,19 +462,7 @@ namespace Barotrauma
RelativeSpacing = 0.01f
};
GUILayoutGroup balanceLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.1f), crewContent.RectTransform));
GUITextBlock balanceLabel = new GUITextBlock(new RectTransform(new Vector2(1f, 0.5f), balanceLayout.RectTransform), TextManager.Get("campaignstore.balance"), textAlignment: Alignment.BottomRight, font: GUIStyle.Font)
{
AutoScaleVertical = true,
ForceUpperCase = ForceUpperCase.Yes
};
GUITextBlock moneyLabel = new GUITextBlock(new RectTransform(new Vector2(1f, 0.5f), balanceLayout.RectTransform), string.Empty, textAlignment: Alignment.TopRight, font: GUIStyle.SubHeadingFont)
{
TextGetter = () => TextManager.FormatCurrency(medicalClinic.GetBalance()),
AutoScaleVertical = true,
TextScale = 1.1f
};
playerBalanceElement = CampaignUI.AddBalanceElement(crewContent, new Vector2(1f, 0.1f));
GUIFrame crewBackground = new GUIFrame(new RectTransform(Vector2.One, crewContent.RectTransform));
@@ -1050,6 +1042,10 @@ namespace Barotrauma
{
CreateUI();
}
else
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
}
refreshTimer += deltaTime;
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using PlayerBalanceElement = Barotrauma.CampaignUI.PlayerBalanceElement;
namespace Barotrauma
{
@@ -66,6 +67,8 @@ namespace Barotrauma
private Point resolutionWhenCreated;
private PlayerBalanceElement? playerBalanceElement;
private Dictionary<ItemPrefab, ItemQuantity> OwnedItems { get; } = new Dictionary<ItemPrefab, ItemQuantity>();
private Location.StoreInfo ActiveStore { get; set; }
@@ -647,23 +650,7 @@ namespace Barotrauma
};
// Player balance ------------------------------------------------
var playerBalanceContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.75f / 14.0f), shoppingCrateContent.RectTransform), childAnchor: Anchor.TopRight)
{
RelativeSpacing = 0.005f
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), playerBalanceContainer.RectTransform),
TextManager.Get("campaignstore.balance"), font: GUIStyle.Font, textAlignment: Alignment.BottomRight)
{
AutoScaleVertical = true,
ForceUpperCase = ForceUpperCase.Yes
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), playerBalanceContainer.RectTransform),
"", textColor: Color.White, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.TopRight)
{
AutoScaleVertical = true,
TextScale = 1.1f,
TextGetter = GetPlayerBalanceText
};
playerBalanceElement = CampaignUI.AddBalanceElement(shoppingCrateContent, new Vector2(1.0f, 0.75f / 14.0f));
// Divider ------------------------------------------------
var dividerFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.6f / 14.0f), shoppingCrateContent.RectTransform), style: null);
@@ -695,7 +682,7 @@ namespace Barotrauma
{
CanBeFocused = false,
TextScale = 1.1f,
TextGetter = () => IsBuying ? GetPlayerBalanceText() : GetMerchantBalanceText()
TextGetter = () => IsBuying ? CampaignUI.GetTotalBalance() : GetMerchantBalanceText()
};
var totalContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), shoppingCrateInventoryContainer.RectTransform), isHorizontal: true)
@@ -744,8 +731,6 @@ namespace Barotrauma
private LocalizedString GetMerchantBalanceText() => TextManager.FormatCurrency(ActiveStore?.Balance ?? 0);
private LocalizedString GetPlayerBalanceText() => TextManager.FormatCurrency(Balance);
private GUILayoutGroup CreateDealsGroup(GUIListBox parentList, int elementCount)
{
// Add 1 for the header
@@ -2183,6 +2168,7 @@ namespace Barotrauma
ActiveShoppingCrateList.Content.RectTransform.Children.Any();
}
private int prevBalance;
private float ownedItemsUpdateTimer = 0.0f, sellableItemsFromSubUpdateTimer = 0.0f;
private const float timerUpdateInterval = 1.5f;
private readonly Stopwatch updateStopwatch = new Stopwatch();
@@ -2198,6 +2184,8 @@ namespace Barotrauma
}
else
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
// Update the owned items at short intervals and check if the interface should be refreshed
ownedItemsUpdateTimer += deltaTime;
if (ownedItemsUpdateTimer >= timerUpdateInterval)
@@ -2234,6 +2222,16 @@ namespace Barotrauma
}
}
}
// Refresh the interface if balance changes and the buy tab is open
if (activeTab == StoreTab.Buy)
{
int currBalance = Balance;
if (prevBalance != currBalance)
{
needsBuyingRefresh = true;
prevBalance = currBalance;
}
}
if (needsItemsToSellRefresh)
{
RefreshItemsToSell();
@@ -5,6 +5,7 @@ using System.Linq;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Globalization;
using PlayerBalanceElement = Barotrauma.CampaignUI.PlayerBalanceElement;
namespace Barotrauma
{
@@ -45,6 +46,8 @@ namespace Barotrauma
private static readonly Color indicatorColor = new Color(112, 149, 129);
private Point createdForResolution;
private PlayerBalanceElement? playerBalanceElement;
private struct SubmarineDisplayContent
{
public GUIFrame background;
@@ -125,10 +128,7 @@ namespace Barotrauma
content = new GUILayoutGroup(new RectTransform(new Point(background.Rect.Width - HUDLayoutSettings.Padding * 4, background.Rect.Height - HUDLayoutSettings.Padding * 4), background.RectTransform, Anchor.Center)) { AbsoluteSpacing = (int)(HUDLayoutSettings.Padding * 1.5f) };
GUITextBlock header = new GUITextBlock(new RectTransform(new Vector2(1f, 0.0f), content.RectTransform), transferService ? TextManager.Get("switchsubmarineheader") : TextManager.GetWithVariable("outpostshipyard", "[location]", GameMain.GameSession.Map.CurrentLocation.Name), font: GUIStyle.LargeFont);
header.CalculateHeightFromText(0, true);
GUITextBlock credits = new GUITextBlock(new RectTransform(Vector2.One, header.RectTransform), "", font: GUIStyle.SubHeadingFont, textAlignment: Alignment.CenterRight)
{
TextGetter = CampaignUI.GetMoney
};
playerBalanceElement = CampaignUI.AddBalanceElement(header, new Vector2(1.0f, 1.5f));
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), content.RectTransform), style: "HorizontalLine");
@@ -256,6 +256,10 @@ namespace Barotrauma
{
RefreshSubmarineDisplay(true);
}
else
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
}
// Input
if (PlayerInput.KeyHit(Keys.Left))
@@ -270,9 +274,22 @@ namespace Barotrauma
public void RefreshSubmarineDisplay(bool updateSubs)
{
if (!initialized) Initialize();
if (GameMain.GraphicsWidth != createdForResolution.X || GameMain.GraphicsHeight != createdForResolution.Y) CreateGUI();
if (updateSubs) UpdateSubmarines();
if (!initialized)
{
Initialize();
}
if (GameMain.GraphicsWidth != createdForResolution.X || GameMain.GraphicsHeight != createdForResolution.Y)
{
CreateGUI();
}
else
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
}
if (updateSubs)
{
UpdateSubmarines();
}
if (pageIndicators != null)
{
@@ -11,6 +11,7 @@ using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using PlayerBalanceElement = Barotrauma.CampaignUI.PlayerBalanceElement;
// ReSharper disable UnusedVariable
@@ -75,6 +76,8 @@ namespace Barotrauma
private bool needsRefresh = true;
private PlayerBalanceElement? playerBalanceElement;
/// <summary>
/// While set to true any call to <see cref="RefreshUpgradeList"/> will cause the buy button to be disabled and to not update the prices.
/// This is to prevent us from buying another upgrade before the server has given us the new prices and causing potential syncing issues.
@@ -293,9 +296,14 @@ namespace Barotrauma
* |---------------------------------------------------------------------------------------------------|
*/
GUILayoutGroup rightLayout = new GUILayoutGroup(rectT(0.5f, 1, topHeaderLayout), childAnchor: Anchor.TopRight);
GUILayoutGroup priceLayout = new GUILayoutGroup(rectT(1, 0.8f, rightLayout), childAnchor: Anchor.Center) { RelativeSpacing = 0.08f };
new GUITextBlock(rectT(1f, 0f, priceLayout), TextManager.Get("CampaignStore.Balance"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Right);
new GUITextBlock(rectT(1f, 0f, priceLayout), TextManager.FormatCurrency(PlayerBalance), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Right) { TextGetter = () => TextManager.FormatCurrency(PlayerBalance) };
playerBalanceElement = CampaignUI.AddBalanceElement(rightLayout, new Vector2(1.0f, 0.8f));
if (playerBalanceElement is { } balanceElement)
{
balanceElement.TotalBalanceContainer.OnAddedToGUIUpdateList += (_) =>
{
playerBalanceElement = CampaignUI.UpdateBalanceElement(playerBalanceElement);
};
}
new GUIFrame(rectT(0.5f, 0.1f, rightLayout, Anchor.BottomRight), style: "HorizontalLine") { IgnoreLayoutGroups = true };
repairButton.OnClicked = upgradeButton.OnClicked = (button, o) =>