-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Simple-Station:master' into GunBuffs
- Loading branch information
Showing
108 changed files
with
2,190 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,100 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Content.Client.Administration.Systems; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.Mind; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.ResourceManagement; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Maths; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Administration | ||
namespace Content.Client.Administration; | ||
|
||
internal sealed class AdminNameOverlay : Overlay | ||
{ | ||
internal sealed class AdminNameOverlay : Overlay | ||
[Dependency] private readonly IConfigurationManager _config = default!; | ||
|
||
private readonly AdminSystem _system; | ||
private readonly IEntityManager _entityManager; | ||
private readonly IEyeManager _eyeManager; | ||
private readonly EntityLookupSystem _entityLookup; | ||
private readonly IUserInterfaceManager _userInterfaceManager; | ||
private readonly Font _font; | ||
|
||
//TODO make this adjustable via GUI | ||
private readonly ProtoId<RoleTypePrototype>[] _filter = | ||
["SoloAntagonist", "TeamAntagonist", "SiliconAntagonist", "FreeAgent"]; | ||
private readonly string _antagLabelClassic = Loc.GetString("admin-overlay-antag-classic"); | ||
private readonly Color _antagColorClassic = Color.OrangeRed; | ||
|
||
public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup, IUserInterfaceManager userInterfaceManager) | ||
{ | ||
private readonly AdminSystem _system; | ||
private readonly IEntityManager _entityManager; | ||
private readonly IEyeManager _eyeManager; | ||
private readonly EntityLookupSystem _entityLookup; | ||
private readonly Font _font; | ||
IoCManager.InjectDependencies(this); | ||
|
||
public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup) | ||
{ | ||
_system = system; | ||
_entityManager = entityManager; | ||
_eyeManager = eyeManager; | ||
_entityLookup = entityLookup; | ||
ZIndex = 200; | ||
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); | ||
} | ||
_system = system; | ||
_entityManager = entityManager; | ||
_eyeManager = eyeManager; | ||
_entityLookup = entityLookup; | ||
_userInterfaceManager = userInterfaceManager; | ||
ZIndex = 200; | ||
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); | ||
} | ||
|
||
public override OverlaySpace Space => OverlaySpace.ScreenSpace; | ||
public override OverlaySpace Space => OverlaySpace.ScreenSpace; | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
var viewport = args.WorldAABB; | ||
|
||
//TODO make this adjustable via GUI | ||
var classic = _config.GetCVar(CCVars.AdminOverlayClassic); | ||
|
||
foreach (var playerInfo in _system.PlayerList) | ||
{ | ||
var viewport = args.WorldAABB; | ||
var entity = _entityManager.GetEntity(playerInfo.NetEntity); | ||
|
||
// Otherwise the entity can not exist yet | ||
if (entity == null || !_entityManager.EntityExists(entity)) | ||
{ | ||
continue; | ||
} | ||
|
||
foreach (var playerInfo in _system.PlayerList) | ||
// if not on the same map, continue | ||
if (_entityManager.GetComponent<TransformComponent>(entity.Value).MapID != args.MapId) | ||
{ | ||
var entity = _entityManager.GetEntity(playerInfo.NetEntity); | ||
|
||
// Otherwise the entity can not exist yet | ||
if (entity == null || !_entityManager.EntityExists(entity)) | ||
{ | ||
continue; | ||
} | ||
|
||
// if not on the same map, continue | ||
if (_entityManager.GetComponent<TransformComponent>(entity.Value).MapID != _eyeManager.CurrentMap) | ||
{ | ||
continue; | ||
} | ||
|
||
var aabb = _entityLookup.GetWorldAABB(entity.Value); | ||
|
||
// if not on screen, continue | ||
if (!aabb.Intersects(in viewport)) | ||
{ | ||
continue; | ||
} | ||
|
||
var lineoffset = new Vector2(0f, 11f); | ||
var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + | ||
new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( | ||
aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); | ||
if (playerInfo.Antag) | ||
{ | ||
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", Color.OrangeRed); | ||
} | ||
args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, playerInfo.Connected ? Color.Yellow : Color.White); | ||
args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, playerInfo.Connected ? Color.Aquamarine : Color.White); | ||
continue; | ||
} | ||
|
||
var aabb = _entityLookup.GetWorldAABB(entity.Value); | ||
|
||
// if not on screen, continue | ||
if (!aabb.Intersects(in viewport)) | ||
{ | ||
continue; | ||
} | ||
|
||
var uiScale = _userInterfaceManager.RootControl.UIScale; | ||
var lineoffset = new Vector2(0f, 11f) * uiScale; | ||
var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + | ||
new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( | ||
aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); | ||
|
||
if (classic && playerInfo.Antag) | ||
{ | ||
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), _antagLabelClassic, uiScale, _antagColorClassic); | ||
} | ||
else if (!classic && _filter.Contains(playerInfo.RoleProto.ID)) | ||
{ | ||
var label = Loc.GetString(playerInfo.RoleProto.Name).ToUpper(); | ||
var color = playerInfo.RoleProto.Color; | ||
|
||
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), label, uiScale, color); | ||
} | ||
|
||
args.ScreenHandle.DrawString(_font, screenCoordinates + lineoffset, playerInfo.Username, uiScale, playerInfo.Connected ? Color.Yellow : Color.White); | ||
args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, uiScale, playerInfo.Connected ? Color.Aquamarine : Color.White); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.