Minor fixes to character profile editor save/reset buttons (#31505)

Merge SetDirty() with preview reload

People were forgetting to SetDirty() when changing a property; move SetDirty()
into preview reloading, since if the preview is being reloaded, some property
has definitely changed anyway.

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
This commit is contained in:
eoineoineoin
2024-08-27 11:20:12 +01:00
committed by GitHub
parent 2f4e297741
commit 55771cab74

View File

@@ -718,6 +718,9 @@ namespace Content.Client.Lobby.UI
PreviewDummy = _controller.LoadProfileEntity(Profile, JobOverride, ShowClothes.Pressed); PreviewDummy = _controller.LoadProfileEntity(Profile, JobOverride, ShowClothes.Pressed);
SpriteView.SetEntity(PreviewDummy); SpriteView.SetEntity(PreviewDummy);
_entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, Profile.Name); _entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, Profile.Name);
// Check and set the dirty flag to enable the save/reset buttons as appropriate.
SetDirty();
} }
/// <summary> /// <summary>
@@ -778,6 +781,9 @@ namespace Content.Client.Lobby.UI
return; return;
_entManager.System<HumanoidAppearanceSystem>().LoadProfile(PreviewDummy, Profile); _entManager.System<HumanoidAppearanceSystem>().LoadProfile(PreviewDummy, Profile);
// Check and set the dirty flag to enable the save/reset buttons as appropriate.
SetDirty();
} }
private void OnSpeciesInfoButtonPressed(BaseButton.ButtonEventArgs args) private void OnSpeciesInfoButtonPressed(BaseButton.ButtonEventArgs args)
@@ -1014,7 +1020,6 @@ namespace Content.Client.Lobby.UI
roleLoadout.AddLoadout(loadoutGroup, loadoutProto, _prototypeManager); roleLoadout.AddLoadout(loadoutGroup, loadoutProto, _prototypeManager);
_loadoutWindow.RefreshLoadouts(roleLoadout, session, collection); _loadoutWindow.RefreshLoadouts(roleLoadout, session, collection);
Profile = Profile?.WithLoadout(roleLoadout); Profile = Profile?.WithLoadout(roleLoadout);
SetDirty();
ReloadPreview(); ReloadPreview();
}; };
@@ -1023,7 +1028,6 @@ namespace Content.Client.Lobby.UI
roleLoadout.RemoveLoadout(loadoutGroup, loadoutProto, _prototypeManager); roleLoadout.RemoveLoadout(loadoutGroup, loadoutProto, _prototypeManager);
_loadoutWindow.RefreshLoadouts(roleLoadout, session, collection); _loadoutWindow.RefreshLoadouts(roleLoadout, session, collection);
Profile = Profile?.WithLoadout(roleLoadout); Profile = Profile?.WithLoadout(roleLoadout);
SetDirty();
ReloadPreview(); ReloadPreview();
}; };
@@ -1033,7 +1037,6 @@ namespace Content.Client.Lobby.UI
_loadoutWindow.OnClose += () => _loadoutWindow.OnClose += () =>
{ {
JobOverride = null; JobOverride = null;
SetDirty();
ReloadPreview(); ReloadPreview();
}; };
@@ -1058,7 +1061,6 @@ namespace Content.Client.Lobby.UI
return; return;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithMarkings(markings.GetForwardEnumerator().ToList())); Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithMarkings(markings.GetForwardEnumerator().ToList()));
SetDirty();
ReloadProfilePreview(); ReloadProfilePreview();
} }
@@ -1126,7 +1128,6 @@ namespace Content.Client.Lobby.UI
} }
} }
SetDirty();
ReloadProfilePreview(); ReloadProfilePreview();
} }
@@ -1157,7 +1158,6 @@ namespace Content.Client.Lobby.UI
{ {
Profile = Profile?.WithAge(newAge); Profile = Profile?.WithAge(newAge);
ReloadPreview(); ReloadPreview();
SetDirty();
} }
private void SetSex(Sex newSex) private void SetSex(Sex newSex)
@@ -1180,14 +1180,12 @@ namespace Content.Client.Lobby.UI
UpdateGenderControls(); UpdateGenderControls();
Markings.SetSex(newSex); Markings.SetSex(newSex);
ReloadPreview(); ReloadPreview();
SetDirty();
} }
private void SetGender(Gender newGender) private void SetGender(Gender newGender)
{ {
Profile = Profile?.WithGender(newGender); Profile = Profile?.WithGender(newGender);
ReloadPreview(); ReloadPreview();
SetDirty();
} }
private void SetSpecies(string newSpecies) private void SetSpecies(string newSpecies)
@@ -1201,7 +1199,6 @@ namespace Content.Client.Lobby.UI
RefreshLoadouts(); RefreshLoadouts();
UpdateSexControls(); // update sex for new species UpdateSexControls(); // update sex for new species
UpdateSpeciesGuidebookIcon(); UpdateSpeciesGuidebookIcon();
SetDirty();
ReloadPreview(); ReloadPreview();
} }