Unstable 0.1500.5.0 (almost forgor edition 💀)
This commit is contained in:
@@ -66,8 +66,6 @@ namespace Barotrauma
|
||||
private SpriteSheet medUIExtra;
|
||||
private float medUIExtraAnimState;
|
||||
|
||||
private GUIComponent draggingMed;
|
||||
|
||||
private int highlightedLimbIndex = -1;
|
||||
private int selectedLimbIndex = -1;
|
||||
private LimbHealth currentDisplayedLimb;
|
||||
@@ -118,7 +116,6 @@ namespace Barotrauma
|
||||
|
||||
if (prevOpenHealthWindow != null)
|
||||
{
|
||||
prevOpenHealthWindow.selectedLimbIndex = -1;
|
||||
prevOpenHealthWindow.highlightedLimbIndex = -1;
|
||||
}
|
||||
|
||||
@@ -207,7 +204,7 @@ namespace Barotrauma
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.2f, 1.0f), nameContainer.RectTransform, Anchor.CenterLeft),
|
||||
onDraw: (spriteBatch, component) =>
|
||||
{
|
||||
character.Info?.DrawPortrait(spriteBatch, new Vector2(component.Rect.X, component.Rect.Center.Y - component.Rect.Width / 2), Vector2.Zero, component.Rect.Width, false, openHealthWindow?.Character != Character.Controlled);
|
||||
character.Info?.DrawPortrait(spriteBatch, new Vector2(component.Rect.X, component.Rect.Center.Y - component.Rect.Width / 2), Vector2.Zero, component.Rect.Width, false, character != Character.Controlled);
|
||||
});
|
||||
characterName = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), nameContainer.RectTransform), "", textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont)
|
||||
{
|
||||
@@ -216,7 +213,7 @@ namespace Barotrauma
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.2f, 1.0f), nameContainer.RectTransform),
|
||||
onDraw: (spriteBatch, component) =>
|
||||
{
|
||||
character.Info?.DrawJobIcon(spriteBatch, component.Rect, openHealthWindow?.Character != Character.Controlled);
|
||||
character.Info?.DrawJobIcon(spriteBatch, component.Rect, character != Character.Controlled);
|
||||
});
|
||||
|
||||
|
||||
@@ -275,6 +272,34 @@ namespace Barotrauma
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cprButton = new GUIButton(new RectTransform(new Vector2(0.17f, 0.17f), characterIndicatorArea.RectTransform, Anchor.BottomLeft, scaleBasis: ScaleBasis.Smallest), text: "", style: "CPRButton")
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
Character selectedCharacter = Character.Controlled?.SelectedCharacter;
|
||||
if (selectedCharacter == null || (!selectedCharacter.IsUnconscious && selectedCharacter.Stun <= 0.0f))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Character.Controlled.AnimController.Anim = (Character.Controlled.AnimController.Anim == AnimController.Animation.CPR) ?
|
||||
AnimController.Animation.None : AnimController.Animation.CPR;
|
||||
|
||||
selectedCharacter.AnimController.ResetPullJoints();
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Treatment });
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
ToolTip = TextManager.Get("doctor.cprobjective"),
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
var limbSelection = new GUICustomComponent(new RectTransform(new Vector2(0.4f, 1.0f), characterIndicatorArea.RectTransform),
|
||||
(spriteBatch, component) =>
|
||||
{
|
||||
@@ -300,7 +325,7 @@ namespace Barotrauma
|
||||
deadIndicator.AutoScaleHorizontal = true;
|
||||
}
|
||||
|
||||
afflictionIconContainer = new GUIListBox(new RectTransform(new Vector2(0.25f, 0.7f), characterIndicatorArea.RectTransform), style: null);
|
||||
afflictionIconContainer = 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: GUI.SubHeadingFont, textAlignment: Alignment.BottomCenter);
|
||||
@@ -324,33 +349,6 @@ namespace Barotrauma
|
||||
|
||||
characterIndicatorArea.Recalculate();
|
||||
|
||||
cprButton = new GUIButton(new RectTransform(new Vector2(afflictionIconContainer.RectTransform.RelativeSize.X, 0.3f), characterIndicatorArea.RectTransform, Anchor.BottomRight, scaleBasis: ScaleBasis.Smallest), text: "", style: "CPRButton")
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
Character selectedCharacter = Character.Controlled?.SelectedCharacter;
|
||||
if (selectedCharacter == null || (!selectedCharacter.IsUnconscious && selectedCharacter.Stun <= 0.0f))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Character.Controlled.AnimController.Anim = (Character.Controlled.AnimController.Anim == AnimController.Animation.CPR) ?
|
||||
AnimController.Animation.None : AnimController.Animation.CPR;
|
||||
|
||||
selectedCharacter.AnimController.ResetPullJoints();
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Treatment });
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
ToolTip = TextManager.Get("doctor.cprobjective"),
|
||||
IgnoreLayoutGroups = true,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
healthBarHolder = new GUIFrame(new RectTransform(Point.Zero, GUI.Canvas), style: null)
|
||||
{
|
||||
HoverCursor = CursorState.Hand
|
||||
@@ -721,20 +719,19 @@ namespace Barotrauma
|
||||
foreach (GUIComponent afflictionIcon in afflictionIconContainer.Content.Children)
|
||||
{
|
||||
if (!(afflictionIcon.UserData is Affliction affliction)) { continue; }
|
||||
var btn = afflictionIcon.GetChild<GUIButton>();
|
||||
if (affliction.AppliedAsFailedTreatmentTime > Timing.TotalTime - 1.0 && btn.FlashTimer <= 0.0f)
|
||||
if (affliction.AppliedAsFailedTreatmentTime > Timing.TotalTime - 1.0 && afflictionIcon.FlashTimer <= 0.0f)
|
||||
{
|
||||
btn.Flash(GUI.Style.Red);
|
||||
afflictionIcon.Flash(GUI.Style.Red);
|
||||
}
|
||||
else if (affliction.AppliedAsSuccessfulTreatmentTime > Timing.TotalTime - 1.0 && btn.FlashTimer <= 0.0f)
|
||||
else if (affliction.AppliedAsSuccessfulTreatmentTime > Timing.TotalTime - 1.0 && afflictionIcon.FlashTimer <= 0.0f)
|
||||
{
|
||||
btn.Flash(GUI.Style.Green);
|
||||
afflictionIcon.Flash(GUI.Style.Green);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUI.MouseOn != null && GUI.MouseOn.UserData is string str && str == "selectaffliction")
|
||||
if (GUI.MouseOn?.UserData is Affliction)
|
||||
{
|
||||
Affliction affliction = GUI.MouseOn.Parent.UserData as Affliction;
|
||||
Affliction affliction = GUI.MouseOn?.UserData as Affliction;
|
||||
|
||||
if (afflictionTooltip == null || afflictionTooltip.UserData != affliction)
|
||||
{
|
||||
@@ -802,6 +799,8 @@ namespace Barotrauma
|
||||
currentDisplayedLimb = selectedLimb;
|
||||
}
|
||||
|
||||
UpdateAfflictionInfos(displayedAfflictions.Select(d => d.affliction));
|
||||
|
||||
foreach (GUIComponent component in recommendedTreatmentContainer.Content.Children)
|
||||
{
|
||||
var treatmentButton = component.GetChild<GUIButton>();
|
||||
@@ -857,15 +856,6 @@ namespace Barotrauma
|
||||
selectedLimbIndex = highlightedLimbIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (draggingMed != null)
|
||||
{
|
||||
if (!PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
OnItemDropped(draggingMed.UserData as Item, ignoreMousePos: false);
|
||||
draggingMed = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1157,8 +1147,6 @@ namespace Barotrauma
|
||||
{
|
||||
CreateRecommendedTreatments();
|
||||
}
|
||||
|
||||
UpdateAfflictionInfos(displayedAfflictions.Select(d => d.affliction));
|
||||
}
|
||||
|
||||
private void CreateAfflictionInfos(IEnumerable<Affliction> afflictions)
|
||||
@@ -1173,28 +1161,40 @@ namespace Barotrauma
|
||||
{
|
||||
displayedAfflictions.Add((affliction, affliction.Strength));
|
||||
|
||||
var child = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), afflictionIconContainer.Content.RectTransform, Anchor.TopCenter))
|
||||
var frame = new GUIButton(new RectTransform(new Vector2(1.0f, 0.25f), afflictionIconContainer.Content.RectTransform), style: "ListBoxElement")
|
||||
{
|
||||
Stretch = true,
|
||||
UserData = affliction
|
||||
};
|
||||
|
||||
var button = new GUIButton(new RectTransform(new Vector2(1.0f, 0.9f), child.RectTransform), style: null)
|
||||
{
|
||||
Color = Color.Gray.Multiply(0.1f).Opaque(),
|
||||
HoverColor = Color.Gray.Multiply(0.4f).Opaque(),
|
||||
SelectedColor = Color.Gray.Multiply(0.25f).Opaque(),
|
||||
PressedColor = Color.Gray.Multiply(0.2f).Opaque(),
|
||||
UserData = "selectaffliction",
|
||||
UserData = affliction,
|
||||
OnClicked = SelectAffliction
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(Vector2.One, frame.RectTransform), style: "GUIFrameListBox") { CanBeFocused = false };
|
||||
|
||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), frame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var progressbarBg = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.18f), content.RectTransform), 0.0f, GUI.Style.Green, style: "GUIAfflictionBar")
|
||||
{
|
||||
UserData = "afflictionstrengthprediction",
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUIProgressBar(new RectTransform(Vector2.One, progressbarBg.RectTransform), 0.0f, Color.Transparent, showFrame: false, style: "GUIAfflictionBar")
|
||||
{
|
||||
UserData = "afflictionstrength",
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.15f), content.RectTransform), style: null) { CanBeFocused = false };
|
||||
|
||||
if (affliction == mostSevereAffliction)
|
||||
{
|
||||
buttonToSelect = button;
|
||||
buttonToSelect = frame;
|
||||
}
|
||||
|
||||
var afflictionIcon = new GUIImage(new RectTransform(Vector2.One * 0.8f, button.RectTransform, Anchor.Center), affliction.Prefab.Icon, scaleToFit: true)
|
||||
var afflictionIcon = new GUIImage(new RectTransform(Vector2.One * 0.8f, content.RectTransform), affliction.Prefab.Icon, scaleToFit: true)
|
||||
{
|
||||
Color = GetAfflictionIconColor(affliction),
|
||||
CanBeFocused = false
|
||||
@@ -1203,32 +1203,22 @@ namespace Barotrauma
|
||||
afflictionIcon.HoverColor = Color.Lerp(afflictionIcon.Color, Color.White, 0.6f);
|
||||
afflictionIcon.SelectedColor = Color.Lerp(afflictionIcon.Color, Color.White, 0.5f);
|
||||
|
||||
float afflictionVitalityDecrease = affliction.GetVitalityDecrease(this);
|
||||
|
||||
Color afflictionEffectColor = Color.White;
|
||||
if (afflictionVitalityDecrease > 0.0f)
|
||||
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.1f, 0.0f), content.RectTransform),
|
||||
affliction.Prefab.Name, font: GUI.SmallFont, textAlignment: Alignment.BottomCenter)
|
||||
{
|
||||
afflictionEffectColor = GUI.Style.Red;
|
||||
}
|
||||
else if (afflictionVitalityDecrease < 0.0f)
|
||||
{
|
||||
afflictionEffectColor = GUI.Style.Green;
|
||||
}
|
||||
|
||||
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), child.RectTransform),
|
||||
affliction.Prefab.Name, font: GUI.SmallFont, textAlignment: Alignment.Center, style: "GUIToolTip");
|
||||
CanBeFocused = false
|
||||
};
|
||||
nameText.Text = ToolBox.LimitString(nameText.Text, nameText.Font, nameText.Rect.Width);
|
||||
nameText.RectTransform.MinSize = new Point(0, (int)(nameText.TextSize.Y * 1.25f));
|
||||
|
||||
new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.15f), child.RectTransform), 0.0f, afflictionEffectColor, style: "GUIAfflictionBar")
|
||||
nameText.RectTransform.MinSize = new Point(0, (int)(nameText.TextSize.Y));
|
||||
nameText.RectTransform.SizeChanged += () =>
|
||||
{
|
||||
UserData = "afflictionstrength"
|
||||
nameText.Text = ToolBox.LimitString(nameText.Text, nameText.Font, nameText.Rect.Width);
|
||||
};
|
||||
|
||||
child.Recalculate();
|
||||
content.Recalculate();
|
||||
}
|
||||
|
||||
buttonToSelect?.OnClicked(buttonToSelect, "selectaffliction");
|
||||
buttonToSelect?.OnClicked(buttonToSelect, buttonToSelect.UserData);
|
||||
afflictionIconContainer.RecalculateChildren();
|
||||
}
|
||||
|
||||
@@ -1448,11 +1438,52 @@ namespace Barotrauma
|
||||
|
||||
private void UpdateAfflictionInfos(IEnumerable<Affliction> afflictions)
|
||||
{
|
||||
var potentialTreatment = Inventory.DraggingItems.FirstOrDefault();
|
||||
if (potentialTreatment == null && GUI.MouseOn?.UserData is ItemPrefab itemPrefab)
|
||||
{
|
||||
potentialTreatment = Character.Controlled.Inventory.AllItems.FirstOrDefault(it => it.prefab == itemPrefab);
|
||||
}
|
||||
potentialTreatment ??= Inventory.SelectedSlot?.Item;
|
||||
|
||||
foreach (Affliction affliction in afflictions)
|
||||
{
|
||||
float afflictionVitalityDecrease = affliction.GetVitalityDecrease(this);
|
||||
Color afflictionEffectColor = Color.White;
|
||||
if (afflictionVitalityDecrease > 0.0f)
|
||||
{
|
||||
afflictionEffectColor = GUI.Style.Red;
|
||||
}
|
||||
else if (afflictionVitalityDecrease < 0.0f)
|
||||
{
|
||||
afflictionEffectColor = GUI.Style.Green;
|
||||
}
|
||||
|
||||
var child = afflictionIconContainer.Content.FindChild(affliction);
|
||||
var afflictionStrengthBar = child.GetChildByUserData("afflictionstrength") as GUIProgressBar;
|
||||
|
||||
var afflictionStrengthPredictionBar = child.GetChild<GUILayoutGroup>().GetChildByUserData("afflictionstrengthprediction") as GUIProgressBar;
|
||||
afflictionStrengthPredictionBar.BarSize = 0.0f;
|
||||
var afflictionStrengthBar = afflictionStrengthPredictionBar.GetChildByUserData("afflictionstrength") as GUIProgressBar;
|
||||
afflictionStrengthBar.BarSize = affliction.Strength / affliction.Prefab.MaxStrength;
|
||||
afflictionStrengthBar.Color = afflictionEffectColor;
|
||||
|
||||
float afflictionStrengthPrediction = GetAfflictionStrengthPrediction(potentialTreatment, affliction);
|
||||
if (!MathUtils.NearlyEqual(afflictionStrengthPrediction, affliction.Strength))
|
||||
{
|
||||
float t = (float)Math.Max(0.5f, (Math.Sin(Timing.TotalTime * 5) + 1.0f) / 2.0f);
|
||||
if (afflictionStrengthPrediction < affliction.Strength)
|
||||
{
|
||||
afflictionStrengthBar.Color = afflictionEffectColor;
|
||||
afflictionStrengthPredictionBar.Color = GUI.Style.Blue * t;
|
||||
afflictionStrengthPredictionBar.BarSize = afflictionStrengthBar.BarSize;
|
||||
afflictionStrengthBar.BarSize = afflictionStrengthPrediction / affliction.Prefab.MaxStrength;
|
||||
}
|
||||
else
|
||||
{
|
||||
afflictionStrengthPredictionBar.Color = Color.Red * t;
|
||||
afflictionStrengthPredictionBar.BarSize = afflictionStrengthPrediction / affliction.Prefab.MaxStrength;
|
||||
}
|
||||
}
|
||||
|
||||
if (afflictionTooltip != null && afflictionTooltip.UserData == affliction)
|
||||
{
|
||||
UpdateAfflictionInfo(afflictionTooltip.Content, affliction);
|
||||
@@ -1460,6 +1491,32 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private float GetAfflictionStrengthPrediction(Item item, Affliction affliction)
|
||||
{
|
||||
float strength = affliction.Strength;
|
||||
if (item == null) { return strength; }
|
||||
|
||||
foreach (ItemComponent ic in item.Components)
|
||||
{
|
||||
if (ic.statusEffectLists == null) { continue; }
|
||||
if (!ic.statusEffectLists.TryGetValue(ActionType.OnUse, out List<StatusEffect> statusEffects)) { continue; }
|
||||
foreach (StatusEffect effect in statusEffects)
|
||||
{
|
||||
foreach (var reduceAffliction in effect.ReduceAffliction)
|
||||
{
|
||||
if (reduceAffliction.affliction != affliction.Identifier && reduceAffliction.affliction != affliction.Prefab.AfflictionType) { continue; }
|
||||
strength -= reduceAffliction.amount * (effect.Duration > 0 ? effect.Duration : 1.0f);
|
||||
}
|
||||
foreach (var addAffliction in effect.Afflictions)
|
||||
{
|
||||
if (addAffliction.Prefab != affliction.Prefab) { continue; }
|
||||
strength += addAffliction.Strength * (effect.Duration > 0 ? effect.Duration : 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return strength;
|
||||
}
|
||||
|
||||
private void UpdateAfflictionInfo(GUIComponent parent, Affliction affliction)
|
||||
{
|
||||
var labelContainer = parent.GetChildByUserData("label");
|
||||
@@ -1722,13 +1779,6 @@ namespace Barotrauma
|
||||
Color.LightGray * 0.5f, width: 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (draggingMed != null)
|
||||
{
|
||||
GUIImage itemImage = draggingMed.GetChild<GUIImage>();
|
||||
float scale = Math.Min(40.0f / itemImage.Sprite.size.X, 40.0f / itemImage.Sprite.size.Y);
|
||||
itemImage.Sprite.Draw(spriteBatch, PlayerInput.MousePosition, itemImage.Color, 0, scale);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLimbAfflictionIcon(SpriteBatch spriteBatch, Affliction affliction, float iconScale, ref Vector2 iconPos)
|
||||
|
||||
Reference in New Issue
Block a user