Added preferences backend (#465)
* Added preferences backend * Gender -> Sex * ClientPreferencesManager properties * Username validation * Fixed client init * WIP db * Actually working sqlite db * Dropped shitty sqlite libraries, dropped DbUp, added MigrationManager * Added profile deletion, test * Docs, sanity, tests, cleanup * Cleaned up profile and appearance, fixed running on .net core Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
committed by
Pieter-Jan Briers
parent
c1b9bb348d
commit
f19795edaf
54
Content.Shared/Preferences/PlayerPreferences.cs
Normal file
54
Content.Shared/Preferences/PlayerPreferences.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains all player characters and the index of the currently selected character.
|
||||
/// Serialized both over the network and to disk.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class PlayerPreferences
|
||||
{
|
||||
public static PlayerPreferences Default()
|
||||
{
|
||||
return new PlayerPreferences
|
||||
{
|
||||
Characters = new List<ICharacterProfile>
|
||||
{
|
||||
HumanoidCharacterProfile.Default()
|
||||
},
|
||||
SelectedCharacterIndex = 0
|
||||
};
|
||||
}
|
||||
|
||||
private List<ICharacterProfile> _characters;
|
||||
private int _selectedCharacterIndex;
|
||||
|
||||
/// <summary>
|
||||
/// All player characters.
|
||||
/// </summary>
|
||||
public List<ICharacterProfile> Characters
|
||||
{
|
||||
get => _characters;
|
||||
set => _characters = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Index of the currently selected character.
|
||||
/// </summary>
|
||||
public int SelectedCharacterIndex
|
||||
{
|
||||
get => _selectedCharacterIndex;
|
||||
set => _selectedCharacterIndex = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the currently selected character.
|
||||
/// </summary>
|
||||
public ICharacterProfile SelectedCharacter => Characters.ElementAtOrDefault(SelectedCharacterIndex);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user