* attempt at moving MainViewport to UIWidget * oldchat (prototype) * separate oldchat and default ss14 HUD into their own files * restores original default game screen logic and adds that logic into separated chat game screen * hand reloading, several tweaks to port oldchat to main ss14 branch oldchat is currently not selectable * screen type cvar, gameplay state screen reloading/loading * reload screen on ui layout cvar change * fixes up basic reloading (HUD switching is still very bad) * some UI widget reloading for main UI screen switching * alert sync on screen change * inventory reload * hotbar margin fix * chat bubbles above viewport * whoops * fixes ordering of speech bubble root * should fix the chat focus issue (at least in-game, not lobby yet) * should fix up the lobby/game chat focus * fixes chat for lobby, turns lobby into a UI state * viewport UI controller * viewport ratio selection * whoops * adds the /tg/ widescreen ratio * removes warning from inventory UI controller, adds background to separated chat game screen's chat portion * menu button reload * unload menu buttons only from gameplay state shutdown * bugfix * character button fix * adds config options for viewport width/UI layout * variable naming changes, get or null instead of get to avoid exceptions * moves entity system get into controller
182 lines
5.0 KiB
C#
182 lines
5.0 KiB
C#
using Content.Client.CharacterInfo;
|
|
using Content.Client.Gameplay;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Client.UserInterface.Systems.Character.Controls;
|
|
using Content.Client.UserInterface.Systems.Character.Windows;
|
|
using Content.Client.UserInterface.Systems.Objectives.Controls;
|
|
using Content.Shared.Input;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.Utility;
|
|
using Robust.Shared.Input.Binding;
|
|
using Robust.Shared.Utility;
|
|
using static Content.Client.CharacterInfo.CharacterInfoSystem;
|
|
using static Robust.Client.UserInterface.Controls.BaseButton;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Character;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class CharacterUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CharacterInfoSystem>
|
|
{
|
|
[UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!;
|
|
|
|
private CharacterWindow? _window;
|
|
private MenuButton? CharacterButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.CharacterButton;
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
DebugTools.Assert(_window == null);
|
|
|
|
_window = UIManager.CreateWindow<CharacterWindow>();
|
|
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
|
|
|
|
|
|
|
|
CommandBinds.Builder
|
|
.Bind(ContentKeyFunctions.OpenCharacterMenu,
|
|
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
|
.Register<CharacterUIController>();
|
|
}
|
|
|
|
public void OnStateExited(GameplayState state)
|
|
{
|
|
if (_window != null)
|
|
{
|
|
_window.Dispose();
|
|
_window = null;
|
|
}
|
|
|
|
CommandBinds.Unregister<CharacterUIController>();
|
|
}
|
|
|
|
public void OnSystemLoaded(CharacterInfoSystem system)
|
|
{
|
|
system.OnCharacterUpdate += CharacterUpdated;
|
|
system.OnCharacterDetached += CharacterDetached;
|
|
}
|
|
|
|
public void OnSystemUnloaded(CharacterInfoSystem system)
|
|
{
|
|
system.OnCharacterUpdate -= CharacterUpdated;
|
|
system.OnCharacterDetached -= CharacterDetached;
|
|
}
|
|
|
|
public void UnloadButton()
|
|
{
|
|
if (CharacterButton == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CharacterButton.OnPressed -= CharacterButtonPressed;
|
|
}
|
|
|
|
public void LoadButton()
|
|
{
|
|
if (CharacterButton == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CharacterButton.OnPressed += CharacterButtonPressed;
|
|
|
|
if (_window == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_window.OnClose += DeactivateButton;
|
|
_window.OnOpen += ActivateButton;
|
|
}
|
|
|
|
private void DeactivateButton() => CharacterButton!.Pressed = false;
|
|
private void ActivateButton() => CharacterButton!.Pressed = true;
|
|
|
|
private void CharacterUpdated(CharacterData data)
|
|
{
|
|
if (_window == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var (job, objectives, briefing, sprite, entityName) = data;
|
|
|
|
_window.SubText.Text = job;
|
|
_window.Objectives.RemoveAllChildren();
|
|
|
|
foreach (var (groupId, conditions) in objectives)
|
|
{
|
|
var objectiveControl = new CharacterObjectiveControl
|
|
{
|
|
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
|
Modulate = Color.Gray
|
|
};
|
|
|
|
objectiveControl.AddChild(new Label
|
|
{
|
|
Text = groupId,
|
|
Modulate = Color.LightSkyBlue
|
|
});
|
|
|
|
foreach (var condition in conditions)
|
|
{
|
|
var conditionControl = new ObjectiveConditionsControl();
|
|
conditionControl.ProgressTexture.Texture = condition.SpriteSpecifier.Frame0();
|
|
conditionControl.ProgressTexture.Progress = condition.Progress;
|
|
|
|
conditionControl.Title.Text = condition.Title;
|
|
conditionControl.Description.Text = condition.Description;
|
|
|
|
objectiveControl.AddChild(conditionControl);
|
|
}
|
|
|
|
var briefingControl = new ObjectiveBriefingControl();
|
|
briefingControl.Label.Text = briefing;
|
|
|
|
objectiveControl.AddChild(briefingControl);
|
|
_window.Objectives.AddChild(objectiveControl);
|
|
}
|
|
|
|
_window.SpriteView.Sprite = sprite;
|
|
_window.NameLabel.Text = entityName;
|
|
}
|
|
|
|
private void CharacterDetached()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
|
|
private void CharacterButtonPressed(ButtonEventArgs args)
|
|
{
|
|
ToggleWindow();
|
|
}
|
|
|
|
private void CloseWindow()
|
|
{
|
|
_window!.Close();
|
|
}
|
|
|
|
private void ToggleWindow()
|
|
{
|
|
if (_window == null)
|
|
return;
|
|
|
|
if (CharacterButton != null)
|
|
{
|
|
CharacterButton.Pressed = !_window.IsOpen;
|
|
}
|
|
|
|
if (_window.IsOpen)
|
|
{
|
|
CloseWindow();
|
|
}
|
|
else
|
|
{
|
|
_characterInfo.RequestCharacterInfo();
|
|
_window.Open();
|
|
}
|
|
}
|
|
}
|