Mass-media console update (#18466)
* Add Console, PDA news tab, and ringstone popup * Add English localization * Add mass-media console board to Advanced Entertainment resrarch * Fix misprint * Deleting unused libraries * Fix round restart problem * Fixing restart problem * Just another fix * Сode optimization * Code optimization * Convert News read tab to cartridge Convert the News read tab into a cartridge, and fix a couple of bugs * Just another fix * Some updates * More fixing!! Fix cooldown, add author label to read menu * Again, fix cooldown bug * Some minor changes * Revert "Some minor changes" This reverts commit 470c8d727629ac79994f70e56162adae8659e944. * Some minor updates * News write Ui update * Just another fix * See commit below comments * More code readability, more!
This commit is contained in:
@@ -1,18 +1,26 @@
|
|||||||
<Control xmlns="https://spacestation14.io"
|
<Control xmlns="https://spacestation14.io"
|
||||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="0 0 0 12">
|
||||||
<PanelContainer VerticalExpand="True" HorizontalExpand="True">
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True">
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
|
||||||
<gfx:StyleBoxFlat BackgroundColor="#202124" />
|
<PanelContainer.PanelOverride>
|
||||||
</PanelContainer.PanelOverride>
|
<gfx:StyleBoxFlat BackgroundColor="#4c6530"/>
|
||||||
<RichTextLabel Name="Name" Margin="8 8 8 8" HorizontalAlignment="Left"/>
|
</PanelContainer.PanelOverride>
|
||||||
<Button Name="Delete"
|
<Label Name="Name" Margin="6 6 6 6" HorizontalAlignment="Center"/>
|
||||||
MinWidth="30"
|
</PanelContainer>
|
||||||
HorizontalAlignment="Right"
|
</BoxContainer>
|
||||||
Text="{Loc 'news-write-ui-delete-text'}"
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||||
Access="Public"
|
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
|
||||||
Margin="6 6 6 6">
|
<PanelContainer.PanelOverride>
|
||||||
</Button>
|
<gfx:StyleBoxFlat BackgroundColor="#33333f"/>
|
||||||
</PanelContainer>
|
</PanelContainer.PanelOverride>
|
||||||
|
<RichTextLabel Name="Author" HorizontalExpand="True" VerticalAlignment="Bottom" Margin="6 6 6 6"/>
|
||||||
|
<Button Name="Delete"
|
||||||
|
Text="{Loc 'news-write-ui-delete-text'}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="8 6 6 6"
|
||||||
|
Access="Public"/>
|
||||||
|
</PanelContainer>
|
||||||
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ public sealed partial class MiniArticleCardControl : Control
|
|||||||
public Action? OnDeletePressed;
|
public Action? OnDeletePressed;
|
||||||
public int ArtcileNum;
|
public int ArtcileNum;
|
||||||
|
|
||||||
public MiniArticleCardControl(string name)
|
public MiniArticleCardControl(string name, string author)
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
Name.SetMarkup(name);
|
Name.Text = name;
|
||||||
|
Author.SetMarkup(author);
|
||||||
|
|
||||||
Delete.OnPressed += _ => OnDeletePressed?.Invoke();
|
Delete.OnPressed += _ => OnDeletePressed?.Invoke();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public sealed partial class NewsWriteMenu : DefaultWindow
|
|||||||
|
|
||||||
for (int i = 0; i < articles.Length; i++)
|
for (int i = 0; i < articles.Length; i++)
|
||||||
{
|
{
|
||||||
var mini = new MiniArticleCardControl(articles[i].Name);
|
var article = articles[i];
|
||||||
|
var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
|
||||||
mini.ArtcileNum = i;
|
mini.ArtcileNum = i;
|
||||||
mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum);
|
mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||||
|
|
||||||
namespace Content.Server.MassMedia.Components
|
namespace Content.Server.MassMedia.Components
|
||||||
@@ -13,5 +14,10 @@ namespace Content.Server.MassMedia.Components
|
|||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("shareCooldown")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("shareCooldown")]
|
||||||
public float ShareCooldown = 60f;
|
public float ShareCooldown = 60f;
|
||||||
|
|
||||||
|
[DataField("noAccessSound")]
|
||||||
|
public SoundSpecifier NoAccessSound = new SoundPathSpecifier("/Audio/Machines/airlock_deny.ogg");
|
||||||
|
[DataField("confirmSound")]
|
||||||
|
public SoundSpecifier ConfirmSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Content.Shared.CartridgeLoader.Cartridges;
|
|||||||
using Content.Server.CartridgeLoader;
|
using Content.Server.CartridgeLoader;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using TerraFX.Interop.Windows;
|
using TerraFX.Interop.Windows;
|
||||||
|
using Content.Server.Popups;
|
||||||
|
|
||||||
namespace Content.Server.MassMedia.Systems;
|
namespace Content.Server.MassMedia.Systems;
|
||||||
|
|
||||||
@@ -23,6 +24,8 @@ 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 CartridgeLoaderSystem? _cartridgeLoaderSystem = default!;
|
[Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
|
|
||||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||||
|
|
||||||
@@ -131,6 +134,8 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_audio.PlayPvs(component.ConfirmSound, uid);
|
||||||
|
|
||||||
_articles.Add(article);
|
_articles.Add(article);
|
||||||
|
|
||||||
component.ShareAvalible = false;
|
component.ShareAvalible = false;
|
||||||
@@ -146,20 +151,15 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
if (msg.ArticleNum > _articles.Count)
|
if (msg.ArticleNum > _articles.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var articleToDelete = _articles[msg.ArticleNum];
|
if (CheckDeleteAccess(_articles[msg.ArticleNum], uid, msg.Session.AttachedEntity))
|
||||||
if (articleToDelete.AuthorStationRecordKeyIds == null || !articleToDelete.AuthorStationRecordKeyIds.Any())
|
|
||||||
{
|
{
|
||||||
_articles.RemoveAt(msg.ArticleNum);
|
_articles.RemoveAt(msg.ArticleNum);
|
||||||
|
_audio.PlayPvs(component.ConfirmSound, uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var author = msg.Session.AttachedEntity;
|
_popup.PopupEntity(Loc.GetString("news-write-no-access-popup"), uid);
|
||||||
if (author.HasValue
|
_audio.PlayPvs(component.NoAccessSound, uid);
|
||||||
&& _accessReader.FindStationRecordKeys(author.Value, out var recordKeys)
|
|
||||||
&& recordKeys.Intersect(articleToDelete.AuthorStationRecordKeyIds).Any())
|
|
||||||
{
|
|
||||||
_articles.RemoveAt(msg.ArticleNum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateReadDevices();
|
UpdateReadDevices();
|
||||||
@@ -217,6 +217,30 @@ public sealed class NewsSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckDeleteAccess(NewsArticle articleToDelete, EntityUid device, EntityUid? user)
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent<AccessReaderComponent>(device, out var accessReader) &&
|
||||||
|
user.HasValue &&
|
||||||
|
_accessReader.IsAllowed(user.Value, accessReader))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (articleToDelete.AuthorStationRecordKeyIds == null ||
|
||||||
|
!articleToDelete.AuthorStationRecordKeyIds.Any())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (user.HasValue
|
||||||
|
&& _accessReader.FindStationRecordKeys(user.Value, out var recordKeys)
|
||||||
|
&& recordKeys.Intersect(articleToDelete.AuthorStationRecordKeyIds).Any())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|||||||
@@ -13,3 +13,5 @@ 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:
|
||||||
|
news-write-no-access-popup = No access
|
||||||
|
|
||||||
|
|||||||
@@ -961,6 +961,8 @@
|
|||||||
board: ComputerMassMediaCircuitboard
|
board: ComputerMassMediaCircuitboard
|
||||||
- type: DeviceNetworkRequiresPower
|
- type: DeviceNetworkRequiresPower
|
||||||
- type: NewsWrite
|
- type: NewsWrite
|
||||||
|
- type: AccessReader
|
||||||
|
access: [[ "Command" ]]
|
||||||
- type: ActivatableUI
|
- type: ActivatableUI
|
||||||
key: enum.NewsWriteUiKey.Key
|
key: enum.NewsWriteUiKey.Key
|
||||||
- type: ActivatableUIRequiresVision
|
- type: ActivatableUIRequiresVision
|
||||||
|
|||||||
Reference in New Issue
Block a user