Unstable 1.2.1.0
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -81,6 +82,8 @@ namespace Barotrauma
|
||||
|
||||
public bool FlashOnAutoCloseCondition { get; set; }
|
||||
|
||||
public Action OnEnterPressed { get; set; }
|
||||
|
||||
public Type MessageBoxType => type;
|
||||
|
||||
public static GUIComponent VisibleBox => MessageBoxes.LastOrDefault();
|
||||
@@ -89,6 +92,10 @@ namespace Barotrauma
|
||||
: this(headerText, text, new LocalizedString[] { "OK" }, relativeSize, minSize, type: type)
|
||||
{
|
||||
this.Buttons[0].OnClicked = Close;
|
||||
OnEnterPressed = () =>
|
||||
{
|
||||
Buttons[0].OnClicked(Buttons[0], Buttons[0].UserData);
|
||||
};
|
||||
}
|
||||
|
||||
public GUIMessageBox(RichString headerText, RichString text, LocalizedString[] buttons,
|
||||
@@ -516,6 +523,11 @@ namespace Barotrauma
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
{
|
||||
if (PlayerInput.KeyHit(Keys.Enter))
|
||||
{
|
||||
OnEnterPressed?.Invoke();
|
||||
}
|
||||
|
||||
if (Draggable)
|
||||
{
|
||||
GUIComponent parent = GUI.MouseOn?.Parent?.Parent;
|
||||
|
||||
@@ -18,6 +18,20 @@ namespace Barotrauma
|
||||
public GUIButton PlusButton { get; private set; }
|
||||
public GUIButton MinusButton { get; private set; }
|
||||
|
||||
private void UpdatePlusMinusButtonVisibility()
|
||||
{
|
||||
if (ForceShowPlusMinusButtons
|
||||
|| inputType == NumberType.Int
|
||||
|| (inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private NumberType inputType;
|
||||
public NumberType InputType
|
||||
{
|
||||
@@ -26,15 +40,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == value) { return; }
|
||||
inputType = value;
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +52,7 @@ namespace Barotrauma
|
||||
{
|
||||
minValueFloat = value;
|
||||
ClampFloatValue();
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
public float? MaxValueFloat
|
||||
@@ -64,15 +62,7 @@ namespace Barotrauma
|
||||
{
|
||||
maxValueFloat = value;
|
||||
ClampFloatValue();
|
||||
if (inputType == NumberType.Int ||
|
||||
(inputType == NumberType.Float && MinValueFloat > float.MinValue && MaxValueFloat < float.MaxValue))
|
||||
{
|
||||
ShowPlusMinusButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePlusMinusButtons();
|
||||
}
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +86,19 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool forceShowPlusMinusButtons;
|
||||
|
||||
public bool ForceShowPlusMinusButtons
|
||||
{
|
||||
get { return forceShowPlusMinusButtons; }
|
||||
set
|
||||
{
|
||||
if (forceShowPlusMinusButtons == value) { return; }
|
||||
forceShowPlusMinusButtons = value;
|
||||
UpdatePlusMinusButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
private int decimalsToDisplay = 1;
|
||||
public int DecimalsToDisplay
|
||||
{
|
||||
@@ -184,7 +187,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool WrapAround;
|
||||
|
||||
public float valueStep;
|
||||
public float ValueStep;
|
||||
|
||||
private float pressedTimer;
|
||||
private readonly float pressedDelay = 0.5f;
|
||||
@@ -339,12 +342,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == NumberType.Int)
|
||||
{
|
||||
IntValue -= valueStep > 0 ? (int)valueStep : 1;
|
||||
IntValue -= ValueStep > 0 ? (int)ValueStep : 1;
|
||||
ClampIntValue();
|
||||
}
|
||||
else if (maxValueFloat.HasValue && minValueFloat.HasValue)
|
||||
{
|
||||
FloatValue -= valueStep > 0 ? valueStep : Round();
|
||||
FloatValue -= ValueStep > 0 ? ValueStep : Round();
|
||||
ClampFloatValue();
|
||||
}
|
||||
}
|
||||
@@ -353,12 +356,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (inputType == NumberType.Int)
|
||||
{
|
||||
IntValue += valueStep > 0 ? (int)valueStep : 1;
|
||||
IntValue += ValueStep > 0 ? (int)ValueStep : 1;
|
||||
ClampIntValue();
|
||||
}
|
||||
else if (inputType == NumberType.Float)
|
||||
{
|
||||
FloatValue += valueStep > 0 ? valueStep : Round();
|
||||
FloatValue += ValueStep > 0 ? ValueStep : Round();
|
||||
ClampFloatValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,9 +341,9 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var panelMaxWidth = (int)(GUI.xScale * (GUI.HorizontalAspectRatio < 1.4f ? 650 : 560));
|
||||
var storeContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform)
|
||||
var storeContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, Anchor.BottomLeft)
|
||||
{
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height)
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height - HUDLayoutSettings.ButtonAreaTop.Bottom)
|
||||
})
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -583,9 +583,9 @@ namespace Barotrauma
|
||||
|
||||
// Shopping Crate ------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
var shoppingCrateContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, anchor: Anchor.TopRight)
|
||||
var shoppingCrateContent = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 1.0f), campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).RectTransform, anchor: Anchor.BottomRight)
|
||||
{
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height)
|
||||
MaxSize = new Point(panelMaxWidth, campaignUI.GetTabContainer(CampaignMode.InteractionType.Store).Rect.Height - HUDLayoutSettings.ButtonAreaTop.Bottom)
|
||||
})
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -922,15 +922,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (itemPrefab.CanBeBoughtFrom(ActiveStore, out PriceInfo priceInfo) && itemPrefab.CanCharacterBuy())
|
||||
{
|
||||
|
||||
bool isDailySpecial = ActiveStore.DailySpecials.Contains(itemPrefab);
|
||||
var itemFrame = isDailySpecial ?
|
||||
storeDailySpecialsGroup.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab == itemPrefab) :
|
||||
storeBuyList.Content.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab == itemPrefab);
|
||||
if (CargoManager.GetPurchasedItem(ActiveStore, itemPrefab) is { } purchasedItem)
|
||||
{
|
||||
quantity = Math.Max(quantity - purchasedItem.Quantity, 0);
|
||||
}
|
||||
|
||||
quantity = Math.Max(quantity - CargoManager.GetPurchasedItemCount(ActiveStore, itemPrefab), 0);
|
||||
if (CargoManager.GetBuyCrateItem(ActiveStore, itemPrefab) is { } buyCrateItem)
|
||||
{
|
||||
quantity = Math.Max(quantity - buyCrateItem.Quantity, 0);
|
||||
@@ -1245,9 +1242,9 @@ namespace Barotrauma
|
||||
int totalPrice = 0;
|
||||
if (ActiveStore != null)
|
||||
{
|
||||
foreach (PurchasedItem item in items)
|
||||
foreach (PurchasedItem item in items.ToList())
|
||||
{
|
||||
if (!(item.ItemPrefab.GetPriceInfo(ActiveStore) is { } priceInfo)) { continue; }
|
||||
if (item.ItemPrefab.GetPriceInfo(ActiveStore) is not { } priceInfo) { continue; }
|
||||
GUINumberInput numInput = null;
|
||||
if (!(listBox.Content.FindChild(c => c.UserData is PurchasedItem pi && pi.ItemPrefab.Identifier == item.ItemPrefab.Identifier) is { } itemFrame))
|
||||
{
|
||||
@@ -1749,7 +1746,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// Add items already purchased
|
||||
CargoManager?.GetPurchasedItems(ActiveStore).ForEach(pi => AddNonEmptyOwnedItems(pi));
|
||||
CargoManager?.GetPurchasedItems(ActiveStore).Where(pi => !pi.DeliverImmediately).ForEach(pi => AddNonEmptyOwnedItems(pi));
|
||||
|
||||
ownedItemsUpdateTimer = 0.0f;
|
||||
|
||||
@@ -1959,14 +1956,13 @@ namespace Barotrauma
|
||||
}
|
||||
catch (NotImplementedException e)
|
||||
{
|
||||
DebugConsole.LogError($"Error getting item availability: Uknown store tab type. {e.StackTrace.CleanupStackTrace()}");
|
||||
DebugConsole.LogError($"Error getting item availability: Unknown store tab type. {e.StackTrace.CleanupStackTrace()}");
|
||||
}
|
||||
if (list != null && list.Find(i => i.ItemPrefab == itemPrefab) is PurchasedItem item)
|
||||
{
|
||||
if (mode == StoreTab.Buy)
|
||||
{
|
||||
var purchasedItem = CargoManager.GetPurchasedItem(ActiveStore, item.ItemPrefab);
|
||||
if (purchasedItem != null) { return Math.Max(item.Quantity - purchasedItem.Quantity, 0); }
|
||||
return Math.Max(item.Quantity - CargoManager.GetPurchasedItemCount(ActiveStore, item.ItemPrefab), 0);
|
||||
}
|
||||
return item.Quantity;
|
||||
}
|
||||
@@ -2093,13 +2089,49 @@ namespace Barotrauma
|
||||
}
|
||||
itemsToRemove.ForEach(i => itemsToPurchase.Remove(i));
|
||||
if (itemsToPurchase.None() || Balance < totalPrice) { return false; }
|
||||
CargoManager.PurchaseItems(ActiveStore.Identifier, itemsToPurchase, true);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
var dialog = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.GetWithVariable("suppliespurchasedmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name),
|
||||
new LocalizedString[] { TextManager.Get("Ok") });
|
||||
dialog.Buttons[0].OnClicked += dialog.Close;
|
||||
|
||||
if (CampaignMode.AllowImmediateItemDelivery())
|
||||
{
|
||||
var deliveryPrompt = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.Get("suppliespurchased.deliverymethod"),
|
||||
new LocalizedString[]
|
||||
{
|
||||
TextManager.Get("suppliespurchased.deliverymethod.deliverimmediately"),
|
||||
TextManager.Get("suppliespurchased.deliverymethod.delivertosub")
|
||||
});
|
||||
deliveryPrompt.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: true);
|
||||
deliveryPrompt.Close();
|
||||
return true;
|
||||
};
|
||||
deliveryPrompt.Buttons[1].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: false);
|
||||
deliveryPrompt.Close();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfirmPurchase(deliverImmediately: false);
|
||||
}
|
||||
|
||||
void ConfirmPurchase(bool deliverImmediately)
|
||||
{
|
||||
itemsToPurchase.ForEach(it => it.DeliverImmediately = deliverImmediately);
|
||||
CargoManager.PurchaseItems(ActiveStore.Identifier, itemsToPurchase, removeFromCrate: true);
|
||||
GameMain.Client?.SendCampaignState();
|
||||
if (!deliverImmediately)
|
||||
{
|
||||
var dialog = new GUIMessageBox(
|
||||
TextManager.Get("newsupplies"),
|
||||
TextManager.GetWithVariable("suppliespurchasedmessage", "[location]", campaignUI?.Campaign?.Map?.CurrentLocation?.Name));
|
||||
dialog.Buttons[0].OnClicked += dialog.Close;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Barotrauma
|
||||
else if (Tile)
|
||||
{
|
||||
Vector2 startPos = new Vector2(rect.X, rect.Y);
|
||||
Sprite.DrawTiled(spriteBatch, startPos, new Vector2(rect.Width, rect.Height), color, startOffset: uvOffset);
|
||||
Sprite.DrawTiled(spriteBatch, startPos, new Vector2(rect.Width, rect.Height), color: color, startOffset: uvOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1110,7 +1110,7 @@ namespace Barotrauma
|
||||
|
||||
public static UpgradeFrame CreateUpgradeFrame(UpgradePrefab prefab, UpgradeCategory category, CampaignMode campaign, RectTransform rectTransform, bool addBuyButton = true)
|
||||
{
|
||||
int price = prefab.Price.GetBuyPrice(campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
int price = prefab.Price.GetBuyPrice(prefab, campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
return CreateUpgradeEntry(rectTransform, prefab.Sprite, prefab.Name, prefab.Description, price, new CategoryData(category, prefab), addBuyButton, upgradePrefab: prefab, currentLevel: campaign.UpgradeManager.GetUpgradeLevel(prefab, category));
|
||||
}
|
||||
|
||||
@@ -1267,7 +1267,7 @@ namespace Barotrauma
|
||||
{
|
||||
LocalizedString promptBody = TextManager.GetWithVariables("Upgrades.PurchasePromptBody",
|
||||
("[upgradename]", prefab.Name),
|
||||
("[amount]", prefab.Price.GetBuyPrice(Campaign.UpgradeManager.GetUpgradeLevel(prefab, category), Campaign.Map?.CurrentLocation, characterList).ToString()));
|
||||
("[amount]", prefab.Price.GetBuyPrice(prefab, Campaign.UpgradeManager.GetUpgradeLevel(prefab, category), Campaign.Map?.CurrentLocation, characterList).ToString()));
|
||||
currectConfirmation = EventEditorScreen.AskForConfirmation(TextManager.Get("Upgrades.PurchasePromptTitle"), promptBody, () =>
|
||||
{
|
||||
if (GameMain.NetworkMember != null)
|
||||
@@ -1682,7 +1682,7 @@ namespace Barotrauma
|
||||
|
||||
GUITextBlock priceLabel = (GUITextBlock)buttonParent.FindChild(UpgradeStoreUserData.PriceLabel, recursive: true);
|
||||
priceLabel.Visible = true;
|
||||
int price = prefab.Price.GetBuyPrice(campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
int price = prefab.Price.GetBuyPrice(prefab, campaign.UpgradeManager.GetUpgradeLevel(prefab, category), campaign.Map?.CurrentLocation, characterList);
|
||||
|
||||
if (!WaitForServerUpdate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user