diff --git a/Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs b/Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs index 4d50d91e168..95da2e0a336 100644 --- a/Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs +++ b/Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs @@ -12,6 +12,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Shared.Enums; using Robust.Shared.Prototypes; +using Robust.Shared.Utility; // ReSharper disable InconsistentNaming @@ -30,7 +31,6 @@ public sealed class ShortConstructionMenuBUI : BoundUserInterface private readonly SpriteSystem _spriteSystem; private RadialMenu? _menu; - public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey) { _construction = _entManager.System(); @@ -39,8 +39,17 @@ public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey protected override void Open() { - _menu = FormMenu(); - _menu.OnClose += Close; + _menu = new RadialMenu + { + HorizontalExpand = true, + VerticalExpand = true, + BackButtonStyleClass = "RadialMenuBackButton", + CloseButtonStyleClass = "RadialMenuCloseButton" + }; + + if (_entManager.TryGetComponent(Owner, out var crafting)) + CreateMenu(crafting.Entries); + _menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / _displayManager.ScreenSize); } @@ -51,56 +60,58 @@ protected override void Dispose(bool disposing) _menu?.Dispose(); } - private RadialMenu FormMenu() + private void CreateMenu(List entries, string? parentCategory = null) { - var menu = new RadialMenu - { - HorizontalExpand = true, - VerticalExpand = true, - BackButtonStyleClass = "RadialMenuBackButton", - CloseButtonStyleClass = "RadialMenuCloseButton" - }; - - if (!_entManager.TryGetComponent(Owner, out var crafting)) - return menu; + if (_menu == null) + return; - var mainContainer = new RadialContainer + var container = new RadialContainer { - Radius = 36f / MathF.Sin(MathF.PI / 2f / crafting.Prototypes.Count) + Name = parentCategory ?? "Main", + Radius = 48f + 24f * MathF.Log(entries.Count), }; - foreach (var protoId in crafting.Prototypes) - { - if (!_protoManager.TryIndex(protoId, out var proto)) - continue; + _menu.AddChild(container); - var button = new RadialMenuTextureButton + foreach (var entry in entries) + { + if (entry.Category != null) { - ToolTip = Loc.GetString(proto.Name), - StyleClasses = { "RadialMenuButton" }, - SetSize = new Vector2(48f, 48f) - }; - - var texture = new TextureRect + var button = CreateButton(entry.Category.Name, entry.Category.Icon); + button.TargetLayer = entry.Category.Name; + CreateMenu(entry.Category.Entries, entry.Category.Name); + container.AddChild(button); + } + else if (entry.Prototype != null + && _protoManager.TryIndex(entry.Prototype, out var proto)) { - VerticalAlignment = Control.VAlignment.Center, - HorizontalAlignment = Control.HAlignment.Center, - Texture = _spriteSystem.Frame0(proto.Icon), - TextureScale = new Vector2(1.5f, 1.5f) - }; + var button = CreateButton(proto.Name, proto.Icon); + button.OnButtonUp += _ => ConstructItem(proto); + container.AddChild(button); + } + } - button.AddChild(texture); + } - button.OnButtonUp += _ => - { - ConstructItem(proto); - }; + private RadialMenuTextureButton CreateButton(string name, SpriteSpecifier icon) + { + var button = new RadialMenuTextureButton + { + ToolTip = Loc.GetString(name), + StyleClasses = { "RadialMenuButton" }, + SetSize = new Vector2(64f, 64f), + }; - mainContainer.AddChild(button); - } + var texture = new TextureRect + { + VerticalAlignment = Control.VAlignment.Center, + HorizontalAlignment = Control.HAlignment.Center, + Texture = _spriteSystem.Frame0(icon), + TextureScale = new Vector2(2f, 2f) + }; - menu.AddChild(mainContainer); - return menu; + button.AddChild(texture); + return button; } /// @@ -121,6 +132,6 @@ private void ConstructItem(ConstructionPrototype prototype) }, new ConstructionPlacementHijack(_construction, prototype)); // Should only close the menu if we're placing a construction hijack. - _menu!.Close(); + // Theres not much point to closing it though. _menu!.Close(); } } diff --git a/Content.Shared/ShortConstruction/ShortConstructionComponent.cs b/Content.Shared/ShortConstruction/ShortConstructionComponent.cs index 4ca40638668..dedf8605bdb 100644 --- a/Content.Shared/ShortConstruction/ShortConstructionComponent.cs +++ b/Content.Shared/ShortConstruction/ShortConstructionComponent.cs @@ -2,6 +2,7 @@ using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; +using Robust.Shared.Utility; namespace Content.Shared.ShortConstruction; @@ -9,7 +10,30 @@ namespace Content.Shared.ShortConstruction; public sealed partial class ShortConstructionComponent : Component { [DataField(required: true)] - public List> Prototypes = new(); + public List Entries = new(); +} + +[DataDefinition] +public sealed partial class ShortConstructionEntry +{ + [DataField] + public ProtoId? Prototype { get; set; } + + [DataField] + public ShortConstructionCategory? Category { get; set; } +} + +[DataDefinition] +public sealed partial class ShortConstructionCategory +{ + [DataField] + public string Name { get; set; } = string.Empty; + + [DataField] + public SpriteSpecifier Icon { get; set; } = default!; + + [DataField] + public List Entries { get; set; } = new(); } [NetSerializable, Serializable] diff --git a/Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml b/Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml index 91ba1abff93..59c9a8fc46f 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml @@ -98,8 +98,13 @@ - type: ActivatableUI key: enum.ShortConstructionUiKey.Key - type: ShortConstruction - prototypes: - - Window + entries: + - prototype: Window + - prototype: WindowDirectional + - prototype: WindowDiagonal + - prototype: SheetRGlass + - prototype: SheetPGlass + - prototype: SheetUGlass - type: entity parent: SheetGlass @@ -193,8 +198,12 @@ - type: ActivatableUI key: enum.ShortConstructionUiKey.Key - type: ShortConstruction - prototypes: - - ReinforcedWindow + entries: + - prototype: SheetRPGlass1 + - prototype: SheetRUGlass1 + - prototype: ReinforcedWindow + - prototype: ReinforcedWindowDiagonal + - prototype: WindowReinforcedDirectional - type: entity parent: SheetRGlass @@ -272,6 +281,18 @@ max: 1 - !type:DoActsBehavior acts: [ "Destruction" ] + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: SheetRPGlass0 + - prototype: PlasmaWindow + - prototype: PlasmaWindowDiagonal + - prototype: PlasmaWindowDirectional - type: entity parent: SheetPGlass @@ -338,6 +359,17 @@ - ReagentId: Carbon Quantity: 0.5 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: ReinforcedPlasmaWindow + - prototype: ReinforcedPlasmaWindowDiagonal + - prototype: PlasmaReinforcedWindowDirectional - type: entity parent: SheetRPGlass @@ -413,6 +445,18 @@ - ReagentId: Uranium Quantity: 10 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: SheetRUGlass0 + - prototype: UraniumWindow + - prototype: UraniumWindowDiagonal + - prototype: UraniumWindowDirectional - type: entity parent: SheetUGlass @@ -467,6 +511,17 @@ - ReagentId: Carbon Quantity: 0.5 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: ReinforcedUraniumWindow + - prototype: ReinforcedUraniumWindowDiagonal + - prototype: UraniumReinforcedWindowDirectional - type: entity parent: SheetRUGlass diff --git a/Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml b/Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml index 83982474d2a..427ae362a7a 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml @@ -76,12 +76,75 @@ - type: ActivatableUI key: enum.ShortConstructionUiKey.Key - type: ShortConstruction - prototypes: - - Girder - - MetalRod - - TileSteel - - TileWhite - - TileDark + entries: + - prototype: Girder + - prototype: MetalRod + - category: + name: Tiles + icon: + sprite: Objects/Tiles/tile.rsi + state: steel + entries: + - prototype: TileSteel + - prototype: TileWhite + - prototype: TileDark + - category: + name: Electronics + icon: + sprite: Structures/Machines/computers.rsi + state: computer-datatheory + entries: + - prototype: MachineFrame + - prototype: Computer + - prototype: Windoor + - prototype: LightTubeFixture + - prototype: APC + - prototype: AirAlarmFixture + - prototype: AirSensor + - prototype: FireAlarm + - category: + name: Atmospherics + icon: + sprite: Structures/Piping/Atmospherics/vent.rsi + state: vent_out + entries: + - prototype: GasPort + - prototype: GasOutletInjector + - prototype: GasVentScrubber + - prototype: GasPassiveVent + - prototype: GasVentPump + - prototype: GasMixer + - prototype: GasFilter + - prototype: GasVolumePump + - prototype: GasPressurePump + - prototype: GasValve + - category: + name: Piping + icon: + sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeFourway + entries: + - prototype: HeatExchanger + - prototype: GasPipeBend + - prototype: GasPipeFourway + - prototype: GasPipeHalf + - prototype: GasPipeStraight + - prototype: GasPipeTJunction + - category: + name: Disposals + icon: + sprite: Structures/Piping/disposal.rsi + state: disposal + entries: + - prototype: DisposalPipe + - prototype: DisposalBend + - prototype: DisposalJunction + - prototype: DisposalYJunction + - prototype: DisposalRouter + - prototype: DisposalTagger + - prototype: DisposalTrunk + - prototype: DisposalUnit + - prototype: CrateGenericSteel - type: entity parent: SheetSteel @@ -218,6 +281,15 @@ - ReagentId: Carbon Quantity: 1 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: SecureWindoor - type: entity parent: SheetPlasteel diff --git a/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml b/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml index dfb51336289..ab8597d02a5 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml @@ -110,6 +110,17 @@ - type: Tag tags: - Sheet + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: SheetPGlass + - prototype: SheetRPGlass + - prototype: SheetRPGlass1 - type: entity parent: SheetPlasma @@ -162,6 +173,15 @@ - ReagentId: Phosphorus Quantity: 5 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: CratePlastic - type: entity parent: SheetPlastic @@ -224,6 +244,17 @@ - ReagentId: Radium Quantity: 2 canReact: false + - type: UserInterface + interfaces: + - key: enum.ShortConstructionUiKey.Key + type: ShortConstructionMenuBUI + - type: ActivatableUI + key: enum.ShortConstructionUiKey.Key + - type: ShortConstruction + entries: + - prototype: SheetUGlass + - prototype: SheetRUGlass + - prototype: SheetRUGlass1 - type: entity parent: SheetUranium diff --git a/Resources/Prototypes/Entities/Objects/Materials/parts.yml b/Resources/Prototypes/Entities/Objects/Materials/parts.yml index 8b916f2e2be..e0547b3dc48 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/parts.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/parts.yml @@ -75,8 +75,30 @@ - type: ActivatableUI key: enum.ShortConstructionUiKey.Key - type: ShortConstruction - prototypes: - - Grille + entries: + - prototype: Grille + - prototype: GrilleDiagonal + - category: + name: Railings + icon: + sprite: Structures/Walls/railing.rsi + state: side + entries: + - prototype: Railing + - prototype: RailingCorner + - prototype: RailingRound + - prototype: RailingCornerSmall + - category: + name: Glass + icon: + sprite: Objects/Materials/Sheets/glass.rsi + state: rglass_3 + entries: + - prototype: SheetRPGlass + - prototype: SheetRPGlass0 + - prototype: SheetRUGlass + - prototype: SheetRUGlass0 + - prototype: SheetRGlass - type: entity parent: PartRodMetal diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/structures/windowdirectional.yml b/Resources/Prototypes/Recipes/Construction/Graphs/structures/windowdirectional.yml index 96f009fabb7..effddd7ca39 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/structures/windowdirectional.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/structures/windowdirectional.yml @@ -28,6 +28,7 @@ - material: ReinforcedPlasmaGlass amount: 1 doAfter: 3 + - to: uraniumWindowDirectional steps: - material: UraniumGlass @@ -136,6 +137,7 @@ doAfter: 2 - tool: Anchoring doAfter: 3 + - node: uraniumWindowDirectional entity: UraniumWindowDirectional edges: diff --git a/Resources/Prototypes/Recipes/Construction/structures.yml b/Resources/Prototypes/Recipes/Construction/structures.yml index b152e827e6a..52b43872561 100644 --- a/Resources/Prototypes/Recipes/Construction/structures.yml +++ b/Resources/Prototypes/Recipes/Construction/structures.yml @@ -688,6 +688,42 @@ objectType: Structure placementMode: SnapgridCenter +- type: construction + name: directional uranium window + id: UraniumWindowDirectional + graph: WindowDirectional + startNode: start + targetNode: uraniumWindowDirectional + category: construction-category-structures + canBuildInImpassable: true + description: Clear and tougher than regular glass, with added RadAbsorb to protect you from deadly radiation. + conditions: + - !type:EmptyOrWindowValidInTile + - !type:NoWindowsInTile + icon: + sprite: Structures/Windows/directional.rsi + state: uranium_window + objectType: Structure + placementMode: SnapgridCenter + +- type: construction + name: directional reinforced uranium window + id: UraniumReinforcedWindowDirectional + graph: WindowDirectional + startNode: start + targetNode: uraniumReinforcedWindowDirectional + category: construction-category-structures + canBuildInImpassable: true + description: Clear and much tougher than regular glass, with added RadAbsorb to protect you from deadly radiation. + conditions: + - !type:EmptyOrWindowValidInTile + - !type:NoWindowsInTile + icon: + sprite: Structures/Windows/directional.rsi + state: uranium_reinforced_window + objectType: Structure + placementMode: SnapgridCenter + - type: construction name: firelock id: Firelock