Flavor text (#8070)
This commit is contained in:
@@ -13,6 +13,7 @@ using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
@@ -29,6 +30,7 @@ namespace Content.Client.Preferences.UI
|
||||
private readonly IClientPreferencesManager _preferencesManager;
|
||||
private readonly IEntityManager _entityManager;
|
||||
private readonly IPrototypeManager _prototypeManager;
|
||||
private readonly IConfigurationManager _configurationManager;
|
||||
private readonly Button _createNewCharacterButton;
|
||||
private readonly HumanoidProfileEditor _humanoidProfileEditor;
|
||||
|
||||
@@ -36,12 +38,14 @@ namespace Content.Client.Preferences.UI
|
||||
IEntityManager entityManager,
|
||||
IResourceCache resourceCache,
|
||||
IClientPreferencesManager preferencesManager,
|
||||
IPrototypeManager prototypeManager)
|
||||
IPrototypeManager prototypeManager,
|
||||
IConfigurationManager configurationManager)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_entityManager = entityManager;
|
||||
_prototypeManager = prototypeManager;
|
||||
_preferencesManager = preferencesManager;
|
||||
_configurationManager = configurationManager;
|
||||
|
||||
var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
|
||||
var back = new StyleBoxTexture
|
||||
@@ -64,7 +68,7 @@ namespace Content.Client.Preferences.UI
|
||||
args.Event.Handle();
|
||||
};
|
||||
|
||||
_humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager, entityManager);
|
||||
_humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager, entityManager, configurationManager);
|
||||
_humanoidProfileEditor.OnProfileChanged += ProfileChanged;
|
||||
CharEditor.AddChild(_humanoidProfileEditor);
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:magicmirror="clr-namespace:Content.Client.CharacterAppearance"
|
||||
xmlns:prefUi="clr-namespace:Content.Client.Preferences.UI"
|
||||
xmlns:markings="clr-namespace:Content.Client.Markings">
|
||||
xmlns:markings="clr-namespace:Content.Client.Markings"
|
||||
xmlns:flavorText="clr-namespace:Content.Client.FlavorText">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<!-- Left side -->
|
||||
<BoxContainer Orientation="Vertical" Margin="10 10 10 10">
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Client.CharacterAppearance;
|
||||
using Content.Client.Lobby.UI;
|
||||
using Content.Client.Message;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.CharacterAppearance;
|
||||
using Content.Shared.CharacterAppearance.Systems;
|
||||
using Content.Shared.GameTicking;
|
||||
@@ -19,6 +20,7 @@ using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -52,13 +54,16 @@ namespace Content.Client.Preferences.UI
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class HumanoidProfileEditor : Control
|
||||
{
|
||||
private readonly IClientPreferencesManager _preferencesManager;
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly IConfigurationManager _configurationManager;
|
||||
|
||||
private LineEdit _ageEdit => CAgeEdit;
|
||||
private LineEdit _nameEdit => CNameEdit;
|
||||
private LineEdit _flavorTextEdit = null!;
|
||||
private Button _nameRandomButton => CNameRandomize;
|
||||
private Button _randomizeEverythingButton => CRandomizeEverything;
|
||||
private RichTextLabel _warningLabel => CWarningLabel;
|
||||
private readonly IClientPreferencesManager _preferencesManager;
|
||||
private readonly IEntityManager _entMan;
|
||||
private Button _saveButton => CSaveButton;
|
||||
private Button _sexFemaleButton => CSexFemale;
|
||||
private Button _sexMaleButton => CSexMale;
|
||||
@@ -104,13 +109,14 @@ namespace Content.Client.Preferences.UI
|
||||
public event Action<HumanoidCharacterProfile, int>? OnProfileChanged;
|
||||
|
||||
public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager,
|
||||
IEntityManager entityManager)
|
||||
IEntityManager entityManager, IConfigurationManager configurationManager)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_random = IoCManager.Resolve<IRobustRandom>();
|
||||
_prototypeManager = prototypeManager;
|
||||
_entMan = entityManager;
|
||||
_preferencesManager = preferencesManager;
|
||||
_configurationManager = configurationManager;
|
||||
|
||||
#region Left
|
||||
|
||||
@@ -458,6 +464,20 @@ namespace Content.Client.Preferences.UI
|
||||
|
||||
#endregion Markings
|
||||
|
||||
#region FlavorText
|
||||
|
||||
if (_configurationManager.GetCVar(CCVars.FlavorText))
|
||||
{
|
||||
var flavorText = new FlavorText.FlavorText();
|
||||
_tabContainer.AddChild(flavorText);
|
||||
_tabContainer.SetTabTitle(_tabContainer.ChildCount-1, Loc.GetString("humanoid-profile-editor-flavortext-tab"));
|
||||
_flavorTextEdit = flavorText.CFlavorTextInput;
|
||||
|
||||
flavorText.OnFlavorTextChanged += OnFlavorTextChange;
|
||||
}
|
||||
|
||||
#endregion FlavorText
|
||||
|
||||
#endregion Left
|
||||
|
||||
if (preferencesManager.ServerDataLoaded)
|
||||
@@ -471,6 +491,15 @@ namespace Content.Client.Preferences.UI
|
||||
IsDirty = false;
|
||||
}
|
||||
|
||||
private void OnFlavorTextChange(string content)
|
||||
{
|
||||
if (Profile is null)
|
||||
return;
|
||||
|
||||
Profile = Profile.WithFlavorText(content);
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
private void OnMarkingChange(MarkingsSet markings)
|
||||
{
|
||||
if (Profile is null)
|
||||
@@ -561,7 +590,7 @@ namespace Content.Client.Preferences.UI
|
||||
}
|
||||
|
||||
IsDirty = true;
|
||||
NeedsDummyRebuild = true; // ugh - fix this asap
|
||||
NeedsDummyRebuild = true; // TODO: ugh - fix this asap
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -716,6 +745,14 @@ namespace Content.Client.Preferences.UI
|
||||
_nameEdit.Text = Profile?.Name ?? "";
|
||||
}
|
||||
|
||||
private void UpdateFlavorTextEdit()
|
||||
{
|
||||
if(_flavorTextEdit != null)
|
||||
{
|
||||
_flavorTextEdit.Text = Profile?.FlavorText ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAgeEdit()
|
||||
{
|
||||
_ageEdit.Text = Profile?.Age.ToString() ?? "";
|
||||
@@ -893,6 +930,7 @@ namespace Content.Client.Preferences.UI
|
||||
{
|
||||
if (Profile is null) return;
|
||||
UpdateNameEdit();
|
||||
UpdateFlavorTextEdit();
|
||||
UpdateSexControls();
|
||||
UpdateGenderControls();
|
||||
UpdateSkinColor();
|
||||
|
||||
Reference in New Issue
Block a user