Описания для спонсоров
This commit is contained in:
parent
4b9524f425
commit
42841c0246
8 changed files with 76 additions and 8 deletions
|
|
@ -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<string>? 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<ILocalizationManager>();
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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<Lo
|
|||
{
|
||||
_profileEditor?.RefreshFlavorText();
|
||||
});
|
||||
// Sunrise-Start
|
||||
_configurationManager.OnValueChanged(SunriseCCVars.FlavorTextSponsorOnly, args =>
|
||||
{
|
||||
_profileEditor?.RefreshFlavorText();
|
||||
});
|
||||
// Sunrise-End
|
||||
|
||||
_configurationManager.OnValueChanged(CCVars.GameRoleTimers, _ => RefreshProfileEditor());
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<DetailExaminableComponent>(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<DetailExaminableComponent>(entity.Value).Content = flavortext;
|
||||
}
|
||||
}
|
||||
// Sunrise-End
|
||||
}
|
||||
|
||||
DoJobSpecials(job, entity.Value);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public sealed partial class CCVars
|
|||
/// Allows flavor text (character descriptions)
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> FlavorText =
|
||||
CVarDef.Create("ic.flavor_text", false, CVar.SERVER | CVar.REPLICATED);
|
||||
CVarDef.Create("ic.flavor_text", true, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a period at the end of a sentence if the sentence ends in a letter.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -380,4 +380,10 @@ public sealed class SunriseCCVars
|
|||
|
||||
public static readonly CVarDef<string> VigersRayVictims =
|
||||
CVarDef.Create("vigers_ray.victims", "", CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Flavor Profile
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> FlavorTextSponsorOnly =
|
||||
CVarDef.Create("flavor_text.sponsor_only", true, CVar.SERVER | CVar.REPLICATED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public interface ISharedSponsorsManager
|
|||
// Client
|
||||
public List<string> GetClientPrototypes();
|
||||
public bool ClientAllowedRespawn();
|
||||
public bool ClientAllowedFlavor();
|
||||
|
||||
public bool ClientIsSponsor();
|
||||
public List<SponsorInfo> 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<string>? ghostTheme);
|
||||
public bool TryGetBypassRoles(NetUserId userId, [NotNullWhen(true)] out List<string>? 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; } = [];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue