Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public DialogWindow(string title, List<QuickDialogEntry> entries, bool ok = true
protected override void Opened()
{
base.Opened();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untouch

// Grab keyboard focus for the first dialog entry
_promptLines[0].Item2.GrabKeyboardFocus();
}
Expand Down
60 changes: 60 additions & 0 deletions Content.Client/_DV/Objectives/Eui/ObjectiveContainer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<BoxContainer
xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
HorizontalExpand="True"
Orientation="Vertical"
>
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<PanelContainer Margin="5" >
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#1B1B1B"/>
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" SeparationOverride="5">
<BoxContainer Orientation="Horizontal" >
<Label Text="Issuer:" Margin="5"/>
<LineEdit
Name="ObjectiveIssuer"
HorizontalExpand="True"
Margin="5"
/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Text="Title:" Margin="5"/>
<LineEdit
Name="ObjectiveTitle"
HorizontalExpand="True"
Margin="5"
/>
</BoxContainer>
<customControls:HSeparator/>
<Label Text="Description:" Margin="5"/>
<TextEdit
Name="ObjectiveDescription"
HorizontalExpand="True"
VerticalExpand="True"
MinWidth="500"
MinHeight="60"
Margin="5"
/>
</BoxContainer>
</PanelContainer>

<BoxContainer Orientation="Vertical" Align="Center">
<BoxContainer Align="Center">
<PanelContainer>
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#1B1B1B"/>
</PanelContainer.PanelOverride>

<TextureButton Name="IconSelectButton" SetWidth="128" SetHeight="128" />
</PanelContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal" Align="Center" >
<Button Name="ViewButton" Text="{Loc objective-editor-admin-ui-view}" StyleClasses="OpenRight" />
<Button Name="ResetButton" Text="{Loc objective-editor-admin-ui-reset}" StyleClasses="OpenLeft"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
143 changes: 143 additions & 0 deletions Content.Client/_DV/Objectives/Eui/ObjectiveContainer.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using Content.Client._DV.UserInterfaces.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Console;
using Robust.Shared.Utility;

namespace Content.Client._DV.Objectives.Eui;

[GenerateTypedNameReferences]
public sealed partial class ObjectiveContainer : BoxContainer
{
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly IConsoleHost _console = default!;
private readonly SpriteSystem _sprite;

private readonly SpritePickerWindow _spritePicker = new();

private ObjectiveUI? _objective = null;

public ObjectiveContainer()
{
RobustXamlLoader.Load(this);

IoCManager.InjectDependencies(this);
_sprite = _entityManager.System<SpriteSystem>();

_spritePicker.OnSpriteSelected += SetIcon;
ObjectiveTitle.OnTextChanged += OnTitleChanged;
ObjectiveIssuer.OnTextChanged += OnIssuerChanged;

ObjectiveDescription.OnTextChanged += OnDescriptionChanged;
ObjectiveDescription.Placeholder = new Rope.Leaf(Loc.GetString("objective-editor-admin-ui-placeholder-description"));

ResetButton.OnPressed += _ => ResetObjective();
ViewButton.OnPressed += _ => OnViewObjective();
IconSelectButton.OnPressed += _ => OnOpenIconSelect();

ClearData();
}

public bool HasChanges()
{
return _objective?.HasChanges ?? false;
}

public void ClearData()
{
_objective = null;

ObjectiveIssuer.Editable = false;
ObjectiveTitle.Editable = false;
ObjectiveDescription.Editable = false;

ResetButton.Disabled = true;
ViewButton.Disabled = true;
IconSelectButton.Disabled = true;

ObjectiveIssuer.Text = "";
ObjectiveTitle.Text = "";
ObjectiveDescription.TextRope = new Rope.Leaf("");

IconSelectButton.TextureNormal = null;
}

public void SetData(ObjectiveUI data)
{
_objective = data;

ObjectiveIssuer.Editable = true;
ObjectiveTitle.Editable = true;
ObjectiveDescription.Editable = true;

ResetButton.Disabled = false;
ViewButton.Disabled = false;
IconSelectButton.Disabled = false;

ObjectiveIssuer.Text = _objective.Issuer;
ObjectiveTitle.Text = _objective.Title;
ObjectiveDescription.TextRope = new Rope.Leaf(_objective.Description);

IconSelectButton.TextureNormal = _sprite.Frame0(data.Icon);
}

public void ResetObjective()
{
if (_objective is null)
return;

_objective.Reset();
IconSelectButton.TextureNormal = _sprite.Frame0(_objective.Icon);
}

private void OnTitleChanged(LineEdit.LineEditEventArgs args)
{
if (_objective is null)
return;

_objective.Title = args.Text;
}

private void OnIssuerChanged(LineEdit.LineEditEventArgs args)
{
if (_objective is null)
return;

_objective.Issuer = args.Text;
}

private void OnDescriptionChanged(TextEdit.TextEditEventArgs args)
{
if (_objective is null)
return;

_objective.Description = Rope.Collapse(args.TextRope).Trim();
}

private void OnOpenIconSelect()
{
if (_objective is null)
return;

_spritePicker.OpenWithSprite(_objective.Icon);
}

private void OnViewObjective()
{
if (_objective is null)
return;

_console.ExecuteCommand($"vv {_objective.Entity}");
}

private void SetIcon(SpriteSpecifier sprite)
{
if (_objective is null)
return;

IconSelectButton.TextureNormal = _sprite.Frame0(sprite);
_objective.Icon = sprite;
}
}
81 changes: 81 additions & 0 deletions Content.Client/_DV/Objectives/Eui/ObjectiveEditorEui.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Content.Client.Eui;
using Content.Shared._DV.Objectives.Eui;
using Content.Shared.Eui;
using Content.Shared.Mind;
using Robust.Shared.Prototypes;

namespace Content.Client._DV.Objectives.Eui;

public sealed class ObjectiveEditorEui : BaseEui
{
[Dependency] private readonly EntityManager _entityManager = default!;
private readonly ObjectiveEditorUi _editorUi;
private Entity<MindComponent> _targetMind;

public ObjectiveEditorEui()
{
IoCManager.InjectDependencies(this);

_editorUi = new ObjectiveEditorUi();
_editorUi.SaveAction += SaveObjectives;
_editorUi.CreateAction += CreateObjective;
}

public override void Opened()
{
base.Opened();
_editorUi.OpenCentered();
}

public override void HandleState(EuiStateBase state)
{
if (state is not ObjectiveEditorEUIState s)
return;

var mind = _entityManager.GetEntity(s.TargetMind);
if (!_entityManager.TryGetComponent<MindComponent>(mind, out var comp))
{
// TODO: Log
return;
}

_targetMind = (mind, comp);

var name = comp.CharacterName ?? Loc.GetString("objective-editor-admin-ui-unknown-mind");
_editorUi.SetEditorTitle(name, comp.RoleType, s.Subtype);
_editorUi.SetObjectives(s.Objectives);
}

public override void HandleMessage(EuiMessageBase msg)
{
base.HandleMessage(msg);

switch (msg)
{
case ObjectiveEditorCreateResponse message:
HandleCreateResponse(message);
break;
}
}

private void HandleCreateResponse(ObjectiveEditorCreateResponse response)
{
if (response.Data == null)
{
// TODO(Barry): Logging
return;
}

_editorUi.AddObjective(response.Data);
}

private void SaveObjectives(bool silentSave)
{
SendMessage(new ObjectiveEditorSaveMessage(_editorUi.GetObjectives(), _entityManager.GetNetEntity(_targetMind), silentSave));
}

private void CreateObjective(EntProtoId? proto)
{
SendMessage(new ObjectiveEditorCreateMessage(proto));
}
}
43 changes: 43 additions & 0 deletions Content.Client/_DV/Objectives/Eui/ObjectiveEditorUi.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:obj="clr-namespace:Content.Client._DV.Objectives.Eui"
Title="{Loc objective-editor-admin-ui-title}"
MinSize="800 400"
>
<BoxContainer Orientation="Vertical" >
<BoxContainer Orientation="Horizontal" Align="End">
<CheckBox
Name="SilentSave"
Text="{Loc objective-editor-admin-ui-silent-save}"
ToolTip="{Loc objective-editor-admin-ui-silent-save-tooltip}"
Margin="5 0 5 0"/>
<controls:ConfirmButton
Name="ResetButton"
Text="{Loc objective-editor-admin-ui-reset-all}"
StyleClasses="OpenRight"
ModulateSelfOverride="Red" />
<controls:ConfirmButton
Name="SaveButton"
Text="{Loc objective-editor-admin-ui-save}"
StyleClasses="OpenLeft"/>
</BoxContainer>

<customControls:HSeparator Margin = "5"/>

<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<BoxContainer Orientation="Vertical" MinWidth="200" Margin="5">
<ItemList Name="ObjectiveList" VerticalExpand="True" HorizontalExpand="True" />
<BoxContainer Orientation="Horizontal" >
<Button Name="AddButton" Text="+" StyleClasses="OpenRight" />
<controls:ConfirmButton Name="RemoveButton" Text="-" StyleClasses="OpenLeft" ModulateSelfOverride="Red"/>
</BoxContainer>
</BoxContainer>
<obj:ObjectiveContainer Name="Container"/>
</BoxContainer>

<customControls:HSeparator />
<Label Text="{Loc objective-editor-admin-ui-check-note}" FontColorOverride="Red" Align="Center"/>
</BoxContainer>
</controls:FancyWindow>
Loading
Loading