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

Custom Specie Name #994

Merged
merged 18 commits into from
Oct 9, 2024
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
6 changes: 6 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
ToolTip="{Loc 'humanoid-profile-editor-guidebook-button-tooltip'}"/>
<OptionButton Name="CSpeciesButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Species -->
<BoxContainer Name="CCustomSpecieName" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-customspeciename-label'}" />
<Control HorizontalExpand="True"/>
<LineEdit Name="CCustomSpecieNameEdit" MinSize="270 0" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Age -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-age-label'}" />
Expand Down
30 changes: 30 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public sealed partial class HumanoidProfileEditor : BoxContainer

private LineEdit _ageEdit => CAgeEdit;
private LineEdit _nameEdit => CNameEdit;

private BoxContainer _ccustomspecienamecontainerEdit => CCustomSpecieName;
private LineEdit _customspecienameEdit => CCustomSpecieNameEdit;
private TextEdit? _flavorTextEdit;
private Button _nameRandomButton => CNameRandomize;
private Button _randomizeEverythingButton => CRandomizeEverything;
Expand Down Expand Up @@ -131,6 +134,12 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Name

#region Custom Specie Name

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

#endregion CustomSpecieName

#region Appearance

CAppearance.Orphan();
Expand Down Expand Up @@ -190,6 +199,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt
SetSpecies(_speciesList[args.Id].ID);
UpdateHairPickers();
OnSkinColorOnValueChanged();
UpdateCustomSpecieNameEdit();
};

#endregion Species
Expand Down Expand Up @@ -940,6 +950,12 @@ private void SetName(string newName)
IsDirty = true;
}

private void SetCustomSpecieName(string customname)
{
Profile = Profile?.WithCustomSpeciesName(customname);
IsDirty = true;
}

private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
{
Profile = Profile?.WithSpawnPriorityPreference(newSpawnPriority);
Expand Down Expand Up @@ -986,6 +1002,19 @@ private void UpdateNameEdit()
_nameEdit.Text = Profile?.Name ?? "";
}

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

_customspecienameEdit.Text = Profile.Customspeciename ?? "";

if (!_prototypeManager.TryIndex<SpeciesPrototype>(Profile.Species, out var speciesProto))
return;

_ccustomspecienamecontainerEdit.Visible = speciesProto.CustomName;
}

private void UpdateFlavorTextEdit()
{
if(_flavorTextEdit != null)
Expand Down Expand Up @@ -1270,6 +1299,7 @@ public void UpdateControls()
return;

UpdateNameEdit();
UpdateCustomSpecieNameEdit();
UpdateFlavorTextEdit();
UpdateSexControls();
UpdateGenderControls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private static HumanoidCharacterProfile CharlieCharlieson()
"Charlie Charlieson",
"The biggest boy around.",
"Human",
"",
1,
1,
21,
Expand Down
Loading
Loading