- add: interaction part 2

This commit is contained in:
2024-02-23 18:52:03 +03:00
parent 28c8b45eec
commit 2ec981e9e6
22 changed files with 608 additions and 79 deletions

View File

@@ -1,16 +1,40 @@
using Content.Client.Eui;
using Content.Shared._Amour.InteractionPanel;
using Content.Shared.Eui;
namespace Content.Client._Amour.InteractionPanel;
public sealed class InteractionPanelEui : BaseEui
{
private InteractionPanelWindow _interactionPanelWindow;
private readonly IEntityManager _entityManager;
private UI.InteractionPanelWindow _interactionPanelWindow;
private InteractionState _interactionState = default!;
public InteractionPanelEui()
{
_interactionPanelWindow = new InteractionPanelWindow();
IoCManager.InjectDependencies(this);
_entityManager = IoCManager.Resolve<IEntityManager>();
_interactionPanelWindow = new UI.InteractionPanelWindow();
_interactionPanelWindow.OnClose += () => SendMessage(new CloseEuiMessage());
_interactionPanelWindow.OnInteraction += InteractionPanelWindowOnInteraction;
}
private void InteractionPanelWindowOnInteraction(string id)
{
SendMessage(new InteractionSelectedMessage(id));
}
public override void HandleState(EuiStateBase state)
{
base.HandleState(state);
if(state is not InteractionState interactionState)
return;
_interactionState = interactionState;
_interactionPanelWindow.Update(_interactionState);
}
public override void Closed()

View File

@@ -1,51 +0,0 @@
<controls:InteractionPanelWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client._Amour.InteractionPanel"
xmlns:controls1="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'interaction-panel-title'}"
MinSize="300 500">
<BoxContainer Orientation="Vertical" Margin="5 5 5 5">
<BoxContainer Orientation="Vertical" Margin="5 20 5 20" HorizontalAlignment="Stretch" HorizontalExpand="True">
<TextureRect TexturePath="/Textures/Interface/Misc/beakerlarge.png" Margin="5 10 5 15" HorizontalAlignment="Center"/>
<BoxContainer HorizontalAlignment="Center" HorizontalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalAlignment="Left" Margin="5 5 5 5">
<PanelContainer/>
<Label Text="- У меня есть ручки"/>
<Label Text="- У меня есть ножки"/>
</BoxContainer>
<controls1:HighDivider HorizontalAlignment="Center" Margin="5 5 5 5"/>
<BoxContainer Orientation="Vertical" HorizontalAlignment="Right" Margin="5 5 5 5">
<PanelContainer/>
<Label Text="- У него есть дырка"/>
<Label Text="- Он няшный"/>
</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">
<Label Text="Смешной прогресс"/>
</ProgressBar>
</BoxContainer>
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Vertical" Margin="5 20 5 20">
<Button Modulate="#ffaaaa">
<BoxContainer HorizontalAlignment="Left">
<TextureRect TexturePath="/Textures/Interface/NavMap/beveled_circle.png" Margin="5 5 5 5"/>
<Label Text="Трахать" Margin="10 0 15 0"/>
</BoxContainer>
<controls1:HighDivider HorizontalAlignment="Center"/>
<Label Text=">" Margin="5 0 5 0" HorizontalAlignment="Right"/>
</Button>
</BoxContainer>
</BoxContainer>
</controls:InteractionPanelWindow>

View File

@@ -1,16 +0,0 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client._Amour.InteractionPanel;
[GenerateTypedNameReferences]
public sealed partial class InteractionPanelWindow : DefaultWindow
{
public InteractionPanelWindow()
{
RobustXamlLoader.Load(this);
}
}

View File

@@ -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>

View File

@@ -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);
}
}

View File

@@ -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>

View File

@@ -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);
}
}
}