Re-organize in-memory character profile storage.

Now uses a dictionary of int -> profile instead of an array filled with nulls.
This commit is contained in:
Pieter-Jan Briers
2020-10-06 15:13:16 +02:00
parent 0b1fd94dc9
commit 390d064304
12 changed files with 228 additions and 204 deletions

View File

@@ -174,12 +174,10 @@ namespace Content.Client.UserInterface
_createNewCharacterButton.ToolTip =
$"A maximum of {_preferencesManager.Settings.MaxCharacterSlots} characters are allowed.";
var characterIndex = 0;
foreach (var character in _preferencesManager.Preferences.Characters)
foreach (var (slot, character) in _preferencesManager.Preferences.Characters)
{
if (character is null)
{
characterIndex++;
continue;
}
@@ -190,7 +188,7 @@ namespace Content.Client.UserInterface
character);
_charactersVBox.AddChild(characterPickerButton);
var characterIndexCopy = characterIndex;
var characterIndexCopy = slot;
characterPickerButton.OnPressed += args =>
{
_humanoidProfileEditor.Profile = (HumanoidCharacterProfile) character;
@@ -200,7 +198,6 @@ namespace Content.Client.UserInterface
UpdateUI();
args.Event.Handle();
};
characterIndex++;
}
_createNewCharacterButton.Disabled =