Unstable 1.2.4.0
This commit is contained in:
@@ -66,7 +66,11 @@ namespace Barotrauma.Items.Components
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), sliderArea.RectTransform, Anchor.TopCenter), "", textColor: GUIStyle.TextColorNormal, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Center)
|
||||
{
|
||||
AutoScaleHorizontal = true,
|
||||
TextGetter = () => { return TextManager.AddPunctuation(':', powerLabel, (int)(targetForce) + " %"); }
|
||||
TextGetter = () =>
|
||||
{
|
||||
return TextManager.AddPunctuation(':', powerLabel,
|
||||
TextManager.GetWithVariable("percentageformat", "[value]", ((int)MathF.Round(targetForce)).ToString()));
|
||||
}
|
||||
};
|
||||
forceSlider = new GUIScrollBar(new RectTransform(new Vector2(0.95f, 0.45f), sliderArea.RectTransform, Anchor.Center), barSize: 0.1f, style: "DeviceSlider")
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -825,11 +826,22 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private readonly record struct SelectedRecipe(Character User, FabricationRecipe SelectedItem, Option<float> OverrideRequiredTime);
|
||||
private Option<SelectedRecipe> LastSelectedRecipe = Option.None;
|
||||
|
||||
private bool SelectItem(Character user, FabricationRecipe selectedItem, float? overrideRequiredTime = null)
|
||||
{
|
||||
this.selectedItem = selectedItem;
|
||||
displayingForCharacter = user;
|
||||
var selectedRecipe = new SelectedRecipe(user, selectedItem, overrideRequiredTime is null ? Option.None : Option.Some(overrideRequiredTime.Value));
|
||||
LastSelectedRecipe = Option.Some(selectedRecipe);
|
||||
CreateSelectedItemUI(selectedRecipe);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CreateSelectedItemUI(SelectedRecipe recipe)
|
||||
{
|
||||
var (user, selectedItem, overrideRequiredTime) = recipe;
|
||||
int max = Math.Max(selectedItem.TargetItem.GetMaxStackSize(outputContainer.Inventory) / selectedItem.Amount, 1);
|
||||
|
||||
if (amountInput != null)
|
||||
@@ -853,8 +865,10 @@ namespace Barotrauma.Items.Components
|
||||
LocalizedString itemName = GetRecipeNameAndAmount(selectedItem);
|
||||
LocalizedString name = itemName;
|
||||
|
||||
float quality = selectedItem.Quality ?? GetFabricatedItemQuality(selectedItem, user);
|
||||
if (quality > 0)
|
||||
QualityResult result = GetFabricatedItemQuality(selectedItem, user);
|
||||
|
||||
float quality = selectedItem.Quality ?? result.Quality;
|
||||
if (quality > 0 || result.HasRandomQualityRollChance)
|
||||
{
|
||||
name = TextManager.GetWithVariable("itemname.quality" + (int)quality, "[itemname]", itemName + '\n')
|
||||
.Fallback(TextManager.GetWithVariable("itemname.quality3", "[itemname]", itemName + '\n'));
|
||||
@@ -865,6 +879,49 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
AutoScaleHorizontal = true
|
||||
};
|
||||
|
||||
if (result.HasRandomQualityRollChance)
|
||||
{
|
||||
var iconLayout = new GUIFrame(new RectTransform(new Vector2(0.4f, 1f), selectedItemFrame.RectTransform, anchor: Anchor.TopRight), style: null);
|
||||
var icon = GameSession.CreateNotificationIcon(iconLayout, offset: true);
|
||||
|
||||
float percentage1 = result.TotalPlusOnePercentage;
|
||||
float percentage2 = result.TotalPlusTwoPercentage;
|
||||
|
||||
string chance1text = percentage1.ToString("F1", CultureInfo.InvariantCulture);
|
||||
string chance2text = percentage2.ToString("F1", CultureInfo.InvariantCulture);
|
||||
|
||||
int quality1 = Math.Clamp(result.Quality + 1, min: 0, max: 3);
|
||||
int quality2 = Math.Clamp(result.Quality + 2, min: 0, max: 3);
|
||||
|
||||
LocalizedString quality1Text = TextManager.Get($"quality{quality1}");
|
||||
LocalizedString quality2Text = TextManager.Get($"quality{quality2}");
|
||||
|
||||
string localizationTag = percentage2 > 0f && percentage1 > 0 && quality1 != quality2 ? "meetsbonusrequirementtwice" : "meetsbonusrequirement";
|
||||
|
||||
var variables = new (string Key, LocalizedString Value)[]
|
||||
{
|
||||
("[chance]", chance1text), ("[quality]", quality1Text),
|
||||
("[chance2]", chance2text), ("[quality2]", quality2Text)
|
||||
};
|
||||
|
||||
if (MathUtils.NearlyEqual(percentage1, 0))
|
||||
{
|
||||
variables = new[] { ("[chance]", chance2text), ("[quality]", quality2Text) };
|
||||
}
|
||||
|
||||
if (quality1 == quality2)
|
||||
{
|
||||
LocalizedString rawPercentage = result.PlusOnePercentage.ToString("F1", CultureInfo.InvariantCulture);
|
||||
variables = new[] { ("[chance]", rawPercentage), ("[quality]", quality1Text) };
|
||||
}
|
||||
|
||||
LocalizedString qualityTooltip = TextManager.GetWithVariables(localizationTag, variables);
|
||||
|
||||
icon.ToolTip = RichString.Rich(qualityTooltip);
|
||||
icon.Visible = icon.CanBeFocused = true;
|
||||
}
|
||||
|
||||
nameBlock.Padding = new Vector4(0, nameBlock.Padding.Y, GUI.IntScale(5), nameBlock.Padding.W);
|
||||
if (nameBlock.TextScale < 0.7f)
|
||||
{
|
||||
@@ -875,15 +932,15 @@ namespace Barotrauma.Items.Components
|
||||
nameBlock.Wrap = true;
|
||||
nameBlock.SetTextPos();
|
||||
nameBlock.RectTransform.MinSize = new Point(0, (int)(nameBlock.TextSize.Y * nameBlock.TextScale));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!selectedItem.TargetItem.Description.IsNullOrEmpty())
|
||||
{
|
||||
var description = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
|
||||
selectedItem.TargetItem.Description,
|
||||
font: GUIStyle.SmallFont, wrap: true);
|
||||
description.Padding = new Vector4(0, description.Padding.Y, description.Padding.Z, description.Padding.W);
|
||||
|
||||
|
||||
while (description.Rect.Height + nameBlock.Rect.Height > paddedFrame.Rect.Height)
|
||||
{
|
||||
var lines = description.WrappedText.Split('\n');
|
||||
@@ -894,13 +951,13 @@ namespace Barotrauma.Items.Components
|
||||
description.ToolTip = selectedItem.TargetItem.Description;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IEnumerable<Skill> inadequateSkills = Enumerable.Empty<Skill>();
|
||||
if (user != null)
|
||||
{
|
||||
inadequateSkills = selectedItem.RequiredSkills.Where(skill => user.GetSkillLevel(skill.Identifier) < Math.Round(skill.Level * SkillRequirementMultiplier));
|
||||
}
|
||||
|
||||
|
||||
if (selectedItem.RequiredSkills.Any())
|
||||
{
|
||||
LocalizedString text = "";
|
||||
@@ -921,9 +978,10 @@ namespace Barotrauma.Items.Components
|
||||
float degreeOfSuccess = user == null ? 0.0f : FabricationDegreeOfSuccess(user, selectedItem.RequiredSkills);
|
||||
if (degreeOfSuccess > 0.5f) { degreeOfSuccess = 1.0f; }
|
||||
|
||||
float requiredTime = overrideRequiredTime ??
|
||||
(user == null ? selectedItem.RequiredTime : GetRequiredTime(selectedItem, user));
|
||||
|
||||
float requiredTime = overrideRequiredTime.TryUnwrap(out var time)
|
||||
? time
|
||||
: (user == null ? selectedItem.RequiredTime : GetRequiredTime(selectedItem, user));
|
||||
|
||||
if ((int)requiredTime > 0)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedReqFrame.RectTransform),
|
||||
@@ -946,7 +1004,6 @@ namespace Barotrauma.Items.Components
|
||||
font: GUIStyle.SmallFont);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void HighlightRecipe(string identifier, Color color)
|
||||
@@ -1056,6 +1113,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPlayerSkillsChanged()
|
||||
=> RefreshSelectedItem();
|
||||
|
||||
public void RefreshSelectedItem()
|
||||
{
|
||||
if (!LastSelectedRecipe.TryUnwrap(out var lastSelected)) { return; }
|
||||
CreateSelectedItemUI(lastSelected);
|
||||
}
|
||||
|
||||
partial void UpdateRequiredTimeProjSpecific()
|
||||
{
|
||||
if (requiredTimeBlock == null) { return; }
|
||||
|
||||
@@ -991,7 +991,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Level.Loaded.StartLocation?.Type is { ShowSonarMarker: true })
|
||||
{
|
||||
DrawMarker(spriteBatch,
|
||||
Level.Loaded.StartLocation.Name,
|
||||
Level.Loaded.StartLocation.DisplayName.Value,
|
||||
(Level.Loaded.StartOutpost != null ? "outpost" : "location").ToIdentifier(),
|
||||
"startlocation",
|
||||
Level.Loaded.StartExitPosition, transducerCenter,
|
||||
@@ -1001,7 +1001,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Level.Loaded is { EndLocation.Type.ShowSonarMarker: true, Type: LevelData.LevelType.LocationConnection })
|
||||
{
|
||||
DrawMarker(spriteBatch,
|
||||
Level.Loaded.EndLocation.Name,
|
||||
Level.Loaded.EndLocation.DisplayName.Value,
|
||||
(Level.Loaded.EndOutpost != null ? "outpost" : "location").ToIdentifier(),
|
||||
"endlocation",
|
||||
Level.Loaded.EndExitPosition, transducerCenter,
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
};
|
||||
levelStartTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.Center),
|
||||
GameMain.GameSession?.StartLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, GUIStyle.SmallFont, textLimit),
|
||||
GameMain.GameSession?.StartLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.DisplayName, GUIStyle.SmallFont, textLimit),
|
||||
font: GUIStyle.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
Enabled = autoPilot,
|
||||
@@ -243,7 +243,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.BottomCenter),
|
||||
(GameMain.GameSession?.EndLocation == null || Level.IsLoadedOutpost) ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, GUIStyle.SmallFont, textLimit),
|
||||
(GameMain.GameSession?.EndLocation == null || Level.IsLoadedOutpost) ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.DisplayName, GUIStyle.SmallFont, textLimit),
|
||||
font: GUIStyle.SmallFont, style: "GUIRadioButton")
|
||||
{
|
||||
Enabled = autoPilot,
|
||||
@@ -389,7 +389,7 @@ namespace Barotrauma.Items.Components
|
||||
if (!ObjectiveManager.AllActiveObjectivesCompleted())
|
||||
{
|
||||
exitOutpostPrompt = new GUIMessageBox("",
|
||||
TextManager.GetWithVariable("CampaignExitTutorialOutpostPrompt", "[locationname]", campaign.Map.CurrentLocation.Name),
|
||||
TextManager.GetWithVariable("CampaignExitTutorialOutpostPrompt", "[locationname]", campaign.Map.CurrentLocation.DisplayName),
|
||||
new LocalizedString[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
exitOutpostPrompt.Buttons[0].OnClicked += (_, _) =>
|
||||
{
|
||||
@@ -509,9 +509,9 @@ namespace Barotrauma.Items.Components
|
||||
noPowerTip = TextManager.Get("SteeringNoPowerTip");
|
||||
autoPilotMaintainPosTip = TextManager.Get("SteeringAutoPilotMaintainPosTip");
|
||||
autoPilotLevelStartTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
|
||||
GameMain.GameSession?.StartLocation == null ? "Start" : GameMain.GameSession.StartLocation.Name);
|
||||
GameMain.GameSession?.StartLocation == null ? "Start" : GameMain.GameSession.StartLocation.DisplayName);
|
||||
autoPilotLevelEndTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
|
||||
GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name);
|
||||
GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.DisplayName);
|
||||
}
|
||||
|
||||
protected override void OnResolutionChanged()
|
||||
|
||||
Reference in New Issue
Block a user