-
Notifications
You must be signed in to change notification settings - Fork 715
Add dedicated objective editor view for admins #6377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
BarryNorfolk
wants to merge
19
commits into
DeltaV-Station:master
Choose a base branch
from
BarryNorfolk:admin/objective_menu
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6ac79b2
Move ThavenMood admin verb to DV space partial
BarryNorfolk f44ba06
Add initial objective editor
BarryNorfolk 158e068
Hook up admin verb to open new Editor
BarryNorfolk 8fdb586
Start adding Role Type and Subtype information
BarryNorfolk b47c17c
Make issuer configurable at runtime
BarryNorfolk 8eac695
Add objective saving, update UI to include Title/Issuer
BarryNorfolk b42e833
Remove re-rolling
BarryNorfolk d3ead8f
Move issuer information into the ObjectiveData structure
BarryNorfolk bcea3b7
Rework to use tab containers, add texture for icon
BarryNorfolk 731cd86
Add new window for picking sprites
BarryNorfolk 8d4f36b
Update Objective editor to use new sprite picker window and update Icons
BarryNorfolk 4d5f13a
Remove requirement to have objectives
BarryNorfolk 6e0b392
Add a default Icon
BarryNorfolk b4b4330
Rework objective editor to handle bare new events
BarryNorfolk 6b9d386
Remove need for sending RoleType
BarryNorfolk 5114a7f
Completely rewrite it again
BarryNorfolk 8ab197d
Fixup adding objectives
BarryNorfolk 1f9d03b
Add ability to popup to the user when updating objectives
BarryNorfolk 9360526
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
143
Content.Client/_DV/Objectives/Eui/ObjectiveContainer.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untouch