- add: more interaction shit
This commit is contained in:
@@ -6,10 +6,21 @@ using Robust.Client.UserInterface.XAML;
|
||||
namespace Content.Client._Amour.InteractionPanel.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class InteractionPanelButton : ContainerButton
|
||||
public sealed partial class InteractionPanelButton : Button
|
||||
{
|
||||
public event Action<string>? OnInteraction;
|
||||
|
||||
private Color _color = Color.White;
|
||||
public Color Color
|
||||
{
|
||||
get => _color;
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
ModulateSelfOverride = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string _interactionId = "Interaction";
|
||||
public string InteractionId
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:controls1="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:ui="clr-namespace:Content.Client._Amour.InteractionPanel.UI"
|
||||
Title="{Loc 'interaction-panel-title'}"
|
||||
MinSize="400 500">
|
||||
MinSize="500 500">
|
||||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
|
||||
<BoxContainer Orientation="Vertical" Margin="5 20 5 20" HorizontalAlignment="Stretch" HorizontalExpand="True">
|
||||
<BoxContainer HorizontalAlignment="Center" HorizontalExpand="True">
|
||||
@@ -35,8 +35,16 @@
|
||||
|
||||
<PanelContainer StyleClasses="LowDivider" />
|
||||
|
||||
<BoxContainer Orientation="Vertical" Margin="5 20 5 20" Name="Interactions">
|
||||
<BoxContainer Margin="5 5 5 5" Orientation="Horizontal">
|
||||
<CheckBox Margin="5 0 5 0" Name="DisCheckbox"/>
|
||||
<Label Margin="5 0 5 0" Text="{Loc 'interaction-hide-unvisible'}"/>
|
||||
</BoxContainer>
|
||||
<Button Margin="5 5 5 5" Text="Update"/>
|
||||
|
||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical" Margin="5 20 5 20" Name="Interactions">
|
||||
</BoxContainer>
|
||||
</ScrollContainer>
|
||||
|
||||
</BoxContainer>
|
||||
</ui:InteractionPanelWindow>
|
||||
|
||||
@@ -1,33 +1,65 @@
|
||||
using Content.Shared._Amour.InteractionPanel;
|
||||
using System.Linq;
|
||||
using Content.Shared._Amour.InteractionPanel;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client._Amour.InteractionPanel.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class InteractionPanelWindow : DefaultWindow
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
public event Action<string>? OnInteraction;
|
||||
|
||||
public event Action? OnUpdateRequired;
|
||||
|
||||
public Dictionary<string, int> Groups = new();
|
||||
|
||||
public InteractionPanelWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
DisCheckbox.OnPressed += _ => OnUpdateRequired?.Invoke();
|
||||
}
|
||||
|
||||
public void AddButton(string id)
|
||||
public void AddButton(InteractionEntry entry)
|
||||
{
|
||||
if(!_prototypeManager.TryIndex<InteractionPrototype>(entry.Prototype, out var prototype)
|
||||
|| !_prototypeManager.TryIndex(prototype.Group, out var groupPrototype))
|
||||
return;
|
||||
|
||||
if (!Groups.TryGetValue(prototype.Group, out var box))
|
||||
return;
|
||||
|
||||
if(DisCheckbox.Pressed && !entry.Enabled)
|
||||
return;
|
||||
|
||||
var btn = new InteractionPanelButton();
|
||||
btn.InteractionId = id;
|
||||
btn.OnInteraction += _id => OnInteraction?.Invoke(_id);
|
||||
Interactions.AddChild(btn);
|
||||
btn.Color = groupPrototype.Color;
|
||||
btn.InteractionId = entry.Prototype;
|
||||
btn.OnInteraction += id => OnInteraction?.Invoke(id);
|
||||
|
||||
btn.Disabled = !entry.Enabled;
|
||||
|
||||
Interactions.GetChild(box).AddChild(btn);
|
||||
}
|
||||
|
||||
public void Update(InteractionState state)
|
||||
{
|
||||
Interactions.Children.Clear();
|
||||
|
||||
Groups.Clear();
|
||||
foreach (var prototype in _prototypeManager.EnumeratePrototypes<InteractionGroupPrototype>().OrderBy(p => p.Priority))
|
||||
{
|
||||
var box = new BoxContainer();
|
||||
Interactions.AddChild(box);
|
||||
box.Orientation = BoxContainer.LayoutOrientation.Vertical;
|
||||
Groups.Add(prototype.ID,Interactions.ChildCount - 1);
|
||||
}
|
||||
|
||||
TargetView.SetEntity(state.Target);
|
||||
PerformerView.SetEntity(state.Performer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user