From e4dcdc0c6e48641dec59735d6e1af563ff669896 Mon Sep 17 00:00:00 2001
From: MishaUnity <81403616+MishaUnity@users.noreply.github.com>
Date: Fri, 28 Jul 2023 22:59:03 +0300
Subject: [PATCH] convert News read tab to PDA Cartridge (#18368)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 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
---
.../CartridgeLoader/Cartridges/NewsReadUi.cs | 50 ++++++
.../Cartridges/NewsReadUiFragment.xaml | 54 ++++++
.../Cartridges/NewsReadUiFragment.xaml.cs | 60 +++++++
.../Cartridges/NotekeeperUiFragment.xaml | 2 +-
.../Ui/NewsReadBoundUserInterface.cs | 58 ------
Content.Client/MassMedia/Ui/NewsReadMenu.xaml | 52 ------
.../MassMedia/Ui/NewsReadMenu.xaml.cs | 50 ------
.../Ui/NewsWriteBoundUserInterface.cs | 9 +-
.../MassMedia/Ui/NewsWriteMenu.xaml.cs | 4 +-
Content.Client/PDA/PdaBoundUserInterface.cs | 6 -
Content.Client/PDA/PdaMenu.xaml | 4 -
.../Cartridges/NewsReadCartridgeComponent.cs | 11 ++
.../NotekeeperCartridgeComponent.cs | 2 +-
.../Cartridges/NotekeeperCartridgeSystem.cs | 2 +-
.../MassMedia/Components/NewsReadComponent.cs | 9 -
.../Components/NewsWriteComponent.cs | 9 +
.../MassMedia/Systems/NewsSystem.cs | 166 +++++++++---------
Content.Server/PDA/PdaSystem.cs | 15 --
.../Cartridges/NewsReadUiMessageEvent.cs | 22 +++
.../Cartridges/NewsReadUiState.cs | 32 ++++
.../Cartridges/NotekeeperUiMessageEvent.cs | 2 +-
.../Components/SharedNewsReadComponent.cs | 57 ------
.../Components/SharedNewsWriteComponent.cs | 4 +-
Content.Shared/PDA/PdaMessagesUi.cs | 6 -
Content.Shared/PDA/PdaUpdateState.cs | 13 +-
.../en-US/cartridge-loader/cartridges.ftl | 1 +
Resources/Locale/en-US/mass-media/news-ui.ftl | 5 +-
.../Devices/Circuitboards/computer.yml | 2 +-
.../Entities/Objects/Devices/cartridges.yml | 21 +++
.../Entities/Objects/Devices/pda.yml | 16 +-
.../Misc/program_icons.rsi/meta.json | 14 ++
.../Misc/program_icons.rsi/news_read.png | Bin 0 -> 417 bytes
32 files changed, 395 insertions(+), 363 deletions(-)
create mode 100644 Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs
create mode 100644 Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml
create mode 100644 Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml.cs
delete mode 100644 Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs
delete mode 100644 Content.Client/MassMedia/Ui/NewsReadMenu.xaml
delete mode 100644 Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs
create mode 100644 Content.Server/CartridgeLoader/Cartridges/NewsReadCartridgeComponent.cs
delete mode 100644 Content.Server/MassMedia/Components/NewsReadComponent.cs
create mode 100644 Content.Shared/CartridgeLoader/Cartridges/NewsReadUiMessageEvent.cs
create mode 100644 Content.Shared/CartridgeLoader/Cartridges/NewsReadUiState.cs
delete mode 100644 Content.Shared/MassMedia/Components/SharedNewsReadComponent.cs
create mode 100644 Resources/Textures/Interface/Misc/program_icons.rsi/meta.json
create mode 100644 Resources/Textures/Interface/Misc/program_icons.rsi/news_read.png
diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs b/Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs
new file mode 100644
index 0000000000..ce240e53a0
--- /dev/null
+++ b/Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs
@@ -0,0 +1,50 @@
+using Content.Client.UserInterface.Fragments;
+using Content.Shared.CartridgeLoader.Cartridges;
+using Content.Shared.CartridgeLoader;
+using Robust.Client.GameObjects;
+using Robust.Client.UserInterface;
+
+namespace Content.Client.CartridgeLoader.Cartridges;
+
+public sealed class NewsReadUi : UIFragment
+{
+ private NewsReadUiFragment? _fragment;
+
+ public override Control GetUIFragmentRoot()
+ {
+ return _fragment!;
+ }
+
+ public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
+ {
+ _fragment = new NewsReadUiFragment();
+
+ _fragment.OnNextButtonPressed += () =>
+ {
+ SendNewsReadMessage(NewsReadUiAction.Next, userInterface);
+ };
+ _fragment.OnPrevButtonPressed += () =>
+ {
+ SendNewsReadMessage(NewsReadUiAction.Prev, userInterface);
+ };
+ _fragment.OnNotificationSwithPressed += () =>
+ {
+ SendNewsReadMessage(NewsReadUiAction.NotificationSwith, userInterface);
+ };
+ }
+
+ public override void UpdateState(BoundUserInterfaceState state)
+ {
+ if (state is NewsReadBoundUserInterfaceState cast)
+ _fragment?.UpdateState(cast.Article, cast.TargetNum, cast.TotalNum, cast.NotificationOn);
+ else if (state is NewsReadEmptyBoundUserInterfaceState empty)
+ _fragment?.UpdateEmptyState(empty.NotificationOn);
+ }
+
+ private void SendNewsReadMessage(NewsReadUiAction action, BoundUserInterface userInterface)
+ {
+ var newsMessage = new NewsReadUiMessageEvent(action);
+ var message = new CartridgeUiMessage(newsMessage);
+ userInterface.SendMessage(message);
+ }
+}
diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml
new file mode 100644
index 0000000000..7431713ea8
--- /dev/null
+++ b/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml.cs
new file mode 100644
index 0000000000..df558429c9
--- /dev/null
+++ b/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml.cs
@@ -0,0 +1,60 @@
+using Content.Client.Message;
+using Content.Shared.MassMedia.Systems;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.CartridgeLoader.Cartridges;
+
+[GenerateTypedNameReferences]
+public sealed partial class NewsReadUiFragment : BoxContainer
+{
+ public event Action? OnNextButtonPressed;
+ public event Action? OnPrevButtonPressed;
+
+ public event Action? OnNotificationSwithPressed;
+
+ public NewsReadUiFragment()
+ {
+ RobustXamlLoader.Load(this);
+ Orientation = LayoutOrientation.Vertical;
+ HorizontalExpand = true;
+ VerticalExpand = true;
+
+ Next.OnPressed += _ => OnNextButtonPressed?.Invoke();
+ Prev.OnPressed += _ => OnPrevButtonPressed?.Invoke();
+ NotificationSwith.OnPressed += _ => OnNotificationSwithPressed?.Invoke();
+ }
+
+ public void UpdateState(NewsArticle article, int targetNum, int totalNum, bool notificationOn)
+ {
+ PageNum.Visible = true;
+ PageText.Visible = true;
+ ShareTime.Visible = true;
+ Author.Visible = true;
+
+ PageName.Text = article.Name;
+ PageText.SetMarkup(article.Content);
+
+ PageNum.Text = $"{targetNum}/{totalNum}";
+
+ NotificationSwith.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
+
+ string shareTime = article.ShareTime.ToString("hh\\:mm\\:ss");
+ ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);
+
+ Author.SetMarkup(Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
+ }
+
+ public void UpdateEmptyState(bool notificationOn)
+ {
+ PageNum.Visible = false;
+ PageText.Visible = false;
+ ShareTime.Visible = false;
+ Author.Visible = false;
+
+ PageName.Text = Loc.GetString("news-read-ui-not-found-text");
+
+ NotificationSwith.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
+ }
+}
diff --git a/Content.Client/CartridgeLoader/Cartridges/NotekeeperUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/NotekeeperUiFragment.xaml
index ed79d0f795..84826979cd 100644
--- a/Content.Client/CartridgeLoader/Cartridges/NotekeeperUiFragment.xaml
+++ b/Content.Client/CartridgeLoader/Cartridges/NotekeeperUiFragment.xaml
@@ -1,4 +1,4 @@
-
diff --git a/Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs b/Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs
deleted file mode 100644
index 98ffd44359..0000000000
--- a/Content.Client/MassMedia/Ui/NewsReadBoundUserInterface.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-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();
- }
- }
-}
diff --git a/Content.Client/MassMedia/Ui/NewsReadMenu.xaml b/Content.Client/MassMedia/Ui/NewsReadMenu.xaml
deleted file mode 100644
index b4c3698946..0000000000
--- a/Content.Client/MassMedia/Ui/NewsReadMenu.xaml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs b/Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs
deleted file mode 100644
index 1b02df34b3..0000000000
--- a/Content.Client/MassMedia/Ui/NewsReadMenu.xaml.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Content.Client.Message;
-using Content.Shared.MassMedia.Systems;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface.CustomControls;
-using Robust.Client.UserInterface.XAML;
-
-namespace Content.Client.MassMedia.Ui;
-
-[GenerateTypedNameReferences]
-public sealed partial class NewsReadMenu : DefaultWindow
-{
- 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} by {article.Author ?? Loc.GetString("news-read-ui-no-author")}";
- 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;
- }
-}
diff --git a/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs b/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
index 9b228efddd..1ec19ad411 100644
--- a/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
+++ b/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs
@@ -57,7 +57,7 @@ namespace Content.Client.MassMedia.Ui
if (_menu == null || state is not NewsWriteBoundUserInterfaceState cast)
return;
- _menu.UpdateUI(cast.Articles);
+ _menu.UpdateUI(cast.Articles, cast.ShareAvalible);
}
private void OnShareButtonPressed()
@@ -71,10 +71,15 @@ namespace Content.Client.MassMedia.Ui
if (_gameTicker == null) return;
NewsArticle article = new NewsArticle();
- article.Name = _menu.NameInput.Text;
+ var stringName = _menu.NameInput.Text;
+ var name = (stringName.Length <= 25 ? stringName.Trim() : $"{stringName.Trim().Substring(0, 25)}...");
+ article.Name = name;
article.Content = stringContent;
article.ShareTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
+ _menu.ContentInput.TextRope = new Rope.Leaf(string.Empty);
+ _menu.NameInput.Text = string.Empty;
+
SendMessage(new NewsWriteShareMessage(article));
}
diff --git a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs b/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
index 788f31b9c9..99b1f47fd1 100644
--- a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
+++ b/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
@@ -26,7 +26,7 @@ public sealed partial class NewsWriteMenu : DefaultWindow
Share.OnPressed += _ => ShareButtonPressed?.Invoke();
}
- public void UpdateUI(NewsArticle[] articles)
+ public void UpdateUI(NewsArticle[] articles, bool shareAvalible)
{
ArticleCardsContainer.Children.Clear();
@@ -38,5 +38,7 @@ public sealed partial class NewsWriteMenu : DefaultWindow
ArticleCardsContainer.AddChild(mini);
}
+
+ Share.Disabled = !shareAvalible;
}
}
diff --git a/Content.Client/PDA/PdaBoundUserInterface.cs b/Content.Client/PDA/PdaBoundUserInterface.cs
index 2238948cce..bd23d5ea55 100644
--- a/Content.Client/PDA/PdaBoundUserInterface.cs
+++ b/Content.Client/PDA/PdaBoundUserInterface.cs
@@ -73,12 +73,6 @@ namespace Content.Client.PDA
SendMessage(new PdaLockUplinkMessage());
};
- _menu.NewsReadButton.OnPressed += _ =>
- {
- SendMessage(new PdaOpenNewsMessage());
- };
-
-
_menu.OnProgramItemPressed += ActivateCartridge;
_menu.OnInstallButtonPressed += InstallCartridge;
_menu.OnUninstallButtonPressed += UninstallCartridge;
diff --git a/Content.Client/PDA/PdaMenu.xaml b/Content.Client/PDA/PdaMenu.xaml
index f6b07d1ca6..dbdcb4d90b 100644
--- a/Content.Client/PDA/PdaMenu.xaml
+++ b/Content.Client/PDA/PdaMenu.xaml
@@ -65,10 +65,6 @@
Text="{Loc 'crew-manifest-button-label'}"
Description="{Loc 'crew-manifest-button-description'}"
Visible="False" />
-
_articles = new List();
public override void Initialize()
{
base.Initialize();
- SubscribeLocalEvent(OnWriteUiMessage);
- SubscribeLocalEvent(OnDeleteUiMessage);
- SubscribeLocalEvent(OnRequestUiMessage);
- SubscribeLocalEvent(OnNextArticleUiMessage);
- SubscribeLocalEvent(OnPrevArticleUiMessage);
- SubscribeLocalEvent(OnReadUiMessage);
+ SubscribeLocalEvent(OnWriteUiShareMessage);
+ SubscribeLocalEvent(OnWriteUiDeleteMessage);
+ SubscribeLocalEvent(OnRequestWriteUiMessage);
+
+ SubscribeLocalEvent(OnReadUiReady);
+ SubscribeLocalEvent(OnReadUiMessage);
SubscribeLocalEvent(OnRoundRestart);
}
@@ -39,17 +48,6 @@ public sealed class NewsSystem : EntitySystem
_articles?.Clear();
}
- public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsReadComponent? component)
- {
- if (!Resolve(deviceEnt, ref component))
- return;
-
- if (!TryComp(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))
@@ -61,41 +59,49 @@ public sealed class NewsSystem : EntitySystem
_ui.TryToggleUi(deviceEnt, NewsWriteUiKey.Key, actor.PlayerSession);
}
- public void UpdateWriteUi(EntityUid uid)
+ public void OnReadUiReady(EntityUid uid, NewsReadCartridgeComponent component, CartridgeUiReadyEvent args)
+ {
+ UpdateReadUi(uid, args.Loader, component);
+ }
+
+ public void UpdateWriteUi(EntityUid uid, NewsWriteComponent component)
{
if (!_ui.TryGetUi(uid, NewsWriteUiKey.Key, out _))
return;
- var state = new NewsWriteBoundUserInterfaceState(_articles.ToArray());
+ var state = new NewsWriteBoundUserInterfaceState(_articles.ToArray(), component.ShareAvalible);
_ui.TrySetUiState(uid, NewsWriteUiKey.Key, state);
}
- public void UpdateReadUi(EntityUid uid, NewsReadComponent component)
+ public void UpdateReadUi(EntityUid uid, EntityUid loaderUid, NewsReadCartridgeComponent? component)
{
- if (!_ui.TryGetUi(uid, NewsReadUiKey.Key, out _))
+ if (!Resolve(uid, ref component))
return;
- if (component.ArticleNum < 0)
- {
- NewsReadPreviousArticle(component);
- }
+ NewsReadLeafArticle(component, 0);
if (_articles.Any())
- {
- 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));
- }
+ _cartridgeLoaderSystem?.UpdateCartridgeUiState(loaderUid, new NewsReadBoundUserInterfaceState(_articles[component.ArticleNum], component.ArticleNum + 1, _articles.Count, component.NotificationOn));
else
- {
- _ui.TrySetUiState(uid, NewsReadUiKey.Key, new NewsReadEmptyBoundUserInterfaceState());
- }
+ _cartridgeLoaderSystem?.UpdateCartridgeUiState(loaderUid, new NewsReadEmptyBoundUserInterfaceState(component.NotificationOn));
}
- public void OnWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg)
+ private void OnReadUiMessage(EntityUid uid, NewsReadCartridgeComponent component, CartridgeMessageEvent args)
+ {
+ if (args is not NewsReadUiMessageEvent message)
+ return;
+
+ if (message.Action == NewsReadUiAction.Next)
+ NewsReadLeafArticle(component, 1);
+ if (message.Action == NewsReadUiAction.Prev)
+ NewsReadLeafArticle(component, -1);
+ if (message.Action == NewsReadUiAction.NotificationSwith)
+ component.NotificationOn = !component.NotificationOn;
+
+ UpdateReadUi(uid, args.LoaderUid, component);
+ }
+
+ public void OnWriteUiShareMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg)
{
var article = msg.Article;
@@ -127,12 +133,15 @@ public sealed class NewsSystem : EntitySystem
_articles.Add(article);
+ component.ShareAvalible = false;
+ component.NextShare = _timing.CurTime + TimeSpan.FromSeconds(component.ShareCooldown);
+
UpdateReadDevices();
UpdateWriteDevices();
TryNotify();
}
- public void OnDeleteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteDeleteMessage msg)
+ public void OnWriteUiDeleteMessage(EntityUid uid, NewsWriteComponent component, NewsWriteDeleteMessage msg)
{
if (msg.ArticleNum > _articles.Count)
return;
@@ -157,67 +166,44 @@ public sealed class NewsSystem : EntitySystem
UpdateWriteDevices();
}
- public void OnRequestUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteArticlesRequestMessage msg)
+ public void OnRequestWriteUiMessage(EntityUid uid, NewsWriteComponent component, NewsWriteArticlesRequestMessage msg)
{
- UpdateWriteUi(uid);
+ UpdateWriteUi(uid, component);
}
- public void OnNextArticleUiMessage(EntityUid uid, NewsReadComponent component, NewsReadNextMessage msg)
+ private void NewsReadLeafArticle(NewsReadCartridgeComponent component, int leafDir)
{
- NewsReadNextArticle(component);
+ component.ArticleNum += leafDir;
- UpdateReadUi(uid, component);
- }
-
- public void OnPrevArticleUiMessage(EntityUid uid, NewsReadComponent component, NewsReadPrevMessage msg)
- {
- NewsReadPreviousArticle(component);
-
- UpdateReadUi(uid, component);
- }
-
- public void OnReadUiMessage(EntityUid uid, NewsReadComponent component, NewsReadArticleRequestMessage msg)
- {
- UpdateReadUi(uid, component);
- }
-
- private void NewsReadNextArticle(NewsReadComponent component)
- {
- if (!_articles.Any())
- {
- return;
- }
-
- component.ArticleNum = (component.ArticleNum + 1) % _articles.Count;
- }
-
- private void NewsReadPreviousArticle(NewsReadComponent component)
- {
- if (!_articles.Any())
- {
- return;
- }
-
- component.ArticleNum = (component.ArticleNum - 1 + _articles.Count) % _articles.Count;
+ if (component.ArticleNum >= _articles.Count) component.ArticleNum = 0;
+ if (component.ArticleNum < 0) component.ArticleNum = _articles.Count - 1;
}
private void TryNotify()
{
- var query = EntityQueryEnumerator();
+ var query = EntityQueryEnumerator();
- while (query.MoveNext(out var owner, out var _, out var ringer))
+ while (query.MoveNext(out var owner, out var comp, out var ringer))
{
- _ringer.RingerPlayRingtone(owner, ringer);
+ foreach (var app in comp.InstalledPrograms)
+ {
+ if (EntityManager.TryGetComponent(app, out var cartridge) && cartridge.NotificationOn)
+ {
+ _ringer.RingerPlayRingtone(owner, ringer);
+ break;
+ }
+ }
}
}
private void UpdateReadDevices()
{
- var query = EntityQueryEnumerator();
+ var query = EntityQueryEnumerator();
while (query.MoveNext(out var owner, out var comp))
{
- UpdateReadUi(owner, comp);
+ if (EntityManager.TryGetComponent(comp.ActiveProgram, out var cartridge))
+ UpdateReadUi(cartridge.Owner, comp.Owner, cartridge);
}
}
@@ -225,9 +211,25 @@ public sealed class NewsSystem : EntitySystem
{
var query = EntityQueryEnumerator();
- while (query.MoveNext(out var owner, out var _))
+ while (query.MoveNext(out var owner, out var comp))
{
- UpdateWriteUi(owner);
+ UpdateWriteUi(owner, comp);
+ }
+ }
+
+ public override void Update(float frameTime)
+ {
+ base.Update(frameTime);
+
+ var query = EntityQueryEnumerator();
+ while (query.MoveNext(out var comp))
+ {
+ if (comp.ShareAvalible || _timing.CurTime < comp.NextShare)
+ continue;
+
+ comp.ShareAvalible = true;
+
+ UpdateWriteUi(comp.Owner, comp);
}
}
}
diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs
index 6168ad8d41..b975b96073 100644
--- a/Content.Server/PDA/PdaSystem.cs
+++ b/Content.Server/PDA/PdaSystem.cs
@@ -44,7 +44,6 @@ namespace Content.Server.PDA
SubscribeLocalEvent(OnUiMessage);
SubscribeLocalEvent(OnUiMessage);
SubscribeLocalEvent(OnUiMessage);
- SubscribeLocalEvent(OnUiMessage);
SubscribeLocalEvent(OnStationRenamed);
SubscribeLocalEvent(OnAlertLevelChanged);
@@ -115,7 +114,6 @@ namespace Content.Server.PDA
var address = GetDeviceNetAddress(uid);
var hasInstrument = HasComp(uid);
var showUplink = HasComp(uid) && IsUnlocked(uid);
- var showNews = HasComp(uid);
UpdateStationName(uid, pda);
UpdateAlertLevel(uid, pda);
@@ -137,7 +135,6 @@ namespace Content.Server.PDA
pda.StationName,
showUplink,
hasInstrument,
- showNews,
address);
_cartridgeLoader?.UpdateUiState(uid, state);
@@ -200,18 +197,6 @@ namespace Content.Server.PDA
}
}
- private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaOpenNewsMessage msg)
- {
- if (!PdaUiKey.Key.Equals(msg.UiKey))
- return;
-
- if (TryComp(uid, out var news))
- {
- _news.ToggleUi(msg.Session.AttachedEntity!.Value, uid, news);
- UpdatePdaUi(uid, pda);
- }
- }
-
private bool IsUnlocked(EntityUid uid)
{
return !TryComp(uid, out var uplink) || uplink.Unlocked;
diff --git a/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiMessageEvent.cs b/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiMessageEvent.cs
new file mode 100644
index 0000000000..323ee17a11
--- /dev/null
+++ b/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiMessageEvent.cs
@@ -0,0 +1,22 @@
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.CartridgeLoader.Cartridges;
+
+[Serializable, NetSerializable]
+public sealed class NewsReadUiMessageEvent : CartridgeMessageEvent
+{
+ public readonly NewsReadUiAction Action;
+
+ public NewsReadUiMessageEvent(NewsReadUiAction action)
+ {
+ Action = action;
+ }
+}
+
+[Serializable, NetSerializable]
+public enum NewsReadUiAction
+{
+ Next,
+ Prev,
+ NotificationSwith
+}
diff --git a/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiState.cs b/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiState.cs
new file mode 100644
index 0000000000..f0a973b014
--- /dev/null
+++ b/Content.Shared/CartridgeLoader/Cartridges/NewsReadUiState.cs
@@ -0,0 +1,32 @@
+using Robust.Shared.Serialization;
+using Content.Shared.MassMedia.Systems;
+
+namespace Content.Shared.CartridgeLoader.Cartridges;
+
+[Serializable, NetSerializable]
+public sealed class NewsReadBoundUserInterfaceState : BoundUserInterfaceState
+{
+ public NewsArticle Article;
+ public int TargetNum;
+ public int TotalNum;
+ public bool NotificationOn;
+
+ public NewsReadBoundUserInterfaceState(NewsArticle article, int targetNum, int totalNum, bool notificationOn)
+ {
+ Article = article;
+ TargetNum = targetNum;
+ TotalNum = totalNum;
+ NotificationOn = notificationOn;
+ }
+}
+
+[Serializable, NetSerializable]
+public sealed class NewsReadEmptyBoundUserInterfaceState : BoundUserInterfaceState
+{
+ public bool NotificationOn;
+
+ public NewsReadEmptyBoundUserInterfaceState(bool notificationOn)
+ {
+ NotificationOn = notificationOn;
+ }
+}
diff --git a/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiMessageEvent.cs b/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiMessageEvent.cs
index 588ffe20f2..456fba2b31 100644
--- a/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiMessageEvent.cs
+++ b/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiMessageEvent.cs
@@ -1,4 +1,4 @@
-using Robust.Shared.Serialization;
+using Robust.Shared.Serialization;
namespace Content.Shared.CartridgeLoader.Cartridges;
diff --git a/Content.Shared/MassMedia/Components/SharedNewsReadComponent.cs b/Content.Shared/MassMedia/Components/SharedNewsReadComponent.cs
deleted file mode 100644
index 499aede51f..0000000000
--- a/Content.Shared/MassMedia/Components/SharedNewsReadComponent.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-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()
- {
- }
-}
diff --git a/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs b/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs
index 88261427d8..7ab737d48b 100644
--- a/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs
+++ b/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs
@@ -13,10 +13,12 @@ public enum NewsWriteUiKey : byte
public sealed class NewsWriteBoundUserInterfaceState : BoundUserInterfaceState
{
public NewsArticle[] Articles;
+ public bool ShareAvalible;
- public NewsWriteBoundUserInterfaceState(NewsArticle[] articles)
+ public NewsWriteBoundUserInterfaceState(NewsArticle[] articles, bool shareAvalible)
{
Articles = articles;
+ ShareAvalible = shareAvalible;
}
}
diff --git a/Content.Shared/PDA/PdaMessagesUi.cs b/Content.Shared/PDA/PdaMessagesUi.cs
index 7bcc0afbe9..00d29e1e1a 100644
--- a/Content.Shared/PDA/PdaMessagesUi.cs
+++ b/Content.Shared/PDA/PdaMessagesUi.cs
@@ -32,12 +32,6 @@ public sealed class PdaShowMusicMessage : BoundUserInterfaceMessage
public PdaShowMusicMessage() { }
}
-[Serializable, NetSerializable]
-public sealed class PdaOpenNewsMessage : BoundUserInterfaceMessage
-{
- public PdaOpenNewsMessage() { }
-}
-
[Serializable, NetSerializable]
public sealed class PdaRequestUpdateInterfaceMessage : BoundUserInterfaceMessage
{
diff --git a/Content.Shared/PDA/PdaUpdateState.cs b/Content.Shared/PDA/PdaUpdateState.cs
index ea2569d21e..f5e44e7beb 100644
--- a/Content.Shared/PDA/PdaUpdateState.cs
+++ b/Content.Shared/PDA/PdaUpdateState.cs
@@ -12,24 +12,17 @@ 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,
- bool hasNewsTab = false,
- string? address = null)
+ public PdaUpdateState(bool flashlightEnabled, bool hasPen, PdaIdInfoText pdaOwnerInfo,
+ string? stationName, bool hasUplink = false,
+ bool canPlayMusic = false, string? address = null)
{
FlashlightEnabled = flashlightEnabled;
HasPen = hasPen;
PdaOwnerInfo = pdaOwnerInfo;
HasUplink = hasUplink;
CanPlayMusic = canPlayMusic;
- HasNewsTab = hasNewsTab;
StationName = stationName;
Address = address;
}
diff --git a/Resources/Locale/en-US/cartridge-loader/cartridges.ftl b/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
index 61e3d336e8..3be0fdcce0 100644
--- a/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
+++ b/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
@@ -1,5 +1,6 @@
default-program-name = Program
notekeeper-program-name = Notekeeper
+news-read-program-name = Station news
net-probe-program-name = NetProbe
net-probe-scan = Scanned {$device}!
diff --git a/Resources/Locale/en-US/mass-media/news-ui.ftl b/Resources/Locale/en-US/mass-media/news-ui.ftl
index 0b2c528634..2f1f634abf 100644
--- a/Resources/Locale/en-US/mass-media/news-ui.ftl
+++ b/Resources/Locale/en-US/mass-media/news-ui.ftl
@@ -1,11 +1,12 @@
-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-read-ui-notification-off = ̶♫̶
+news-read-ui-notification-on = ♫
news-read-ui-no-author = Anonymous
+news-read-ui-author-prefix = Author:
news-write-ui-default-title = Mass-media Management
news-write-ui-articles-label = Articles:
news-write-ui-delete-text = Delete
diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml
index b72f53689c..44ea3cf1f0 100644
--- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml
+++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml
@@ -369,7 +369,7 @@
- type: entity
parent: BaseComputerCircuitboard
id: ComputerMassMediaCircuitboard
- name: mass media console board
+ name: mass-media console board
description: Write your message to the world!
components:
- type: Sprite
diff --git a/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml b/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml
index fa66dfe6d1..78092d414e 100644
--- a/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml
+++ b/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml
@@ -19,6 +19,27 @@
state: book6
- type: NotekeeperCartridge
+- type: entity
+ parent: BaseItem
+ id: NewsReadCartridge
+ name: News Cartridge
+ description: A program for reading news
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/cartridge.rsi
+ state: cart-y
+ - type: Icon
+ sprite: Objects/Devices/cartridge.rsi
+ state: cart-y
+ - type: UIFragment
+ ui: !type:NewsReadUi
+ - type: Cartridge
+ programName: news-read-program-name
+ icon:
+ sprite: Interface/Misc/program_icons.rsi
+ state: news_read
+ - type: NewsReadCartridge
+
- type: entity
parent: BaseItem
id: NetProbeCartridge
diff --git a/Resources/Prototypes/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/Entities/Objects/Devices/pda.yml
index 3d65c5f9d4..161a68124c 100644
--- a/Resources/Prototypes/Entities/Objects/Devices/pda.yml
+++ b/Resources/Prototypes/Entities/Objects/Devices/pda.yml
@@ -73,6 +73,7 @@
uiKey: enum.PdaUiKey.Key
preinstalled:
- NotekeeperCartridge
+ - NewsReadCartridge
cartridgeSlot:
priority: -1
name: Cartridge
@@ -97,11 +98,8 @@
type: InstrumentBoundUserInterface
- key: enum.HealthAnalyzerUiKey.Key
type: HealthAnalyzerBoundUserInterface
- - key: enum.NewsReadUiKey.Key
- type: NewsReadBoundUserInterface
- type: CrewManifestViewer
unsecure: true
- - type: NewsRead
- type: Tag
tags:
- DoorBumpOpener
@@ -733,6 +731,18 @@
borderColor: "#891417"
- type: Icon
state: pda-syndi
+ - type: CartridgeLoader
+ uiKey: enum.PdaUiKey.Key
+ preinstalled:
+ - NotekeeperCartridge
+ cartridgeSlot:
+ priority: -1
+ name: Cartridge
+ ejectSound: /Audio/Machines/id_swipe.ogg
+ insertSound: /Audio/Weapons/Guns/MagIn/batrifle_magin.ogg
+ whitelist:
+ components:
+ - Cartridge
- type: entity
parent: BasePDA
diff --git a/Resources/Textures/Interface/Misc/program_icons.rsi/meta.json b/Resources/Textures/Interface/Misc/program_icons.rsi/meta.json
new file mode 100644
index 0000000000..5ed7f67860
--- /dev/null
+++ b/Resources/Textures/Interface/Misc/program_icons.rsi/meta.json
@@ -0,0 +1,14 @@
+{
+ "version": 1,
+ "license": "CC-BY-SA-3.0",
+ "copyright": "Made with love, by Misha_Unity",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "news_read"
+ }
+ ]
+}
diff --git a/Resources/Textures/Interface/Misc/program_icons.rsi/news_read.png b/Resources/Textures/Interface/Misc/program_icons.rsi/news_read.png
new file mode 100644
index 0000000000000000000000000000000000000000..799316da3b1ddcb940262a030271c571da3be46b
GIT binary patch
literal 417
zcmV;S0bc%zP)wR-dG9M=%Y*%j4=oGZ@1Q0DC`u+PZ~2JL)Y2
zFkAJ_c(gHPSsI!-`Vax&<;T~^Bn8N_?35_20L@;b0a^jI2H?Xg0iYYW4uTrM4hU(0
zb_eekc;@ZMg?_UL?*_on0bd*b1pxaml^@mww*Uda37&$|L8JjtA4JlG!CCNcM=^(>
zlTZs$=`aGIq~n-YB-sy%Z(F!MG