Фикс панели выбора персонажей

This commit is contained in:
Valtos
2023-06-23 10:02:58 +07:00
committed by Aviu00
parent dd45d9d613
commit 204aab28dd
2 changed files with 6 additions and 13 deletions

View File

@@ -126,11 +126,10 @@ namespace Content.Client.Preferences.UI
continue; continue;
} }
isDisplayedMaxSlots = numberOfFullSlots >= _preferencesManager.Settings.MaxCharacterSlots;
if (isDisplayedMaxSlots)
break;
numberOfFullSlots++; numberOfFullSlots++;
isDisplayedMaxSlots = numberOfFullSlots >= _preferencesManager.Settings.MaxCharacterSlots;
var characterPickerButton = new CharacterPickerButton(_entityManager, var characterPickerButton = new CharacterPickerButton(_entityManager,
_preferencesManager, _preferencesManager,
_prototypeManager, _prototypeManager,
@@ -148,6 +147,7 @@ namespace Content.Client.Preferences.UI
UpdateUI(); UpdateUI();
args.Event.Handle(); args.Event.Handle();
}; };
characterPickerButton.Disabled = numberOfFullSlots >= _preferencesManager.Settings.MaxCharacterSlots + 1;
} }
_createNewCharacterButton.Disabled = isDisplayedMaxSlots; _createNewCharacterButton.Disabled = isDisplayedMaxSlots;

View File

@@ -36,8 +36,6 @@ namespace Content.Server.Preferences.Managers
private readonly Dictionary<NetUserId, PlayerPrefData> _cachedPlayerPrefs = private readonly Dictionary<NetUserId, PlayerPrefData> _cachedPlayerPrefs =
new(); new();
//private int MaxCharacterSlots => _cfg.GetCVar(CCVars.GameMaxCharacterSlots);
public void Init() public void Init()
{ {
_netManager.RegisterNetMessage<MsgPreferencesAndSettings>(); _netManager.RegisterNetMessage<MsgPreferencesAndSettings>();
@@ -133,7 +131,7 @@ namespace Content.Server.Preferences.Managers
return; return;
} }
if (slot < 0 || slot >= GetMaxUserCharacterSlots(userId)) if (slot < 0)
{ {
return; return;
} }
@@ -238,12 +236,7 @@ namespace Content.Server.Preferences.Managers
{ {
var maxSlots = _cfg.GetCVar(CCVars.GameMaxCharacterSlots); var maxSlots = _cfg.GetCVar(CCVars.GameMaxCharacterSlots);
var extraSlots = _sponsors.TryGetInfo(userId, out var sponsor) ? sponsor.ExtraSlots : 0; var extraSlots = _sponsors.TryGetInfo(userId, out var sponsor) ? sponsor.ExtraSlots : 0;
var maxSavedSlots = 1; return maxSlots + extraSlots;
if (_cachedPlayerPrefs.TryGetValue(userId, out var pref))
{
maxSavedSlots = pref.Prefs!.Characters.Count;
}
return Math.Max(maxSlots + extraSlots, maxSavedSlots - 1);
} }
/// <summary> /// <summary>