Files
tbd-station-14/Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml.cs
MishaUnity e4dcdc0c6e convert News read tab to PDA Cartridge (#18368)
* 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
2023-07-28 13:59:03 -06:00

61 lines
2.1 KiB
C#

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");
}
}