Files
tbd-station-14/Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs
Moony f98df73fae Adds even more smites and a bunch of tools. (#9825)
* Adds three new smites, headstand, locker stuff, and reptilian species swap.

* Localize all the smites.

* save work

* More smites...

* Final tweaks.

* oops

* !PLEH

* Adds disarm prone and improved hand removal options.

* fix chances.

* take out the trash.

* Add some admin TRICKS instead of more smites.

* oop

* Implements the admin test arena and associated trick.

* Tricks for granting/revoking access.

* e

* mfw

* Implement quick dialogs, for when you don't want to spend 20 minutes writing a simple dialog prompt.

* Forgot the rejuv icon.

* E

* docs

* augh

* Add rename/redescribe buttons.

* Adds objects menu, implements a couple tricks for stations.

* 1984

* Adds a trick for effectively infinite power.

* fixes some icon uggo.

* a

* HALT!

* Pause/unpause buttons.

* Forgor the textures.

* they broke every bone in their body.

* i added more

* more battery actions, touch up battery icon.

* Address reviews.
2022-07-21 17:30:00 -05:00

74 lines
2.3 KiB
C#

using System.Linq;
using Content.Client.Station;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Administration.UI.Tabs.ObjectsTab;
[GenerateTypedNameReferences]
public sealed partial class ObjectsTab : Control
{
[Dependency] private readonly EntityManager _entityManager = default!;
private readonly List<ObjectsTabEntry> _objects = new();
private List<ObjectsTabSelection> _selections = new();
public event Action<BaseButton.ButtonEventArgs>? OnEntryPressed;
public ObjectsTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
ObjectTypeOptions.OnItemSelected += ev =>
{
ObjectTypeOptions.SelectId(ev.Id);
RefreshObjectList(_selections[ev.Id]);
};
foreach (var type in Enum.GetValues(typeof(ObjectsTabSelection)))
{
_selections.Add((ObjectsTabSelection)type!);
ObjectTypeOptions.AddItem(Enum.GetName((ObjectsTabSelection)type!)!);
}
RefreshObjectList(_selections[ObjectTypeOptions.SelectedId]);
}
private void RefreshObjectList(ObjectsTabSelection selection)
{
var entities = selection switch
{
ObjectsTabSelection.Stations => _entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations.ToList(),
ObjectsTabSelection.Grids => _entityManager.EntityQuery<IMapGridComponent>(true).Select(x => x.Owner).ToList(),
ObjectsTabSelection.Maps => _entityManager.EntityQuery<IMapComponent>(true).Select(x => x.Owner).ToList(),
_ => throw new ArgumentOutOfRangeException(nameof(selection), selection, null)
};
foreach (var control in _objects)
{
ObjectList.RemoveChild(control);
}
_objects.Clear();
foreach (var entity in entities)
{
var ctrl = new ObjectsTabEntry(_entityManager.GetComponent<MetaDataComponent>(entity).EntityName, entity);
_objects.Add(ctrl);
ObjectList.AddChild(ctrl);
ctrl.OnPressed += args => OnEntryPressed?.Invoke(args);
}
}
private enum ObjectsTabSelection
{
Grids,
Maps,
Stations,
}
}