Add auth to the mass-media console (#18345)
* process my own comments * add fields and handling * little cleanups * localization * u * whoops
This commit is contained in:
@@ -1,18 +1,14 @@
|
|||||||
using Content.Client.Message;
|
using Content.Client.Message;
|
||||||
|
using Content.Shared.MassMedia.Systems;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Content.Shared.MassMedia.Systems;
|
|
||||||
|
|
||||||
namespace Content.Client.MassMedia.Ui;
|
namespace Content.Client.MassMedia.Ui;
|
||||||
|
|
||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public sealed partial class NewsReadMenu : DefaultWindow
|
public sealed partial class NewsReadMenu : DefaultWindow
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
||||||
|
|
||||||
public event Action? NextButtonPressed;
|
public event Action? NextButtonPressed;
|
||||||
public event Action? PastButtonPressed;
|
public event Action? PastButtonPressed;
|
||||||
|
|
||||||
@@ -34,13 +30,13 @@ public sealed partial class NewsReadMenu : DefaultWindow
|
|||||||
PageText.Visible = true;
|
PageText.Visible = true;
|
||||||
ShareTime.Visible = true;
|
ShareTime.Visible = true;
|
||||||
|
|
||||||
PageName.Text = article.Name;
|
PageName.Text = $"{article.Name} by {article.Author ?? Loc.GetString("news-read-ui-no-author")}";
|
||||||
PageText.SetMarkup(article.Content);
|
PageText.SetMarkup(article.Content);
|
||||||
|
|
||||||
PageNum.Text = $"{targetNum}/{totalNum}";
|
PageNum.Text = $"{targetNum}/{totalNum}";
|
||||||
|
|
||||||
string shareTime = article.ShareTime.ToString("hh\\:mm\\:ss");
|
string shareTime = article.ShareTime.ToString("hh\\:mm\\:ss");
|
||||||
ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);
|
ShareTime.SetMarkup($"{Loc.GetString("news-read-ui-time-prefix-text")} {shareTime}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateEmptyUI()
|
public void UpdateEmptyUI()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Content.Client.MassMedia.Ui
|
|||||||
_menu.OnClose += Close;
|
_menu.OnClose += Close;
|
||||||
|
|
||||||
_menu.ShareButtonPressed += OnShareButtonPressed;
|
_menu.ShareButtonPressed += OnShareButtonPressed;
|
||||||
_menu.DeleteButtonPressed += num => OnDeleteButtonPressed(num);
|
_menu.DeleteButtonPressed += OnDeleteButtonPressed;
|
||||||
|
|
||||||
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
|
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,10 @@
|
|||||||
Name="ArticleCardsContainer"
|
Name="ArticleCardsContainer"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
VerticalExpand="True">
|
VerticalExpand="True">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
|
||||||
<BoxContainer Orientation="Vertical"
|
<BoxContainer Orientation="Vertical"
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
using Content.Server.MassMedia.Components;
|
using Content.Server.MassMedia.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Content.Server.PDA.Ringer;
|
||||||
|
using Content.Shared.Access.Components;
|
||||||
|
using Content.Shared.Access.Systems;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.MassMedia.Components;
|
using Content.Shared.MassMedia.Components;
|
||||||
using Content.Shared.MassMedia.Systems;
|
using Content.Shared.MassMedia.Systems;
|
||||||
using Content.Server.PDA.Ringer;
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.GameTicking;
|
using Robust.Server.GameObjects;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using TerraFX.Interop.Windows;
|
||||||
|
|
||||||
namespace Content.Server.MassMedia.Systems;
|
namespace Content.Server.MassMedia.Systems;
|
||||||
|
|
||||||
@@ -12,18 +16,19 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
[Dependency] private readonly RingerSystem _ringer = default!;
|
[Dependency] private readonly RingerSystem _ringer = default!;
|
||||||
|
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||||
|
|
||||||
public List<NewsArticle> Articles = new List<NewsArticle>();
|
private readonly List<NewsArticle> _articles = new List<NewsArticle>();
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteShareMessage>(OnWriteUiMessage);
|
SubscribeLocalEvent<NewsWriteComponent, NewsWriteShareMessage>(OnWriteUiMessage);
|
||||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteDeleteMessage>(OnWriteUiMessage);
|
SubscribeLocalEvent<NewsWriteComponent, NewsWriteDeleteMessage>(OnDeleteUiMessage);
|
||||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteArticlesRequestMessage>(OnWriteUiMessage);
|
SubscribeLocalEvent<NewsWriteComponent, NewsWriteArticlesRequestMessage>(OnRequestUiMessage);
|
||||||
SubscribeLocalEvent<NewsReadComponent, NewsReadNextMessage>(OnReadUiMessage);
|
SubscribeLocalEvent<NewsReadComponent, NewsReadNextMessage>(OnNextArticleUiMessage);
|
||||||
SubscribeLocalEvent<NewsReadComponent, NewsReadPrevMessage>(OnReadUiMessage);
|
SubscribeLocalEvent<NewsReadComponent, NewsReadPrevMessage>(OnPrevArticleUiMessage);
|
||||||
SubscribeLocalEvent<NewsReadComponent, NewsReadArticleRequestMessage>(OnReadUiMessage);
|
SubscribeLocalEvent<NewsReadComponent, NewsReadArticleRequestMessage>(OnReadUiMessage);
|
||||||
|
|
||||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||||
@@ -31,7 +36,7 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnRoundRestart(RoundRestartCleanupEvent ev)
|
private void OnRoundRestart(RoundRestartCleanupEvent ev)
|
||||||
{
|
{
|
||||||
if (Articles != null) Articles.Clear();
|
_articles?.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsReadComponent? component)
|
public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsReadComponent? component)
|
||||||
@@ -56,12 +61,12 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
_ui.TryToggleUi(deviceEnt, NewsWriteUiKey.Key, actor.PlayerSession);
|
_ui.TryToggleUi(deviceEnt, NewsWriteUiKey.Key, actor.PlayerSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateWriteUi(EntityUid uid, NewsWriteComponent component)
|
public void UpdateWriteUi(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (!_ui.TryGetUi(uid, NewsWriteUiKey.Key, out _))
|
if (!_ui.TryGetUi(uid, NewsWriteUiKey.Key, out _))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var state = new NewsWriteBoundUserInterfaceState(Articles.ToArray());
|
var state = new NewsWriteBoundUserInterfaceState(_articles.ToArray());
|
||||||
_ui.TrySetUiState(uid, NewsWriteUiKey.Key, state);
|
_ui.TrySetUiState(uid, NewsWriteUiKey.Key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,49 +75,103 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
if (!_ui.TryGetUi(uid, NewsReadUiKey.Key, out _))
|
if (!_ui.TryGetUi(uid, NewsReadUiKey.Key, out _))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.ArticleNum < 0) NewsReadLeafArticle(component, -1);
|
if (component.ArticleNum < 0)
|
||||||
|
{
|
||||||
|
NewsReadPreviousArticle(component);
|
||||||
|
}
|
||||||
|
|
||||||
if (Articles.Any())
|
if (_articles.Any())
|
||||||
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadBoundUserInterfaceState(Articles[component.ArticleNum], component.ArticleNum + 1, Articles.Count));
|
{
|
||||||
|
if (component.ArticleNum >= _articles.Count)
|
||||||
|
{
|
||||||
|
component.ArticleNum = _articles.Count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadBoundUserInterfaceState(_articles[component.ArticleNum], component.ArticleNum + 1, _articles.Count));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadEmptyBoundUserInterfaceState());
|
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadEmptyBoundUserInterfaceState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg)
|
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg)
|
||||||
{
|
{
|
||||||
Articles.Add(msg.Article);
|
var article = msg.Article;
|
||||||
|
|
||||||
|
var author = msg.Session.AttachedEntity;
|
||||||
|
if (author.HasValue
|
||||||
|
&& _accessReader.FindAccessItemsInventory(author.Value, out var items)
|
||||||
|
&& _accessReader.FindStationRecordKeys(author.Value, out var stationRecordKeys, items))
|
||||||
|
{
|
||||||
|
article.AuthorStationRecordKeyIds = stationRecordKeys;
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
// ID Card
|
||||||
|
if (TryComp(item, out IdCardComponent? id))
|
||||||
|
{
|
||||||
|
article.Author = id.FullName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// PDA
|
||||||
|
else if (TryComp(item, out PdaComponent? pda)
|
||||||
|
&& pda.ContainedId != null
|
||||||
|
&& TryComp(pda.ContainedId, out id))
|
||||||
|
{
|
||||||
|
article.Author = id.FullName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_articles.Add(article);
|
||||||
|
|
||||||
UpdateReadDevices();
|
UpdateReadDevices();
|
||||||
UpdateWriteDevices();
|
UpdateWriteDevices();
|
||||||
TryNotify();
|
TryNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteDeleteMessage msg)
|
public void OnDeleteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteDeleteMessage msg)
|
||||||
{
|
{
|
||||||
if (msg.ArticleNum < Articles.Count)
|
if (msg.ArticleNum > _articles.Count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var articleToDelete = _articles[msg.ArticleNum];
|
||||||
|
if (articleToDelete.AuthorStationRecordKeyIds == null || !articleToDelete.AuthorStationRecordKeyIds.Any())
|
||||||
{
|
{
|
||||||
Articles.RemoveAt(msg.ArticleNum);
|
_articles.RemoveAt(msg.ArticleNum);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var author = msg.Session.AttachedEntity;
|
||||||
|
if (author.HasValue
|
||||||
|
&& _accessReader.FindStationRecordKeys(author.Value, out var recordKeys)
|
||||||
|
&& recordKeys.Intersect(articleToDelete.AuthorStationRecordKeyIds).Any())
|
||||||
|
{
|
||||||
|
_articles.RemoveAt(msg.ArticleNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateReadDevices();
|
UpdateReadDevices();
|
||||||
UpdateWriteDevices();
|
UpdateWriteDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteArticlesRequestMessage msg)
|
public void OnRequestUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteArticlesRequestMessage msg)
|
||||||
{
|
{
|
||||||
UpdateWriteUi(uid, component);
|
UpdateWriteUi(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadNextMessage msg)
|
public void OnNextArticleUiMessage(EntityUid uid, NewsReadComponent component, NewsReadNextMessage msg)
|
||||||
{
|
{
|
||||||
NewsReadLeafArticle(component, 1);
|
NewsReadNextArticle(component);
|
||||||
|
|
||||||
UpdateReadUi(uid, component);
|
UpdateReadUi(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadPrevMessage msg)
|
public void OnPrevArticleUiMessage(EntityUid uid, NewsReadComponent component, NewsReadPrevMessage msg)
|
||||||
{
|
{
|
||||||
NewsReadLeafArticle(component, -1);
|
NewsReadPreviousArticle(component);
|
||||||
|
|
||||||
UpdateReadUi(uid, component);
|
UpdateReadUi(uid, component);
|
||||||
}
|
}
|
||||||
@@ -122,21 +181,33 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
UpdateReadUi(uid, component);
|
UpdateReadUi(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewsReadLeafArticle(NewsReadComponent component, int leafDir)
|
private void NewsReadNextArticle(NewsReadComponent component)
|
||||||
{
|
{
|
||||||
component.ArticleNum += leafDir;
|
if (!_articles.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (component.ArticleNum >= Articles.Count) component.ArticleNum = 0;
|
component.ArticleNum = (component.ArticleNum + 1) % _articles.Count;
|
||||||
if (component.ArticleNum < 0) component.ArticleNum = Articles.Count - 1;
|
}
|
||||||
|
|
||||||
|
private void NewsReadPreviousArticle(NewsReadComponent component)
|
||||||
|
{
|
||||||
|
if (!_articles.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.ArticleNum = (component.ArticleNum - 1 + _articles.Count) % _articles.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryNotify()
|
private void TryNotify()
|
||||||
{
|
{
|
||||||
var query = EntityQueryEnumerator<NewsReadComponent, RingerComponent>();
|
var query = EntityQueryEnumerator<NewsReadComponent, RingerComponent>();
|
||||||
|
|
||||||
while (query.MoveNext(out var comp, out var ringer))
|
while (query.MoveNext(out var owner, out var _, out var ringer))
|
||||||
{
|
{
|
||||||
_ringer.RingerPlayRingtone(comp.Owner, ringer);
|
_ringer.RingerPlayRingtone(owner, ringer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,9 +215,9 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
var query = EntityQueryEnumerator<NewsReadComponent>();
|
var query = EntityQueryEnumerator<NewsReadComponent>();
|
||||||
|
|
||||||
while (query.MoveNext(out var comp))
|
while (query.MoveNext(out var owner, out var comp))
|
||||||
{
|
{
|
||||||
UpdateReadUi(comp.Owner, comp);
|
UpdateReadUi(owner, comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,9 +225,9 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
var query = EntityQueryEnumerator<NewsWriteComponent>();
|
var query = EntityQueryEnumerator<NewsWriteComponent>();
|
||||||
|
|
||||||
while (query.MoveNext(out var comp))
|
while (query.MoveNext(out var owner, out var _))
|
||||||
{
|
{
|
||||||
UpdateWriteUi(comp.Owner, comp);
|
UpdateWriteUi(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ using Content.Server.DeviceNetwork.Components;
|
|||||||
using Content.Server.Instruments;
|
using Content.Server.Instruments;
|
||||||
using Content.Server.Light.EntitySystems;
|
using Content.Server.Light.EntitySystems;
|
||||||
using Content.Server.Light.Events;
|
using Content.Server.Light.Events;
|
||||||
|
using Content.Server.MassMedia.Components;
|
||||||
|
using Content.Server.MassMedia.Systems;
|
||||||
using Content.Server.Mind;
|
using Content.Server.Mind;
|
||||||
using Content.Server.PDA.Ringer;
|
using Content.Server.PDA.Ringer;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
using Content.Server.Store.Components;
|
using Content.Server.Store.Components;
|
||||||
using Content.Server.Store.Systems;
|
using Content.Server.Store.Systems;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
|
using Content.Shared.Light.Component;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Content.Shared.Light.Component;
|
|
||||||
using Content.Server.MassMedia.Components;
|
|
||||||
using Content.Server.MassMedia.Systems;
|
|
||||||
|
|
||||||
namespace Content.Server.PDA
|
namespace Content.Server.PDA
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,6 @@ namespace Content.Server.PDA
|
|||||||
[Dependency] private readonly NewsSystem _news = default!;
|
[Dependency] private readonly NewsSystem _news = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
|
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
|
||||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Content.Server.PDA.Ringer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("range")]
|
[DataField("range")]
|
||||||
public float Range = 0.5f;
|
public float Range = 3f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("volume")]
|
[DataField("volume")]
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using Content.Shared.Inventory;
|
|
||||||
using Content.Shared.Emag.Components;
|
|
||||||
using Content.Shared.Emag.Systems;
|
|
||||||
using Content.Shared.PDA;
|
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.DeviceLinking.Events;
|
using Content.Shared.DeviceLinking.Events;
|
||||||
using Robust.Shared.Containers;
|
using Content.Shared.Emag.Components;
|
||||||
using Robust.Shared.Prototypes;
|
using Content.Shared.Emag.Systems;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
|
using Content.Shared.Inventory;
|
||||||
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.StationRecords;
|
using Content.Shared.StationRecords;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Content.Shared.Access.Systems;
|
namespace Content.Shared.Access.Systems;
|
||||||
|
|
||||||
@@ -42,9 +42,9 @@ public sealed class AccessReaderSystem : EntitySystem
|
|||||||
if (args.Current is not AccessReaderComponentState state)
|
if (args.Current is not AccessReaderComponentState state)
|
||||||
return;
|
return;
|
||||||
component.Enabled = state.Enabled;
|
component.Enabled = state.Enabled;
|
||||||
component.AccessKeys = new (state.AccessKeys);
|
component.AccessKeys = new(state.AccessKeys);
|
||||||
component.AccessLists = new (state.AccessLists);
|
component.AccessLists = new(state.AccessLists);
|
||||||
component.DenyTags = new (state.DenyTags);
|
component.DenyTags = new(state.DenyTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLinkAttempt(EntityUid uid, AccessReaderComponent component, LinkAttemptEvent args)
|
private void OnLinkAttempt(EntityUid uid, AccessReaderComponent component, LinkAttemptEvent args)
|
||||||
@@ -67,24 +67,24 @@ public sealed class AccessReaderSystem : EntitySystem
|
|||||||
/// required entity.
|
/// required entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="target">The entity to search for a container</param>
|
/// <param name="target">The entity to search for a container</param>
|
||||||
private bool FindAccessReadersInContainer(EntityUid target, AccessReaderComponent accessReader, out List<AccessReaderComponent> result)
|
private bool FindAccessReadersInContainer(EntityUid target, AccessReaderComponent accessReader, out List<AccessReaderComponent> result)
|
||||||
|
{
|
||||||
|
result = new();
|
||||||
|
if (accessReader.ContainerAccessProvider == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!_containerSystem.TryGetContainer(target, accessReader.ContainerAccessProvider, out var container))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var entity in container.ContainedEntities)
|
||||||
{
|
{
|
||||||
result = new();
|
if (TryComp<AccessReaderComponent>(entity, out var entityAccessReader))
|
||||||
if (accessReader.ContainerAccessProvider == null)
|
result.Add(entityAccessReader);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!_containerSystem.TryGetContainer(target, accessReader.ContainerAccessProvider, out var container))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
foreach (var entity in container.ContainedEntities)
|
|
||||||
{
|
|
||||||
if (TryComp<AccessReaderComponent>(entity, out var entityAccessReader))
|
|
||||||
result.Add(entityAccessReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.Any();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result.Any();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the source for access tags
|
/// Searches the source for access tags
|
||||||
/// then compares it with the all targets accesses to see if it is allowed.
|
/// then compares it with the all targets accesses to see if it is allowed.
|
||||||
@@ -94,22 +94,22 @@ public sealed class AccessReaderSystem : EntitySystem
|
|||||||
/// <param name="reader">Optional reader from the target entity</param>
|
/// <param name="reader">Optional reader from the target entity</param>
|
||||||
public bool IsAllowed(EntityUid source, EntityUid target, AccessReaderComponent? reader = null)
|
public bool IsAllowed(EntityUid source, EntityUid target, AccessReaderComponent? reader = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(target, ref reader, false))
|
if (!Resolve(target, ref reader, false))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (FindAccessReadersInContainer(target, reader, out var accessReaderList))
|
if (FindAccessReadersInContainer(target, reader, out var accessReaderList))
|
||||||
|
{
|
||||||
|
foreach (var access in accessReaderList)
|
||||||
{
|
{
|
||||||
foreach (var access in accessReaderList)
|
if (IsAllowed(source, access))
|
||||||
{
|
return true;
|
||||||
if (IsAllowed(source, access))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return IsAllowed(source, reader);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return IsAllowed(source, reader);
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the given entity for access tags
|
/// Searches the given entity for access tags
|
||||||
/// then compares it with the readers access list to see if it is allowed.
|
/// then compares it with the readers access list to see if it is allowed.
|
||||||
@@ -118,16 +118,17 @@ public sealed class AccessReaderSystem : EntitySystem
|
|||||||
/// <param name="reader">A reader from a different entity</param>
|
/// <param name="reader">A reader from a different entity</param>
|
||||||
public bool IsAllowed(EntityUid entity, AccessReaderComponent reader)
|
public bool IsAllowed(EntityUid entity, AccessReaderComponent reader)
|
||||||
{
|
{
|
||||||
var allEnts = FindPotentialAccessItems(entity);
|
|
||||||
|
|
||||||
// Access reader is totally disabled, so access is always allowed.
|
// Access reader is totally disabled, so access is always allowed.
|
||||||
if (!reader.Enabled)
|
if (!reader.Enabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
var allEnts = FindPotentialAccessItems(entity);
|
||||||
|
|
||||||
if (AreAccessTagsAllowed(FindAccessTags(entity, allEnts), reader))
|
if (AreAccessTagsAllowed(FindAccessTags(entity, allEnts), reader))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (AreStationRecordKeysAllowed(FindStationRecordKeys(entity, allEnts), reader))
|
if (FindStationRecordKeys(entity, out var recordKeys, allEnts)
|
||||||
|
&& AreStationRecordKeysAllowed(recordKeys, reader))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -202,19 +203,19 @@ public sealed class AccessReaderSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid">The entity that is being searched.</param>
|
/// <param name="uid">The entity that is being searched.</param>
|
||||||
/// <param name="items">All of the items to search for access. If none are passed in, <see cref="FindPotentialAccessItems"/> will be used.</param>
|
/// <param name="items">All of the items to search for access. If none are passed in, <see cref="FindPotentialAccessItems"/> will be used.</param>
|
||||||
public ICollection<StationRecordKey> FindStationRecordKeys(EntityUid uid, HashSet<EntityUid>? items = null)
|
public bool FindStationRecordKeys(EntityUid uid, out ICollection<StationRecordKey> recordKeys, HashSet<EntityUid>? items = null)
|
||||||
{
|
{
|
||||||
HashSet<StationRecordKey> keys = new();
|
recordKeys = new HashSet<StationRecordKey>();
|
||||||
|
|
||||||
items ??= FindPotentialAccessItems(uid);
|
items ??= FindPotentialAccessItems(uid);
|
||||||
|
|
||||||
foreach (var ent in items)
|
foreach (var ent in items)
|
||||||
{
|
{
|
||||||
if (FindStationRecordKeyItem(ent, out var key))
|
if (FindStationRecordKeyItem(ent, out var key))
|
||||||
keys.Add(key.Value);
|
recordKeys.Add(key.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys;
|
return recordKeys.Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Robust.Shared.Serialization;
|
|
||||||
using Content.Shared.MassMedia.Systems;
|
using Content.Shared.MassMedia.Systems;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.MassMedia.Components;
|
namespace Content.Shared.MassMedia.Components;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using Content.Shared.StationRecords;
|
||||||
|
|
||||||
namespace Content.Shared.MassMedia.Systems;
|
namespace Content.Shared.MassMedia.Systems;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@@ -5,5 +7,7 @@ public struct NewsArticle
|
|||||||
{
|
{
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Content;
|
public string Content;
|
||||||
|
public string? Author;
|
||||||
|
public ICollection<StationRecordKey>? AuthorStationRecordKeyIds;
|
||||||
public TimeSpan ShareTime;
|
public TimeSpan ShareTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Content.Shared.CartridgeLoader;
|
using Content.Shared.CartridgeLoader;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Shared.PDA
|
namespace Content.Shared.PDA
|
||||||
{
|
{
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
@@ -16,9 +15,14 @@ namespace Content.Shared.PDA
|
|||||||
public bool HasNewsTab;
|
public bool HasNewsTab;
|
||||||
public string? Address;
|
public string? Address;
|
||||||
|
|
||||||
public PdaUpdateState(bool flashlightEnabled, bool hasPen, PdaIdInfoText pdaOwnerInfo,
|
public PdaUpdateState(bool flashlightEnabled,
|
||||||
string? stationName, bool hasUplink = false,
|
bool hasPen,
|
||||||
bool canPlayMusic = false, bool hasNewsTab = false, string? address = null)
|
PdaIdInfoText pdaOwnerInfo,
|
||||||
|
string? stationName,
|
||||||
|
bool hasUplink = false,
|
||||||
|
bool canPlayMusic = false,
|
||||||
|
bool hasNewsTab = false,
|
||||||
|
string? address = null)
|
||||||
{
|
{
|
||||||
FlashlightEnabled = flashlightEnabled;
|
FlashlightEnabled = flashlightEnabled;
|
||||||
HasPen = hasPen;
|
HasPen = hasPen;
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ news-read-ui-past-text = Past
|
|||||||
news-read-ui-default-title = Station News
|
news-read-ui-default-title = Station News
|
||||||
news-read-ui-not-found-text = No articles found
|
news-read-ui-not-found-text = No articles found
|
||||||
news-read-ui-time-prefix-text = Publication time:
|
news-read-ui-time-prefix-text = Publication time:
|
||||||
|
news-read-ui-no-author = Anonymous
|
||||||
news-write-ui-default-title = Mass-media Management
|
news-write-ui-default-title = Mass-media Management
|
||||||
news-write-ui-articles-label = Articles:
|
news-write-ui-articles-label = Articles:
|
||||||
news-write-ui-delete-text = Delete
|
news-write-ui-delete-text = Delete
|
||||||
news-write-ui-share-text = Publish
|
news-write-ui-share-text = Publish
|
||||||
news-write-ui-article-name-label = Heading:
|
news-write-ui-article-name-label = Heading:
|
||||||
news-write-ui-article-content-label = Content:
|
news-write-ui-article-content-label = Content:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user