Unstable v0.19.3.0
This commit is contained in:
+21
-10
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -33,14 +34,18 @@ namespace Barotrauma.Items.Components
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float InfoAreaWidth { get; set; }
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
public bool ShowOutput { get; set; }
|
||||
|
||||
partial void InitProjSpecific(XElement _)
|
||||
{
|
||||
CreateGUI();
|
||||
}
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
{
|
||||
base.OnResolutionChanged();
|
||||
OnItemLoadedProjSpecific();
|
||||
}
|
||||
|
||||
@@ -122,11 +127,14 @@ namespace Barotrauma.Items.Components
|
||||
// === OUTPUT SLOTS === //
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f - InfoAreaWidth, 1f), outputArea.RectTransform, Anchor.CenterLeft), style: null);
|
||||
|
||||
GUILayoutGroup outputDisplayLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), paddedFrame.RectTransform), childAnchor: Anchor.TopCenter);
|
||||
GUILayoutGroup outDisplayTopGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.2f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
GUITextBlock outDisplayBlock = new GUITextBlock(new RectTransform(Vector2.One, outDisplayTopGroup.RectTransform), TextManager.Get("deconstructor.output"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
GUILayoutGroup outDisplayBottomGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.975f, 0.8f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
outputDisplayListBox = new GUIListBox(new RectTransform(new Vector2(1f, 1f), outDisplayBottomGroup.RectTransform), isHorizontal: true, style: null);
|
||||
if (ShowOutput)
|
||||
{
|
||||
GUILayoutGroup outputDisplayLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), paddedFrame.RectTransform), childAnchor: Anchor.TopCenter);
|
||||
GUILayoutGroup outDisplayTopGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.2f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
GUITextBlock outDisplayBlock = new GUITextBlock(new RectTransform(Vector2.One, outDisplayTopGroup.RectTransform), TextManager.Get("deconstructor.output"), font: GUIStyle.SubHeadingFont) { Padding = Vector4.Zero };
|
||||
GUILayoutGroup outDisplayBottomGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.975f, 0.8f), outputDisplayLayout.RectTransform), isHorizontal: true);
|
||||
outputDisplayListBox = new GUIListBox(new RectTransform(new Vector2(1f, 1f), outDisplayBottomGroup.RectTransform), isHorizontal: true, style: null);
|
||||
}
|
||||
|
||||
if (InfoAreaWidth >= 0.0f)
|
||||
{
|
||||
@@ -255,16 +263,17 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (DeconstructItem deconstructItem in it.Prefab.DeconstructItems)
|
||||
{
|
||||
if (!deconstructItem.IsValidDeconstructor(item)) { continue; }
|
||||
RegisterItem(deconstructItem.ItemIdentifier, deconstructItem.Amount);
|
||||
}
|
||||
|
||||
if (it.OwnInventory is { } inventory)
|
||||
/*if (it.OwnInventory is { } inventory)
|
||||
{
|
||||
foreach (Item inventoryItems in inventory.AllItems)
|
||||
{
|
||||
RegisterItem(inventoryItems.Prefab.Identifier);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void RegisterItem(Identifier identifier, int amount = 1)
|
||||
{
|
||||
@@ -383,6 +392,8 @@ namespace Barotrauma.Items.Components
|
||||
inputContainer.Inventory.RectTransform = inputInventoryHolder.RectTransform;
|
||||
outputContainer.AllowUIOverlap = true;
|
||||
outputContainer.Inventory.RectTransform = outputInventoryHolder.RectTransform;
|
||||
|
||||
inputContainer.Inventory.Locked = IsActive;
|
||||
}
|
||||
|
||||
private void DrawOverLay(SpriteBatch spriteBatch, GUICustomComponent overlayComponent)
|
||||
@@ -446,7 +457,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.Write(pendingState);
|
||||
msg.WriteBoolean(pendingState);
|
||||
}
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
|
||||
@@ -51,11 +51,13 @@ namespace Barotrauma.Items.Components
|
||||
[Serialize("vendingmachine.outofstock", IsPropertySaveable.Yes)]
|
||||
public string FabricationLimitReachedText { get; set; }
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
{
|
||||
if (GuiFrame != null)
|
||||
{
|
||||
OnItemLoadedProjSpecific();
|
||||
InitInventoryUIs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +234,17 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void InitInventoryUIs()
|
||||
{
|
||||
if (inputInventoryHolder != null)
|
||||
{
|
||||
inputContainer.AllowUIOverlap = true;
|
||||
inputContainer.Inventory.RectTransform = inputInventoryHolder.RectTransform;
|
||||
}
|
||||
outputContainer.AllowUIOverlap = true;
|
||||
outputContainer.Inventory.RectTransform = outputInventoryHolder.RectTransform;
|
||||
}
|
||||
|
||||
private LocalizedString GetRecipeNameAndAmount(FabricationRecipe fabricationRecipe)
|
||||
{
|
||||
if (fabricationRecipe == null) { return ""; }
|
||||
@@ -249,13 +262,7 @@ namespace Barotrauma.Items.Components
|
||||
partial void OnItemLoadedProjSpecific()
|
||||
{
|
||||
CreateGUI();
|
||||
if (inputInventoryHolder != null)
|
||||
{
|
||||
inputContainer.AllowUIOverlap = true;
|
||||
inputContainer.Inventory.RectTransform = inputInventoryHolder.RectTransform;
|
||||
}
|
||||
outputContainer.AllowUIOverlap = true;
|
||||
outputContainer.Inventory.RectTransform = outputInventoryHolder.RectTransform;
|
||||
InitInventoryUIs();
|
||||
}
|
||||
|
||||
partial void SelectProjSpecific(Character character)
|
||||
@@ -328,76 +335,112 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<FabricationRecipe.RequiredItem, int> missingIngredientCounts = new Dictionary<FabricationRecipe.RequiredItem, int>();
|
||||
private float ingredientHighlightTimer;
|
||||
|
||||
private void DrawInputOverLay(SpriteBatch spriteBatch, GUICustomComponent overlayComponent)
|
||||
{
|
||||
overlayComponent.RectTransform.SetAsLastChild();
|
||||
|
||||
missingIngredientCounts.Clear();
|
||||
|
||||
FabricationRecipe targetItem = fabricatedItem ?? selectedItem;
|
||||
if (targetItem != null)
|
||||
{
|
||||
int slotIndex = 0;
|
||||
|
||||
var missingItems = new List<FabricationRecipe.RequiredItem>();
|
||||
|
||||
foreach (FabricationRecipe.RequiredItem requiredItem in targetItem.RequiredItems)
|
||||
{
|
||||
for (int i = 0; i < requiredItem.Amount; i++)
|
||||
if (missingIngredientCounts.ContainsKey(requiredItem))
|
||||
{
|
||||
missingItems.Add(requiredItem);
|
||||
missingIngredientCounts[requiredItem] += requiredItem.Amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
missingIngredientCounts[requiredItem] = requiredItem.Amount;
|
||||
}
|
||||
}
|
||||
foreach (Item item in inputContainer.Inventory.AllItems)
|
||||
{
|
||||
missingItems.Remove(missingItems.FirstOrDefault(mi => mi.ItemPrefabs.Contains(item.Prefab)));
|
||||
}
|
||||
var missingCounts = missingItems.GroupBy(missingItem => missingItem).ToDictionary(x => x.Key, x => x.Count());
|
||||
missingItems = missingItems.Distinct().ToList();
|
||||
var missingIngredient = missingIngredientCounts.Keys.FirstOrDefault(mi => mi.MatchesItem(item));
|
||||
if (missingIngredient == null) { continue; }
|
||||
|
||||
foreach (FabricationRecipe.RequiredItem requiredItem in missingItems)
|
||||
if (missingIngredientCounts[missingIngredient] == 1)
|
||||
{
|
||||
missingIngredientCounts.Remove(missingIngredient);
|
||||
}
|
||||
else
|
||||
{
|
||||
missingIngredientCounts[missingIngredient]--;
|
||||
}
|
||||
}
|
||||
|
||||
if (ingredientHighlightTimer <= 0.0f)
|
||||
{
|
||||
//highlight inventory slots that contain suitable ingredients in linked inventories
|
||||
foreach (var inventory in linkedInventories)
|
||||
{
|
||||
if (inventory.visualSlots == null) { continue; }
|
||||
for (int i = 0; i < inventory.Capacity; i++)
|
||||
{
|
||||
if (inventory.visualSlots[i].HighlightTimer > 0.0f) { continue; }
|
||||
var availableItem = inventory.GetItemAt(i);
|
||||
if (availableItem == null) { continue; }
|
||||
|
||||
if (missingIngredientCounts.Keys.Any(it => it.MatchesItem(availableItem)))
|
||||
{
|
||||
inventory.visualSlots[i].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f, 0.2f);
|
||||
continue;
|
||||
}
|
||||
if (availableItem.OwnInventory != null)
|
||||
{
|
||||
for (int j = 0; j < availableItem.OwnInventory.Capacity; j++)
|
||||
{
|
||||
var availableContainedItem = availableItem.OwnInventory.GetItemAt(i);
|
||||
if (availableContainedItem == null) { continue; }
|
||||
if (missingIngredientCounts.Keys.Any(it => it.MatchesItem(availableContainedItem)))
|
||||
{
|
||||
inventory.visualSlots[i].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f, 0.2f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ingredientHighlightTimer = 1.0f;
|
||||
}
|
||||
|
||||
int slotIndex = 0;
|
||||
foreach (var kvp in missingIngredientCounts)
|
||||
{
|
||||
var requiredItem = kvp.Key;
|
||||
int missingCount = kvp.Value;
|
||||
|
||||
while (slotIndex < inputContainer.Capacity && inputContainer.Inventory.GetItemAt(slotIndex) != null)
|
||||
{
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
requiredItem.ItemPrefabs
|
||||
.Where(requiredPrefab => availableIngredients.ContainsKey(requiredPrefab.Identifier))
|
||||
.ForEach(requiredPrefab => {
|
||||
var availableItems = availableIngredients[requiredPrefab.Identifier];
|
||||
foreach (Item it in availableItems)
|
||||
{
|
||||
if (it.ParentInventory == inputContainer.Inventory) { continue; }
|
||||
var rootInventoryOwner = it.GetRootInventoryOwner();
|
||||
Inventory rootInventory = (rootInventoryOwner as Item)?.OwnInventory as Inventory ?? (rootInventoryOwner as Character)?.Inventory;
|
||||
if (rootInventory?.visualSlots == null) { continue; }
|
||||
int availableSlotIndex = rootInventory.FindIndex((it.Container != rootInventoryOwner ? it.Container : it) ?? it);
|
||||
if (availableSlotIndex < 0) { continue; }
|
||||
if (rootInventory.visualSlots[availableSlotIndex].HighlightTimer <= 0.0f)
|
||||
{
|
||||
rootInventory.visualSlots[availableSlotIndex].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f, 0.2f);
|
||||
if (slotIndex < inputContainer.Capacity)
|
||||
{
|
||||
inputContainer.Inventory.visualSlots[slotIndex].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f, 0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (slotIndex >= inputContainer.Capacity) { break; }
|
||||
|
||||
var itemIcon = requiredItem.ItemPrefabs.First().InventoryIcon ?? requiredItem.ItemPrefabs.First().Sprite;
|
||||
if (slotIndex < inputContainer.Capacity &&
|
||||
inputContainer.Inventory.visualSlots[slotIndex].HighlightTimer <= 0.0f &&
|
||||
availableIngredients.Any(i => i.Value.Any() && requiredItem.MatchesItem(i.Value.First())))
|
||||
{
|
||||
inputContainer.Inventory.visualSlots[slotIndex].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f, 0.2f);
|
||||
}
|
||||
|
||||
var requiredItemPrefab = requiredItem.FirstMatchingPrefab;
|
||||
var itemIcon = requiredItemPrefab.InventoryIcon ?? requiredItemPrefab.Sprite;
|
||||
Rectangle slotRect = inputContainer.Inventory.visualSlots[slotIndex].Rect;
|
||||
itemIcon.Draw(
|
||||
spriteBatch,
|
||||
slotRect.Center.ToVector2(),
|
||||
color: requiredItem.ItemPrefabs.First().InventoryIconColor * 0.3f,
|
||||
color: requiredItemPrefab.InventoryIconColor * 0.3f,
|
||||
scale: Math.Min(slotRect.Width / itemIcon.size.X, slotRect.Height / itemIcon.size.Y));
|
||||
|
||||
|
||||
if (missingCounts[requiredItem] > 1)
|
||||
|
||||
if (missingCount > 1)
|
||||
{
|
||||
Vector2 stackCountPos = new Vector2(slotRect.Right, slotRect.Bottom);
|
||||
string stackCountText = "x" + missingCounts[requiredItem];
|
||||
string stackCountText = "x" + missingCount;
|
||||
stackCountPos -= GUIStyle.SmallFont.MeasureString(stackCountText) + new Vector2(4, 2);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos + Vector2.One, Color.Black);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, stackCountText, stackCountPos, Color.White);
|
||||
@@ -446,9 +489,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
toolTipText = TextManager.GetWithVariable("displayname.emptyitem", "[itemname]", toolTipText);
|
||||
}
|
||||
if (!requiredItem.ItemPrefabs.First().Description.IsNullOrEmpty())
|
||||
if (!requiredItemPrefab.Description.IsNullOrEmpty())
|
||||
{
|
||||
toolTipText += '\n' + requiredItem.ItemPrefabs.First().Description;
|
||||
toolTipText += '\n' + requiredItemPrefab.Description;
|
||||
}
|
||||
tooltip = new ToolTip { TargetElement = slotRect, Tooltip = toolTipText };
|
||||
}
|
||||
@@ -715,6 +758,8 @@ namespace Barotrauma.Items.Components
|
||||
activateButton.Enabled = false;
|
||||
inSufficientPowerWarning.Visible = IsActive && !hasPower;
|
||||
|
||||
ingredientHighlightTimer -= deltaTime;
|
||||
|
||||
if (!IsActive)
|
||||
{
|
||||
//only check ingredients if the fabricator isn't active (if it is, this is done in Update)
|
||||
@@ -763,7 +808,7 @@ namespace Barotrauma.Items.Components
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
uint recipeHash = pendingFabricatedItem?.RecipeHash ?? 0;
|
||||
msg.Write(recipeHash);
|
||||
msg.WriteUInt32(recipeHash);
|
||||
}
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
|
||||
@@ -510,7 +510,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 origin = weaponSprite.Origin;
|
||||
float scale = parentWidth / Math.Max(weaponSprite.size.X, weaponSprite.size.Y);
|
||||
Color color = !hasPower ? NoPowerColor : turret.ActiveUser is null ? Color.DimGray : GUIStyle.Green;
|
||||
weaponSprite.Draw(batch, center, color, origin, rotation, scale, it.SpriteEffects);
|
||||
weaponSprite.Draw(batch, center, color, origin, rotation, scale, SpriteEffects.None);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
//flowpercentage can only be adjusted at 10% intervals -> no need for more accuracy than this
|
||||
msg.WriteRangedInteger((int)(flowPercentage / 10.0f), -10, 10);
|
||||
msg.Write(IsActive);
|
||||
msg.WriteBoolean(IsActive);
|
||||
}
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
|
||||
@@ -34,9 +34,8 @@ namespace Barotrauma.Items.Components
|
||||
private Color optimalRangeColor = new Color(74,238,104,255);
|
||||
private Color offRangeColor = Color.Orange;
|
||||
private Color warningColor = Color.Red;
|
||||
private Color coldColor = Color.LightBlue;
|
||||
private Color warmColor = Color.Orange;
|
||||
private Color hotColor = Color.Red;
|
||||
|
||||
private readonly Color[] temperatureColors = new Color[] { Color.Blue, Color.LightBlue, Color.Orange, Color.Red };
|
||||
private Color outputColor = Color.Goldenrod;
|
||||
private Color loadColor = Color.LightSteelBlue;
|
||||
|
||||
@@ -66,10 +65,11 @@ namespace Barotrauma.Items.Components
|
||||
"ReactorWarningOverheating", "ReactorWarningHighOutput", "ReactorWarningFuelOut", "ReactorWarningSCRAM"
|
||||
};
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
// TODO: need to recreate the gui when the resolution changes
|
||||
|
||||
CreateGUI();
|
||||
fissionRateMeter = new Sprite(element.GetChildElement("fissionratemeter")?.GetChildElement("sprite"));
|
||||
turbineOutputMeter = new Sprite(element.GetChildElement("turbineoutputmeter")?.GetChildElement("sprite"));
|
||||
meterPointer = new Sprite(element.GetChildElement("meterpointer")?.GetChildElement("sprite"));
|
||||
@@ -81,7 +81,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
string textureDir = GetTextureDirectory(subElement);
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "temperatureboostsoundup":
|
||||
@@ -92,11 +91,16 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateGUI()
|
||||
{
|
||||
warningButtons.Clear();
|
||||
|
||||
paddedFrame = new GUILayoutGroup(new RectTransform(
|
||||
GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
isHorizontal: true)
|
||||
GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = GUIStyle.ItemFrameOffset },
|
||||
isHorizontal: true)
|
||||
{
|
||||
RelativeSpacing = 0.012f,
|
||||
Stretch = true
|
||||
@@ -438,6 +442,19 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
LocalizedString outputStr = TextManager.Get("ReactorOutput");
|
||||
outputText.TextGetter += () => $"{outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())} {kW}";
|
||||
|
||||
InitInventoryUI();
|
||||
}
|
||||
|
||||
private void InitInventoryUI()
|
||||
{
|
||||
var itemContainer = item.GetComponent<ItemContainer>();
|
||||
if (itemContainer != null)
|
||||
{
|
||||
itemContainer.UILabel = "";
|
||||
itemContainer.AllowUIOverlap = true;
|
||||
itemContainer.Inventory.RectTransform = inventoryContainer.RectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
@@ -445,23 +462,10 @@ namespace Barotrauma.Items.Components
|
||||
base.OnItemLoaded();
|
||||
TurbineOutputScrollBar.BarScroll = TargetTurbineOutput / 100.0f;
|
||||
FissionRateScrollBar.BarScroll = TargetFissionRate / 100.0f;
|
||||
var itemContainer = item.GetComponent<ItemContainer>();
|
||||
if (itemContainer != null)
|
||||
{
|
||||
itemContainer.UILabel = "";
|
||||
itemContainer.AllowUIOverlap = true;
|
||||
itemContainer.Inventory.RectTransform = inventoryContainer.RectTransform;
|
||||
/*var inventoryLabel = inventoryContainer.Parent?.GetChild<GUITextBlock>();
|
||||
if (inventoryLabel != null)
|
||||
{
|
||||
inventoryLabel.RectTransform.MinSize = new Point(100, 0);
|
||||
inventoryLabel.Text = itemContainer.GetUILabel();
|
||||
inventoryLabel.CalculateHeightFromText();
|
||||
(inventoryLabel.Parent as GUILayoutGroup).Recalculate();
|
||||
}*/
|
||||
}
|
||||
InitInventoryUI();
|
||||
}
|
||||
|
||||
|
||||
private void DrawTempMeter(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
{
|
||||
Vector2 meterPos = new Vector2(container.Rect.X, container.Rect.Y);
|
||||
@@ -474,7 +478,7 @@ namespace Barotrauma.Items.Components
|
||||
while (meterBarPos.Y > container.Rect.Bottom + (int)(5 * GUI.yScale) - container.Rect.Height * tempFill)
|
||||
{
|
||||
float tempRatio = 1.0f - ((meterBarPos.Y - container.Rect.Y) / container.Rect.Height);
|
||||
Color color = ToolBox.GradientLerp(tempRatio, coldColor, optimalRangeColor, warmColor, hotColor);
|
||||
Color color = ToolBox.GradientLerp(tempRatio, temperatureColors);
|
||||
tempMeterBar.Draw(spriteBatch, meterBarPos, color: color, scale: meterBarScale);
|
||||
int spacing = 2;
|
||||
meterBarPos.Y -= tempMeterBar.size.Y * meterBarScale + spacing;
|
||||
@@ -691,7 +695,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
float normalizedValue = (value - range.X) / (range.Y - range.X);
|
||||
float valueRad = MathHelper.Lerp(sectorRad.X, sectorRad.Y, normalizedValue);
|
||||
Vector2 offset = new Vector2(0, 40) * scale;
|
||||
meterPointer.Draw(spriteBatch, pointerPos, valueRad, scale);
|
||||
}
|
||||
|
||||
@@ -769,8 +772,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.Write(autoTemp);
|
||||
msg.Write(PowerOn);
|
||||
msg.WriteBoolean(autoTemp);
|
||||
msg.WriteBoolean(PowerOn);
|
||||
msg.WriteRangedSingle(TargetFissionRate, 0.0f, 100.0f, 8);
|
||||
msg.WriteRangedSingle(TargetTurbineOutput, 0.0f, 100.0f, 8);
|
||||
|
||||
|
||||
@@ -140,8 +140,7 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
private bool AllowUsingMineralScanner =>
|
||||
HasMineralScanner && !isConnectedToSteering;
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
@@ -195,7 +194,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
{
|
||||
base.OnResolutionChanged();
|
||||
UpdateGUIElements();
|
||||
}
|
||||
|
||||
@@ -302,7 +300,7 @@ namespace Barotrauma.Items.Components
|
||||
TextManager.Get("SonarDirectionalPing"), GUIStyle.TextColorNormal, GUIStyle.SubHeadingFont, Alignment.CenterLeft);
|
||||
textBlocksToScaleAndNormalize.Add(directionalModeSwitchText);
|
||||
|
||||
if (AllowUsingMineralScanner)
|
||||
if (HasMineralScanner)
|
||||
{
|
||||
AddMineralScannerSwitchToGUI();
|
||||
}
|
||||
@@ -373,7 +371,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
base.OnItemLoaded();
|
||||
zoomSlider.BarScroll = MathUtils.InverseLerp(MinZoom, MaxZoom, zoom);
|
||||
if (AllowUsingMineralScanner && mineralScannerSwitch == null)
|
||||
if (HasMineralScanner && mineralScannerSwitch == null)
|
||||
{
|
||||
AddMineralScannerSwitchToGUI();
|
||||
GUITextBlock.AutoScaleAndNormalize(textBlocksToScaleAndNormalize);
|
||||
@@ -417,12 +415,32 @@ namespace Barotrauma.Items.Components
|
||||
unsentChanges = true;
|
||||
correctionTimer = CorrectionDelay;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var mineralScannerSwitchText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1), mineralScannerFrame.RectTransform, Anchor.CenterRight),
|
||||
TextManager.Get("SonarMineralScanner"), GUIStyle.TextColorNormal, GUIStyle.SubHeadingFont, Alignment.CenterLeft);
|
||||
textBlocksToScaleAndNormalize.Add(mineralScannerSwitchText);
|
||||
|
||||
PreventMineralScannerOverlap();
|
||||
}
|
||||
|
||||
private void PreventMineralScannerOverlap()
|
||||
{
|
||||
if (item.GetComponent<Steering>() is { } steering && controlContainer is { } container)
|
||||
{
|
||||
int containerBottom = container.Rect.Y + container.Rect.Height,
|
||||
steeringTop = steering.ControlContainer.Rect.Top;
|
||||
|
||||
int amountRaised = 0;
|
||||
|
||||
while (GetContainerBottom() > steeringTop) { amountRaised++; }
|
||||
|
||||
container.RectTransform.AbsoluteOffset = new Point(0, -amountRaised);
|
||||
|
||||
int GetContainerBottom() => containerBottom - amountRaised;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
@@ -502,7 +520,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2.DistanceSquared(sonarView.Rect.Center.ToVector2(), PlayerInput.MousePosition) <
|
||||
(sonarView.Rect.Width / 2 * sonarView.Rect.Width / 2);
|
||||
|
||||
if (AllowUsingMineralScanner && Level.Loaded != null && !Level.Loaded.Generating)
|
||||
if (HasMineralScanner && Level.Loaded != null && !Level.Loaded.Generating)
|
||||
{
|
||||
if (MineralClusters == null)
|
||||
{
|
||||
@@ -985,7 +1003,7 @@ namespace Barotrauma.Items.Components
|
||||
missionIndex++;
|
||||
}
|
||||
|
||||
if (AllowUsingMineralScanner && useMineralScanner && CurrentMode == Mode.Active && MineralClusters != null &&
|
||||
if (HasMineralScanner && useMineralScanner && CurrentMode == Mode.Active && MineralClusters != null &&
|
||||
(item.CurrentHull == null || !DetectSubmarineWalls))
|
||||
{
|
||||
foreach (var c in MineralClusters)
|
||||
@@ -1754,17 +1772,17 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.Write(currentMode == Mode.Active);
|
||||
msg.WriteBoolean(currentMode == Mode.Active);
|
||||
if (currentMode == Mode.Active)
|
||||
{
|
||||
msg.WriteRangedSingle(zoom, MinZoom, MaxZoom, 8);
|
||||
msg.Write(useDirectionalPing);
|
||||
msg.WriteBoolean(useDirectionalPing);
|
||||
if (useDirectionalPing)
|
||||
{
|
||||
float pingAngle = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(pingDirection));
|
||||
msg.WriteRangedSingle(MathUtils.InverseLerp(0.0f, MathHelper.TwoPi, pingAngle), 0.0f, 1.0f, 8);
|
||||
}
|
||||
msg.Write(useMineralScanner);
|
||||
msg.WriteBoolean(useMineralScanner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUITickBox maintainPosTickBox, levelEndTickBox, levelStartTickBox;
|
||||
|
||||
private GUIComponent statusContainer, dockingContainer, controlContainer;
|
||||
private GUIComponent statusContainer, dockingContainer;
|
||||
|
||||
public GUIComponent ControlContainer { get; private set; }
|
||||
|
||||
private bool dockingNetworkMessagePending;
|
||||
|
||||
@@ -90,6 +92,24 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool disableControls;
|
||||
/// <summary>
|
||||
/// Can be used by status effects to disable all the UI controls
|
||||
/// </summary>
|
||||
public bool DisableControls
|
||||
{
|
||||
get { return disableControls; }
|
||||
set
|
||||
{
|
||||
if (disableControls == value) { return; }
|
||||
disableControls = value;
|
||||
UpdateGUIElements();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
foreach (var subElement in element.Elements())
|
||||
@@ -112,8 +132,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected override void CreateGUI()
|
||||
{
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(Sonar.controlBoxSize.X, 1 - Sonar.controlBoxSize.Y * 2), GuiFrame.RectTransform, Anchor.CenterRight), "ItemUI");
|
||||
var paddedControlContainer = new GUIFrame(new RectTransform(controlContainer.Rect.Size - GUIStyle.ItemFrameMargin, controlContainer.RectTransform, Anchor.Center)
|
||||
ControlContainer = new GUIFrame(new RectTransform(new Vector2(Sonar.controlBoxSize.X, 1 - Sonar.controlBoxSize.Y * 2), GuiFrame.RectTransform, Anchor.CenterRight), "ItemUI");
|
||||
var paddedControlContainer = new GUIFrame(new RectTransform(ControlContainer.Rect.Size - GUIStyle.ItemFrameMargin, ControlContainer.RectTransform, Anchor.Center)
|
||||
{
|
||||
AbsoluteOffset = GUIStyle.ItemFrameOffset
|
||||
}, style: null);
|
||||
@@ -472,7 +492,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
{
|
||||
base.OnResolutionChanged();
|
||||
UpdateGUIElements();
|
||||
}
|
||||
|
||||
@@ -658,6 +677,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (DisableControls)
|
||||
{
|
||||
dockingModeEnabled = false;
|
||||
}
|
||||
|
||||
dockingContainer.Visible = DockingModeEnabled;
|
||||
statusContainer.Visible = !DockingModeEnabled;
|
||||
if (!DockingModeEnabled)
|
||||
@@ -745,7 +769,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
iceSpireWarningText.Visible = item.Submarine != null && !pressureWarningText.Visible && showIceSpireWarning && Timing.TotalTime % 1.0f < 0.8f;
|
||||
|
||||
if (Vector2.DistanceSquared(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerRadius * steerRadius)
|
||||
if (!disableControls && Vector2.DistanceSquared(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerRadius * steerRadius)
|
||||
{
|
||||
if (PlayerInput.PrimaryMouseButtonHeld() && !CrewManager.IsCommandInterfaceOpen && !GameSession.IsTabMenuOpen &&
|
||||
(!GameMain.GameSession?.Campaign?.ShowCampaignUI ?? true) && !GUIMessageBox.MessageBoxes.Any(msgBox => msgBox is GUIMessageBox { MessageBoxType: GUIMessageBox.Type.Default }))
|
||||
@@ -815,7 +839,7 @@ namespace Barotrauma.Items.Components
|
||||
keyboardInput = Vector2.Zero;
|
||||
}
|
||||
|
||||
if (!UseAutoDocking) { return; }
|
||||
if (!UseAutoDocking || DisableControls) { return; }
|
||||
|
||||
if (checkConnectedPortsTimer <= 0.0f)
|
||||
{
|
||||
@@ -894,27 +918,27 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
msg.Write(AutoPilot);
|
||||
msg.Write(dockingNetworkMessagePending);
|
||||
msg.WriteBoolean(AutoPilot);
|
||||
msg.WriteBoolean(dockingNetworkMessagePending);
|
||||
dockingNetworkMessagePending = false;
|
||||
|
||||
if (!AutoPilot)
|
||||
{
|
||||
//no need to write steering info if autopilot is controlling
|
||||
msg.Write(steeringInput.X);
|
||||
msg.Write(steeringInput.Y);
|
||||
msg.WriteSingle(steeringInput.X);
|
||||
msg.WriteSingle(steeringInput.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Write(posToMaintain != null);
|
||||
msg.WriteBoolean(posToMaintain != null);
|
||||
if (posToMaintain != null)
|
||||
{
|
||||
msg.Write(((Vector2)posToMaintain).X);
|
||||
msg.Write(((Vector2)posToMaintain).Y);
|
||||
msg.WriteSingle(((Vector2)posToMaintain).X);
|
||||
msg.WriteSingle(((Vector2)posToMaintain).Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Write(LevelStartSelected);
|
||||
msg.WriteBoolean(LevelStartSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -998,9 +1022,20 @@ namespace Barotrauma.Items.Components
|
||||
steeringModeSwitch.Selected = AutoPilot;
|
||||
autopilotIndicator.Selected = AutoPilot;
|
||||
manualPilotIndicator.Selected = !AutoPilot;
|
||||
maintainPosTickBox.Enabled = AutoPilot;
|
||||
levelEndTickBox.Enabled = AutoPilot;
|
||||
levelStartTickBox.Enabled = AutoPilot;
|
||||
if (DisableControls)
|
||||
{
|
||||
steeringModeSwitch.Enabled = false;
|
||||
maintainPosTickBox.Enabled = false;
|
||||
levelEndTickBox.Enabled = false;
|
||||
levelStartTickBox.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
steeringModeSwitch.Enabled = true;
|
||||
maintainPosTickBox.Enabled = AutoPilot;
|
||||
levelEndTickBox.Enabled = AutoPilot;
|
||||
levelStartTickBox.Enabled = AutoPilot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user