Skip to content

Commit

Permalink
Admeme ebent icons fixes (#971)
Browse files Browse the repository at this point in the history
* fixed ebent role icons display

* fixed jobiconchanger
  • Loading branch information
DexlerXD authored May 5, 2024
1 parent 15b3c90 commit e33453a
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 34 deletions.
13 changes: 8 additions & 5 deletions Content.Client/SS220/AdmemeEvents/EventRoleIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ public override void Initialize()
SubscribeLocalEvent<EventRoleComponent, CanDisplayStatusIconsEvent>(OnCanShowRevIcon);
}

private void OnCanShowRevIcon(EntityUid uid, IAntagStatusIconComponent component, ref CanDisplayStatusIconsEvent args)
private void OnCanShowRevIcon(Entity<EventRoleComponent> entity, ref CanDisplayStatusIconsEvent args)
{
args.Cancelled = !CanDisplayIcon(args.User, component.IconVisibleToGhost);
args.Cancelled = !CanDisplayIcon(args.User, entity.Comp.IconVisibleToGhost, entity.Comp.RoleGroupKey);
}

private bool CanDisplayIcon(EntityUid? ent, bool visibleToGhost)
private bool CanDisplayIcon(EntityUid? ent, bool visibleToGhost, string roleGroupKey)
{
if (HasComp<GhostComponent>(ent) && visibleToGhost)
return true;

if (!HasComp<EventRoleComponent>(ent))
if (!TryComp<EventRoleComponent>(ent, out var comp))
return false;

return true;
if (!string.IsNullOrEmpty(roleGroupKey) && roleGroupKey == comp.RoleGroupKey)
return true;

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ protected override void Dispose(bool disposing)

_window?.Dispose();
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not JobIconChangerBoundUserInterfaceState iconChangerState)
return;

_window?.OnUpdateState(iconChangerState.Filter);
}
}
24 changes: 21 additions & 3 deletions Content.Client/SS220/AdmemeEvents/UI/JobIconChangerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Numerics;
using Content.Client.Stylesheets;
using Content.Shared.Antag;
using Content.Shared.SS220.AdmemeEvents;
using Content.Shared.StatusIcon;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -36,13 +36,31 @@ public JobIconChangerWindow(JobIconChangerBoundUserInterface bui)

_spriteSystem = _entitySystem.GetEntitySystem<SpriteSystem>();
_bui = bui;
}

public void OnUpdateState(EventRoleIconFilterGroup filter)
{
SetAllowedIcons(GetIconsList(filter));
}

public List<StatusIconPrototype> GetIconsList(EventRoleIconFilterGroup filter)
{
if (filter == EventRoleIconFilterGroup.None)
{
var allEventIcons = _prototypeManager.EnumeratePrototypes<StatusIconPrototype>()
.Where(icon => JobIconFilter.Any(filter => icon.ID.StartsWith(filter)))
.OrderBy(icon => icon.ID)
.ToList();

return allEventIcons;
}

var jobIconList = _prototypeManager.EnumeratePrototypes<StatusIconPrototype>()
.Where(icon => JobIconFilter.Any(filter => icon.ID.StartsWith(filter)))
.Where(icon => icon.ID.StartsWith(filter.ToString()))
.OrderBy(icon => icon.ID)
.ToList();

SetAllowedIcons(jobIconList);
return jobIconList;
}

public void SetAllowedIcons(List<StatusIconPrototype> jobIconList)
Expand Down
11 changes: 10 additions & 1 deletion Content.Server/SS220/AdmemeEvents/JobIconChangerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Content.Server.SS220.AdmemeEvents;

using Content.Shared.SS220.AdmemeEvents;
using Content.Shared.StatusIcon;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

[RegisterComponent]
Expand All @@ -12,4 +12,13 @@ public sealed partial class JobIconChangerComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<StatusIconPrototype>? JobIcon;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool CheckReach = false;

/// <summary>
/// Filter mode: None | IOT | NT | USSP
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public EventRoleIconFilterGroup IconFilterGroup = EventRoleIconFilterGroup.None;
}
22 changes: 15 additions & 7 deletions Content.Server/SS220/AdmemeEvents/JobIconChangerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Server.Administration.Logs;
using Content.Shared.Interaction;
using Content.Shared.SS220.AdmemeEvents;
using Robust.Server.GameObjects;

namespace Content.Server.SS220.AdmemeEvents;

public sealed class JobIconChangerSystem : EntitySystem
{
[Dependency] private readonly UserInterfaceSystem _ui = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<JobIconChangerComponent, JobIconChangerChangedMessage>(OnJobChanged);
SubscribeLocalEvent<JobIconChangerComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<JobIconChangerComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
}

private void OnBoundUIOpened(Entity<JobIconChangerComponent> entity, ref BoundUIOpenedEvent args)
{
if (!_ui.HasUi(entity, args.UiKey))
return;

_ui.SetUiState(entity.Owner, JobIconChangerKey.Key, new JobIconChangerBoundUserInterfaceState(entity.Comp.IconFilterGroup));
}

