This commit is contained in:
Morb
2023-09-15 00:12:11 +03:00
committed by GitHub
parent 96dc673904
commit 94de2bea3d
3 changed files with 35 additions and 5 deletions

View File

@@ -4,6 +4,8 @@ using Robust.Client.GameObjects;
using Content.Shared.MassMedia.Systems;
using Content.Shared.MassMedia.Components;
using Content.Client.GameTicking.Managers;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
using Robust.Shared.Utility;
namespace Content.Client.MassMedia.Ui
@@ -15,7 +17,7 @@ namespace Content.Client.MassMedia.Ui
private NewsWriteMenu? _menu;
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
private ClientGameTicker? _gameTicker;
[ViewVariables]
@@ -71,10 +73,16 @@ namespace Content.Client.MassMedia.Ui
return;
var stringName = _menu.NameInput.Text;
var name = (stringName.Length <= 25 ? stringName.Trim() : $"{stringName.Trim().Substring(0, 25)}...");
var maxNameLength = _cfg.GetCVar(CCVars.NewsNameLimit);
var maxContentLength = _cfg.GetCVar(CCVars.NewsContentLimit);
var name = (stringName.Length <= maxNameLength ? stringName.Trim() : $"{stringName.Trim().Substring(0, maxNameLength)}...");
var content = (stringContent.Length <= maxContentLength ? stringContent.Trim() : $"{stringContent.Trim().Substring(0, maxContentLength)}...");
_menu.ContentInput.TextRope = new Rope.Leaf(string.Empty);
_menu.NameInput.Text = string.Empty;
SendMessage(new NewsWriteShareMessage(name, stringContent));
SendMessage(new NewsWriteShareMessage(name, content));
}
private void OnDeleteButtonPressed(int articleNum)

View File

@@ -17,7 +17,9 @@ using Content.Server.GameTicking;
using Robust.Shared.Timing;
using Content.Server.Popups;
using Content.Server.StationRecords.Systems;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Utility;
@@ -26,6 +28,7 @@ namespace Content.Server.MassMedia.Systems;
public sealed class NewsSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly RingerSystem _ringer = default!;
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoaderSystem = default!;
@@ -142,11 +145,14 @@ public sealed class NewsSystem : EntitySystem
}
}
var maxNameLength = _cfg.GetCVar(CCVars.NewsNameLimit);
var maxContentLength = _cfg.GetCVar(CCVars.NewsContentLimit);
NewsArticle article = new NewsArticle
{
Author = authorName,
Name = (msg.Name.Length <= 25 ? msg.Name.Trim() : $"{msg.Name.Trim().Substring(0, 25)}..."),
Content = msg.Content,
Name = (msg.Name.Length <= maxNameLength ? msg.Name.Trim() : $"{msg.Name.Trim().Substring(0, maxNameLength)}..."),
Content = (msg.Content.Length <= maxContentLength ? msg.Name.Trim() : $"{msg.Content.Trim().Substring(0, maxContentLength)}..."),
ShareTime = _ticker.RoundDuration()
};

View File

@@ -1757,5 +1757,21 @@ namespace Content.Shared.CCVar
/// </summary>
public static readonly CVarDef<string> ReplayAutoRecordTempDir =
CVarDef.Create("replay.auto_record_temp_dir", "", CVar.SERVERONLY);
/*
* News
*/
/// <summary>
/// Maximum number of characters that can be specified in the news name
/// </summary>
public static readonly CVarDef<int> NewsNameLimit =
CVarDef.Create("news.name_limit", 25, CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Maximum number of characters that can be specified in the news content
/// </summary>
public static readonly CVarDef<int> NewsContentLimit =
CVarDef.Create("news.content_limit", 2048, CVar.SERVER | CVar.REPLICATED);
}
}