-
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
base: develop
Are you sure you want to change the base?
Ивентовый контент #545
Changes from 7 commits
0b1f88d
b2e0db6
f6f4bae
137c914
bb476de
025bcda
3cbd80f
d4b7541
26aa1bc
7802300
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(); | ||
| } | ||
| } | ||
| } | ||
|
|
| 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> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,295 @@ | ||
| using System.Collections.Generic; | ||
| using System.Numerics; | ||
| using Content.Client.Imperial.UI.Windows.BaseImperialWindow; | ||
| 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; | ||
| using Robust.Client.GameObjects; | ||
|
|
||
| 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 Dictionary<NetEntity, PanelContainer> _animCards = new(); | ||
| private Dictionary<NetEntity, Color> _buttonOriginalColors = new(); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public AnimatronicControllerWindow() | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
| IoCManager.InjectDependencies(this); | ||
| } | ||
|
|
||
| public void UpdateState(AnimDataStateEvent state) | ||
| { | ||
| var animScrollContainer = Contents.GetChild(0) as ScrollContainer; | ||
| var animList = animScrollContainer?.GetChild(0) as BoxContainer; | ||
|
|
||
XxRaay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| animList?.RemoveAllChildren(); | ||
| _animCards.Clear(); | ||
| _buttonOriginalColors.Clear(); | ||
|
|
||
| foreach (var anim in state.Animatronics) | ||
| { | ||
| var card = CreateAnimatronicCard(anim, state.Waypoints); | ||
| animList?.AddChild(card); | ||
| _animCards[anim.Entity] = card; | ||
| } | ||
| } | ||
|
|
||
| private PanelContainer CreateAnimatronicCard(AnimDto anim, List<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[wp.Entity] = 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(wpEntity, out var original)) | ||
| wpButton.ModulateSelfOverride = original; | ||
| }; | ||
XxRaay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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; | ||
| } | ||
|
||
| } | ||
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