private void OnJobChanged(Entity<JobIconChangerComponent> entity, ref JobIconChangerChangedMessage args)
Expand All @@ -26,20 +37,17 @@ private void OnJobChanged(Entity<JobIconChangerComponent> entity, ref JobIconCha

private void OnAfterInteract(Entity<JobIconChangerComponent> entity, ref AfterInteractEvent args)
{
//if (component.JobIcon == null || !args.CanReach)
// return;

if (args.Handled || args.Target is not { } target)
if (entity.Comp.CheckReach && !args.CanReach)
return;

if (!TryComp(target, out EventRoleComponent? eventRoleComponent))
if (args.Handled || args.Target is not { } target)
return;

if (entity.Comp.JobIcon == null)
return;

var eventRoleComponent = EnsureComp<EventRoleComponent>(target);
eventRoleComponent.StatusIcon = entity.Comp.JobIcon.Value;

args.Handled = true;

Dirty(target, eventRoleComponent);
Expand Down
20 changes: 20 additions & 0 deletions Content.Shared/SS220/AdmemeEvents/SharedJobIconChangerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ public enum JobIconChangerKey : byte
Key
}

[Serializable, NetSerializable]
public enum EventRoleIconFilterGroup : byte
{
None,
IOT,
NT,
USSP
}

[Serializable, NetSerializable]
public sealed class JobIconChangerChangedMessage : BoundUserInterfaceMessage
{
Expand All @@ -20,3 +29,14 @@ public JobIconChangerChangedMessage(string jobIcon)
JobIcon = jobIcon;
}
}

[Serializable, NetSerializable]
public sealed class JobIconChangerBoundUserInterfaceState : BoundUserInterfaceState
{
public EventRoleIconFilterGroup Filter { get; }

public JobIconChangerBoundUserInterfaceState(EventRoleIconFilterGroup filter)
{
Filter = filter;
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
ent-JobIconChanger = Изменитель статус-иконок
.desc = Используется для изменения статус-иконок.
.desc = Используется для изменения статус-иконок.
ent-JobIconChangerIOT = Изменитель должности Железного отряда
.desc = Используется для изменения должностных маркировок.
ent-JobIconChangerNT = Изменитель должности NanoTransen
.desc = Используется для изменения должностных маркировок.
ent-JobIconChangerUSSP = Изменитель должности СССП
.desc = Используется для изменения должностных маркировок.
32 changes: 31 additions & 1 deletion Resources/Prototypes/SS220/Shitspawn/Ebent/job_icon_changer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,34 @@
interfaces:
enum.JobIconChangerKey.Key:
type: JobIconChangerBoundUserInterface
- type: JobIconChanger
- type: JobIconChanger

- type: entity
parent: JobIconChanger
id: JobIconChangerIOT
name: iron squad job icons changer
suffix: Shitspawn, Ebent, FractWar, IOT
components:
- type: JobIconChanger
checkReach: true
iconFilterGroup: IOT

- type: entity
parent: JobIconChanger
id: JobIconChangerNT
name: nanotransen icons changer
suffix: Shitspawn, Ebent, FractWar, NT
components:
- type: JobIconChanger
checkReach: true
iconFilterGroup: NT

- type: entity
parent: JobIconChanger
id: JobIconChangerUSSP
name: ussp job icons changer
suffix: Shitspawn, Ebent, FractWar, USSP
components:
- type: JobIconChanger
checkReach: true
iconFilterGroup: USSP
38 changes: 22 additions & 16 deletions Resources/Prototypes/SS220/StatusIcons/antag.yml
Original file line number Diff line number Diff line change
@@ -1,105 +1,111 @@
# © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
- type: statusIcon
id: IOTCommand
id: FractWarIcon
abstract: true
priority: 11
locationPreference: Right

- type: statusIcon
parent: FractWarIcon
id: IOTCommand
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: IOTCommand

- type: statusIcon
parent: FractWarIcon
id: IOTEngineerOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: IOTEngineerOfficer

- type: statusIcon
parent: FractWarIcon
id: IOTMedic
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: IOTMedic

- type: statusIcon
parent: FractWarIcon
id: IOTMedicalOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: IOTMedicalOfficer

- type: statusIcon
parent: FractWarIcon
id: IOTCombatant
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: IOTCombatant

- type: statusIcon
parent: FractWarIcon
id: NTCombatant
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: NTCombatant

- type: statusIcon
parent: FractWarIcon
id: NTEngineerOfficer
priority: 11
icon:
sprite: SS220/Interface/Misc/event-job-icons.rsi
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: NTEngineerOfficer

- type: statusIcon
parent: FractWarIcon
id: NTMedic
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: NTMedic

- type: statusIcon
parent: FractWarIcon
id: NTMedicalOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: NTMedicalOfficer

- type: statusIcon
parent: FractWarIcon
id: NTSpecOpsOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: NTSpecOpsOfficer

- type: statusIcon
parent: FractWarIcon
id: USSPCombatant
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: USSPCombatant

- type: statusIcon
parent: FractWarIcon
id: USSPEngineerOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: USSPEngineerOfficer

- type: statusIcon
parent: FractWarIcon
id: USSPMarshal
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: USSPMarshal

- type: statusIcon
parent: FractWarIcon
id: USSPMedic
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: USSPMedic

- type: statusIcon
parent: FractWarIcon
id: USSPMedicalOfficer
priority: 11
icon:
sprite: /Textures/SS220/Interface/Misc/event-job-icons.rsi
state: USSPMedicalOfficer

0 comments on commit e33453a

Please sign in to comment.