- add: interaction part 2
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<ui:InteractionPanelButton
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:ui="clr-namespace:Content.Client._Amour.InteractionPanel.UI"
|
||||
xmlns:controls1="clr-namespace:Content.Client.UserInterface.Controls">
|
||||
<Control Name="ColorControl">
|
||||
<BoxContainer HorizontalAlignment="Left">
|
||||
<TextureRect TexturePath="/Textures/Interface/NavMap/beveled_circle.png" Name="Rect" Margin="5 5 5 5"/>
|
||||
<Label Name="InteractionName" Margin="10 0 15 0"/>
|
||||
</BoxContainer>
|
||||
<Label Text=">" Margin="5 0 5 0" HorizontalAlignment="Right"/>
|
||||
</Control>
|
||||
</ui:InteractionPanelButton>
|
||||
@@ -0,0 +1,35 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client._Amour.InteractionPanel.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class InteractionPanelButton : ContainerButton
|
||||
{
|
||||
public event Action<string>? OnInteraction;
|
||||
|
||||
private string _interactionId = "Interaction";
|
||||
public string InteractionId
|
||||
{
|
||||
get => _interactionId;
|
||||
set
|
||||
{
|
||||
_interactionId = value;
|
||||
InteractionName.Text = Loc.GetString($"interaction-name-{_interactionId.ToLower()}");
|
||||
}
|
||||
}
|
||||
|
||||
public InteractionPanelButton()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
OnPressed += OnOnPressed;
|
||||
}
|
||||
|
||||
private void OnOnPressed(ButtonEventArgs obj)
|
||||
{
|
||||
OnInteraction?.Invoke(InteractionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<ui:InteractionPanelWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
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">
|
||||
<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">
|
||||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
|
||||
<SpriteView Name="PerformerView" Margin="5 10 5 15" HorizontalAlignment="Center"/>
|
||||
<RichTextLabel Name="PerformerDesc"/>
|
||||
</BoxContainer>
|
||||
|
||||
<controls1:HighDivider Margin="5 5 5 5"/>
|
||||
|
||||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
|
||||
<SpriteView Name="TargetView" Margin="5 10 5 15" HorizontalAlignment="Center"/>
|
||||
<RichTextLabel Name="TargerDesc"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
<ProgressBar Name="CummingProgress"
|
||||
HorizontalExpand="True"
|
||||
MinValue="0"
|
||||
MaxValue="1"
|
||||
MinHeight = "25"
|
||||
Page="0"
|
||||
Margin="10 10 0 0"
|
||||
Value="0.5"
|
||||
Modulate="#795695"
|
||||
Visible="False">
|
||||
<Label Text="Смешной прогресс" HorizontalAlignment="Center"/>
|
||||
</ProgressBar>
|
||||
</BoxContainer>
|
||||
|
||||
<PanelContainer StyleClasses="LowDivider" />
|
||||
|
||||
<BoxContainer Orientation="Vertical" Margin="5 20 5 20" Name="Interactions">
|
||||
</BoxContainer>
|
||||
|
||||
</BoxContainer>
|
||||
</ui:InteractionPanelWindow>
|
||||
@@ -0,0 +1,40 @@
|
||||
using Content.Shared._Amour.InteractionPanel;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client._Amour.InteractionPanel.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class InteractionPanelWindow : DefaultWindow
|
||||
{
|
||||
public event Action<string>? OnInteraction;
|
||||
|
||||
public InteractionPanelWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public void AddButton(string id)
|
||||
{
|
||||
var btn = new InteractionPanelButton();
|
||||
btn.InteractionId = id;
|
||||
btn.OnInteraction += _id => OnInteraction?.Invoke(_id);
|
||||
Interactions.AddChild(btn);
|
||||
}
|
||||
|
||||
public void Update(InteractionState state)
|
||||
{
|
||||
Interactions.Children.Clear();
|
||||
|
||||
TargetView.SetEntity(state.Target);
|
||||
PerformerView.SetEntity(state.Performer);
|
||||
|
||||
foreach (var interaction in state.AvailableInteractions)
|
||||
{
|
||||
AddButton(interaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user