add mass-media system (#18251)
* 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
This commit is contained in:
18
Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml
Normal file
18
Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<PanelContainer VerticalExpand="True" HorizontalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#202124" />
|
||||
</PanelContainer.PanelOverride>
|
||||
<RichTextLabel Name="Name" Margin="8 8 8 8" HorizontalAlignment="Left"/>
|
||||
<Button Name="Delete"
|
||||
MinWidth="30"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{Loc 'news-write-ui-delete-text'}"
|
||||
Access="Public"
|
||||
Margin="6 6 6 6">
|
||||
</Button>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</Control>
|
||||
26
Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml.cs
Normal file
26
Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.MassMedia.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class MiniArticleCardControl : Control
|
||||
{
|
||||
public Action? OnDeletePressed;
|
||||
public int ArtcileNum;
|
||||
|
||||
public MiniArticleCardControl(string name)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
Name.SetMarkup(name);
|
||||
|
||||
Delete.OnPressed += _ => OnDeletePressed?.Invoke();
|
||||
}
|
||||
}
|
||||
58
Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs
Normal file
58
Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Content.Shared.MassMedia.Components;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.MassMedia.Ui
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NewsReadBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private NewsReadMenu? _menu;
|
||||
|
||||
[ViewVariables]
|
||||
private string _windowName = Loc.GetString("news-read-ui-default-title");
|
||||
|
||||
public NewsReadBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
_menu = new NewsReadMenu(_windowName);
|
||||
|
||||
_menu.OpenCentered();
|
||||
_menu.OnClose += Close;
|
||||
|
||||
_menu.NextButtonPressed += () => SendMessage(new NewsReadNextMessage());
|
||||
_menu.PastButtonPressed += () => SendMessage(new NewsReadPrevMessage());
|
||||
|
||||
SendMessage(new NewsReadArticleRequestMessage());
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Close();
|
||||
_menu?.Dispose();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
if (_menu == null)
|
||||
return;
|
||||
|
||||
if (state is NewsReadBoundUserInterfaceState cast)
|
||||
_menu.UpdateUI(cast.Article, cast.TargetNum, cast.TotalNum);
|
||||
if (state is NewsReadEmptyBoundUserInterfaceState)
|
||||
_menu.UpdateEmptyUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Content.Client/MassMedia/Ui/NewsReadMenu.xaml
Normal file
52
Content.Client/MassMedia/Ui/NewsReadMenu.xaml
Normal file
@@ -0,0 +1,52 @@
|
||||
<DefaultWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
Title="{Loc 'news-read-ui-default-title'}"
|
||||
MinSize="512 512"
|
||||
SetSize="512 512">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Margin="4,4,4,4" Orientation="Horizontal">
|
||||
<Button
|
||||
Name="Past"
|
||||
MinWidth="64"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Loc 'news-read-ui-past-text'}"
|
||||
Access="Public"
|
||||
HorizontalExpand="True" />
|
||||
<Button
|
||||
Name="Next"
|
||||
MinWidth="64"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{Loc 'news-read-ui-next-text'}" />
|
||||
</BoxContainer>
|
||||
<controls:StripeBack Name="АrticleNameContainer">
|
||||
<PanelContainer>
|
||||
<Label Name="PageNum" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0"/>
|
||||
<Label Name="PageName" Align="Center"/>
|
||||
</PanelContainer>
|
||||
</controls:StripeBack>
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#80808005" />
|
||||
</PanelContainer.PanelOverride>
|
||||
<ScrollContainer
|
||||
Name="PageTextScroll"
|
||||
HScrollEnabled="False"
|
||||
HorizontalExpand="True"
|
||||
MinSize="100 256"
|
||||
SizeFlagsStretchRatio="2"
|
||||
VerticalExpand="True">
|
||||
<BoxContainer
|
||||
Name="PageTextContainer"
|
||||
MinSize="100 256"
|
||||
Orientation="Vertical"
|
||||
SizeFlagsStretchRatio="2"
|
||||
VerticalExpand="True">
|
||||
</BoxContainer>
|
||||
<RichTextLabel Margin="8,8,8,8" Name="PageText" VerticalAlignment="Top"/>
|
||||
</ScrollContainer>
|
||||
</PanelContainer>
|
||||
<RichTextLabel Margin="8,8,8,8" Name="ShareTime" VerticalAlignment="Top"/>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
54
Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs
Normal file
54
Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Content.Client.Message;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
|
||||
namespace Content.Client.MassMedia.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
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? PastButtonPressed;
|
||||
|
||||
public NewsReadMenu(string name)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
if (Window != null)
|
||||
Window.Title = name;
|
||||
|
||||
Next.OnPressed += _ => NextButtonPressed?.Invoke();
|
||||
Past.OnPressed += _ => PastButtonPressed?.Invoke();
|
||||
}
|
||||
|
||||
public void UpdateUI(NewsArticle article, int targetNum, int totalNum)
|
||||
{
|
||||
PageNum.Visible = true;
|
||||
PageText.Visible = true;
|
||||
ShareTime.Visible = true;
|
||||
|
||||
PageName.Text = article.Name;
|
||||
PageText.SetMarkup(article.Content);
|
||||
|
||||
PageNum.Text = $"{targetNum}/{totalNum}";
|
||||
|
||||
string shareTime = article.ShareTime.ToString("hh\\:mm\\:ss");
|
||||
ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);
|
||||
}
|
||||
|
||||
public void UpdateEmptyUI()
|
||||
{
|
||||
PageName.Text = Loc.GetString("news-read-ui-not-found-text");
|
||||
|
||||
PageNum.Visible = false;
|
||||
PageText.Visible = false;
|
||||
ShareTime.Visible = false;
|
||||
}
|
||||
}
|
||||
88
Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
Normal file
88
Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Robust.Shared.Timing;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
using Content.Shared.MassMedia.Components;
|
||||
using Content.Client.GameTicking.Managers;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.MassMedia.Ui
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class NewsWriteBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private NewsWriteMenu? _menu;
|
||||
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
private ClientGameTicker? _gameTicker;
|
||||
|
||||
[ViewVariables]
|
||||
private string _windowName = Loc.GetString("news-read-ui-default-title");
|
||||
|
||||
public NewsWriteBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
_menu = new NewsWriteMenu(_windowName);
|
||||
|
||||
_menu.OpenCentered();
|
||||
_menu.OnClose += Close;
|
||||
|
||||
_menu.ShareButtonPressed += OnShareButtonPressed;
|
||||
_menu.DeleteButtonPressed += num => OnDeleteButtonPressed(num);
|
||||
|
||||
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
|
||||
|
||||
SendMessage(new NewsWriteArticlesRequestMessage());
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_menu?.Close();
|
||||
_menu?.Dispose();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
if (_menu == null || state is not NewsWriteBoundUserInterfaceState cast)
|
||||
return;
|
||||
|
||||
_menu.UpdateUI(cast.Articles);
|
||||
}
|
||||
|
||||
private void OnShareButtonPressed()
|
||||
{
|
||||
if (_menu == null || _menu.NameInput.Text.Length == 0)
|
||||
return;
|
||||
|
||||
var stringContent = Rope.Collapse(_menu.ContentInput.TextRope);
|
||||
|
||||
if (stringContent == null || stringContent.Length == 0) return;
|
||||
if (_gameTicker == null) return;
|
||||
|
||||
NewsArticle article = new NewsArticle();
|
||||
article.Name = _menu.NameInput.Text;
|
||||
article.Content = stringContent;
|
||||
article.ShareTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
|
||||
|
||||
SendMessage(new NewsWriteShareMessage(article));
|
||||
}
|
||||
|
||||
private void OnDeleteButtonPressed(int articleNum)
|
||||
{
|
||||
if (_menu == null) return;
|
||||
|
||||
SendMessage(new NewsWriteDeleteMessage(articleNum));
|
||||
}
|
||||
}
|
||||
}
|
||||
72
Content.Client/MassMedia/Ui/NewsWriteMenu.xaml
Normal file
72
Content.Client/MassMedia/Ui/NewsWriteMenu.xaml
Normal file
@@ -0,0 +1,72 @@
|
||||
<DefaultWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Title="{Loc 'news-write-ui-default-title'}"
|
||||
MinSize="680 512"
|
||||
SetSize="680 512">
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
VerticalExpand="True"
|
||||
SizeFlagsStretchRatio="2"
|
||||
Margin="10 0 10 10"
|
||||
MinWidth="350">
|
||||
<Label Text="{Loc 'news-write-ui-articles-label'}" HorizontalAlignment="Center"/>
|
||||
<customControls:HSeparator StyleClasses="LowDivider" Margin="0 0 0 10"/>
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
|
||||
</PanelContainer.PanelOverride>
|
||||
<ScrollContainer
|
||||
HScrollEnabled="False"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<BoxContainer
|
||||
Name="ArticleCardsContainer"
|
||||
Orientation="Vertical"
|
||||
VerticalExpand="True">
|
||||
|
||||
|
||||
|
||||
</BoxContainer>
|
||||
</ScrollContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
|
||||
<BoxContainer Orientation="Vertical"
|
||||
VerticalExpand="True"
|
||||
HorizontalExpand="True"
|
||||
Margin="15 0 0 0">
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<Label Text="{Loc 'news-write-ui-article-name-label'}"/>
|
||||
<LineEdit Name="NameInput"
|
||||
MinSize="60 0"
|
||||
VerticalAlignment="Top"
|
||||
Margin="4 0 0 0"
|
||||
Access="Public"
|
||||
HorizontalExpand="True"/>
|
||||
</BoxContainer>
|
||||
<customControls:HSeparator StyleClasses="LowDivider" Margin="0 5 0 5"/>
|
||||
<Label Text="{Loc 'news-write-ui-article-content-label'}" Margin="0 0 0 5"/>
|
||||
<PanelContainer Name="InputContainer"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalExpand="True"
|
||||
HorizontalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#333237"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<TextEdit Name="ContentInput" Access="Public" />
|
||||
</PanelContainer>
|
||||
<Button Name="Share"
|
||||
MinWidth="30"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Loc 'news-write-ui-share-text'}"
|
||||
Access="Public"
|
||||
Margin="0 4 4 4">
|
||||
</Button>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
42
Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
Normal file
42
Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
|
||||
namespace Content.Client.MassMedia.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class NewsWriteMenu : DefaultWindow
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public event Action? ShareButtonPressed;
|
||||
public event Action<int>? DeleteButtonPressed;
|
||||
|
||||
public NewsWriteMenu(string name)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
if (Window != null)
|
||||
Window.Title = name;
|
||||
|
||||
Share.OnPressed += _ => ShareButtonPressed?.Invoke();
|
||||
}
|
||||
|
||||
public void UpdateUI(NewsArticle[] articles)
|
||||
{
|
||||
ArticleCardsContainer.Children.Clear();
|
||||
|
||||
for (int i = 0; i < articles.Length; i++)
|
||||
{
|
||||
var mini = new MiniArticleCardControl(articles[i].Name);
|
||||
mini.ArtcileNum = i;
|
||||
mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum);
|
||||
|
||||
ArticleCardsContainer.AddChild(mini);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,12 @@ namespace Content.Client.PDA
|
||||
SendMessage(new PdaLockUplinkMessage());
|
||||
};
|
||||
|
||||
_menu.NewsReadButton.OnPressed += _ =>
|
||||
{
|
||||
SendMessage(new PdaOpenNewsMessage());
|
||||
};
|
||||
|
||||
|
||||
_menu.OnProgramItemPressed += ActivateCartridge;
|
||||
_menu.OnInstallButtonPressed += InstallCartridge;
|
||||
_menu.OnUninstallButtonPressed += UninstallCartridge;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<pda:PdaWindow xmlns="https://spacestation14.io"
|
||||
<pda:PdaWindow xmlns="https://spacestation14.io"
|
||||
xmlns:pda="clr-namespace:Content.Client.PDA"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
MinSize="576 450"
|
||||
@@ -65,6 +65,10 @@
|
||||
Text="{Loc 'crew-manifest-button-label'}"
|
||||
Description="{Loc 'crew-manifest-button-description'}"
|
||||
Visible="False" />
|
||||
<pda:PdaSettingsButton Name="NewsReadButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'pda-news-button-label'}"
|
||||
Description="{Loc 'pda-news-button-description'}"/>
|
||||
<pda:PdaSettingsButton Name="ActivateMusicButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'pda-bound-user-interface-music-button'}"
|
||||
|
||||
9
Content.Server/MassMedia/Components/NewsReadComponent.cs
Normal file
9
Content.Server/MassMedia/Components/NewsReadComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Server.MassMedia.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class NewsReadComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int ArticleNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server.MassMedia.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class NewsWriteComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
163
Content.Server/MassMedia/Systems/NewsSystem.cs
Normal file
163
Content.Server/MassMedia/Systems/NewsSystem.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using Content.Server.MassMedia.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Content.Shared.MassMedia.Components;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
using Content.Server.PDA.Ringer;
|
||||
using Content.Shared.GameTicking;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.MassMedia.Systems;
|
||||
|
||||
public sealed class NewsSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly RingerSystem _ringer = default!;
|
||||
|
||||
public List<NewsArticle> Articles = new List<NewsArticle>();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteShareMessage>(OnWriteUiMessage);
|
||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteDeleteMessage>(OnWriteUiMessage);
|
||||
SubscribeLocalEvent<NewsWriteComponent, NewsWriteArticlesRequestMessage>(OnWriteUiMessage);
|
||||
SubscribeLocalEvent<NewsReadComponent, NewsReadNextMessage>(OnReadUiMessage);
|
||||
SubscribeLocalEvent<NewsReadComponent, NewsReadPrevMessage>(OnReadUiMessage);
|
||||
SubscribeLocalEvent<NewsReadComponent, NewsReadArticleRequestMessage>(OnReadUiMessage);
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
|
||||
}
|
||||
|
||||
private void OnRoundRestart(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
if (Articles != null) Articles.Clear();
|
||||
}
|
||||
|
||||
public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsReadComponent? component)
|
||||
{
|
||||
if (!Resolve(deviceEnt, ref component))
|
||||
return;
|
||||
|
||||
if (!TryComp<ActorComponent>(user, out var actor))
|
||||
return;
|
||||
|
||||
_ui.TryToggleUi(deviceEnt, NewsReadUiKey.Key, actor.PlayerSession);
|
||||
}
|
||||
|
||||
public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsWriteComponent? component)
|
||||
{
|
||||
if (!Resolve(deviceEnt, ref component))
|
||||
return;
|
||||
|
||||
if (!TryComp<ActorComponent>(user, out var actor))
|
||||
return;
|
||||
|
||||
_ui.TryToggleUi(deviceEnt, NewsWriteUiKey.Key, actor.PlayerSession);
|
||||
}
|
||||
|
||||
public void UpdateWriteUi(EntityUid uid, NewsWriteComponent component)
|
||||
{
|
||||
if (!_ui.TryGetUi(uid, NewsWriteUiKey.Key, out _))
|
||||
return;
|
||||
|
||||
var state = new NewsWriteBoundUserInterfaceState(Articles.ToArray());
|
||||
_ui.TrySetUiState(uid, NewsWriteUiKey.Key, state);
|
||||
}
|
||||
|
||||
public void UpdateReadUi(EntityUid uid, NewsReadComponent component)
|
||||
{
|
||||
if (!_ui.TryGetUi(uid, NewsReadUiKey.Key, out _))
|
||||
return;
|
||||
|
||||
if (component.ArticleNum < 0) NewsReadLeafArticle(component, -1);
|
||||
|
||||
if (Articles.Any())
|
||||
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadBoundUserInterfaceState(Articles[component.ArticleNum], component.ArticleNum + 1, Articles.Count));
|
||||
else
|
||||
_ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadEmptyBoundUserInterfaceState());
|
||||
}
|
||||
|
||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg)
|
||||
{
|
||||
Articles.Add(msg.Article);
|
||||
|
||||
UpdateReadDevices();
|
||||
UpdateWriteDevices();
|
||||
TryNotify();
|
||||
}
|
||||
|
||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteDeleteMessage msg)
|
||||
{
|
||||
if (msg.ArticleNum < Articles.Count)
|
||||
{
|
||||
Articles.RemoveAt(msg.ArticleNum);
|
||||
}
|
||||
|
||||
UpdateReadDevices();
|
||||
UpdateWriteDevices();
|
||||
}
|
||||
|
||||
public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteArticlesRequestMessage msg)
|
||||
{
|
||||
UpdateWriteUi(uid, component);
|
||||
}
|
||||
|
||||
public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadNextMessage msg)
|
||||
{
|
||||
NewsReadLeafArticle(component, 1);
|
||||
|
||||
UpdateReadUi(uid, component);
|
||||
}
|
||||
|
||||
public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadPrevMessage msg)
|
||||
{
|
||||
NewsReadLeafArticle(component, -1);
|
||||
|
||||
UpdateReadUi(uid, component);
|
||||
}
|
||||
|
||||
public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadArticleRequestMessage msg)
|
||||
{
|
||||
UpdateReadUi(uid, component);
|
||||
}
|
||||
|
||||
private void NewsReadLeafArticle(NewsReadComponent component, int leafDir)
|
||||
{
|
||||
component.ArticleNum += leafDir;
|
||||
|
||||
if (component.ArticleNum >= Articles.Count) component.ArticleNum = 0;
|
||||
if (component.ArticleNum < 0) component.ArticleNum = Articles.Count - 1;
|
||||
}
|
||||
|
||||
private void TryNotify()
|
||||
{
|
||||
var query = EntityQueryEnumerator<NewsReadComponent, RingerComponent>();
|
||||
|
||||
while (query.MoveNext(out var comp, out var ringer))
|
||||
{
|
||||
_ringer.RingerPlayRingtone(comp.Owner, ringer);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateReadDevices()
|
||||
{
|
||||
var query = EntityQueryEnumerator<NewsReadComponent>();
|
||||
|
||||
while (query.MoveNext(out var comp))
|
||||
{
|
||||
UpdateReadUi(comp.Owner, comp);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWriteDevices()
|
||||
{
|
||||
var query = EntityQueryEnumerator<NewsWriteComponent>();
|
||||
|
||||
while (query.MoveNext(out var comp))
|
||||
{
|
||||
UpdateWriteUi(comp.Owner, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Shared.Light.Component;
|
||||
using Content.Server.MassMedia.Components;
|
||||
using Content.Server.MassMedia.Systems;
|
||||
|
||||
namespace Content.Server.PDA
|
||||
{
|
||||
@@ -25,6 +27,7 @@ namespace Content.Server.PDA
|
||||
[Dependency] private readonly RingerSystem _ringer = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly StoreSystem _store = default!;
|
||||
[Dependency] private readonly NewsSystem _news = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
@@ -42,6 +45,7 @@ namespace Content.Server.PDA
|
||||
SubscribeLocalEvent<PdaComponent, PdaShowMusicMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaShowUplinkMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaLockUplinkMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaOpenNewsMessage>(OnUiMessage);
|
||||
|
||||
SubscribeLocalEvent<StationRenamedEvent>(OnStationRenamed);
|
||||
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||
@@ -112,6 +116,7 @@ namespace Content.Server.PDA
|
||||
var address = GetDeviceNetAddress(uid);
|
||||
var hasInstrument = HasComp<InstrumentComponent>(uid);
|
||||
var showUplink = HasComp<StoreComponent>(uid) && IsUnlocked(uid);
|
||||
var showNews = HasComp<NewsReadComponent>(uid);
|
||||
|
||||
UpdateStationName(uid, pda);
|
||||
UpdateAlertLevel(uid, pda);
|
||||
@@ -133,6 +138,7 @@ namespace Content.Server.PDA
|
||||
pda.StationName,
|
||||
showUplink,
|
||||
hasInstrument,
|
||||
showNews,
|
||||
address);
|
||||
|
||||
_cartridgeLoader?.UpdateUiState(uid, state);
|
||||
@@ -195,6 +201,18 @@ namespace Content.Server.PDA
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaOpenNewsMessage msg)
|
||||
{
|
||||
if (!PdaUiKey.Key.Equals(msg.UiKey))
|
||||
return;
|
||||
|
||||
if (TryComp<NewsReadComponent>(uid, out var news))
|
||||
{
|
||||
_news.ToggleUi(msg.Session.AttachedEntity!.Value, uid, news);
|
||||
UpdatePdaUi(uid, pda);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsUnlocked(EntityUid uid)
|
||||
{
|
||||
return !TryComp<RingerUplinkComponent>(uid, out var uplink) || uplink.Unlocked;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Server.PDA.Ringer
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("range")]
|
||||
public float Range = 3f;
|
||||
public float Range = 0.5f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("volume")]
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Store.Components;
|
||||
using Content.Server.Store.Systems;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.PDA.Ringer;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Store;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
@@ -19,6 +20,7 @@ namespace Content.Server.PDA.Ringer
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -48,6 +50,18 @@ namespace Content.Server.PDA.Ringer
|
||||
private void RingerPlayRingtone(EntityUid uid, RingerComponent ringer, RingerPlayRingtoneMessage args)
|
||||
{
|
||||
EnsureComp<ActiveRingerComponent>(uid);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("comp-ringer-vibration-popup"), uid, Filter.Pvs(uid, 0.05f), false, PopupType.Small);
|
||||
|
||||
UpdateRingerUserInterface(uid, ringer);
|
||||
}
|
||||
|
||||
public void RingerPlayRingtone(EntityUid uid, RingerComponent ringer)
|
||||
{
|
||||
EnsureComp<ActiveRingerComponent>(uid);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("comp-ringer-vibration-popup"), uid, Filter.Pvs(uid, 0.05f), false, PopupType.Small);
|
||||
|
||||
UpdateRingerUserInterface(uid, ringer);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
|
||||
namespace Content.Shared.MassMedia.Components;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum NewsReadUiKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsReadBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public NewsArticle Article;
|
||||
public int TargetNum;
|
||||
public int TotalNum;
|
||||
|
||||
public NewsReadBoundUserInterfaceState(NewsArticle article, int targetNum, int totalNum)
|
||||
{
|
||||
Article = article;
|
||||
TargetNum = targetNum;
|
||||
TotalNum = totalNum;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsReadEmptyBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public NewsReadEmptyBoundUserInterfaceState()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsReadNextMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public NewsReadNextMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsReadPrevMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public NewsReadPrevMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsReadArticleRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public NewsReadArticleRequestMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
|
||||
namespace Content.Shared.MassMedia.Components;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum NewsWriteUiKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsWriteBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public NewsArticle[] Articles;
|
||||
|
||||
public NewsWriteBoundUserInterfaceState(NewsArticle[] articles)
|
||||
{
|
||||
Articles = articles;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsWriteShareMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public NewsArticle Article;
|
||||
|
||||
public NewsWriteShareMessage(NewsArticle article)
|
||||
{
|
||||
Article = article;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsWriteDeleteMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int ArticleNum;
|
||||
|
||||
public NewsWriteDeleteMessage(int num)
|
||||
{
|
||||
ArticleNum = num;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewsWriteArticlesRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public NewsWriteArticlesRequestMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
9
Content.Shared/MassMedia/Systems/SharedNewsSystem.cs
Normal file
9
Content.Shared/MassMedia/Systems/SharedNewsSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.MassMedia.Systems;
|
||||
|
||||
[Serializable]
|
||||
public struct NewsArticle
|
||||
{
|
||||
public string Name;
|
||||
public string Content;
|
||||
public TimeSpan ShareTime;
|
||||
}
|
||||
@@ -32,6 +32,12 @@ public sealed class PdaShowMusicMessage : BoundUserInterfaceMessage
|
||||
public PdaShowMusicMessage() { }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PdaOpenNewsMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public PdaOpenNewsMessage() { }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PdaRequestUpdateInterfaceMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
|
||||
@@ -13,17 +13,19 @@ namespace Content.Shared.PDA
|
||||
public string? StationName;
|
||||
public bool HasUplink;
|
||||
public bool CanPlayMusic;
|
||||
public bool HasNewsTab;
|
||||
public string? Address;
|
||||
|
||||
public PdaUpdateState(bool flashlightEnabled, bool hasPen, PdaIdInfoText pdaOwnerInfo,
|
||||
string? stationName, bool hasUplink = false,
|
||||
bool canPlayMusic = false, string? address = null)
|
||||
bool canPlayMusic = false, bool hasNewsTab = false, string? address = null)
|
||||
{
|
||||
FlashlightEnabled = flashlightEnabled;
|
||||
HasPen = hasPen;
|
||||
PdaOwnerInfo = pdaOwnerInfo;
|
||||
HasUplink = hasUplink;
|
||||
CanPlayMusic = canPlayMusic;
|
||||
HasNewsTab = hasNewsTab;
|
||||
StationName = stationName;
|
||||
Address = address;
|
||||
}
|
||||
|
||||
14
Resources/Locale/en-US/mass-media/news-ui.ftl
Normal file
14
Resources/Locale/en-US/mass-media/news-ui.ftl
Normal file
@@ -0,0 +1,14 @@
|
||||
pda-news-button-label = News
|
||||
pda-news-button-description = View station news
|
||||
news-read-ui-next-text = Next
|
||||
news-read-ui-past-text = Past
|
||||
news-read-ui-default-title = Station News
|
||||
news-read-ui-not-found-text = No articles found
|
||||
news-read-ui-time-prefix-text = Publication time:
|
||||
news-write-ui-default-title = Mass-media Management
|
||||
news-write-ui-articles-label = Articles:
|
||||
news-write-ui-delete-text = Delete
|
||||
news-write-ui-share-text = Publish
|
||||
news-write-ui-article-name-label = Heading:
|
||||
news-write-ui-article-content-label = Content:
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
# For the PDA Ringer screen
|
||||
|
||||
comp-ringer-vibration-popup = PDA vibrates
|
||||
|
||||
comp-ringer-ui-menu-title = Ringtone
|
||||
|
||||
comp-ringer-ui-test-ringtone-button = Test
|
||||
|
||||
@@ -365,3 +365,16 @@
|
||||
components:
|
||||
- type: ComputerBoard
|
||||
prototype: ComputerIFFSyndicate
|
||||
|
||||
- type: entity
|
||||
parent: BaseComputerCircuitboard
|
||||
id: ComputerMassMediaCircuitboard
|
||||
name: mass media console board
|
||||
description: Write your message to the world!
|
||||
components:
|
||||
- type: Sprite
|
||||
state: cpu_service
|
||||
- type: StaticPrice
|
||||
price: 150
|
||||
- type: ComputerBoard
|
||||
prototype: ComputerMassMedia
|
||||
@@ -97,8 +97,11 @@
|
||||
type: InstrumentBoundUserInterface
|
||||
- key: enum.HealthAnalyzerUiKey.Key
|
||||
type: HealthAnalyzerBoundUserInterface
|
||||
- key: enum.NewsReadUiKey.Key
|
||||
type: NewsReadBoundUserInterface
|
||||
- type: CrewManifestViewer
|
||||
unsecure: true
|
||||
- type: NewsRead
|
||||
- type: Tag
|
||||
tags:
|
||||
- DoorBumpOpener
|
||||
|
||||
@@ -940,3 +940,33 @@
|
||||
radius: 1.5
|
||||
energy: 1.6
|
||||
color: "#b89f25"
|
||||
|
||||
- type: entity
|
||||
parent: BaseComputer
|
||||
id: ComputerMassMedia
|
||||
name: mass-media console
|
||||
description: Write your message to the world!
|
||||
components:
|
||||
- type: Sprite
|
||||
layers:
|
||||
- map: ["computerLayerBody"]
|
||||
state: computer
|
||||
- map: ["computerLayerKeyboard"]
|
||||
state: generic_keyboard
|
||||
- map: ["computerLayerScreen"]
|
||||
state: service
|
||||
- map: ["computerLayerKeys"]
|
||||
state: service_keys
|
||||
- type: Computer
|
||||
board: ComputerMassMediaCircuitboard
|
||||
- type: DeviceNetworkRequiresPower
|
||||
- type: NewsWrite
|
||||
- type: ActivatableUI
|
||||
key: enum.NewsWriteUiKey.Key
|
||||
- type: ActivatableUIRequiresVision
|
||||
- type: Transform
|
||||
anchored: true
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.NewsWriteUiKey.Key
|
||||
type: NewsWriteBoundUserInterface
|
||||
|
||||
@@ -316,6 +316,7 @@
|
||||
- BoozeDispenserMachineCircuitboard
|
||||
- SodaDispenserMachineCircuitboard
|
||||
- TelecomServerCircuitboard
|
||||
- MassMediaCircuitboard
|
||||
- type: MaterialStorage
|
||||
whitelist:
|
||||
tags:
|
||||
|
||||
@@ -645,3 +645,11 @@
|
||||
materials:
|
||||
Steel: 100
|
||||
Glass: 900
|
||||
|
||||
- type: latheRecipe
|
||||
id: MassMediaCircuitboard
|
||||
result: ComputerMassMediaCircuitboard
|
||||
completetime: 4
|
||||
materials:
|
||||
Steel: 100
|
||||
Glass: 900
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
- ComputerTelevisionCircuitboard
|
||||
- SynthesizerInstrument
|
||||
- DawInstrumentMachineCircuitboard
|
||||
- MassMediaCircuitboard
|
||||
|
||||
# Tier 2
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Resources/Textures/Structures/Machines/computers.rsi/service.png
Normal file
BIN
Resources/Textures/Structures/Machines/computers.rsi/service.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 435 B |
Reference in New Issue
Block a user