Objectives (#2459)
* temp commit to save progress * adds objectives * refactors mind.addobjective a bit * better names for my testobjectives which i'll remove later on anyways * nullable errors * some misc fixes * no sorted or set, what was i thinking here? * removes unused imports * added commands * fully implements stealcondition * started uiwork * moved prototypeicon to engine * removes objective class & uiwork * refactors ui to only update when opened adds progresstexturerect * adds some margin * removes some testing code * ignores objectiveprototypes on clientside * fixes * removes using statements for exp * gets the job * always show issuer * locs & _ * giving commands some love * Update Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterBar.cs Co-authored-by: Exp <theexp111@gmail.com> * makes commands use new thingy * string interpolation * good catch exp * loc'd * linq gone * runtime * moves function from engine * oopsie * Update Content.Server/Objectives/Conditions/StealCondition.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * makes messages directed * base call & validation * shuffle once * No? Money down! Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: Exp <theexp111@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
#nullable enable
|
||||
using System.Drawing;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Shared.GameObjects.Components.Actor;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Actor
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class CharacterInfoComponent : Component, ICharacterUI
|
||||
public sealed class CharacterInfoComponent : SharedCharacterInfoComponent, ICharacterUI
|
||||
{
|
||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||
|
||||
private CharacterInfoControl _control;
|
||||
private CharacterInfoControl _control = default!;
|
||||
|
||||
public override string Name => "CharacterInfo";
|
||||
|
||||
public Control Scene { get; private set; }
|
||||
public Control Scene { get; private set; } = default!;
|
||||
public UIPriority Priority => UIPriority.Info;
|
||||
|
||||
public override void OnAdd()
|
||||
@@ -30,18 +34,29 @@ namespace Content.Client.GameObjects.Components.Actor
|
||||
Scene = _control = new CharacterInfoControl(_resourceCache);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
public void Opened()
|
||||
{
|
||||
base.Initialize();
|
||||
SendNetworkMessage(new RequestCharacterInfoMessage());
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out ISpriteComponent spriteComponent))
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
|
||||
{
|
||||
base.HandleNetworkMessage(message, netChannel, session);
|
||||
|
||||
if(session?.AttachedEntity != Owner) return;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
_control.SpriteView.Sprite = spriteComponent;
|
||||
}
|
||||
case CharacterInfoMessage characterInfoMessage:
|
||||
_control.UpdateUI(characterInfoMessage);
|
||||
if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent))
|
||||
{
|
||||
_control.SpriteView.Sprite = spriteComponent;
|
||||
}
|
||||
|
||||
_control.NameLabel.Text = Owner.Name;
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
_control.SubText.Text = Loc.GetString("Professional Greyshirt");
|
||||
_control.NameLabel.Text = Owner.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class CharacterInfoControl : VBoxContainer
|
||||
@@ -50,8 +65,12 @@ namespace Content.Client.GameObjects.Components.Actor
|
||||
public Label NameLabel { get; }
|
||||
public Label SubText { get; }
|
||||
|
||||
public VBoxContainer ObjectivesContainer { get; }
|
||||
|
||||
public CharacterInfoControl(IResourceCache resourceCache)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
AddChild(new HBoxContainer
|
||||
{
|
||||
Children =
|
||||
@@ -66,7 +85,8 @@ namespace Content.Client.GameObjects.Components.Actor
|
||||
(SubText = new Label
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.None,
|
||||
StyleClasses = {StyleNano.StyleClassLabelSubText}
|
||||
StyleClasses = {StyleNano.StyleClassLabelSubText},
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -78,16 +98,65 @@ namespace Content.Client.GameObjects.Components.Actor
|
||||
PlaceholderText = Loc.GetString("Health & status effects")
|
||||
});
|
||||
|
||||
AddChild(new Placeholder(resourceCache)
|
||||
AddChild(new Label
|
||||
{
|
||||
PlaceholderText = Loc.GetString("Objectives")
|
||||
Text = Loc.GetString("Objectives"),
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
|
||||
});
|
||||
ObjectivesContainer = new VBoxContainer();
|
||||
AddChild(ObjectivesContainer);
|
||||
|
||||
AddChild(new Placeholder(resourceCache)
|
||||
{
|
||||
PlaceholderText = Loc.GetString("Antagonist Roles")
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateUI(CharacterInfoMessage characterInfoMessage)
|
||||
{
|
||||
SubText.Text = characterInfoMessage.JobTitle;
|
||||
|
||||
ObjectivesContainer.RemoveAllChildren();
|
||||
foreach (var (groupId, objectiveConditions) in characterInfoMessage.Objectives)
|
||||
{
|
||||
var vbox = new VBoxContainer
|
||||
{
|
||||
Modulate = Color.Gray
|
||||
};
|
||||
|
||||
vbox.AddChild(new Label
|
||||
{
|
||||
Text = groupId,
|
||||
Modulate = Color.LightSkyBlue
|
||||
});
|
||||
|
||||
foreach (var objectiveCondition in objectiveConditions)
|
||||
{
|
||||
var hbox = new HBoxContainer();
|
||||
hbox.AddChild(new ProgressTextureRect
|
||||
{
|
||||
Texture = objectiveCondition.SpriteSpecifier.Frame0(),
|
||||
Progress = objectiveCondition.Progress,
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||
});
|
||||
hbox.AddChild(new Control
|
||||
{
|
||||
CustomMinimumSize = (10,0)
|
||||
});
|
||||
hbox.AddChild(new VBoxContainer
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new Label{Text = objectiveCondition.Title},
|
||||
new Label{Text = objectiveCondition.Description}
|
||||
}
|
||||
}
|
||||
);
|
||||
vbox.AddChild(hbox);
|
||||
}
|
||||
ObjectivesContainer.AddChild(vbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user