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:
Exp
2020-08-29 13:33:38 +02:00
committed by GitHub
parent 1ecf8aad1a
commit b993ebb30a
13 changed files with 61 additions and 37 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
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))
{
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)
{

View File

@@ -8,13 +8,12 @@ namespace Content.Client.UserInterface
/// </summary>
public sealed class StatusEffectsUI : Control
{
public VBoxContainer VBox => _vBox;
private readonly VBoxContainer _vBox;
public VBoxContainer VBox { get; }
public StatusEffectsUI()
{
_vBox = new VBoxContainer();
AddChild(_vBox);
VBox = new VBoxContainer();
AddChild(VBox);
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetAnchorAndMarginPreset(this, LayoutContainer.LayoutPreset.TopRight, margin: 10);

View File

@@ -193,8 +193,14 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
{
if (Owner.TryGetComponent(out ServerStatusEffectsComponent status))
{
status.ChangeStatusEffectIcon(StatusEffect.Cuffed,
CanStillInteract ? "/Textures/Interface/StatusEffects/Handcuffed/Uncuffed.png" : "/Textures/Interface/StatusEffects/Handcuffed/Handcuffed.png");
if (CanStillInteract)
{
status.RemoveStatusEffect(StatusEffect.Cuffed);
}
else
{
status.ChangeStatusEffectIcon(StatusEffect.Cuffed, "/Textures/Interface/StatusEffects/Handcuffed/Handcuffed.png");
}
}
}

View File

@@ -113,10 +113,14 @@ namespace Content.Server.GameObjects.Components.Buckle
{
if (Owner.TryGetComponent(out ServerStatusEffectsComponent? status))
{
status.ChangeStatusEffectIcon(StatusEffect.Buckled,
Buckled
? BuckledTo!.BuckledIcon
: "/Textures/Interface/StatusEffects/Buckle/unbuckled.png");
if (Buckled)
{
status.ChangeStatusEffectIcon(StatusEffect.Buckled, BuckledTo!.BuckledIcon);
}
else
{
status.RemoveStatusEffect(StatusEffect.Buckled);
}
}
}

View File

@@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Buckle;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Players;
@@ -113,6 +114,9 @@ namespace Content.Server.GameObjects.Components.Mobs
hands.StopPull();
break;
default:
player.PopupMessage(player, msg.Effect.ToString());
break;
}
break;

View File

@@ -68,15 +68,12 @@ namespace Content.Server.GameObjects.Components.Nutrition
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 string[] _hungerThresholdImages =
public static readonly Dictionary<HungerThreshold, string> HungerThresholdImages = new Dictionary<HungerThreshold, string>
{
"/Textures/Interface/StatusEffects/Hunger/Overfed.png",
"/Textures/Interface/StatusEffects/Hunger/Okay.png",
"/Textures/Interface/StatusEffects/Hunger/Peckish.png",
"/Textures/Interface/StatusEffects/Hunger/Starving.png",
"/Textures/Interface/StatusEffects/Hunger/Dead.png",
{ HungerThreshold.Overfed, "/Textures/Interface/StatusEffects/Hunger/Overfed.png" },
{ HungerThreshold.Peckish, "/Textures/Interface/StatusEffects/Hunger/Peckish.png" },
{ HungerThreshold.Starving, "/Textures/Interface/StatusEffects/Hunger/Starving.png" },
};
public void HungerThresholdEffect(bool force = false)
@@ -92,7 +89,16 @@ namespace Content.Server.GameObjects.Components.Nutrition
// Update UI
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)
{
case HungerThreshold.Overfed:

View File

@@ -52,8 +52,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
private float _currentThirst;
[ViewVariables(VVAccess.ReadOnly)]
public Dictionary<ThirstThreshold, float> ThirstThresholds => _thirstThresholds;
private readonly Dictionary<ThirstThreshold, float> _thirstThresholds = new Dictionary<ThirstThreshold, float>
public Dictionary<ThirstThreshold, float> ThirstThresholds { get; } = new Dictionary<ThirstThreshold, float>
{
{ThirstThreshold.OverHydrated, 600.0f},
{ThirstThreshold.Okay, 450.0f},
@@ -62,15 +61,11 @@ namespace Content.Server.GameObjects.Components.Nutrition
{ThirstThreshold.Dead, 0.0f},
};
// for shared string dict, since we don't define these anywhere in content
[UsedImplicitly]
public static readonly string[] _thirstThresholdImages =
public static readonly Dictionary<ThirstThreshold, string> ThirstThresholdImages = new Dictionary<ThirstThreshold, string>
{
"/Textures/Interface/StatusEffects/Thirst/OverHydrated.png",
"/Textures/Interface/StatusEffects/Thirst/Okay.png",
"/Textures/Interface/StatusEffects/Thirst/Thirsty.png",
"/Textures/Interface/StatusEffects/Thirst/Parched.png",
"/Textures/Interface/StatusEffects/Thirst/Dead.png",
{ThirstThreshold.OverHydrated, "/Textures/Interface/StatusEffects/Thirst/OverHydrated.png"},
{ThirstThreshold.Thirsty, "/Textures/Interface/StatusEffects/Thirst/Thirsty.png"},
{ThirstThreshold.Parched, "/Textures/Interface/StatusEffects/Thirst/Parched.png"},
};
public override void ExposeData(ObjectSerializer serializer)
@@ -92,8 +87,15 @@ namespace Content.Server.GameObjects.Components.Nutrition
// Update UI
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)
{
@@ -135,8 +137,8 @@ namespace Content.Server.GameObjects.Components.Nutrition
{
base.Startup();
_currentThirst = IoCManager.Resolve<IRobustRandom>().Next(
(int)_thirstThresholds[ThirstThreshold.Thirsty] + 10,
(int)_thirstThresholds[ThirstThreshold.Okay] - 1);
(int)ThirstThresholds[ThirstThreshold.Thirsty] + 10,
(int)ThirstThresholds[ThirstThreshold.Okay] - 1);
_currentThirstThreshold = GetThirstThreshold(_currentThirst);
_lastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
// 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;
var value = ThirstThresholds[ThirstThreshold.OverHydrated];
foreach (var threshold in _thirstThresholds)
foreach (var threshold in ThirstThresholds)
{
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