added Character Setup (#511)

* added Character Setup

* whoops

* reverted unrelated changes

* Made everything work post-rebase

* Removed unused PreferencesChanged event

* nope, don't need this

* HumanoidProfileEditorPanel -> HumanoidProfileEditor

* Set initial data for hair pickers

* Fixed nullable warning

* Renamed LooksComponent -> HumanoidAppearanceComponent

* Renamed LooksComponentState -> HumanoidAppearanceComponentState

* Final renaming maybe

* Use a human-like dummy instead of a real human

* Change preferences structs back to classes
This commit is contained in:
DamianX
2020-01-18 01:54:13 +01:00
committed by Pieter-Jan Briers
parent d03da83fda
commit a4e369e629
41 changed files with 1423 additions and 756 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Client.Interfaces;
using Content.Shared.Preferences;
using Robust.Shared.Interfaces.Network;
@@ -6,8 +7,9 @@ using Robust.Shared.IoC;
namespace Content.Client
{
/// <summary>
/// Receives <see cref="PlayerPreferences"/> and <see cref="GameSettings"/> from the server during the initial connection.
/// Stores preferences on the server through <see cref="SelectCharacter"/> and <see cref="UpdateCharacter"/>.
/// Receives <see cref="PlayerPreferences" /> and <see cref="GameSettings" /> from the server during the initial
/// connection.
/// Stores preferences on the server through <see cref="SelectCharacter" /> and <see cref="UpdateCharacter" />.
/// </summary>
public class ClientPreferencesManager : SharedPreferencesManager, IClientPreferencesManager
{
@@ -24,14 +26,14 @@ namespace Content.Client
HandlePreferencesAndSettings);
}
private void HandlePreferencesAndSettings(MsgPreferencesAndSettings message)
public void SelectCharacter(ICharacterProfile profile)
{
Preferences = message.Preferences;
Settings = message.Settings;
SelectCharacter(Preferences.IndexOfCharacter(profile));
}
public void SelectCharacter(int slot)
{
Preferences = new PlayerPreferences(Preferences.Characters, slot);
var msg = _netManager.CreateNetMessage<MsgSelectCharacter>();
msg.SelectedCharacterIndex = slot;
_netManager.ClientSendMessage(msg);
@@ -39,10 +41,34 @@ namespace Content.Client
public void UpdateCharacter(ICharacterProfile profile, int slot)
{
var characters = Preferences.Characters.ToArray();
characters[slot] = profile;
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex);
var msg = _netManager.CreateNetMessage<MsgUpdateCharacter>();
msg.Profile = profile;
msg.Slot = slot;
_netManager.ClientSendMessage(msg);
}
public void CreateCharacter(ICharacterProfile profile)
{
UpdateCharacter(profile, Preferences.FirstEmptySlot);
}
public void DeleteCharacter(ICharacterProfile profile)
{
DeleteCharacter(Preferences.IndexOfCharacter(profile));
}
public void DeleteCharacter(int slot)
{
UpdateCharacter(null, slot);
}
private void HandlePreferencesAndSettings(MsgPreferencesAndSettings message)
{
Preferences = message.Preferences;
Settings = message.Settings;
}
}
}