Build 0.20.4.0
This commit is contained in:
@@ -47,8 +47,8 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, wallTargetPos - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Orange, false);
|
||||
GUI.DrawLine(spriteBatch, pos, wallTargetPos, Color.Orange * 0.5f, 0, 5);
|
||||
}
|
||||
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity} ({GetTargetMemory(SelectedAiTarget, false)?.Priority.FormatZeroDecimal()})", GUIStyle.Red, Color.Black);
|
||||
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 40.0f, $"({targetValue.FormatZeroDecimal()})", GUIStyle.Red, Color.Black);
|
||||
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity}", GUIStyle.Red, Color.Black);
|
||||
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 40.0f, $"{targetValue.FormatZeroDecimal()} (M: {SelectedTargetMemory?.Priority.FormatZeroDecimal()}, P: {SelectedTargetingParams?.Priority.FormatZeroDecimal()})", GUIStyle.Red, Color.Black);
|
||||
}
|
||||
|
||||
/*GUIStyle.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, GUIStyle.Red);
|
||||
|
||||
@@ -981,7 +981,24 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (IsDead) { return; }
|
||||
|
||||
|
||||
var healthBarMode = GameMain.NetworkMember?.ServerSettings.ShowEnemyHealthBars ?? GameSettings.CurrentConfig.ShowEnemyHealthBars;
|
||||
if (healthBarMode != EnemyHealthBarMode.ShowAll)
|
||||
{
|
||||
if (Controlled == null)
|
||||
{
|
||||
if (!IsOnPlayerTeam) { return; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!HumanAIController.IsFriendly(Controlled, this) ||
|
||||
(AIController is HumanAIController humanAi && humanAi.ObjectiveManager.CurrentObjective is AIObjectiveCombat combatObjective && HumanAIController.IsFriendly(Controlled, combatObjective.Enemy)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CharacterHealth.DisplayedVitality < MaxVitality * 0.98f && hudInfoVisible)
|
||||
{
|
||||
hudInfoAlpha = Math.Max(hudInfoAlpha, Math.Min(CharacterHealth.DamageOverlayTimer, 1.0f));
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.Tutorials;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -114,7 +113,7 @@ namespace Barotrauma
|
||||
return
|
||||
character?.Inventory != null &&
|
||||
!character.Removed && !character.IsKnockedDown &&
|
||||
(controller?.User != character || !controller.HideHUD) &&
|
||||
(controller?.User != character || !controller.HideHUD || Screen.Selected.IsEditor) &&
|
||||
!IsCampaignInterfaceOpen &&
|
||||
!ConversationAction.FadeScreenToBlack;
|
||||
}
|
||||
@@ -548,7 +547,7 @@ namespace Barotrauma
|
||||
if (CharacterHealth.OpenHealthWindow == character.SelectedCharacter.CharacterHealth)
|
||||
{
|
||||
character.SelectedCharacter.CharacterHealth.Alignment = Alignment.Left;
|
||||
character.SelectedCharacter.CharacterHealth.DrawStatusHUD(spriteBatch);
|
||||
//character.SelectedCharacter.CharacterHealth.DrawStatusHUD(spriteBatch);
|
||||
}
|
||||
}
|
||||
else if (character.Inventory != null)
|
||||
@@ -644,6 +643,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (character == null || character.IsDead || character.Removed) { return; }
|
||||
|
||||
var healthBarMode = GameMain.NetworkMember?.ServerSettings.ShowEnemyHealthBars ?? GameSettings.CurrentConfig.ShowEnemyHealthBars;
|
||||
if (healthBarMode == EnemyHealthBarMode.HideAll)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var existingBar = bossHealthBars.Find(b => b.Character == character);
|
||||
if (existingBar != null)
|
||||
{
|
||||
@@ -669,6 +674,8 @@ namespace Barotrauma
|
||||
|
||||
public static void UpdateBossHealthBars(float deltaTime)
|
||||
{
|
||||
var healthBarMode = GameMain.NetworkMember?.ServerSettings.ShowEnemyHealthBars ?? GameSettings.CurrentConfig.ShowEnemyHealthBars;
|
||||
|
||||
for (int i = 0; i < bossHealthBars.Count; i++)
|
||||
{
|
||||
var bossHealthBar = bossHealthBars[i];
|
||||
@@ -710,7 +717,7 @@ namespace Barotrauma
|
||||
for (int i = bossHealthBars.Count - 1; i >= 0 ; i--)
|
||||
{
|
||||
var bossHealthBar = bossHealthBars[i];
|
||||
if (bossHealthBar.FadeTimer <= 0)
|
||||
if (bossHealthBar.FadeTimer <= 0 || healthBarMode == EnemyHealthBarMode.HideAll)
|
||||
{
|
||||
bossHealthBar.SideContainer.Parent?.RemoveChild(bossHealthBar.SideContainer);
|
||||
bossHealthBar.TopContainer.Parent?.RemoveChild(bossHealthBar.TopContainer);
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
Color? nameColor = null;
|
||||
if (Job != null) { nameColor = Job.Prefab.UIColor; }
|
||||
|
||||
GUITextBlock characterNameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform), ToolBox.LimitString(Name, GUIStyle.Font, headerTextArea.Rect.Width), textColor: nameColor, font: GUIStyle.Font)
|
||||
GUITextBlock characterNameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), headerTextArea.RectTransform), ToolBox.LimitString(Name, GUIStyle.Font, headerTextArea.Rect.Width), textColor: nameColor, font: GUIStyle.Font)
|
||||
{
|
||||
ForceUpperCase = ForceUpperCase.Yes,
|
||||
Padding = Vector4.Zero
|
||||
@@ -92,8 +92,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (Job != null)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform), Job.Name, textColor: Job.Prefab.UIColor, font: font)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), headerTextArea.RectTransform), Job.Name, textColor: Job.Prefab.UIColor, font: font)
|
||||
{
|
||||
Padding = Vector4.Zero
|
||||
};
|
||||
@@ -101,7 +101,7 @@ namespace Barotrauma
|
||||
|
||||
if (PersonalityTrait != null)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform),
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), headerTextArea.RectTransform),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("PersonalityTrait"), PersonalityTrait.DisplayName),
|
||||
font: font)
|
||||
{
|
||||
@@ -109,7 +109,23 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
if (Job != null && (Character == null || !Character.IsDead))
|
||||
GUIButton manageTalentButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.25f), headerTextArea.RectTransform),
|
||||
text: TextManager.Get("ClientPermission.ManageBotTalents"), style: "GUIButtonSmall")
|
||||
{
|
||||
Enabled = false,
|
||||
UserData = TalentMenu.ManageBotTalentsButtonUserData,
|
||||
TextBlock =
|
||||
{
|
||||
AutoScaleHorizontal = true
|
||||
}
|
||||
};
|
||||
|
||||
if (TalentMenu.CanManageTalents(this))
|
||||
{
|
||||
manageTalentButton.Enabled = true;
|
||||
}
|
||||
|
||||
if (Job != null && Character is not { IsDead: true })
|
||||
{
|
||||
var skillsArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.63f), paddedFrame.RectTransform, Anchor.BottomCenter, Pivot.BottomCenter))
|
||||
{
|
||||
@@ -120,7 +136,7 @@ namespace Barotrauma
|
||||
skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level));
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillsArea.RectTransform), TextManager.AddPunctuation(':', TextManager.Get("skills"), string.Empty), font: font) { Padding = Vector4.Zero };
|
||||
|
||||
|
||||
foreach (Skill skill in skills)
|
||||
{
|
||||
Color textColor = Color.White * (0.5f + skill.Level / 200.0f);
|
||||
@@ -144,7 +160,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Character != null && Character.IsDead)
|
||||
else if (Character is { IsDead: true })
|
||||
{
|
||||
var deadArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.63f), paddedFrame.RectTransform, Anchor.BottomCenter, Pivot.BottomCenter))
|
||||
{
|
||||
|
||||
@@ -89,11 +89,23 @@ namespace Barotrauma
|
||||
private int selectedLimbIndex = -1;
|
||||
private LimbHealth currentDisplayedLimb;
|
||||
|
||||
/// <summary>
|
||||
/// Container for the icons above the health bar
|
||||
/// </summary>
|
||||
private GUIComponent afflictionIconContainer;
|
||||
|
||||
private GUIButton showHiddenAfflictionsButton;
|
||||
|
||||
/// <summary>
|
||||
/// Container for passive afflictions that have been hidden from afflictionIconContainer
|
||||
/// </summary>
|
||||
private GUIComponent hiddenAfflictionIconContainer;
|
||||
|
||||
private GUIProgressBar healthWindowHealthBar;
|
||||
private GUIProgressBar healthWindowHealthBarShadow;
|
||||
|
||||
private GUITextBlock characterName;
|
||||
private GUIListBox afflictionIconContainer;
|
||||
private GUIListBox afflictionIconList;
|
||||
private GUILayoutGroup treatmentLayout;
|
||||
private GUIListBox recommendedTreatmentContainer;
|
||||
|
||||
@@ -331,7 +343,7 @@ namespace Barotrauma
|
||||
deadIndicator.AutoScaleHorizontal = true;
|
||||
}
|
||||
|
||||
afflictionIconContainer = new GUIListBox(new RectTransform(new Vector2(0.25f, 1.0f), characterIndicatorArea.RectTransform), style: null);
|
||||
afflictionIconList = new GUIListBox(new RectTransform(new Vector2(0.25f, 1.0f), characterIndicatorArea.RectTransform), style: null);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), healthWindowVerticalLayout.RectTransform),
|
||||
TextManager.Get("SuitableTreatments"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomCenter);
|
||||
@@ -379,6 +391,25 @@ namespace Barotrauma
|
||||
Enabled = true
|
||||
};
|
||||
|
||||
afflictionIconContainer = new GUILayoutGroup(
|
||||
HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.HealthBarAfflictionArea, GUI.Canvas),
|
||||
isHorizontal: true, childAnchor: Anchor.CenterRight)
|
||||
{
|
||||
AbsoluteSpacing = GUI.IntScale(5)
|
||||
};
|
||||
|
||||
showHiddenAfflictionsButton = new GUIButton(new RectTransform(new Point(afflictionIconContainer.Rect.Height), afflictionIconContainer.RectTransform), style: "GUIButtonCircular")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
hiddenAfflictionIconContainer = new GUILayoutGroup(
|
||||
HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.HealthBarAfflictionArea, GUI.Canvas),
|
||||
isHorizontal: true, childAnchor: Anchor.CenterRight)
|
||||
{
|
||||
AbsoluteSpacing = GUI.IntScale(5)
|
||||
};
|
||||
|
||||
UpdateAlignment();
|
||||
|
||||
SuicideButton = new GUIButton(new RectTransform(new Vector2(0.1f, 0.02f), GUI.Canvas, Anchor.TopCenter)
|
||||
@@ -596,7 +627,7 @@ namespace Barotrauma
|
||||
|
||||
public void UpdateHUD(float deltaTime)
|
||||
{
|
||||
if (GUI.DisableHUD) return;
|
||||
if (GUI.DisableHUD) { return; }
|
||||
if (openHealthWindow != null)
|
||||
{
|
||||
if (openHealthWindow != Character.Controlled?.CharacterHealth && openHealthWindow != Character.Controlled?.SelectedCharacter?.CharacterHealth)
|
||||
@@ -700,6 +731,8 @@ namespace Barotrauma
|
||||
distortTimer = 0.0f;
|
||||
}
|
||||
|
||||
UpdateStatusHUD(deltaTime);
|
||||
|
||||
if (PlayerInput.KeyHit(InputType.Health) && GUI.KeyboardDispatcher.Subscriber == null &&
|
||||
Character.Controlled.AllowInput && !toggledThisFrame)
|
||||
{
|
||||
@@ -726,9 +759,9 @@ namespace Barotrauma
|
||||
OpenHealthWindow = null;
|
||||
}
|
||||
|
||||
foreach (GUIComponent afflictionIcon in afflictionIconContainer.Content.Children)
|
||||
foreach (GUIComponent afflictionIcon in afflictionIconList.Content.Children)
|
||||
{
|
||||
if (!(afflictionIcon.UserData is Affliction affliction)) { continue; }
|
||||
if (afflictionIcon.UserData is not Affliction affliction) { continue; }
|
||||
if (affliction.AppliedAsFailedTreatmentTime > Timing.TotalTime - 1.0 && afflictionIcon.FlashTimer <= 0.0f)
|
||||
{
|
||||
afflictionIcon.Flash(GUIStyle.Red);
|
||||
@@ -900,7 +933,7 @@ namespace Barotrauma
|
||||
|
||||
healthBarHolder.CanBeFocused = healthBar.CanBeFocused = healthBarShadow.CanBeFocused = !Character.ShouldLockHud();
|
||||
if (Character.AllowInput && UseHealthWindow && !Character.DisableHealthWindow && healthBar.Enabled && healthBar.CanBeFocused &&
|
||||
(GUI.IsMouseOn(healthBar) || highlightedAfflictionIcon != null) && Inventory.SelectedSlot == null)
|
||||
(GUI.IsMouseOn(healthBar) || GUI.MouseOn?.UserData is AfflictionPrefab) && Inventory.SelectedSlot == null)
|
||||
{
|
||||
healthBar.State = GUIComponent.ComponentState.Hover;
|
||||
if (PlayerInput.PrimaryMouseButtonClicked())
|
||||
@@ -960,7 +993,12 @@ namespace Barotrauma
|
||||
}
|
||||
else if (Character.Controlled == Character && !CharacterHUD.IsCampaignInterfaceOpen)
|
||||
{
|
||||
healthBarHolder.AddToGUIUpdateList();
|
||||
healthBarHolder.AddToGUIUpdateList();
|
||||
afflictionIconContainer.AddToGUIUpdateList();
|
||||
if (hiddenAfflictionIconContainer.Visible)
|
||||
{
|
||||
hiddenAfflictionIconContainer.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
if (SuicideButton.Visible && Character == Character.Controlled)
|
||||
{
|
||||
@@ -989,7 +1027,7 @@ namespace Barotrauma
|
||||
if (affliction.Prefab.AfflictionOverlay != null)
|
||||
{
|
||||
Sprite ScreenAfflictionOverlay = affliction.Prefab.AfflictionOverlay;
|
||||
ScreenAfflictionOverlay?.Draw(spriteBatch, Vector2.Zero, Color.White * (affliction.GetAfflictionOverlayMultiplier()), Vector2.Zero, 0.0f,
|
||||
ScreenAfflictionOverlay?.Draw(spriteBatch, Vector2.Zero, Color.White * affliction.GetAfflictionOverlayMultiplier(), Vector2.Zero, 0.0f,
|
||||
new Vector2(GameMain.GraphicsWidth / DamageOverlay.size.X, GameMain.GraphicsHeight / DamageOverlay.size.Y));
|
||||
}
|
||||
}
|
||||
@@ -1021,94 +1059,133 @@ namespace Barotrauma
|
||||
// If manning a turret the portrait doesn't get rendered so we push the health bar to remove the empty gap
|
||||
healthBarHolder.RectTransform.ScreenSpaceOffset = Character.ShouldLockHud() ? new Point(0, HUDLayoutSettings.PortraitArea.Height) : Point.Zero;
|
||||
}
|
||||
|
||||
DrawStatusHUD(spriteBatch);
|
||||
}
|
||||
|
||||
private (Affliction Affliction, LocalizedString NameToolTip)? highlightedAfflictionIcon = null;
|
||||
public void DrawStatusHUD(SpriteBatch spriteBatch)
|
||||
//private (Affliction Affliction, LocalizedString NameToolTip)? highlightedAfflictionIcon = null;
|
||||
|
||||
private readonly List<Affliction> statusIcons = new List<Affliction>();
|
||||
private readonly Dictionary<AfflictionPrefab, float> statusIconVisibleTime = new Dictionary<AfflictionPrefab, float>();
|
||||
private float hideStatusIconDelay = 5.0f;
|
||||
|
||||
public void UpdateStatusHUD(float deltaTime)
|
||||
{
|
||||
highlightedAfflictionIcon = null;
|
||||
//Rectangle interactArea = healthBar.Rect;
|
||||
if (Character.Controlled?.SelectedCharacter == null && openHealthWindow == null)
|
||||
{
|
||||
var statusIcons = new List<(Affliction Affliction, LocalizedString Warning)>();
|
||||
statusIcons.Clear();
|
||||
if (Character.InPressure)
|
||||
{
|
||||
statusIcons.Add((pressureAffliction, TextManager.Get("PressureHUDWarning")));
|
||||
statusIcons.Add(pressureAffliction);
|
||||
}
|
||||
if (Character.CurrentHull != null && Character.OxygenAvailable < LowOxygenThreshold && oxygenLowAffliction.Strength < oxygenLowAffliction.Prefab.ShowIconThreshold)
|
||||
{
|
||||
statusIcons.Add((oxygenLowAffliction, TextManager.Get("OxygenHUDWarning")));
|
||||
statusIcons.Add(oxygenLowAffliction);
|
||||
}
|
||||
|
||||
foreach (Affliction affliction in currentDisplayedAfflictions)
|
||||
{
|
||||
statusIcons.Add((affliction, affliction.Prefab.Name));
|
||||
statusIcons.Add(affliction);
|
||||
}
|
||||
|
||||
Vector2 highlightedIconPos = Vector2.Zero;
|
||||
Rectangle afflictionArea = HUDLayoutSettings.AfflictionAreaLeft;
|
||||
|
||||
// Push the icons down since the portrait doesn't get rendered
|
||||
int spacing = GUI.IntScale(10);
|
||||
if (Character.ShouldLockHud())
|
||||
{
|
||||
afflictionArea.Y += HUDLayoutSettings.PortraitArea.Height;
|
||||
// Push the icons down since the portrait doesn't get rendered
|
||||
afflictionIconContainer.RectTransform.ScreenSpaceOffset = new Point(0, HUDLayoutSettings.PortraitArea.Height);
|
||||
hiddenAfflictionIconContainer.RectTransform.ScreenSpaceOffset = new Point(0, -hiddenAfflictionIconContainer.Rect.Height - spacing + HUDLayoutSettings.PortraitArea.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
afflictionIconContainer.RectTransform.ScreenSpaceOffset = new Point(0, 0);
|
||||
hiddenAfflictionIconContainer.RectTransform.ScreenSpaceOffset = new Point(0, -hiddenAfflictionIconContainer.Rect.Height - spacing);
|
||||
}
|
||||
//remove affliction icons for afflictions that no longer exist
|
||||
|
||||
bool horizontal = afflictionArea.Width > afflictionArea.Height;
|
||||
int iconSize = horizontal ? afflictionArea.Height : afflictionArea.Width;
|
||||
|
||||
Point pos = new Point(afflictionArea.Right - iconSize, afflictionArea.Top);
|
||||
RemoveNonExistentIcons(afflictionIconContainer);
|
||||
RemoveNonExistentIcons(hiddenAfflictionIconContainer);
|
||||
void RemoveNonExistentIcons(GUIComponent container)
|
||||
{
|
||||
for (int i = container.CountChildren - 1; i >= 0; i--)
|
||||
{
|
||||
var child = container.GetChild(i);
|
||||
if (child.UserData is not AfflictionPrefab afflictionPrefab) { continue; }
|
||||
if (!statusIcons.Any(s => s.Prefab == afflictionPrefab))
|
||||
{
|
||||
container.RemoveChild(child);
|
||||
statusIconVisibleTime.Remove(afflictionPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var statusIcon in statusIcons)
|
||||
{
|
||||
Affliction affliction = statusIcon.Affliction;
|
||||
Affliction affliction = statusIcon;
|
||||
AfflictionPrefab afflictionPrefab = affliction.Prefab;
|
||||
|
||||
Rectangle afflictionIconRect = new Rectangle(pos, new Point(iconSize));
|
||||
if (afflictionIconRect.Contains(PlayerInput.MousePosition) && !Character.ShouldLockHud() && GUI.MouseOn == null)
|
||||
if (!statusIconVisibleTime.ContainsKey(afflictionPrefab)) { statusIconVisibleTime.Add(afflictionPrefab, 0.0f); }
|
||||
statusIconVisibleTime[afflictionPrefab] += deltaTime;
|
||||
|
||||
var matchingIcon =
|
||||
afflictionIconContainer.GetChildByUserData(afflictionPrefab) ??
|
||||
hiddenAfflictionIconContainer.GetChildByUserData(afflictionPrefab);
|
||||
if (matchingIcon == null)
|
||||
{
|
||||
highlightedAfflictionIcon = statusIcon;
|
||||
highlightedIconPos = afflictionIconRect.Location.ToVector2();
|
||||
matchingIcon = new GUIButton(new RectTransform(new Point(afflictionIconContainer.Rect.Height), afflictionIconContainer.RectTransform), style: null)
|
||||
{
|
||||
UserData = afflictionPrefab,
|
||||
ToolTip = affliction.Prefab.Name,
|
||||
CanBeSelected = false
|
||||
};
|
||||
if (affliction == pressureAffliction)
|
||||
{
|
||||
matchingIcon.ToolTip = TextManager.Get("PressureHUDWarning");
|
||||
}
|
||||
else if (affliction == pressureAffliction)
|
||||
{
|
||||
matchingIcon.ToolTip = TextManager.Get("OxygenHUDWarning");
|
||||
}
|
||||
new GUIImage(new RectTransform(Vector2.One, matchingIcon.RectTransform, Anchor.BottomCenter), afflictionPrefab.Icon, scaleToFit: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
|
||||
if (affliction.DamagePerSecond > 1.0f)
|
||||
if (afflictionPrefab.HideIconAfterDelay && statusIconVisibleTime[afflictionPrefab] > hideStatusIconDelay)
|
||||
{
|
||||
Rectangle glowRect = afflictionIconRect;
|
||||
glowRect.Inflate((int)(20 * GUI.Scale), (int)(20 * GUI.Scale));
|
||||
var glow = GUIStyle.GetComponentStyle("OuterGlowCircular");
|
||||
glow.Sprites[GUIComponent.ComponentState.None][0].Draw(
|
||||
spriteBatch, glowRect,
|
||||
GUIStyle.Red * (float)((Math.Sin(affliction.DamagePerSecondTimer * MathHelper.TwoPi - MathHelper.PiOver2) + 1.0f) * 0.5f));
|
||||
matchingIcon.RectTransform.Parent = hiddenAfflictionIconContainer.RectTransform;
|
||||
}
|
||||
var image = matchingIcon.GetChild<GUIImage>();
|
||||
image.Color = GetAfflictionIconColor(afflictionPrefab, affliction);
|
||||
image.HoverColor = Color.Lerp(image.Color, Color.White, 0.5f);
|
||||
|
||||
float alphaMultiplier = highlightedAfflictionIcon == statusIcon ? 1f : 0.8f;
|
||||
|
||||
afflictionPrefab.Icon?.Draw(spriteBatch,
|
||||
pos.ToVector2(),
|
||||
/*highlightedIcon == statusIcon ? statusIcon.First.Prefab.IconColor : statusIcon.First.Prefab.IconColor * 0.8f,*/ // OLD IMPLEMENTATION
|
||||
GetAfflictionIconColor(afflictionPrefab, affliction) * alphaMultiplier,
|
||||
rotate: 0,
|
||||
scale: iconSize / afflictionPrefab.Icon.size.X);
|
||||
|
||||
if (horizontal)
|
||||
pos.X -= iconSize + (int)(5 * GUI.Scale);
|
||||
else
|
||||
pos.Y += iconSize + (int)(5 * GUI.Scale);
|
||||
if (affliction.DamagePerSecond > 1.0f && matchingIcon.FlashTimer <= 0.0f)
|
||||
{
|
||||
matchingIcon.Flash(useCircularFlash: true, flashDuration: 1.5f, flashRectInflate: Vector2.One * 15.0f * GUI.Scale);
|
||||
image.Pulsate(Vector2.One, Vector2.One * 1.2f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (highlightedAfflictionIcon != null)
|
||||
afflictionIconContainer.RectTransform.SortChildren((r1, r2) =>
|
||||
{
|
||||
LocalizedString nameTooltip = highlightedAfflictionIcon.Value.NameToolTip;
|
||||
Vector2 offset = GUIStyle.Font.MeasureString(nameTooltip);
|
||||
if (r1.GUIComponent.UserData is not AfflictionPrefab prefab1) { return -1; }
|
||||
if (r2.GUIComponent.UserData is not AfflictionPrefab prefab2) { return 1; }
|
||||
var index1 = statusIcons.IndexOf(s => s.Prefab == prefab1);
|
||||
var index2 = statusIcons.IndexOf(s => s.Prefab == prefab2);
|
||||
return index1.CompareTo(index2);
|
||||
});
|
||||
(afflictionIconContainer as GUILayoutGroup).NeedsToRecalculate = true;
|
||||
|
||||
GUI.DrawString(spriteBatch,
|
||||
alignment == Alignment.Left ? highlightedIconPos + offset : highlightedIconPos - offset,
|
||||
nameTooltip,
|
||||
Color.White * 0.8f, Color.Black * 0.5f);
|
||||
Rectangle hiddenAfflictionHoverArea = showHiddenAfflictionsButton.Rect;
|
||||
foreach (GUIComponent child in hiddenAfflictionIconContainer.Children)
|
||||
{
|
||||
hiddenAfflictionHoverArea = Rectangle.Union(hiddenAfflictionHoverArea, child.Rect);
|
||||
}
|
||||
|
||||
hiddenAfflictionIconContainer.Visible =
|
||||
showHiddenAfflictionsButton.Rect.Contains(PlayerInput.MousePosition) ||
|
||||
(hiddenAfflictionIconContainer.Visible && hiddenAfflictionHoverArea.Contains(PlayerInput.MousePosition));
|
||||
showHiddenAfflictionsButton.Visible = hiddenAfflictionIconContainer.CountChildren > 0;
|
||||
showHiddenAfflictionsButton.IgnoreLayoutGroups = !showHiddenAfflictionsButton.Visible;
|
||||
showHiddenAfflictionsButton.Text = $"+{hiddenAfflictionIconContainer.CountChildren}";
|
||||
|
||||
if (Vitality > 0.0f)
|
||||
{
|
||||
float currHealth = healthBar.BarSize;
|
||||
@@ -1150,18 +1227,20 @@ namespace Barotrauma
|
||||
|
||||
public static Color GetAfflictionIconColor(AfflictionPrefab prefab, float afflictionStrength)
|
||||
{
|
||||
//use sqrt to make the color change rapidly when strength is low
|
||||
//(low strength is where seeing the severity of the affliction makes more difference - at high strengths the character is already unconscious or dead)
|
||||
float colorT = MathF.Sqrt(afflictionStrength / prefab.MaxStrength);
|
||||
// No specific colors, use generic
|
||||
if (prefab.IconColors == null)
|
||||
{
|
||||
if (prefab.IsBuff)
|
||||
{
|
||||
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUIStyle.BuffColorLow, GUIStyle.BuffColorMedium, GUIStyle.BuffColorHigh);
|
||||
return ToolBox.GradientLerp(colorT, GUIStyle.BuffColorLow, GUIStyle.BuffColorMedium, GUIStyle.BuffColorHigh);
|
||||
}
|
||||
|
||||
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUIStyle.DebuffColorLow, GUIStyle.DebuffColorMedium, GUIStyle.DebuffColorHigh);
|
||||
return ToolBox.GradientLerp(colorT, GUIStyle.DebuffColorLow, GUIStyle.DebuffColorMedium, GUIStyle.DebuffColorHigh);
|
||||
}
|
||||
|
||||
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, prefab.IconColors);
|
||||
return ToolBox.GradientLerp(colorT, prefab.IconColors);
|
||||
}
|
||||
|
||||
public static Color GetAfflictionIconColor(Affliction affliction) => GetAfflictionIconColor(affliction.Prefab, affliction);
|
||||
@@ -1172,7 +1251,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (selectedLimb == null)
|
||||
{
|
||||
afflictionIconContainer.Content.ClearChildren();
|
||||
afflictionIconList.Content.ClearChildren();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1286,7 @@ namespace Barotrauma
|
||||
|
||||
private void CreateAfflictionInfos(IEnumerable<Affliction> afflictions)
|
||||
{
|
||||
afflictionIconContainer.ClearChildren();
|
||||
afflictionIconList.ClearChildren();
|
||||
displayedAfflictions.Clear();
|
||||
|
||||
Affliction mostSevereAffliction = SortAfflictionsBySeverity(afflictions, excludeBuffs: false).FirstOrDefault();
|
||||
@@ -1217,7 +1296,7 @@ namespace Barotrauma
|
||||
{
|
||||
displayedAfflictions.Add((affliction, affliction.Strength));
|
||||
|
||||
var frame = new GUIButton(new RectTransform(new Vector2(1.0f, 0.25f), afflictionIconContainer.Content.RectTransform), style: "ListBoxElement")
|
||||
var frame = new GUIButton(new RectTransform(new Vector2(1.0f, 0.25f), afflictionIconList.Content.RectTransform), style: "ListBoxElement")
|
||||
{
|
||||
UserData = affliction,
|
||||
OnClicked = SelectAffliction
|
||||
@@ -1275,7 +1354,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
buttonToSelect?.OnClicked(buttonToSelect, buttonToSelect.UserData);
|
||||
afflictionIconContainer.RecalculateChildren();
|
||||
afflictionIconList.RecalculateChildren();
|
||||
}
|
||||
|
||||
private void CreateRecommendedTreatments()
|
||||
@@ -1386,7 +1465,7 @@ namespace Barotrauma
|
||||
|
||||
recommendedTreatmentContainer.RecalculateChildren();
|
||||
|
||||
afflictionIconContainer.Content.RectTransform.SortChildren((r1, r2) =>
|
||||
afflictionIconList.Content.RectTransform.SortChildren((r1, r2) =>
|
||||
{
|
||||
var first = r1.GUIComponent.UserData as Affliction;
|
||||
var second = r2.GUIComponent.UserData as Affliction;
|
||||
@@ -1437,7 +1516,10 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var description = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), parent.RectTransform),
|
||||
affliction.Prefab.Description, textAlignment: Alignment.TopLeft, wrap: true)
|
||||
affliction.Prefab.GetDescription(
|
||||
affliction.Strength,
|
||||
Character == Character.Controlled ? AfflictionPrefab.Description.TargetType.Self : AfflictionPrefab.Description.TargetType.OtherCharacter),
|
||||
textAlignment: Alignment.TopLeft, wrap: true)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -1482,10 +1564,9 @@ namespace Barotrauma
|
||||
private bool SelectAffliction(GUIButton button, object userData)
|
||||
{
|
||||
bool selected = button.Selected;
|
||||
foreach (var child in afflictionIconContainer.Content.Children)
|
||||
foreach (var child in afflictionIconList.Content.Children)
|
||||
{
|
||||
GUIButton btn = child.GetChild<GUIButton>();
|
||||
if (btn != null)
|
||||
if (child is GUIButton btn)
|
||||
{
|
||||
btn.Selected = btn == button && !selected;
|
||||
}
|
||||
@@ -1516,7 +1597,7 @@ namespace Barotrauma
|
||||
afflictionEffectColor = GUIStyle.Green;
|
||||
}
|
||||
|
||||
var child = afflictionIconContainer.Content.FindChild(affliction);
|
||||
var child = afflictionIconList.Content.FindChild(affliction);
|
||||
|
||||
var afflictionStrengthPredictionBar = child.GetChild<GUILayoutGroup>().GetChildByUserData("afflictionstrengthprediction") as GUIProgressBar;
|
||||
afflictionStrengthPredictionBar.BarSize = 0.0f;
|
||||
@@ -1836,14 +1917,14 @@ namespace Barotrauma
|
||||
i++;
|
||||
}
|
||||
|
||||
if (selectedLimbIndex > -1 && afflictionIconContainer.Content.CountChildren > 0)
|
||||
if (selectedLimbIndex > -1 && afflictionIconList.Content.CountChildren > 0)
|
||||
{
|
||||
LimbHealth limbHealth = limbHealths[selectedLimbIndex];
|
||||
if (limbHealth?.IndicatorSprite != null)
|
||||
{
|
||||
Rectangle selectedLimbArea = GetLimbHighlightArea(limbHealth, drawArea);
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(afflictionIconContainer.Rect.X, afflictionIconContainer.Rect.Y),
|
||||
new Vector2(afflictionIconList.Rect.X, afflictionIconList.Rect.Y),
|
||||
selectedLimbArea.Center.ToVector2(),
|
||||
Color.LightGray * 0.5f, width: 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user