mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 21:24:18 +01:00
Fix issue with null-favorites.
This commit is contained in:
parent
6a3fb7f599
commit
34fa1e37c8
1 changed files with 8 additions and 10 deletions
|
|
@ -15,7 +15,8 @@ public class FavoriteManager : ISavable
|
||||||
=> (uint)Id.Value | ((uint)Type << 8) | ((uint)Race << 16) | ((uint)Gender << 24);
|
=> (uint)Id.Value | ((uint)Type << 8) | ((uint)Race << 16) | ((uint)Gender << 24);
|
||||||
|
|
||||||
public FavoriteHairStyle(uint value)
|
public FavoriteHairStyle(uint value)
|
||||||
: this((Gender)((value >> 24) & 0xFF), (SubRace)((value >> 16) & 0xFF), (CustomizeIndex)((value >> 8) & 0xFF), (CustomizeValue)(value & 0xFF))
|
: this((Gender)((value >> 24) & 0xFF), (SubRace)((value >> 16) & 0xFF), (CustomizeIndex)((value >> 8) & 0xFF),
|
||||||
|
(CustomizeValue)(value & 0xFF))
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +55,7 @@ public class FavoriteManager : ISavable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var load = JsonConvert.DeserializeObject<LoadStruct>(text);
|
var load = JsonConvert.DeserializeObject<LoadIntermediary>(text);
|
||||||
switch (load.Version)
|
switch (load.Version)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -91,19 +92,19 @@ public class FavoriteManager : ISavable
|
||||||
using var j = new JsonTextWriter(writer);
|
using var j = new JsonTextWriter(writer);
|
||||||
j.Formatting = Formatting.Indented;
|
j.Formatting = Formatting.Indented;
|
||||||
j.WriteStartObject();
|
j.WriteStartObject();
|
||||||
j.WritePropertyName(nameof(LoadStruct.Version));
|
j.WritePropertyName(nameof(LoadIntermediary.Version));
|
||||||
j.WriteValue(CurrentVersion);
|
j.WriteValue(CurrentVersion);
|
||||||
j.WritePropertyName(nameof(LoadStruct.FavoriteItems));
|
j.WritePropertyName(nameof(LoadIntermediary.FavoriteItems));
|
||||||
j.WriteStartArray();
|
j.WriteStartArray();
|
||||||
foreach (var item in _favorites)
|
foreach (var item in _favorites)
|
||||||
j.WriteValue(item.Id);
|
j.WriteValue(item.Id);
|
||||||
j.WriteEndArray();
|
j.WriteEndArray();
|
||||||
j.WritePropertyName(nameof(LoadStruct.FavoriteColors));
|
j.WritePropertyName(nameof(LoadIntermediary.FavoriteColors));
|
||||||
j.WriteStartArray();
|
j.WriteStartArray();
|
||||||
foreach (var stain in _favoriteColors)
|
foreach (var stain in _favoriteColors)
|
||||||
j.WriteValue(stain.Id);
|
j.WriteValue(stain.Id);
|
||||||
j.WriteEndArray();
|
j.WriteEndArray();
|
||||||
j.WritePropertyName(nameof(LoadStruct.FavoriteHairStyles));
|
j.WritePropertyName(nameof(LoadIntermediary.FavoriteHairStyles));
|
||||||
j.WriteStartArray();
|
j.WriteStartArray();
|
||||||
foreach (var hairStyle in _favoriteHairStyles)
|
foreach (var hairStyle in _favoriteHairStyles)
|
||||||
j.WriteValue(hairStyle.ToValue());
|
j.WriteValue(hairStyle.ToValue());
|
||||||
|
|
@ -192,14 +193,11 @@ public class FavoriteManager : ISavable
|
||||||
public bool Contains(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value)
|
public bool Contains(Gender gender, SubRace race, CustomizeIndex type, CustomizeValue value)
|
||||||
=> _favoriteHairStyles.Contains(new FavoriteHairStyle(gender, race, type, value));
|
=> _favoriteHairStyles.Contains(new FavoriteHairStyle(gender, race, type, value));
|
||||||
|
|
||||||
private struct LoadStruct
|
private class LoadIntermediary
|
||||||
{
|
{
|
||||||
public int Version = CurrentVersion;
|
public int Version = CurrentVersion;
|
||||||
public uint[] FavoriteItems = [];
|
public uint[] FavoriteItems = [];
|
||||||
public byte[] FavoriteColors = [];
|
public byte[] FavoriteColors = [];
|
||||||
public uint[] FavoriteHairStyles = [];
|
public uint[] FavoriteHairStyles = [];
|
||||||
|
|
||||||
public LoadStruct()
|
|
||||||
{ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue