Skip to content

Commit

Permalink
Custom Specie Name (#994)
Browse files Browse the repository at this point in the history
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Add a Custom Specie Name for servers that wishes to allow players to
have custom names.
This simply add some variables to the Profile/Humanoid, meaning copying
the profile will keep the custom names.

By default its is disabled, for servers owners wishing to enable those
please edit the Specie Prototype and add:
```
customName: true
```

Enabling it will make it able for players to edit the specie name of the
selected specie, and will have the window enabled.

This is my first time fucking with Profile and Database, i fucking hate
it.

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>


![image](https://github.com/user-attachments/assets/a6226fef-c015-45be-add9-ff8e3660d4bb)

![image](https://github.com/user-attachments/assets/cf440f13-5882-44fb-863a-4ba7d8dd1f68)

</p>
</details>

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- add: Custom Species Names.

---------

Signed-off-by: FoxxoTrystan <45297731+FoxxoTrystan@users.noreply.github.com>
Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 87cc149 commit 39ddc33
Show file tree
Hide file tree
Showing 17 changed files with 3,738 additions and 6 deletions.
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

0 comments on commit 39ddc33

Please sign in to comment.