Skip to content

Commit

Permalink
Client customization late-join spawner priority for arrivals/cryostor…
Browse files Browse the repository at this point in the history
…age (#24586)

* Initial commit, requires server restart to take effect

* Exposes callbacks directly instead, takes effect immediately

* Cleaned up control flow, swapped cvar for client customization

* Switched to int, dictionary of callbacks, migration

* Update Content.Shared/Preferences/SpawnPriorityPreference.cs

* krunkle stan

---------

Co-authored-by: metalgearsloth <[email protected]>
Co-authored-by: metalgearsloth <[email protected]>

(cherry picked from commit ed0f2aa2213cc47b817476206a2dd0b4e7c176b1)
  • Loading branch information
Krunklehorn authored and DebugOk committed Feb 8, 2024
1 parent b9804a6 commit 922407e
Show file tree
Hide file tree
Showing 18 changed files with 3,654 additions and 20 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 @@ -96,6 +96,12 @@
<Control HorizontalExpand="True"/>
<OptionButton Name="CBackpackButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Spawn Priority -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-spawn-priority-label'}" />
<Control HorizontalExpand="True"/>
<OptionButton Name="CSpawnPriorityButton" HorizontalAlignment="Right" />
</BoxContainer>
</BoxContainer>
<!-- Skin -->
<BoxContainer Margin="10" HorizontalExpand="True" Orientation="Vertical">
Expand Down
33 changes: 33 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public sealed partial class HumanoidProfileEditor : Control
private Slider _skinColor => CSkin;
private OptionButton _clothingButton => CClothingButton;
private OptionButton _backpackButton => CBackpackButton;
private OptionButton _spawnPriorityButton => CSpawnPriorityButton;
private SingleMarkingPicker _hairPicker => CHairStylePicker;
private SingleMarkingPicker _facialHairPicker => CFacialHairPicker;
private EyeColorPicker _eyesPicker => CEyeColorPicker;
Expand Down Expand Up @@ -340,6 +341,21 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Backpack

#region SpawnPriority

foreach (var value in Enum.GetValues<SpawnPriorityPreference>())
{
_spawnPriorityButton.AddItem(Loc.GetString($"humanoid-profile-editor-preference-spawn-priority-{value.ToString().ToLower()}"), (int) value);
}

_spawnPriorityButton.OnItemSelected += args =>
{
_spawnPriorityButton.SelectId(args.Id);
SetSpawnPriority((SpawnPriorityPreference) args.Id);
};

#endregion SpawnPriority

#region Eyes

_eyesPicker.OnEyeColorPicked += newColor =>
Expand Down Expand Up @@ -831,6 +847,12 @@ private void SetBackpack(BackpackPreference newBackpack)
IsDirty = true;
}

private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
{
Profile = Profile?.WithSpawnPriorityPreference(newSpawnPriority);
IsDirty = true;
}

public void Save()
{
IsDirty = false;
Expand Down Expand Up @@ -1006,6 +1028,16 @@ private void UpdateBackpackControls()
_backpackButton.SelectId((int) Profile.Backpack);
}

private void UpdateSpawnPriorityControls()
{
if (Profile == null)
{
return;
}

_spawnPriorityButton.SelectId((int) Profile.SpawnPriority);
}

private void UpdateHairPickers()
{
if (Profile == null)
Expand Down Expand Up @@ -1145,6 +1177,7 @@ public void UpdateControls()
UpdateSpecies();
UpdateClothingControls();
UpdateBackpackControls();
UpdateSpawnPriorityControls();
UpdateAgeEdit();
UpdateEyePickers();
UpdateSaveButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private static HumanoidCharacterProfile CharlieCharlieson()
),
ClothingPreference.Jumpskirt,
BackpackPreference.Backpack,
SpawnPriorityPreference.Arrivals,
new Dictionary<string, JobPriority>
{
{SharedGameTicker.FallbackOverflowJob, JobPriority.High}
Expand Down
Loading

0 comments on commit 922407e

Please sign in to comment.