diff --git a/Content.Client/FlavorText/FlavorText.xaml.cs b/Content.Client/FlavorText/FlavorText.xaml.cs index 91b59046a4..46fd37b904 100644 --- a/Content.Client/FlavorText/FlavorText.xaml.cs +++ b/Content.Client/FlavorText/FlavorText.xaml.cs @@ -1,4 +1,5 @@ -using Robust.Client.AutoGenerated; +using Content.Sunrise.Interfaces.Shared; +using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; using Robust.Shared.Utility; @@ -10,14 +11,28 @@ namespace Content.Client.FlavorText { public Action? OnFlavorTextChanged; - public FlavorText() + private ISharedSponsorsManager? _sponsorsMgr; // Sunrise-Sponsors + + public FlavorText(ISharedSponsorsManager? sponsorsMgr, bool sponsorOnly) // Sunrise-Edit { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); + _sponsorsMgr = sponsorsMgr; + var loc = IoCManager.Resolve(); CFlavorTextInput.Placeholder = new Rope.Leaf(loc.GetString("flavor-text-placeholder")); CFlavorTextInput.OnTextChanged += _ => FlavorTextChanged(); + // Sunrise-Start + if (sponsorOnly && _sponsorsMgr != null && !_sponsorsMgr.ClientAllowedFlavor()) + { + CFlavorTextInput.Editable = false; + } + else + { + CFlavorTextInput.Editable = true; + } + // Sunrise-End } public void FlavorTextChanged() diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index 03e6798897..91ea85ea25 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -5,6 +5,7 @@ using Content.Client.Inventory; using Content.Client.Lobby.UI; using Content.Client.Players.PlayTimeTracking; using Content.Client.Station; +using Content.Shared._Sunrise.SunriseCCVars; using Content.Shared.CCVar; using Content.Shared.Clothing; using Content.Shared.GameTicking; @@ -75,6 +76,12 @@ public sealed partial class LobbyUIController : UIController, IOnStateEntered + { + _profileEditor?.RefreshFlavorText(); + }); + // Sunrise-End _configurationManager.OnValueChanged(CCVars.GameRoleTimers, _ => RefreshProfileEditor()); diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs index c4eee784d7..d3a320a29f 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs @@ -470,7 +470,10 @@ namespace Content.Client.Lobby.UI if (_flavorText != null) return; - _flavorText = new FlavorText.FlavorText(); + // Sunrise-Start + var sponsorOnly = _cfgManager.GetCVar(SunriseCCVars.FlavorTextSponsorOnly); + _flavorText = new FlavorText.FlavorText(_sponsorsMgr, sponsorOnly); + // Sunrise-End TabContainer.AddChild(_flavorText); TabContainer.SetTabTitle(TabContainer.ChildCount - 1, Loc.GetString("humanoid-profile-editor-flavortext-tab")); _flavorTextEdit = _flavorText.CFlavorTextInput; diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 4c37fc1931..ad933b64af 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -9,6 +9,7 @@ using Content.Server.Shuttles.Systems; using Content.Server.Spawners.Components; using Content.Server.Spawners.EntitySystems; using Content.Server.Station.Components; +using Content.Shared._Sunrise.SunriseCCVars; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.CCVar; @@ -206,10 +207,25 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem _humanoidSystem.LoadProfile(entity.Value, profile); _metaSystem.SetEntityName(entity.Value, profile.Name); + // Sunrise-Start if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText)) { - AddComp(entity.Value).Content = profile.FlavorText; + var session = _actors.GetSession(entity); + if (!_configurationManager.GetCVar(SunriseCCVars.FlavorTextSponsorOnly) + && _sponsorsManager != null + && _sponsorsManager.ClientAllowedFlavor() + && session != null) + { + var maxDescLength = _sponsorsManager.GetSizeFlavor(session.UserId); + var flavortext = profile.FlavorText; + if (flavortext.Length > maxDescLength) // Sunrise-Edit + { + flavortext = FormattedMessage.RemoveMarkupOrThrow(flavortext)[..maxDescLength]; + } + AddComp(entity.Value).Content = flavortext; + } } + // Sunrise-End } DoJobSpecials(job, entity.Value); diff --git a/Content.Shared/CCVar/CCVars.Ic.cs b/Content.Shared/CCVar/CCVars.Ic.cs index 2ca1027f9a..e7d4b264c4 100644 --- a/Content.Shared/CCVar/CCVars.Ic.cs +++ b/Content.Shared/CCVar/CCVars.Ic.cs @@ -14,7 +14,7 @@ public sealed partial class CCVars /// Allows flavor text (character descriptions) /// public static readonly CVarDef FlavorText = - CVarDef.Create("ic.flavor_text", false, CVar.SERVER | CVar.REPLICATED); + CVarDef.Create("ic.flavor_text", true, CVar.SERVER | CVar.REPLICATED); /// /// Adds a period at the end of a sentence if the sentence ends in a letter. diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index f4f62b0ad8..ab11b8ca3a 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -572,10 +572,22 @@ namespace Content.Shared.Preferences name = GetName(Species, gender); } - string flavortext; - if (FlavorText.Length > MaxDescLength) + // Sunrise-Start + var maxDescLength = MaxDescLength; + if (_sponsorsMgr != null) { - flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..MaxDescLength]; + maxDescLength = _sponsorsMgr.GetSizeFlavor(session.UserId); + if (_sponsorsMgr.IsAllowedFlavor(session.UserId)) + { + FlavorText = string.Empty; + } + } + // Sunrise-End + + string flavortext; + if (FlavorText.Length > maxDescLength) // Sunrise-Edit + { + flavortext = FormattedMessage.RemoveMarkupOrThrow(FlavorText)[..maxDescLength]; // Sunrise-Edit } else { diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs index 71d5b71905..c45a658b55 100644 --- a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs @@ -380,4 +380,10 @@ public sealed class SunriseCCVars public static readonly CVarDef VigersRayVictims = CVarDef.Create("vigers_ray.victims", "", CVar.SERVERONLY); + + /// + /// Flavor Profile + /// + public static readonly CVarDef FlavorTextSponsorOnly = + CVarDef.Create("flavor_text.sponsor_only", true, CVar.SERVER | CVar.REPLICATED); } diff --git a/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedSponsorsManager.cs b/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedSponsorsManager.cs index 507d1d3cd3..bed052e407 100644 --- a/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedSponsorsManager.cs +++ b/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedSponsorsManager.cs @@ -17,6 +17,7 @@ public interface ISharedSponsorsManager // Client public List GetClientPrototypes(); public bool ClientAllowedRespawn(); + public bool ClientAllowedFlavor(); public bool ClientIsSponsor(); public List GetSponsorTiers(); @@ -27,6 +28,8 @@ public interface ISharedSponsorsManager public bool TryGetOocColor(NetUserId userId, [NotNullWhen(true)] out Color? color); public bool TryGetGhostThemes(NetUserId userId, [NotNullWhen(true)] out List? ghostTheme); public bool TryGetBypassRoles(NetUserId userId, [NotNullWhen(true)] out List? bypassRoles); + public int GetSizeFlavor(NetUserId userId); + public bool IsAllowedFlavor(NetUserId userId); public int GetExtraCharSlots(NetUserId userId); public bool HavePriorityJoin(NetUserId userId); public bool IsSponsor(NetUserId userId); @@ -62,6 +65,12 @@ public sealed class SponsorInfo [JsonPropertyName("allowedRespawn")] public bool AllowedRespawn { get; set; } = false; + [JsonPropertyName("allowedFlavor")] + public bool AllowedFlavor { get; set; } = false; + + [JsonPropertyName("sizeFlavor")] + public int SizeFlavor { get; set; } + [JsonPropertyName("ghostThemes")] public string[] GhostThemes { get; set; } = [];