MechSoundboardUiFragment.xaml.cs 777 B

12345678910111213141516171819202122232425262728
  1. using Content.Shared.Mech;
  2. using Robust.Client.AutoGenerated;
  3. using Robust.Client.UserInterface.Controls;
  4. using Robust.Client.UserInterface.XAML;
  5. namespace Content.Client.Mech.Ui.Equipment;
  6. [GenerateTypedNameReferences]
  7. public sealed partial class MechSoundboardUiFragment : BoxContainer
  8. {
  9. public event Action<int>? OnPlayAction;
  10. public MechSoundboardUiFragment()
  11. {
  12. RobustXamlLoader.Load(this);
  13. IoCManager.InjectDependencies(this);
  14. }
  15. public void UpdateContents(MechSoundboardUiState state)
  16. {
  17. foreach (var sound in state.Sounds)
  18. {
  19. Sounds.AddItem(Loc.GetString($"mech-soundboard-{sound}")).OnSelected += item => {
  20. OnPlayAction?.Invoke(Sounds.IndexOf(item));
  21. };
  22. }
  23. }
  24. }