Status Effect Tooltip & Notify on click (#1943)
* -Show tooltip on hover -Show notify on click * -Status Effects now get removed instead of going invisible -Removed empty textures for that * Revert break in HungerComponent
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
@@ -100,7 +100,10 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
foreach (var (key, effect) in _status.OrderBy(x => (int) x.Key))
|
foreach (var (key, effect) in _status.OrderBy(x => (int) x.Key))
|
||||||
{
|
{
|
||||||
var texture = _resourceCache.GetTexture(effect.Icon);
|
var texture = _resourceCache.GetTexture(effect.Icon);
|
||||||
var status = new StatusControl(key, texture);
|
var status = new StatusControl(key, texture)
|
||||||
|
{
|
||||||
|
ToolTip = key.ToString()
|
||||||
|
};
|
||||||
|
|
||||||
if (effect.Cooldown.HasValue)
|
if (effect.Cooldown.HasValue)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ namespace Content.Client.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class StatusEffectsUI : Control
|
public sealed class StatusEffectsUI : Control
|
||||||
{
|
{
|
||||||
public VBoxContainer VBox => _vBox;
|
public VBoxContainer VBox { get; }
|
||||||
private readonly VBoxContainer _vBox;
|
|
||||||
|
|
||||||
public StatusEffectsUI()
|
public StatusEffectsUI()
|
||||||
{
|
{
|
||||||
_vBox = new VBoxContainer();
|
VBox = new VBoxContainer();
|
||||||
AddChild(_vBox);
|
AddChild(VBox);
|
||||||
|
|
||||||
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
|
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
|
||||||
LayoutContainer.SetAnchorAndMarginPreset(this, LayoutContainer.LayoutPreset.TopRight, margin: 10);
|
LayoutContainer.SetAnchorAndMarginPreset(this, LayoutContainer.LayoutPreset.TopRight, margin: 10);
|
||||||
|
|||||||
@@ -193,8 +193,14 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
|
|||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out ServerStatusEffectsComponent status))
|
if (Owner.TryGetComponent(out ServerStatusEffectsComponent status))
|
||||||
{
|
{
|
||||||
status.ChangeStatusEffectIcon(StatusEffect.Cuffed,
|
if (CanStillInteract)
|
||||||
CanStillInteract ? "/Textures/Interface/StatusEffects/Handcuffed/Uncuffed.png" : "/Textures/Interface/StatusEffects/Handcuffed/Handcuffed.png");
|
{
|
||||||
|
status.RemoveStatusEffect(StatusEffect.Cuffed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.ChangeStatusEffectIcon(StatusEffect.Cuffed, "/Textures/Interface/StatusEffects/Handcuffed/Handcuffed.png");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,10 +113,14 @@ namespace Content.Server.GameObjects.Components.Buckle
|
|||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out ServerStatusEffectsComponent? status))
|
if (Owner.TryGetComponent(out ServerStatusEffectsComponent? status))
|
||||||
{
|
{
|
||||||
status.ChangeStatusEffectIcon(StatusEffect.Buckled,
|
if (Buckled)
|
||||||
Buckled
|
{
|
||||||
? BuckledTo!.BuckledIcon
|
status.ChangeStatusEffectIcon(StatusEffect.Buckled, BuckledTo!.BuckledIcon);
|
||||||
: "/Textures/Interface/StatusEffects/Buckle/unbuckled.png");
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.RemoveStatusEffect(StatusEffect.Buckled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Buckle;
|
using Content.Server.GameObjects.Components.Buckle;
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Content.Shared.Interfaces;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
@@ -113,6 +114,9 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
|
|
||||||
hands.StopPull();
|
hands.StopPull();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
player.PopupMessage(player, msg.Effect.ToString());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -68,15 +68,12 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
serializer.DataField(ref _baseDecayRate, "base_decay_rate", 0.1f);
|
serializer.DataField(ref _baseDecayRate, "base_decay_rate", 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for shared string dict, since we don't define these anywhere in content
|
|
||||||
[UsedImplicitly]
|
public static readonly Dictionary<HungerThreshold, string> HungerThresholdImages = new Dictionary<HungerThreshold, string>
|
||||||
public static readonly string[] _hungerThresholdImages =
|
|
||||||
{
|
{
|
||||||
"/Textures/Interface/StatusEffects/Hunger/Overfed.png",
|
{ HungerThreshold.Overfed, "/Textures/Interface/StatusEffects/Hunger/Overfed.png" },
|
||||||
"/Textures/Interface/StatusEffects/Hunger/Okay.png",
|
{ HungerThreshold.Peckish, "/Textures/Interface/StatusEffects/Hunger/Peckish.png" },
|
||||||
"/Textures/Interface/StatusEffects/Hunger/Peckish.png",
|
{ HungerThreshold.Starving, "/Textures/Interface/StatusEffects/Hunger/Starving.png" },
|
||||||
"/Textures/Interface/StatusEffects/Hunger/Starving.png",
|
|
||||||
"/Textures/Interface/StatusEffects/Hunger/Dead.png",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void HungerThresholdEffect(bool force = false)
|
public void HungerThresholdEffect(bool force = false)
|
||||||
@@ -92,7 +89,16 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
Owner.TryGetComponent(out ServerStatusEffectsComponent statusEffectsComponent);
|
Owner.TryGetComponent(out ServerStatusEffectsComponent statusEffectsComponent);
|
||||||
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Hunger, _hungerThresholdImages[ (int)_currentHungerThreshold ]);
|
|
||||||
|
if (HungerThresholdImages.TryGetValue(_currentHungerThreshold, out var statusTexture))
|
||||||
|
{
|
||||||
|
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Hunger, statusTexture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statusEffectsComponent?.RemoveStatusEffect(StatusEffect.Hunger);
|
||||||
|
}
|
||||||
|
|
||||||
switch (_currentHungerThreshold)
|
switch (_currentHungerThreshold)
|
||||||
{
|
{
|
||||||
case HungerThreshold.Overfed:
|
case HungerThreshold.Overfed:
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
private float _currentThirst;
|
private float _currentThirst;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public Dictionary<ThirstThreshold, float> ThirstThresholds => _thirstThresholds;
|
public Dictionary<ThirstThreshold, float> ThirstThresholds { get; } = new Dictionary<ThirstThreshold, float>
|
||||||
private readonly Dictionary<ThirstThreshold, float> _thirstThresholds = new Dictionary<ThirstThreshold, float>
|
|
||||||
{
|
{
|
||||||
{ThirstThreshold.OverHydrated, 600.0f},
|
{ThirstThreshold.OverHydrated, 600.0f},
|
||||||
{ThirstThreshold.Okay, 450.0f},
|
{ThirstThreshold.Okay, 450.0f},
|
||||||
@@ -62,15 +61,11 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
{ThirstThreshold.Dead, 0.0f},
|
{ThirstThreshold.Dead, 0.0f},
|
||||||
};
|
};
|
||||||
|
|
||||||
// for shared string dict, since we don't define these anywhere in content
|
public static readonly Dictionary<ThirstThreshold, string> ThirstThresholdImages = new Dictionary<ThirstThreshold, string>
|
||||||
[UsedImplicitly]
|
|
||||||
public static readonly string[] _thirstThresholdImages =
|
|
||||||
{
|
{
|
||||||
"/Textures/Interface/StatusEffects/Thirst/OverHydrated.png",
|
{ThirstThreshold.OverHydrated, "/Textures/Interface/StatusEffects/Thirst/OverHydrated.png"},
|
||||||
"/Textures/Interface/StatusEffects/Thirst/Okay.png",
|
{ThirstThreshold.Thirsty, "/Textures/Interface/StatusEffects/Thirst/Thirsty.png"},
|
||||||
"/Textures/Interface/StatusEffects/Thirst/Thirsty.png",
|
{ThirstThreshold.Parched, "/Textures/Interface/StatusEffects/Thirst/Parched.png"},
|
||||||
"/Textures/Interface/StatusEffects/Thirst/Parched.png",
|
|
||||||
"/Textures/Interface/StatusEffects/Thirst/Dead.png",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
@@ -92,8 +87,15 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
Owner.TryGetComponent(out ServerStatusEffectsComponent statusEffectsComponent);
|
Owner.TryGetComponent(out ServerStatusEffectsComponent statusEffectsComponent);
|
||||||
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Thirst, "/Textures/Interface/StatusEffects/Thirst/" +
|
|
||||||
_currentThirstThreshold + ".png");
|
if (ThirstThresholdImages.TryGetValue(_currentThirstThreshold, out var statusTexture))
|
||||||
|
{
|
||||||
|
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Thirst, statusTexture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statusEffectsComponent?.RemoveStatusEffect(StatusEffect.Thirst);
|
||||||
|
}
|
||||||
|
|
||||||
switch (_currentThirstThreshold)
|
switch (_currentThirstThreshold)
|
||||||
{
|
{
|
||||||
@@ -135,8 +137,8 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
{
|
{
|
||||||
base.Startup();
|
base.Startup();
|
||||||
_currentThirst = IoCManager.Resolve<IRobustRandom>().Next(
|
_currentThirst = IoCManager.Resolve<IRobustRandom>().Next(
|
||||||
(int)_thirstThresholds[ThirstThreshold.Thirsty] + 10,
|
(int)ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
||||||
(int)_thirstThresholds[ThirstThreshold.Okay] - 1);
|
(int)ThirstThresholds[ThirstThreshold.Okay] - 1);
|
||||||
_currentThirstThreshold = GetThirstThreshold(_currentThirst);
|
_currentThirstThreshold = GetThirstThreshold(_currentThirst);
|
||||||
_lastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
_lastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
||||||
// TODO: Check all thresholds make sense and throw if they don't.
|
// TODO: Check all thresholds make sense and throw if they don't.
|
||||||
@@ -148,7 +150,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
{
|
{
|
||||||
ThirstThreshold result = ThirstThreshold.Dead;
|
ThirstThreshold result = ThirstThreshold.Dead;
|
||||||
var value = ThirstThresholds[ThirstThreshold.OverHydrated];
|
var value = ThirstThresholds[ThirstThreshold.OverHydrated];
|
||||||
foreach (var threshold in _thirstThresholds)
|
foreach (var threshold in ThirstThresholds)
|
||||||
{
|
{
|
||||||
if (threshold.Value <= value && threshold.Value >= drink)
|
if (threshold.Value <= value && threshold.Value >= drink)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Binary file not shown.
|
Before Width: | Height: | Size: 97 B |
Reference in New Issue
Block a user