Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,159 @@
using Content.Client.CharacterInterface;
using Content.Client.HUD.UI;
using Content.Client.Stylesheets;
using Content.Shared.CharacterInfo;
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Players;
namespace Content.Client.CharacterInfo.Components
{
[RegisterComponent]
public sealed class CharacterInfoComponent : SharedCharacterInfoComponent, ICharacterUI
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
private CharacterInfoControl _control = default!;
public Control Scene { get; private set; } = default!;
public UIPriority Priority => UIPriority.Info;
public override void OnAdd()
{
base.OnAdd();
Scene = _control = new CharacterInfoControl(_resourceCache);
}
public void Opened()
{
SendNetworkMessage(new RequestCharacterInfoMessage());
}
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
{
base.HandleNetworkMessage(message, netChannel, session);
switch (message)
{
case CharacterInfoMessage characterInfoMessage:
_control.UpdateUI(characterInfoMessage);
if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent))
{
_control.SpriteView.Sprite = spriteComponent;
}
_control.NameLabel.Text = Owner.Name;
break;
}
}
private sealed class CharacterInfoControl : VBoxContainer
{
public SpriteView SpriteView { get; }
public Label NameLabel { get; }
public Label SubText { get; }
public VBoxContainer ObjectivesContainer { get; }
public CharacterInfoControl(IResourceCache resourceCache)
{
IoCManager.InjectDependencies(this);
AddChild(new HBoxContainer
{
Children =
{
(SpriteView = new SpriteView { Scale = (2, 2)}),
new VBoxContainer
{
VerticalAlignment = VAlignment.Top,
Children =
{
(NameLabel = new Label()),
(SubText = new Label
{
VerticalAlignment = VAlignment.Top,
StyleClasses = {StyleNano.StyleClassLabelSubText},
})
}
}
}
});
AddChild(new Placeholder()
{
PlaceholderText = Loc.GetString("Health & status effects")
});
AddChild(new Label
{
Text = Loc.GetString("Objectives"),
HorizontalAlignment = HAlignment.Center
});
ObjectivesContainer = new VBoxContainer();
AddChild(ObjectivesContainer);
AddChild(new Placeholder()
{
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,
VerticalAlignment = VAlignment.Center
});
hbox.AddChild(new Control
{
MinSize = (10,0)
});
hbox.AddChild(new VBoxContainer
{
Children =
{
new Label{Text = objectiveCondition.Title},
new Label{Text = objectiveCondition.Description}
}
}
);
vbox.AddChild(hbox);
}
ObjectivesContainer.AddChild(vbox);
}
}
}
}
}

View File

@@ -0,0 +1,26 @@
using Content.Client.CharacterInterface;
using Robust.Client.UserInterface;
namespace Content.Client.CharacterInfo.Components
{
/// <summary>
/// An interface which is gathered to assemble the character window from multiple components
/// </summary>
public interface ICharacterUI
{
/// <summary>
/// The control which holds the character user interface to be included in the window
/// </summary>
Control Scene { get; }
/// <summary>
/// The order it will appear in the character UI, higher is lower
/// </summary>
UIPriority Priority { get; }
/// <summary>
/// Called when the CharacterUi was opened
/// </summary>
void Opened(){}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using Content.Client.DoAfter.UI;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
namespace Content.Client.CharacterInfo
{
public class ProgressTextureRect : TextureRect
{
public float Progress;
protected override void Draw(DrawingHandleScreen handle)
{
var dims = Texture != null ? GetDrawDimensions(Texture) : UIBox2.FromDimensions(Vector2.Zero, PixelSize);
dims.Top = Math.Max(dims.Bottom - dims.Bottom * Progress,0);
handle.DrawRect(dims, DoAfterHelpers.GetProgressColor(Progress));
base.Draw(handle);
}
}
}