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
This commit is contained in:
MishaUnity
2023-07-28 22:59:03 +03:00
committed by GitHub
parent 70ceba5fbc
commit e4dcdc0c6e
32 changed files with 395 additions and 363 deletions

View File

@@ -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();
}
}
}

View File

@@ -1,52 +0,0 @@
<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>

View File

@@ -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;
}
}

View File

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

View File

@@ -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;
}
}