Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,35 @@
using Content.Client.Eui;
using Content.Shared.Administration;
using Content.Shared.Eui;
using JetBrains.Annotations;
namespace Content.Client.Administration.UI.SetOutfit
{
[UsedImplicitly]
public sealed class SetOutfitEui : BaseEui
{
private readonly SetOutfitMenu _window;
public SetOutfitEui()
{
_window = new SetOutfitMenu();
}
public override void Opened()
{
_window.OpenCentered();
}
public override void Closed()
{
base.Closed();
_window.Close();
}
public override void HandleState(EuiStateBase state)
{
var outfitState = (SetOutfitEuiState) state;
_window.TargetEntityId = outfitState.TargetEntityId;
}
}
}

View File

@@ -0,0 +1,15 @@
<SS14Window
xmlns="https://spacestation14.io">
<HBoxContainer HorizontalExpand="True">
<VBoxContainer HorizontalExpand="True" SizeFlagsStretchRatio="0.45">
<HBoxContainer HorizontalExpand="True" VerticalExpand="True"
SizeFlagsStretchRatio="0.1">
<LineEdit Name="SearchBar" PlaceHolder="Search" HorizontalExpand="True"
SizeFlagsStretchRatio="0.6" />
</HBoxContainer>
<ItemList Name="OutfitList" SelectMode="Single" VerticalExpand="True"
SizeFlagsStretchRatio="0.9" />
<Button Name="ConfirmButton" HorizontalExpand="True" />
</VBoxContainer>
</HBoxContainer>
</SS14Window>

View File

@@ -0,0 +1,97 @@
using Content.Shared.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
namespace Content.Client.Administration.UI.SetOutfit
{
[GenerateTypedNameReferences]
public partial class SetOutfitMenu : SS14Window
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
public EntityUid? TargetEntityId { get; set; }
private StartingGearPrototype? _selectedOutfit;
public SetOutfitMenu()
{
MinSize = SetSize = (250, 320);
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
Title = Loc.GetString("Set Outfit");
ConfirmButton.Text = Loc.GetString("Confirm");
ConfirmButton.OnPressed += ConfirmButtonOnOnPressed;
SearchBar.OnTextChanged += SearchBarOnOnTextChanged;
OutfitList.OnItemSelected += OutfitListOnOnItemSelected;
OutfitList.OnItemDeselected += OutfitListOnOnItemDeselected;
PopulateList();
}
private void ConfirmButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
if (TargetEntityId == null || _selectedOutfit == null)
return;
var command = $"setoutfit {TargetEntityId} {_selectedOutfit.ID}";
_consoleHost.ExecuteCommand(command);
Close();
}
private void OutfitListOnOnItemSelected(ItemList.ItemListSelectedEventArgs obj)
{
_selectedOutfit = (StartingGearPrototype) obj.ItemList[obj.ItemIndex].Metadata!;
ConfirmButton.Disabled = false;
}
private void OutfitListOnOnItemDeselected(ItemList.ItemListDeselectedEventArgs obj)
{
_selectedOutfit = null;
ConfirmButton.Disabled = true;
}
private void SearchBarOnOnTextChanged(LineEdit.LineEditEventArgs obj)
{
PopulateByFilter(SearchBar.Text);
}
private void PopulateList()
{
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
{
OutfitList.Add(GetItem(gear, OutfitList));
}
}
private void PopulateByFilter(string filter)
{
OutfitList.Clear();
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
{
if (!string.IsNullOrEmpty(filter) &&
gear.ID.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant()))
{
OutfitList.Add(GetItem(gear, OutfitList));
}
}
}
private static ItemList.Item GetItem(StartingGearPrototype gear, ItemList itemList)
{
return new(itemList)
{
Metadata = gear,
Text = gear.ID
};
}
}
}