-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
Content.Client/_White/InhandCrafting/UI/InhandCraftMenu.xaml
This file contains 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,12 @@ | ||
<ui:RadialMenu xmlns="https://spacestation14.io" | ||
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
BackButtonStyleClass="RadialMenuBackButton" | ||
CloseButtonStyleClass="RadialMenuCloseButton" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" | ||
MinSize="350 350"> | ||
|
||
<!-- Main container to hold all crafts--> | ||
<ui:RadialContainer Name="Main" VerticalExpand="True" HorizontalExpand="True" Radius="100" | ||
ReserveSpaceForHiddenChildren="False" /> | ||
</ui:RadialMenu> |
73 changes: 73 additions & 0 deletions
73
Content.Client/_White/InhandCrafting/UI/InhandCraftMenu.xaml.cs
This file contains 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,73 @@ | ||
using System.Numerics; | ||
using Content.Client.Construction; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared._White.InhandCrafting; | ||
using Content.Shared.Construction.Prototypes; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Placement; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client._White.InhandCrafting.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class InhandCraftMenu : RadialMenu | ||
{ | ||
[Dependency] private readonly EntityManager _entManager = default!; | ||
[Dependency] private readonly IPrototypeManager _protoManager = default!; | ||
[Dependency] private readonly IPlacementManager _placementManager = default!; | ||
|
||
private readonly ConstructionSystem _construction; | ||
|
||
public InhandCraftMenu(EntityUid owner) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
RobustXamlLoader.Load(this); | ||
_construction = _entManager.System<ConstructionSystem>(); | ||
|
||
if (!_entManager.TryGetComponent<InhandCraftingComponent>(owner, out var crafting)) | ||
return; | ||
|
||
var spriteSystem = _entManager.System<SpriteSystem>(); | ||
var main = FindControl<RadialContainer>("Main"); | ||
|
||
foreach (var protoId in crafting.Prototypes) | ||
{ | ||
if (!_protoManager.TryIndex(protoId, out var proto)) | ||
continue; | ||
|
||
var button = new RadialMenuTextureButton | ||
{ | ||
ToolTip = Loc.GetString(proto.Name), | ||
TextureNormal = spriteSystem.Frame0(proto.Icon), | ||
StyleClasses = { "RadialMenuButton" }, | ||
SetSize = new Vector2(48f, 48f), | ||
}; | ||
|
||
button.OnButtonUp += _ => | ||
{ | ||
BuildItem(proto); | ||
Close(); | ||
}; | ||
|
||
main.AddChild(button); | ||
} | ||
} | ||
|
||
private void BuildItem(ConstructionPrototype prototype) | ||
{ | ||
if (prototype.Type == ConstructionType.Item) | ||
{ | ||
_construction.TryStartItemConstruction(prototype.ID); | ||
return; | ||
} | ||
|
||
_placementManager.BeginPlacing(new PlacementInformation | ||
{ | ||
IsTile = false, | ||
PlacementOption = prototype.PlacementMode | ||
}, new ConstructionPlacementHijack(_construction, prototype)); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Content.Client/_White/InhandCrafting/UI/InhandCraftMenuBUI.cs
This file contains 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,33 @@ | ||
using JetBrains.Annotations; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Input; | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
namespace Content.Client._White.InhandCrafting.UI; | ||
|
||
[UsedImplicitly] | ||
public sealed class InhandCraftMenuBUI(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) | ||
{ | ||
[Dependency] private readonly IClyde _displayManager = default!; | ||
[Dependency] private readonly IInputManager _inputManager = default!; | ||
private InhandCraftMenu? _menu; | ||
|
||
protected override void Open() | ||
{ | ||
_menu = new InhandCraftMenu(Owner); | ||
_menu.OnClose += Close; | ||
|
||
var vpSize = _displayManager.ScreenSize; | ||
_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / vpSize); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) | ||
return; | ||
|
||
_menu?.Dispose(); | ||
} | ||
} |
This file contains 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
13 changes: 13 additions & 0 deletions
13
Content.Shared/_White/InhandCrafting/InhandCraftingComponent.cs
This file contains 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,13 @@ | ||
using Content.Shared.Construction.Prototypes; | ||
using Robust.Client.Placement; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared._White.InhandCrafting; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class InhandCraftingComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public List<ProtoId<ConstructionPrototype>> Prototypes; | ||
} |
This file contains 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,9 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared._White.InhandCrafting; | ||
|
||
[NetSerializable, Serializable] | ||
public enum InhandCraftingUiKey : byte | ||
{ | ||
Key, | ||
} |
This file contains 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