[feat] Custom name for clown, mime and borgs

This commit is contained in:
rhailrake
2023-05-04 13:44:24 +06:00
committed by Aviu00
parent f04400926e
commit 68e52f60c9
18 changed files with 3124 additions and 43 deletions

View File

@@ -19,7 +19,31 @@ namespace Content.Client.Preferences.UI
if (Profile == null) return;
var name = HumanoidCharacterProfile.GetName(Profile.Species, Profile.Gender);
SetName(name);
UpdateNameEdit();
UpdateNamesEdit();
}
private void RandomizeClownName()
{
if (Profile == null) return;
var name = HumanoidCharacterProfile.GetClownName();
SetClownName(name);
UpdateNamesEdit();
}
private void RandomizeMimeName()
{
if (Profile == null) return;
var name = HumanoidCharacterProfile.GetMimeName();
SetMimeName(name);
UpdateNamesEdit();
}
private void RandomizeBorgName()
{
if (Profile == null) return;
var name = HumanoidCharacterProfile.GetBorgName();
SetBorgName(name);
UpdateNamesEdit();
}
}
}

View File

@@ -19,6 +19,21 @@
<LineEdit Name="CNameEdit" MinSize="270 0" VerticalAlignment="Center" Margin="5 0 0 0" />
<Button Name="CNameRandomize" Text="{Loc 'humanoid-profile-editor-name-random-button'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-clown-name-label'}" />
<LineEdit Name="CClownNameEdit" MinSize="270 0" VerticalAlignment="Center" Margin="5 0 0 0" />
<Button Name="CClownNameRandomize" Text="{Loc 'humanoid-profile-editor-name-random-button'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-mime-name-label'}" />
<LineEdit Name="CMimeNameEdit" MinSize="270 0" VerticalAlignment="Center" Margin="5 0 0 0" />
<Button Name="CMimeNameRandomize" Text="{Loc 'humanoid-profile-editor-name-random-button'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-borg-name-label'}" />
<LineEdit Name="CBorgNameEdit" MinSize="270 0" VerticalAlignment="Center" Margin="5 0 0 0" />
<Button Name="CBorgNameRandomize" Text="{Loc 'humanoid-profile-editor-name-random-button'}" />
</BoxContainer>
<Button Name="CRandomizeEverything" HorizontalAlignment="Center"
HorizontalExpand="False" MaxWidth="256"
Text="{Loc 'humanoid-profile-editor-randomize-everything-button'}" />

View File

@@ -69,7 +69,13 @@ namespace Content.Client.Preferences.UI
private LineEdit _ageEdit => CAgeEdit;
private LineEdit _nameEdit => CNameEdit;
private TextEdit _flavorTextEdit = null!;
private LineEdit _nameClownEdit => CClownNameEdit;
private LineEdit _nameMimeEdit => CMimeNameEdit;
private LineEdit _nameBorgEdit => CBorgNameEdit;
private Button _nameRandomButton => CNameRandomize;
private Button _nameClownRandomButton => CClownNameRandomize;
private Button _nameMimeRandomButton => CMimeNameRandomize;
private Button _nameBorgRandomButton => CBorgNameRandomize;
private Button _randomizeEverythingButton => CRandomizeEverything;
private RichTextLabel _warningLabel => CWarningLabel;
private Button _saveButton => CSaveButton;
@@ -136,7 +142,13 @@ namespace Content.Client.Preferences.UI
#region Name
_nameEdit.OnTextChanged += args => { SetName(args.Text); };
_nameClownEdit.OnTextChanged += args => { SetClownName(args.Text); };
_nameMimeEdit.OnTextChanged += args => { SetMimeName(args.Text); };
_nameBorgEdit.OnTextChanged += args => { SetBorgName(args.Text); };
_nameRandomButton.OnPressed += args => RandomizeName();
_nameClownRandomButton.OnPressed += args => RandomizeClownName();
_nameMimeRandomButton.OnPressed += args => RandomizeMimeName();
_nameBorgRandomButton.OnPressed += args => RandomizeBorgName();
_randomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
_warningLabel.SetMarkup($"[color=red]{Loc.GetString("humanoid-profile-editor-naming-rules-warning")}[/color]");
@@ -817,6 +829,24 @@ namespace Content.Client.Preferences.UI
IsDirty = true;
}
private void SetClownName(string newName)
{
Profile = Profile?.WithClownName(newName);
IsDirty = true;
}
private void SetMimeName(string newName)
{
Profile = Profile?.WithMimeName(newName);
IsDirty = true;
}
private void SetBorgName(string newName)
{
Profile = Profile?.WithBorgName(newName);
IsDirty = true;
}
private void SetClothing(ClothingPreference newClothing)
{
Profile = Profile?.WithClothingPreference(newClothing);
@@ -852,9 +882,12 @@ namespace Content.Client.Preferences.UI
}
}
private void UpdateNameEdit()
private void UpdateNamesEdit()
{
_nameEdit.Text = Profile?.Name ?? "";
_nameClownEdit.Text = Profile?.ClownName ?? "";
_nameMimeEdit.Text = Profile?.MimeName ?? "";
_nameBorgEdit.Text = Profile?.BorgName ?? "";
}
private void UpdateFlavorTextEdit()
@@ -1134,8 +1167,10 @@ namespace Content.Client.Preferences.UI
public void UpdateControls()
{
if (Profile is null) return;
UpdateNameEdit();
if (Profile is null)
return;
UpdateNamesEdit();
UpdateFlavorTextEdit();
UpdateSexControls();
UpdateGenderControls();