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'}"
|
||||
|
||||
Reference in New Issue
Block a user