Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silicon Jobs: Name Customization #158

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Content.Client/Humanoid/HumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public override void LoadProfile(EntityUid uid, HumanoidCharacterProfile? profil
humanoid.Sex = profile.Sex;
humanoid.Gender = profile.Gender;
humanoid.DisplayPronouns = profile.DisplayPronouns;
humanoid.StationAiName = profile.StationAiName;
humanoid.CyborgName = profile.CyborgName;
humanoid.Age = profile.Age;
humanoid.Species = profile.Species;
humanoid.SkinColor = profile.Appearance.SkinColor;
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using static Content.Shared.Humanoid.SharedHumanoidAppearanceSystem;
using CharacterSetupGui = Content.Client.Lobby.UI.CharacterSetupGui;
Expand All @@ -38,6 +39,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly JobRequirementsManager _requirements = default!;
[Dependency] private readonly MarkingManager _markings = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
[UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[UISystemDependency] private readonly ClientInventorySystem _inventory = default!;
Expand Down Expand Up @@ -202,7 +204,8 @@ private void SaveProfile()
_playerManager,
_prototypeManager,
_requirements,
_markings);
_markings,
_random);

_characterSetup = new CharacterSetupGui(EntityManager, _prototypeManager, _resourceCache, _preferencesManager, _profileEditor);

Expand Down
12 changes: 12 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@
<Control HorizontalExpand="True"/>
<LineEdit Name="DisplayPronounsNameEdit" MinSize="270 0" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Station AI name -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-station-ai-name-label'}" />
<Control HorizontalExpand="True"/>
<LineEdit Name="StationAINameEdit" MinSize="270 0" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Cyborg name -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cyborg-name-label'}" />
<Control HorizontalExpand="True"/>
<LineEdit Name="CyborgNameEdit" MinSize="270 0" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Show clothing -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-clothing'}" />
Expand Down
82 changes: 78 additions & 4 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Customization.Systems;
using Content.Shared.Dataset;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
Expand All @@ -33,6 +34,7 @@
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Direction = Robust.Shared.Maths.Direction;

Expand All @@ -51,6 +53,8 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
private readonly JobRequirementsManager _requirements;
private readonly CharacterRequirementsSystem _characterRequirementsSystem;
private readonly LobbyUIController _controller;
private readonly IRobustRandom _random;

private FlavorText.FlavorText? _flavorText;
private BoxContainer _ccustomspecienamecontainerEdit => CCustomSpecieName;
private LineEdit _customspecienameEdit => CCustomSpecieNameEdit;
Expand Down Expand Up @@ -87,6 +91,12 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
[ValidatePrototypeId<GuideEntryPrototype>]
private const string DefaultSpeciesGuidebook = "Species";

[ValidatePrototypeId<LocalizedDatasetPrototype>]
private const string StationAiNames = "NamesAI";

[ValidatePrototypeId<DatasetPrototype>]
private const string CyborgNames = "names_borg";

public HumanoidProfileEditor(
IClientPreferencesManager preferencesManager,
IConfigurationManager cfgManager,
Expand All @@ -95,7 +105,8 @@ public HumanoidProfileEditor(
IPlayerManager playerManager,
IPrototypeManager prototypeManager,
JobRequirementsManager requirements,
MarkingManager markings
MarkingManager markings,
IRobustRandom random
)
{
RobustXamlLoader.Load(this);
Expand All @@ -107,6 +118,8 @@ MarkingManager markings
_markingManager = markings;
_preferencesManager = preferencesManager;
_requirements = requirements;
_random = random;

_characterRequirementsSystem = _entManager.System<CharacterRequirementsSystem>();
_controller = UserInterfaceManager.GetUIController<LobbyUIController>();

Expand All @@ -131,11 +144,11 @@ MarkingManager markings

#endregion Name

#region Custom Specie Name
#region Custom Species Name

_customspecienameEdit.OnTextChanged += args => { SetCustomSpecieName(args.Text); };

#endregion CustomSpecieName
#endregion Custom Species Name

#region Appearance

Expand Down Expand Up @@ -188,7 +201,14 @@ MarkingManager markings

DisplayPronounsNameEdit.OnTextChanged += args => { SetDisplayPronouns(args.Text); };

#endregion CustomSpecieName
#endregion Display Pronouns

#region Custom Names

StationAINameEdit.OnTextChanged += args => { SetStationAiName(args.Text); };
CyborgNameEdit.OnTextChanged += args => { SetCyborgName(args.Text); };

#endregion

#region Species

Expand Down Expand Up @@ -652,6 +672,8 @@ public void SetProfile(HumanoidCharacterProfile? profile, int? slot)
UpdateSexControls();
UpdateGenderControls();
UpdateDisplayPronounsControls();
UpdateStationAiControls();
UpdateCyborgControls();
UpdateSkinColor();
UpdateSpawnPriorityControls();
UpdateFlavorTextEdit();
Expand Down Expand Up @@ -1168,6 +1190,20 @@ private void SetDisplayPronouns(string? displayPronouns)
IsDirty = true;
}

private void SetStationAiName(string? stationAiName)
{
Profile = Profile?.WithStationAiName(stationAiName);
ReloadPreview();
IsDirty = true;
}

private void SetCyborgName(string? cyborgName)
{
Profile = Profile?.WithCyborgName(cyborgName);
ReloadPreview();
IsDirty = true;
}

private string GetFormattedPronounsFromGender()
{
if (Profile == null)
Expand Down Expand Up @@ -1403,6 +1439,44 @@ private void UpdateDisplayPronounsControls()
DisplayPronounsNameEdit.Text = Profile.DisplayPronouns;
}

private void UpdateStationAiControls()
{
if (Profile == null)
return;

if (Profile?.StationAiName != null)
{
StationAINameEdit.Text = Profile.StationAiName;
return;
}

if (StationAINameEdit.Text != string.Empty)
return;

var stationAiNames = _prototypeManager.Index<LocalizedDatasetPrototype>(StationAiNames);
var randomName = _random.Pick(stationAiNames.Values);
StationAINameEdit.PlaceHolder = Loc.GetString(randomName);
}

private void UpdateCyborgControls()
{
if (Profile == null)
return;

if (Profile?.CyborgName != null)
{
CyborgNameEdit.Text = Profile.CyborgName;
return;
}

if (CyborgNameEdit.Text != string.Empty)
return;

var borgNames = _prototypeManager.Index<DatasetPrototype>(CyborgNames);
var randomName = _random.Pick(borgNames.Values);
CyborgNameEdit.PlaceHolder = Loc.GetString(randomName);
}

private void UpdateSpawnPriorityControls()
{
if (Profile == null)
Expand Down
Loading
Loading