-
Notifications
You must be signed in to change notification settings - Fork 110
Ивентовый контент #545
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
Open
XxRaay
wants to merge
10
commits into
imperial-space:develop
Choose a base branch
from
XxRaay:animatronic
base: develop
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.
Open
Ивентовый контент #545
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0b1f88d
feat(Animatronics): Implement animatronic controller and waypoints
XxRaay b2e0db6
refactor(Animatronics): Remove AnimatronicRuntimeComponent and stream…
XxRaay f6f4bae
Merge remote-tracking branch 'upstream/develop' into animatronic
XxRaay 137c914
Update
XxRaay bb476de
fix
XxRaay 025bcda
Merge remote-tracking branch 'upstream/develop' into animatronic
XxRaay 3cbd80f
Merge remote-tracking branch 'upstream/develop' into animatronic
XxRaay d4b7541
refactor animatronic controller and networking robustness
XxRaay 26aa1bc
fix animatronic build breaks from incorrect namespaces
XxRaay 7802300
Merge pull request #2 from XxRaay/codex/perform-code-review-and-refac…
XxRaay 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Content.Client/Imperial/XxRaay/UI/AnimatronicControllerBoundUserInterface.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,58 @@ | ||
| using Content.Shared.Imperial.XxRaay.Components; | ||
| using Robust.Client.UserInterface; | ||
|
|
||
| namespace Content.Client.Imperial.XxRaay.UI; | ||
|
|
||
| public sealed class AnimatronicControllerBoundUserInterface : BoundUserInterface | ||
| { | ||
| [ViewVariables] | ||
| private AnimatronicControllerWindow? _window; | ||
|
|
||
| public AnimatronicControllerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
| { | ||
| } | ||
|
|
||
| protected override void Open() | ||
| { | ||
| base.Open(); | ||
|
|
||
| _window = this.CreateWindow<AnimatronicControllerWindow>(); | ||
|
|
||
| _window.OnAnimatronicWaypointSelected += (animEntity, wpEntity) => | ||
| { | ||
| SendMessage(new SetAnimatronicTargetEvent(animEntity, wpEntity)); | ||
| }; | ||
|
|
||
| _window.OnAnimatronicClearTarget += (animEntity) => | ||
| { | ||
| SendMessage(new SetAnimatronicTargetEvent(animEntity, true)); | ||
| }; | ||
|
|
||
| _window.OnAnimatronicObserving += (animEntity) => | ||
| { | ||
| SendMessage(new SetAnimatronicObservingEvent(animEntity)); | ||
| }; | ||
|
|
||
| SendMessage(new RequestAnimDataEvent()); | ||
| } | ||
|
|
||
| protected override void UpdateState(BoundUserInterfaceState state) | ||
| { | ||
| base.UpdateState(state); | ||
|
|
||
| if (state is AnimDataStateEvent animState) | ||
| { | ||
| _window?.UpdateState(animState); | ||
| } | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) | ||
| { | ||
| base.Dispose(disposing); | ||
| if (disposing) | ||
| { | ||
| _window?.Dispose(); | ||
| } | ||
| } | ||
| } | ||
|
|
15 changes: 15 additions & 0 deletions
15
Content.Client/Imperial/XxRaay/UI/AnimatronicControllerWindow.xaml
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,15 @@ | ||
| <i:BaseImperialWindow | ||
| xmlns="https://spacestation14.io" | ||
| xmlns:i="clr-namespace:Content.Client.Imperial.UI.Windows.BaseImperialWindow" | ||
| xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
| xmlns:ac="clr-namespace:Content.Client.Imperial.XxRaay.UI" | ||
| HeaderText="{Loc animatronic-controller-window-title}" | ||
| MinSize="700 400" | ||
| SetSize="800 450" | ||
| Resizable="True"> | ||
| <BoxContainer Name="Contents" Access="Public" Orientation="Vertical" Margin="20 20 20 20"> | ||
| <ScrollContainer VerticalExpand="True" MinHeight="300"> | ||
| <BoxContainer Name="AnimatronicsList" Access="Public" Orientation="Vertical" SeparationOverride="10" /> | ||
| </ScrollContainer> | ||
| </BoxContainer> | ||
| </i:BaseImperialWindow> | ||
289 changes: 289 additions & 0 deletions
289
Content.Client/Imperial/XxRaay/UI/AnimatronicControllerWindow.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,289 @@ | ||
| using System.Collections.Generic; | ||
| using System.Numerics; | ||
| using Content.Client.Imperial.UI.Windows.BaseImperialWindow; | ||
| using Robust.Client.GameObjects; | ||
| using Content.Shared.Imperial.XxRaay.Components; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.Graphics; | ||
| using Robust.Client.UserInterface.Controls; | ||
| using Robust.Client.UserInterface.XAML; | ||
| using Robust.Shared.Localization; | ||
| using Robust.Shared.Maths; | ||
| using Robust.Shared.Network; | ||
|
|
||
| namespace Content.Client.Imperial.XxRaay.UI; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class AnimatronicControllerWindow : BaseImperialWindow | ||
| { | ||
| [Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
|
||
| public event Action<NetEntity, NetEntity>? OnAnimatronicWaypointSelected; | ||
| public event Action<NetEntity>? OnAnimatronicClearTarget; | ||
| public event Action<NetEntity>? OnAnimatronicObserving; | ||
|
|
||
| private readonly Dictionary<Button, Color> _buttonOriginalColors = new(); | ||
|
|
||
| public AnimatronicControllerWindow() | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
| IoCManager.InjectDependencies(this); | ||
| } | ||
|
|
||
| public void UpdateState(AnimDataStateEvent state) | ||
| { | ||
| AnimatronicsList.RemoveAllChildren(); | ||
| _buttonOriginalColors.Clear(); | ||
|
|
||
| foreach (var anim in state.Animatronics) | ||
| { | ||
| var card = CreateAnimatronicCard(anim, state.Waypoints); | ||
| AnimatronicsList.AddChild(card); | ||
| } | ||
| } | ||
|
|
||
| private PanelContainer CreateAnimatronicCard(AnimDto anim, IReadOnlyList<WaypointDto> waypoints) | ||
| { | ||
| var card = new PanelContainer | ||
| { | ||
| StyleClasses = { "AngleRectPass" }, | ||
| HorizontalExpand = true, | ||
| Margin = new Thickness(0, 0, 0, 5) | ||
| }; | ||
|
|
||
| var cardContent = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
| Margin = new Thickness(10, 10, 10, 10), | ||
| SeparationOverride = 0, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var spritePanel = new PanelContainer | ||
| { | ||
| PanelOverride = new StyleBoxFlat | ||
| { | ||
| BackgroundColor = Color.FromHex("#2A2A2A") | ||
| }, | ||
| VerticalExpand = true | ||
| }; | ||
|
|
||
| var spriteView = new SpriteView | ||
| { | ||
| OverrideDirection = Direction.South, | ||
| Scale = new Vector2(5f, 5f), | ||
| SetSize = new Vector2(96, 96), | ||
| Margin = new Thickness(5, 5, 5, 5), | ||
| VerticalExpand = true, | ||
| VerticalAlignment = VAlignment.Center | ||
| }; | ||
|
|
||
| var entity = _entityManager.GetEntity(anim.Entity); | ||
| if (entity.Valid) | ||
| { | ||
| spriteView.SetEntity(entity); | ||
| } | ||
|
Comment on lines
+81
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Нет обработки случая невалидной entity. Если 🤖 Prompt for AI Agents |
||
|
|
||
| spritePanel.AddChild(spriteView); | ||
|
|
||
| var nameStatusPanel = new PanelContainer | ||
| { | ||
| PanelOverride = new StyleBoxFlat | ||
| { | ||
| BackgroundColor = Color.FromHex("#333333") | ||
| }, | ||
| HorizontalExpand = true, | ||
| VerticalExpand = true | ||
| }; | ||
|
|
||
| var nameStatusContent = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
| Margin = new Thickness(5, 5, 5, 5), | ||
| SeparationOverride = 10, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var nameStatusContainer = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Vertical, | ||
| VerticalExpand = true, | ||
| VerticalAlignment = VAlignment.Center | ||
| }; | ||
|
|
||
| var nameLabel = new Label | ||
| { | ||
| Text = anim.DisplayName, | ||
| StyleClasses = { "LabelSubTextPassExtraBoldServerName" }, | ||
| ModulateSelfOverride = Color.White | ||
| }; | ||
|
|
||
| var statusContainer = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
| SeparationOverride = 3 | ||
| }; | ||
|
|
||
| if (anim.CurrentWaypointId != null) | ||
| { | ||
| var dotsLabel = new Label | ||
| { | ||
| Text = Loc.GetString("animatronic-controller-waypoint-separator"), | ||
| StyleClasses = { "LabelSubTextPassMediumBuy" }, | ||
| ModulateSelfOverride = Color.FromHex("#FFD700"), | ||
| VerticalAlignment = VAlignment.Center, | ||
| Margin = new Thickness(0, 0, 3, 0) | ||
| }; | ||
|
|
||
| var waypointLabel = new Label | ||
| { | ||
| Text = anim.CurrentWaypointId, | ||
| StyleClasses = { "LabelSubTextPassMediumBuy" }, | ||
| ModulateSelfOverride = Color.FromHex("#FFD700"), | ||
| VerticalAlignment = VAlignment.Center | ||
| }; | ||
|
|
||
| statusContainer.AddChild(dotsLabel); | ||
| statusContainer.AddChild(waypointLabel); | ||
| } | ||
| else | ||
| { | ||
| var statusLabel = new Label | ||
| { | ||
| Text = Loc.GetString("animatronic-controller-status-idle"), | ||
| StyleClasses = { "LabelSubTextPassMediumBuy" }, | ||
| ModulateSelfOverride = Color.FromHex("#888888") | ||
| }; | ||
| statusContainer.AddChild(statusLabel); | ||
| } | ||
|
|
||
| nameStatusContainer.AddChild(nameLabel); | ||
| nameStatusContainer.AddChild(statusContainer); | ||
|
|
||
| var waypointButtonsContent = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
| SeparationOverride = 5, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var waypointGrid = new GridContainer | ||
| { | ||
| Columns = 2, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| foreach (var wp in waypoints) | ||
| { | ||
| var isActive = anim.CurrentWaypointId == wp.WaypointId; | ||
| var wpButton = new Button | ||
| { | ||
| Text = wp.WaypointId, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var originalColor = isActive ? Color.FromHex("#4CAF50") : Color.FromHex("#888888"); | ||
| _buttonOriginalColors[wpButton] = originalColor; | ||
| wpButton.ModulateSelfOverride = originalColor; | ||
|
|
||
| wpButton.StyleClasses.Add("ButtonOpenBoth"); | ||
|
|
||
| var animEntity = anim.Entity; | ||
| var wpEntity = wp.Entity; | ||
|
|
||
| wpButton.OnPressed += _ => | ||
| { | ||
| OnAnimatronicWaypointSelected?.Invoke(animEntity, wpEntity); | ||
| }; | ||
|
|
||
| wpButton.OnMouseEntered += _ => | ||
| { | ||
| if (!isActive) | ||
| wpButton.ModulateSelfOverride = Color.FromHex("#AAAAAA"); | ||
| }; | ||
|
|
||
| wpButton.OnMouseExited += _ => | ||
| { | ||
| if (!isActive && _buttonOriginalColors.TryGetValue(wpButton, out var original)) | ||
| wpButton.ModulateSelfOverride = original; | ||
| }; | ||
|
|
||
| waypointGrid.AddChild(wpButton); | ||
| } | ||
|
|
||
| var buttonsContainer = new BoxContainer | ||
| { | ||
| Orientation = BoxContainer.LayoutOrientation.Vertical, | ||
| SeparationOverride = 5, | ||
| VerticalExpand = true | ||
| }; | ||
|
|
||
| var clearButton = new Button | ||
| { | ||
| Text = Loc.GetString("animatronic-controller-button-clear"), | ||
| StyleClasses = { "ButtonOpenBoth" }, | ||
| ModulateSelfOverride = Color.FromHex("#FF4444"), | ||
| VerticalExpand = true, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var clearButtonOriginalColor = Color.FromHex("#FF4444"); | ||
| var animEntityForClear = anim.Entity; | ||
| clearButton.OnPressed += _ => | ||
| { | ||
| OnAnimatronicClearTarget?.Invoke(animEntityForClear); | ||
| }; | ||
|
|
||
| clearButton.OnMouseEntered += _ => | ||
| { | ||
| clearButton.ModulateSelfOverride = Color.FromHex("#FF6666"); | ||
| }; | ||
|
|
||
| clearButton.OnMouseExited += _ => | ||
| { | ||
| clearButton.ModulateSelfOverride = clearButtonOriginalColor; | ||
| }; | ||
|
|
||
| var observingButton = new Button | ||
| { | ||
| Text = Loc.GetString("animatronic-controller-button-observing"), | ||
| StyleClasses = { "ButtonOpenBoth" }, | ||
| ModulateSelfOverride = Color.FromHex("#4A90E2"), | ||
| VerticalExpand = true, | ||
| HorizontalExpand = true | ||
| }; | ||
|
|
||
| var observingButtonOriginalColor = Color.FromHex("#4A90E2"); | ||
| var animEntityForObserving = anim.Entity; | ||
| observingButton.OnPressed += _ => | ||
| { | ||
| OnAnimatronicObserving?.Invoke(animEntityForObserving); | ||
| }; | ||
|
|
||
| observingButton.OnMouseEntered += _ => | ||
| { | ||
| observingButton.ModulateSelfOverride = Color.FromHex("#6BA3E8"); | ||
| }; | ||
|
|
||
| observingButton.OnMouseExited += _ => | ||
| { | ||
| observingButton.ModulateSelfOverride = observingButtonOriginalColor; | ||
| }; | ||
|
|
||
| buttonsContainer.AddChild(clearButton); | ||
| buttonsContainer.AddChild(observingButton); | ||
|
|
||
| waypointButtonsContent.AddChild(waypointGrid); | ||
| waypointButtonsContent.AddChild(buttonsContainer); | ||
|
|
||
| nameStatusContent.AddChild(nameStatusContainer); | ||
| nameStatusContent.AddChild(waypointButtonsContent); | ||
| nameStatusPanel.AddChild(nameStatusContent); | ||
|
|
||
| cardContent.AddChild(spritePanel); | ||
| cardContent.AddChild(nameStatusPanel); | ||
| card.AddChild(cardContent); | ||
|
|
||
| return card; | ||
| } | ||
| } | ||
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.
🧹 Nitpick | 🔵 Trivial
Неиспользуемые пространства имён
controlsиac.Оба xmlns-объявления (
xmlns:controlsиxmlns:ac) не используются в XAML. Их можно удалить.♻️ Предлагаемое исправление
<i:BaseImperialWindow xmlns="https://spacestation14.io" xmlns:i="clr-namespace:Content.Client.Imperial.UI.Windows.BaseImperialWindow" - xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" - xmlns:ac="clr-namespace:Content.Client.Imperial.XxRaay.UI" HeaderText="{Loc animatronic-controller-window-title}"📝 Committable suggestion
🤖 Prompt for AI Agents