refactors adminmenu a timid amount (#5095)
Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -27,20 +28,18 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab
|
||||
|
||||
private void SpawnEntitiesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
_entitySpawnWindow ??= new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IPrototypeManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(_entitySpawnWindow);
|
||||
EntitySystem.Get<AdminSystem>().OpenCommand(_entitySpawnWindow);
|
||||
}
|
||||
|
||||
private void SpawnTilesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IAdminMenuManager>();
|
||||
_tileSpawnWindow ??= new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
|
||||
IoCManager.Resolve<IPlacementManager>(),
|
||||
IoCManager.Resolve<IResourceCache>());
|
||||
manager.OpenCommand(_tileSpawnWindow);
|
||||
EntitySystem.Get<AdminSystem>().OpenCommand(_tileSpawnWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<Control xmlns="https://spacestation14.io">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Name="PlayerCount" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
<Label Name="PlayerCount" HorizontalExpand="True" SizeFlagsStretchRatio="0.50"
|
||||
Text="{Loc Player Count}" />
|
||||
<Button Name="RefreshButton" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
Text="{Loc Refresh}" />
|
||||
<Button Name="OverlayButtonOn" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
Text="{Loc Overlay On}"/>
|
||||
<Button Name="OverlayButtonOff" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Administration.Menu;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
@@ -16,30 +17,28 @@ namespace Content.Client.Administration.UI.Tabs
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class PlayerTab : Control
|
||||
{
|
||||
public delegate void PlayerListRefresh();
|
||||
|
||||
public delegate void AdminNameOverlayToggle();
|
||||
|
||||
public event PlayerListRefresh? OnPlayerListRefresh;
|
||||
public event AdminNameOverlayToggle? OnAdminNameOverlayOn;
|
||||
public event AdminNameOverlayToggle? OnAdminNameOverlayOff;
|
||||
|
||||
private readonly AdminSystem _adminSystem;
|
||||
|
||||
public PlayerTab()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_adminSystem = EntitySystem.Get<AdminSystem>();
|
||||
RobustXamlLoader.Load(this);
|
||||
RefreshButton.OnPressed += (_) => OnPlayerListRefresh?.Invoke();
|
||||
OverlayButtonOn.OnPressed += (_) => OnAdminNameOverlayOn?.Invoke();
|
||||
OverlayButtonOff.OnPressed += (_) => OnAdminNameOverlayOff?.Invoke();
|
||||
RefreshPlayerList(_adminSystem.PlayerList);
|
||||
_adminSystem.PlayerListChanged += RefreshPlayerList;
|
||||
OverlayButtonOn.OnPressed += _adminSystem.AdminOverlayOn;
|
||||
OverlayButtonOff.OnPressed += _adminSystem.AdminOverlayOff;
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
OnPlayerListRefresh?.Invoke();
|
||||
base.Dispose(disposing);
|
||||
|
||||
_adminSystem.PlayerListChanged -= RefreshPlayerList;
|
||||
OverlayButtonOn.OnPressed -= _adminSystem.AdminOverlayOn;
|
||||
OverlayButtonOff.OnPressed -= _adminSystem.AdminOverlayOff;
|
||||
}
|
||||
|
||||
public void RefreshPlayerList(IEnumerable<AdminMenuPlayerListMessage.PlayerInfo> players)
|
||||
private void RefreshPlayerList(IReadOnlyList<PlayerInfo> players)
|
||||
{
|
||||
PlayerList.RemoveAllChildren();
|
||||
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
|
||||
Reference in New Issue
Block a user