Build 0.17.13.0
This commit is contained in:
@@ -172,7 +172,7 @@ namespace Barotrauma
|
||||
{
|
||||
AutoScaleVertical = true,
|
||||
TextScale = 1.1f,
|
||||
TextGetter = () => TextManager.FormatCurrency(campaign.Wallet.Balance)
|
||||
TextGetter = () => TextManager.FormatCurrency(campaign.GetBalance())
|
||||
};
|
||||
|
||||
var pendingAndCrewGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), anchor: Anchor.Center,
|
||||
@@ -344,7 +344,7 @@ namespace Barotrauma
|
||||
Color? jobColor = null;
|
||||
if (characterInfo.Job != null)
|
||||
{
|
||||
skill = characterInfo.Job?.PrimarySkill ?? characterInfo.Job.Skills.OrderByDescending(s => s.Level).FirstOrDefault();
|
||||
skill = characterInfo.Job?.PrimarySkill ?? characterInfo.Job.GetSkills().OrderByDescending(s => s.Level).FirstOrDefault();
|
||||
jobColor = characterInfo.Job.Prefab.UIColor;
|
||||
}
|
||||
|
||||
@@ -547,8 +547,8 @@ namespace Barotrauma
|
||||
GUILayoutGroup skillGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.475f), mainGroup.RectTransform), isHorizontal: true);
|
||||
GUILayoutGroup skillNameGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 1.0f), skillGroup.RectTransform));
|
||||
GUILayoutGroup skillLevelGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.2f, 1.0f), skillGroup.RectTransform));
|
||||
List<Skill> characterSkills = characterInfo.Job.Skills;
|
||||
blockHeight = 1.0f / characterSkills.Count;
|
||||
var characterSkills = characterInfo.Job.GetSkills();
|
||||
blockHeight = 1.0f / characterSkills.Count();
|
||||
foreach (Skill skill in characterSkills)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, blockHeight), skillNameGroup.RectTransform), TextManager.Get("SkillName." + skill.Identifier));
|
||||
@@ -630,7 +630,7 @@ namespace Barotrauma
|
||||
total += ((InfoSkill)c.UserData).CharacterInfo.Salary;
|
||||
});
|
||||
totalBlock.Text = TextManager.FormatCurrency(total);
|
||||
bool enoughMoney = campaign == null || campaign.Wallet.CanAfford(total);
|
||||
bool enoughMoney = campaign == null || campaign.CanAfford(total);
|
||||
totalBlock.TextColor = enoughMoney ? Color.White : Color.Red;
|
||||
validateHiresButton.Enabled = enoughMoney && HasPermission && pendingList.Content.RectTransform.Children.Any();
|
||||
}
|
||||
@@ -652,7 +652,7 @@ namespace Barotrauma
|
||||
|
||||
int total = nonDuplicateHires.Aggregate(0, (total, info) => total + info.Salary);
|
||||
|
||||
if (!campaign.Wallet.CanAfford(total)) { return false; }
|
||||
if (!campaign.CanAfford(total)) { return false; }
|
||||
|
||||
bool atLeastOneHired = false;
|
||||
foreach (CharacterInfo ci in nonDuplicateHires)
|
||||
|
||||
@@ -395,14 +395,13 @@ namespace Barotrauma
|
||||
origin = TextSize * 0.5f;
|
||||
|
||||
origin.X = 0;
|
||||
if (textAlignment.HasFlag(Alignment.Left) && !overflowClipActive)
|
||||
if (textAlignment.HasFlag(Alignment.Left))
|
||||
{
|
||||
textPos.X = padding.X;
|
||||
}
|
||||
if (textAlignment.HasFlag(Alignment.Right) || overflowClipActive)
|
||||
if (textAlignment.HasFlag(Alignment.Right))
|
||||
{
|
||||
textPos.X = rect.Width - padding.Z;
|
||||
//origin.X = TextSize.X;
|
||||
}
|
||||
if (textAlignment.HasFlag(Alignment.Top))
|
||||
{
|
||||
|
||||
@@ -443,24 +443,7 @@ namespace Barotrauma
|
||||
|
||||
if (CaretEnabled)
|
||||
{
|
||||
if (textBlock.OverflowClipActive)
|
||||
{
|
||||
float left = textBlock.Rect.X + textBlock.Padding.X;
|
||||
if (CaretScreenPos.X < left)
|
||||
{
|
||||
float diff = left - CaretScreenPos.X;
|
||||
textBlock.TextPos = new Vector2(textBlock.TextPos.X + diff, textBlock.TextPos.Y);
|
||||
CalculateCaretPos();
|
||||
}
|
||||
|
||||
float right = textBlock.Rect.Right - textBlock.Padding.Z;
|
||||
if (CaretScreenPos.X > right)
|
||||
{
|
||||
float diff = CaretScreenPos.X - right;
|
||||
textBlock.TextPos = new Vector2(textBlock.TextPos.X - diff, textBlock.TextPos.Y);
|
||||
CalculateCaretPos();
|
||||
}
|
||||
}
|
||||
HandleCaretBoundsOverflow();
|
||||
caretTimer += deltaTime;
|
||||
caretVisible = ((caretTimer * 1000.0f) % 1000) < 500;
|
||||
if (caretVisible && caretPosDirty)
|
||||
@@ -486,6 +469,29 @@ namespace Barotrauma
|
||||
textBlock.State = State;
|
||||
}
|
||||
|
||||
private void HandleCaretBoundsOverflow()
|
||||
{
|
||||
if (textBlock.OverflowClipActive)
|
||||
{
|
||||
CalculateCaretPos();
|
||||
float left = textBlock.Rect.X + textBlock.Padding.X;
|
||||
if (CaretScreenPos.X < left)
|
||||
{
|
||||
float diff = left - CaretScreenPos.X;
|
||||
textBlock.TextPos = new Vector2(textBlock.TextPos.X + diff, textBlock.TextPos.Y);
|
||||
CalculateCaretPos();
|
||||
}
|
||||
|
||||
float right = textBlock.Rect.Right - textBlock.Padding.Z;
|
||||
if (CaretScreenPos.X > right)
|
||||
{
|
||||
float diff = CaretScreenPos.X - right;
|
||||
textBlock.TextPos = new Vector2(textBlock.TextPos.X - diff, textBlock.TextPos.Y);
|
||||
CalculateCaretPos();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCaretAndSelection(SpriteBatch spriteBatch, GUICustomComponent customComponent)
|
||||
{
|
||||
if (!Visible) { return; }
|
||||
@@ -554,15 +560,33 @@ namespace Barotrauma
|
||||
{
|
||||
RemoveSelectedText();
|
||||
}
|
||||
Vector2 textPos = textBlock.TextPos;
|
||||
bool wasOverflowClipActive = textBlock.OverflowClipActive;
|
||||
using var _ = new TextPosPreservation(this);
|
||||
if (SetText(Text.Insert(CaretIndex, input)))
|
||||
{
|
||||
CaretIndex = Math.Min(Text.Length, CaretIndex + input.Length);
|
||||
OnTextChanged?.Invoke(this, Text);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ref struct TextPosPreservation
|
||||
{
|
||||
private readonly GUITextBox textBox;
|
||||
private GUITextBlock textBlock => textBox.TextBlock;
|
||||
private readonly bool wasOverflowClipActive;
|
||||
private readonly Vector2 textPos;
|
||||
|
||||
public TextPosPreservation(GUITextBox tb)
|
||||
{
|
||||
textBox = tb;
|
||||
wasOverflowClipActive = tb.TextBlock.OverflowClipActive;
|
||||
textPos = tb.TextBlock.TextPos;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (textBlock.OverflowClipActive && wasOverflowClipActive && !MathUtils.NearlyEqual(textBlock.TextPos, textPos))
|
||||
{
|
||||
textBlock.TextPos = textPos + Vector2.UnitX * Font.MeasureString(input).X * TextBlock.TextScale;
|
||||
textBlock.TextPos = textPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -577,6 +601,8 @@ namespace Barotrauma
|
||||
switch (command)
|
||||
{
|
||||
case '\b' when !Readonly: //backspace
|
||||
{
|
||||
using var _ = new TextPosPreservation(this);
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl))
|
||||
{
|
||||
SetText(string.Empty, false);
|
||||
@@ -595,6 +621,7 @@ namespace Barotrauma
|
||||
}
|
||||
OnTextChanged?.Invoke(this, Text);
|
||||
break;
|
||||
}
|
||||
case (char)0x3: // ctrl-c
|
||||
CopySelectedText();
|
||||
break;
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Barotrauma
|
||||
healList.PriceBlock.Text = TextManager.FormatCurrency(totalCost);
|
||||
healList.PriceBlock.TextColor = GUIStyle.Red;
|
||||
healList.HealButton.Enabled = false;
|
||||
if (medicalClinic.GetWallet().CanAfford(totalCost))
|
||||
if (medicalClinic.GetBalance() >= totalCost)
|
||||
{
|
||||
healList.PriceBlock.TextColor = GUIStyle.TextColorNormal;
|
||||
if (medicalClinic.PendingHeals.Any())
|
||||
@@ -467,7 +467,7 @@ namespace Barotrauma
|
||||
|
||||
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.GetWallet().Balance),
|
||||
TextGetter = () => TextManager.FormatCurrency(medicalClinic.GetBalance()),
|
||||
AutoScaleVertical = true,
|
||||
TextScale = 1.1f
|
||||
};
|
||||
@@ -577,7 +577,7 @@ namespace Barotrauma
|
||||
GUILayoutGroup buttonLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), footerLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterRight);
|
||||
GUIButton healButton = new GUIButton(new RectTransform(new Vector2(0.33f, 1f), buttonLayout.RectTransform), TextManager.Get("medicalclinic.heal"))
|
||||
{
|
||||
Enabled = medicalClinic.PendingHeals.Any() && medicalClinic.GetWallet().CanAfford(medicalClinic.GetTotalCost()),
|
||||
Enabled = medicalClinic.PendingHeals.Any() && medicalClinic.GetBalance() >= medicalClinic.GetTotalCost(),
|
||||
OnClicked = (button, _) =>
|
||||
{
|
||||
button.Enabled = false;
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace Barotrauma
|
||||
|
||||
private CargoManager CargoManager => campaignUI.Campaign.CargoManager;
|
||||
private Location CurrentLocation => campaignUI.Campaign.Map?.CurrentLocation;
|
||||
private Wallet PlayerWallet => campaignUI.Campaign.Wallet;
|
||||
private int Balance => campaignUI.Campaign.GetBalance();
|
||||
|
||||
private bool IsBuying => activeTab switch
|
||||
{
|
||||
StoreTab.Buy => true,
|
||||
@@ -207,7 +208,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (CurrentLocation?.Stores != null)
|
||||
{
|
||||
if (CurrentLocation.GetStore(identifier) is { } store)
|
||||
if (!identifier.IsEmpty && CurrentLocation.GetStore(identifier) is { } store)
|
||||
{
|
||||
ActiveStore = store;
|
||||
if (storeNameBlock != null)
|
||||
@@ -223,14 +224,45 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
ActiveStore = null;
|
||||
string msg = $"Error selecting store with identifier \"{identifier}\" at {CurrentLocation}: store with the identifier doesn't exist at the location.";
|
||||
string errorId, msg;
|
||||
if (identifier.IsEmpty)
|
||||
{
|
||||
errorId = "Store.SelectStore:IdentifierEmpty";
|
||||
msg = $"Error selecting store at {CurrentLocation}: identifier is empty.";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorId = "Store.SelectStore:StoreDoesntExist";
|
||||
msg = $"Error selecting store with identifier \"{identifier}\" at {CurrentLocation}: store with the identifier doesn't exist at the location.";
|
||||
}
|
||||
DebugConsole.ShowError(msg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Store.SelectStore:StoreDoesntExist", GameAnalyticsManager.ErrorSeverity.Error, msg);
|
||||
GameAnalyticsManager.AddErrorEventOnce(errorId, GameAnalyticsManager.ErrorSeverity.Error, msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveStore = null;
|
||||
string errorId = "", msg = "";
|
||||
if (campaignUI.Campaign.Map == null)
|
||||
{
|
||||
errorId = "Store.SelectStore:MapNull";
|
||||
msg = $"Error selecting store with identifier \"{identifier}\": Map is null.";
|
||||
}
|
||||
else if (CurrentLocation == null)
|
||||
{
|
||||
errorId = "Store.SelectStore:CurrentLocationNull";
|
||||
msg = $"Error selecting store with identifier \"{identifier}\": CurrentLocation is null.";
|
||||
}
|
||||
else if (CurrentLocation.Stores == null)
|
||||
{
|
||||
errorId = "Store.SelectStore:StoresNull";
|
||||
msg = $"Error selecting store with identifier \"{identifier}\": CurrentLocation.Stores is null.";
|
||||
}
|
||||
if (!msg.IsNullOrEmpty())
|
||||
{
|
||||
DebugConsole.ShowError(msg);
|
||||
GameAnalyticsManager.AddErrorEventOnce(errorId, GameAnalyticsManager.ErrorSeverity.Error, msg);
|
||||
}
|
||||
}
|
||||
RefreshItemsToSell();
|
||||
Refresh();
|
||||
@@ -712,7 +744,7 @@ namespace Barotrauma
|
||||
|
||||
private LocalizedString GetMerchantBalanceText() => TextManager.FormatCurrency(ActiveStore?.Balance ?? 0);
|
||||
|
||||
private LocalizedString GetPlayerBalanceText() => TextManager.FormatCurrency(PlayerWallet.Balance);
|
||||
private LocalizedString GetPlayerBalanceText() => TextManager.FormatCurrency(Balance);
|
||||
|
||||
private GUILayoutGroup CreateDealsGroup(GUIListBox parentList, int elementCount)
|
||||
{
|
||||
@@ -2037,7 +2069,7 @@ namespace Barotrauma
|
||||
totalPrice += item.Quantity * ActiveStore.GetAdjustedItemBuyPrice(item.ItemPrefab, priceInfo: priceInfo);
|
||||
}
|
||||
itemsToRemove.ForEach(i => itemsToPurchase.Remove(i));
|
||||
if (itemsToPurchase.None() || !PlayerWallet.CanAfford(totalPrice)) { return false; }
|
||||
if (itemsToPurchase.None() || Balance < totalPrice) { return false; }
|
||||
CargoManager.PurchaseItems(ActiveStore.Identifier, itemsToPurchase, true);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
var dialog = new GUIMessageBox(
|
||||
@@ -2091,7 +2123,7 @@ namespace Barotrauma
|
||||
if (IsBuying)
|
||||
{
|
||||
shoppingCrateTotal.Text = TextManager.FormatCurrency(buyTotal);
|
||||
shoppingCrateTotal.TextColor = !PlayerWallet.CanAfford(buyTotal) ? Color.Red : Color.White;
|
||||
shoppingCrateTotal.TextColor = Balance < buyTotal ? Color.Red : Color.White;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2137,7 +2169,7 @@ namespace Barotrauma
|
||||
ActiveShoppingCrateList.Content.RectTransform.Children.Any() &&
|
||||
activeTab switch
|
||||
{
|
||||
StoreTab.Buy => PlayerWallet.CanAfford(buyTotal),
|
||||
StoreTab.Buy => Balance >= buyTotal,
|
||||
StoreTab.Sell => CurrentLocation != null && sellTotal <= ActiveStore.Balance,
|
||||
StoreTab.SellSub => CurrentLocation != null && sellFromSubTotal <= ActiveStore.Balance,
|
||||
_ => false
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Barotrauma
|
||||
private readonly List<SubmarineInfo> subsToShow;
|
||||
private readonly SubmarineDisplayContent[] submarineDisplays = new SubmarineDisplayContent[submarinesPerPage];
|
||||
private SubmarineInfo selectedSubmarine = null;
|
||||
private LocalizedString purchaseAndSwitchText, purchaseOnlyText, deliveryText, currentSubText, deliveryFeeText, priceText, switchText, missingPreviewText, currencyName;
|
||||
private LocalizedString purchaseAndSwitchText, purchaseOnlyText, deliveryText, currentSubText, switchText, missingPreviewText, currencyName;
|
||||
private readonly RectTransform parent;
|
||||
private readonly Action closeAction;
|
||||
private Sprite pageIndicator;
|
||||
@@ -85,12 +86,10 @@ namespace Barotrauma
|
||||
{
|
||||
initialized = true;
|
||||
currentSubText = TextManager.Get("currentsub");
|
||||
deliveryFeeText = TextManager.Get("deliveryfee");
|
||||
deliveryText = TextManager.Get("requestdeliverybutton");
|
||||
switchText = TextManager.Get("switchtosubmarinebutton");
|
||||
purchaseAndSwitchText = TextManager.Get("purchaseandswitch");
|
||||
purchaseOnlyText = TextManager.Get("purchase");
|
||||
priceText = TextManager.Get("price");
|
||||
if (transferService)
|
||||
{
|
||||
deliveryFee = CalculateDeliveryFee();
|
||||
@@ -327,12 +326,12 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
submarineDisplays[i].submarineName.Text = subToDisplay.DisplayName;
|
||||
submarineDisplays[i].submarineClass.Text = $"{TextManager.GetWithVariable("submarineclass.classsuffixformat", "[type]", TextManager.Get($"submarineclass.{subToDisplay.SubmarineClass}"))}";
|
||||
submarineDisplays[i].submarineClass.Text = TextManager.GetWithVariable("submarineclass.classsuffixformat", "[type]", TextManager.Get($"submarineclass.{subToDisplay.SubmarineClass}"));
|
||||
|
||||
if (!GameMain.GameSession.IsSubmarineOwned(subToDisplay))
|
||||
{
|
||||
LocalizedString amountString = TextManager.FormatCurrency(subToDisplay.Price);
|
||||
submarineDisplays[i].submarineFee.Text = priceText.Replace("[amount]", amountString).Replace("[currencyname]", string.Empty).TrimEnd();
|
||||
submarineDisplays[i].submarineFee.Text = TextManager.GetWithVariable("price", "[amount]", amountString);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -341,7 +340,7 @@ namespace Barotrauma
|
||||
if (deliveryFee > 0)
|
||||
{
|
||||
LocalizedString amountString = TextManager.FormatCurrency(deliveryFee);
|
||||
submarineDisplays[i].submarineFee.Text = deliveryFeeText.Replace("[amount]", amountString).Replace("[currencyname]", string.Empty).TrimEnd();
|
||||
submarineDisplays[i].submarineFee.Text = TextManager.GetWithVariable("deliveryfee", "[amount]", amountString);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -577,7 +576,7 @@ namespace Barotrauma
|
||||
|
||||
private void ShowTransferPrompt()
|
||||
{
|
||||
if (!GameMain.GameSession.Campaign.Wallet.CanAfford(deliveryFee) && deliveryFee > 0)
|
||||
if (!GameMain.GameSession.Campaign.CanAfford(deliveryFee) && deliveryFee > 0)
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("deliveryrequestheader"), TextManager.GetWithVariables("notenoughmoneyfordeliverytext",
|
||||
("[currencyname]", currencyName),
|
||||
@@ -625,7 +624,7 @@ namespace Barotrauma
|
||||
|
||||
private void ShowBuyPrompt(bool purchaseOnly)
|
||||
{
|
||||
if (!GameMain.GameSession.Campaign.Wallet.CanAfford(selectedSubmarine.Price))
|
||||
if (!GameMain.GameSession.Campaign.CanAfford(selectedSubmarine.Price))
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("purchasesubmarineheader"), TextManager.GetWithVariables("notenoughmoneyforpurchasetext",
|
||||
("[currencyname]", currencyName),
|
||||
|
||||
@@ -698,6 +698,12 @@ namespace Barotrauma
|
||||
Color = Color.Transparent
|
||||
};
|
||||
|
||||
frame.OnSecondaryClicked += (component, data) =>
|
||||
{
|
||||
NetLobbyScreen.CreateModerationContextMenu(client);
|
||||
return true;
|
||||
};
|
||||
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.9f), frame.RectTransform, Anchor.Center), isHorizontal: true)
|
||||
{
|
||||
AbsoluteSpacing = 2
|
||||
@@ -1057,7 +1063,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
bool hasMoneyPermissions = campaign.AllowedToManageCampaign(ClientPermissions.ManageMoney);
|
||||
bool hasMoneyPermissions = CampaignMode.AllowedToManageWallets();
|
||||
salarySlider.Enabled = hasMoneyPermissions;
|
||||
Wallet otherWallet;
|
||||
|
||||
@@ -1402,6 +1408,12 @@ namespace Barotrauma
|
||||
|
||||
private void CreateMissionInfo(GUIFrame infoFrame)
|
||||
{
|
||||
if (Level.Loaded?.LevelData == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to display mission info in the tab menu (no level loaded).\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
infoFrame.ClearChildren();
|
||||
GUIFrame missionFrame = new GUIFrame(new RectTransform(Vector2.One, infoFrame.RectTransform, Anchor.TopCenter), style: "GUIFrameListBox");
|
||||
int padding = (int)(0.0245f * missionFrame.Rect.Height);
|
||||
@@ -2016,7 +2028,7 @@ namespace Barotrauma
|
||||
{
|
||||
parent.Content.ClearChildren();
|
||||
List<GUITextBlock> skillNames = new List<GUITextBlock>();
|
||||
foreach (Skill skill in character.Info.Job.Skills)
|
||||
foreach (Skill skill in character.Info.Job.GetSkills())
|
||||
{
|
||||
GUILayoutGroup skillContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.2f), parent.Content.RectTransform), isHorizontal: true) { CanBeFocused = false };
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
|
||||
private readonly CampaignUI campaignUI;
|
||||
private CampaignMode? Campaign => campaignUI.Campaign;
|
||||
private Wallet PlayerWallet => Campaign?.Wallet ?? Wallet.Invalid;
|
||||
private int PlayerBalance => Campaign?.GetBalance() ?? 0;
|
||||
private UpgradeTab selectedUpgradeTab = UpgradeTab.Upgrade;
|
||||
|
||||
private GUIMessageBox? currectConfirmation;
|
||||
@@ -295,7 +295,7 @@ 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(PlayerWallet.Balance), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Right) { TextGetter = () => TextManager.FormatCurrency(PlayerWallet.Balance) };
|
||||
new GUITextBlock(rectT(1f, 0f, priceLayout), TextManager.FormatCurrency(PlayerBalance), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Right) { TextGetter = () => TextManager.FormatCurrency(PlayerBalance) };
|
||||
new GUIFrame(rectT(0.5f, 0.1f, rightLayout, Anchor.BottomRight), style: "HorizontalLine") { IgnoreLayoutGroups = true };
|
||||
|
||||
repairButton.OnClicked = upgradeButton.OnClicked = (button, o) =>
|
||||
@@ -435,14 +435,14 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PlayerWallet.CanAfford(hullRepairCost))
|
||||
if (PlayerBalance >= hullRepairCost)
|
||||
{
|
||||
LocalizedString body = TextManager.GetWithVariable("WallRepairs.PurchasePromptBody", "[amount]", hullRepairCost.ToString());
|
||||
currectConfirmation = EventEditorScreen.AskForConfirmation(TextManager.Get("Upgrades.PurchasePromptTitle"), body, () =>
|
||||
{
|
||||
if (PlayerWallet.Balance >= hullRepairCost)
|
||||
if (PlayerBalance >= hullRepairCost)
|
||||
{
|
||||
PlayerWallet.TryDeduct(hullRepairCost);
|
||||
Campaign.TryPurchase(null, hullRepairCost);
|
||||
GameAnalyticsManager.AddMoneySpentEvent(hullRepairCost, GameAnalyticsManager.MoneySink.Service, "hullrepairs");
|
||||
Campaign.PurchasedHullRepairs = true;
|
||||
button.Enabled = false;
|
||||
@@ -470,14 +470,14 @@ namespace Barotrauma
|
||||
|
||||
CreateRepairEntry(currentStoreLayout.Content, TextManager.Get("repairallitems"), "RepairItemsButton", itemRepairCost, (button, o) =>
|
||||
{
|
||||
if (PlayerWallet.Balance >= itemRepairCost && !Campaign.PurchasedItemRepairs)
|
||||
if (PlayerBalance >= itemRepairCost && !Campaign.PurchasedItemRepairs)
|
||||
{
|
||||
LocalizedString body = TextManager.GetWithVariable("ItemRepairs.PurchasePromptBody", "[amount]", itemRepairCost.ToString());
|
||||
currectConfirmation = EventEditorScreen.AskForConfirmation(TextManager.Get("Upgrades.PurchasePromptTitle"), body, () =>
|
||||
{
|
||||
if (PlayerWallet.Balance >= itemRepairCost && !Campaign.PurchasedItemRepairs)
|
||||
if (PlayerBalance >= itemRepairCost && !Campaign.PurchasedItemRepairs)
|
||||
{
|
||||
PlayerWallet.TryDeduct(itemRepairCost);
|
||||
Campaign.TryPurchase(null, itemRepairCost);
|
||||
GameAnalyticsManager.AddMoneySpentEvent(hullRepairCost, GameAnalyticsManager.MoneySink.Service, "devicerepairs");
|
||||
Campaign.PurchasedItemRepairs = true;
|
||||
button.Enabled = false;
|
||||
@@ -516,14 +516,14 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PlayerWallet.CanAfford(shuttleRetrieveCost) && !Campaign.PurchasedLostShuttles)
|
||||
if (PlayerBalance >= shuttleRetrieveCost && !Campaign.PurchasedLostShuttles)
|
||||
{
|
||||
LocalizedString body = TextManager.GetWithVariable("ReplaceLostShuttles.PurchasePromptBody", "[amount]", shuttleRetrieveCost.ToString());
|
||||
currectConfirmation = EventEditorScreen.AskForConfirmation(TextManager.Get("Upgrades.PurchasePromptTitle"), body, () =>
|
||||
{
|
||||
if (PlayerWallet.Balance >= shuttleRetrieveCost && !Campaign.PurchasedLostShuttles)
|
||||
if (PlayerBalance >= shuttleRetrieveCost && !Campaign.PurchasedLostShuttles)
|
||||
{
|
||||
PlayerWallet.TryDeduct(shuttleRetrieveCost);
|
||||
Campaign.TryPurchase(null, shuttleRetrieveCost);
|
||||
GameAnalyticsManager.AddMoneySpentEvent(hullRepairCost, GameAnalyticsManager.MoneySink.Service, "retrieveshuttle");
|
||||
Campaign.PurchasedLostShuttles = true;
|
||||
button.Enabled = false;
|
||||
@@ -581,13 +581,13 @@ namespace Barotrauma
|
||||
new GUITextBlock(rectT(1, 0, textLayout), title, font: GUIStyle.SubHeadingFont) { CanBeFocused = false, AutoScaleHorizontal = true };
|
||||
new GUITextBlock(rectT(1, 0, textLayout), TextManager.FormatCurrency(price));
|
||||
GUILayoutGroup buyButtonLayout = new GUILayoutGroup(rectT(0.2f, 1, contentLayout), childAnchor: Anchor.Center) { UserData = "buybutton" };
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: "RepairBuyButton") { ClickSound = GUISoundType.HireRepairClick, Enabled = PlayerWallet.Balance >= price && !isDisabled, OnClicked = onPressed };
|
||||
new GUIButton(rectT(0.7f, 0.5f, buyButtonLayout), string.Empty, style: "RepairBuyButton") { ClickSound = GUISoundType.HireRepairClick, Enabled = PlayerBalance >= price && !isDisabled, OnClicked = onPressed };
|
||||
contentLayout.Recalculate();
|
||||
buyButtonLayout.Recalculate();
|
||||
|
||||
if (disableElement)
|
||||
{
|
||||
frameChild.Enabled = PlayerWallet.Balance >= price && !isDisabled;
|
||||
frameChild.Enabled = PlayerBalance >= price && !isDisabled;
|
||||
}
|
||||
|
||||
if (!HasPermission)
|
||||
@@ -972,7 +972,7 @@ namespace Barotrauma
|
||||
buttonStyle: isPurchased ? "WeaponInstallButton" : "StoreAddToCrateButton"));
|
||||
|
||||
if (!(frames.Last().FindChild(c => c is GUIButton, recursive: true) is GUIButton buyButton)) { continue; }
|
||||
if (PlayerWallet.CanAfford(price))
|
||||
if (PlayerBalance >= price)
|
||||
{
|
||||
buyButton.Enabled = true;
|
||||
buyButton.OnClicked += (button, o) =>
|
||||
@@ -1602,7 +1602,7 @@ namespace Barotrauma
|
||||
if (button != null)
|
||||
{
|
||||
button.Enabled = currentLevel < prefab.MaxLevel;
|
||||
if (WaitForServerUpdate || !campaign.Wallet.CanAfford(price))
|
||||
if (WaitForServerUpdate || campaign.GetBalance() < price)
|
||||
{
|
||||
button.Enabled = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user