diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-11 06:42:38 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-11 06:42:38 +0200 |
commit | 8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c (patch) | |
tree | 6ea7d5f1e5d3cf29bf8abcd16bbb30bf71ec3419 /src/core/hle/service/mii/mii_manager.cpp | |
parent | service: mii: separate mii types into their own file (diff) | |
download | yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar.gz yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar.bz2 yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar.lz yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar.xz yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.tar.zst yuzu-8d7d62dc24b0788b6158fd6b3bd5bce6a6969a8c.zip |
Diffstat (limited to 'src/core/hle/service/mii/mii_manager.cpp')
-rw-r--r-- | src/core/hle/service/mii/mii_manager.cpp | 235 |
1 files changed, 3 insertions, 232 deletions
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 035eed505..9ae7fb960 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -394,173 +394,9 @@ CharInfo MiiManager::BuildDefault(std::size_t index) { } CharInfo MiiManager::ConvertV3ToCharInfo(const Ver3StoreData& mii_v3) const { - Service::Mii::MiiManager manager; - auto mii = manager.BuildBase(Mii::Gender::Male); - - if (!ValidateV3Info(mii_v3)) { - return mii; - } - - // TODO: We are ignoring a bunch of data from the mii_v3 - - mii.gender = static_cast<u8>(mii_v3.mii_information.gender); - mii.favorite_color = static_cast<u8>(mii_v3.mii_information.favorite_color); - mii.height = mii_v3.height; - mii.build = mii_v3.build; - - // Copy name until string terminator - mii.name = {}; - for (std::size_t index = 0; index < mii.name.size() - 1; index++) { - mii.name[index] = mii_v3.mii_name[index]; - if (mii.name[index] == 0) { - break; - } - } - - mii.font_region = mii_v3.region_information.character_set; - - mii.faceline_type = mii_v3.appearance_bits1.face_shape; - mii.faceline_color = mii_v3.appearance_bits1.skin_color; - mii.faceline_wrinkle = mii_v3.appearance_bits2.wrinkles; - mii.faceline_make = mii_v3.appearance_bits2.makeup; - - mii.hair_type = mii_v3.hair_style; - mii.hair_color = mii_v3.appearance_bits3.hair_color; - mii.hair_flip = mii_v3.appearance_bits3.flip_hair; - - mii.eye_type = static_cast<u8>(mii_v3.appearance_bits4.eye_type); - mii.eye_color = static_cast<u8>(mii_v3.appearance_bits4.eye_color); - mii.eye_scale = static_cast<u8>(mii_v3.appearance_bits4.eye_scale); - mii.eye_aspect = static_cast<u8>(mii_v3.appearance_bits4.eye_vertical_stretch); - mii.eye_rotate = static_cast<u8>(mii_v3.appearance_bits4.eye_rotation); - mii.eye_x = static_cast<u8>(mii_v3.appearance_bits4.eye_spacing); - mii.eye_y = static_cast<u8>(mii_v3.appearance_bits4.eye_y_position); - - mii.eyebrow_type = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_style); - mii.eyebrow_color = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_color); - mii.eyebrow_scale = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_scale); - mii.eyebrow_aspect = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_yscale); - mii.eyebrow_rotate = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_rotation); - mii.eyebrow_x = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_spacing); - mii.eyebrow_y = static_cast<u8>(mii_v3.appearance_bits5.eyebrow_y_position); - - mii.nose_type = static_cast<u8>(mii_v3.appearance_bits6.nose_type); - mii.nose_scale = static_cast<u8>(mii_v3.appearance_bits6.nose_scale); - mii.nose_y = static_cast<u8>(mii_v3.appearance_bits6.nose_y_position); - - mii.mouth_type = static_cast<u8>(mii_v3.appearance_bits7.mouth_type); - mii.mouth_color = static_cast<u8>(mii_v3.appearance_bits7.mouth_color); - mii.mouth_scale = static_cast<u8>(mii_v3.appearance_bits7.mouth_scale); - mii.mouth_aspect = static_cast<u8>(mii_v3.appearance_bits7.mouth_horizontal_stretch); - mii.mouth_y = static_cast<u8>(mii_v3.appearance_bits8.mouth_y_position); - - mii.mustache_type = static_cast<u8>(mii_v3.appearance_bits8.mustache_type); - mii.mustache_scale = static_cast<u8>(mii_v3.appearance_bits9.mustache_scale); - mii.mustache_y = static_cast<u8>(mii_v3.appearance_bits9.mustache_y_position); - - mii.beard_type = static_cast<u8>(mii_v3.appearance_bits9.bear_type); - mii.beard_color = static_cast<u8>(mii_v3.appearance_bits9.facial_hair_color); - - mii.glasses_type = static_cast<u8>(mii_v3.appearance_bits10.glasses_type); - mii.glasses_color = static_cast<u8>(mii_v3.appearance_bits10.glasses_color); - mii.glasses_scale = static_cast<u8>(mii_v3.appearance_bits10.glasses_scale); - mii.glasses_y = static_cast<u8>(mii_v3.appearance_bits10.glasses_y_position); - - mii.mole_type = static_cast<u8>(mii_v3.appearance_bits11.mole_enabled); - mii.mole_scale = static_cast<u8>(mii_v3.appearance_bits11.mole_scale); - mii.mole_x = static_cast<u8>(mii_v3.appearance_bits11.mole_x_position); - mii.mole_y = static_cast<u8>(mii_v3.appearance_bits11.mole_y_position); - - // TODO: Validate mii data - - return mii; -} - -Ver3StoreData MiiManager::BuildFromStoreData(const CharInfo& mii) const { - Service::Mii::MiiManager manager; - Ver3StoreData mii_v3{}; - - // TODO: We are ignoring a bunch of data from the mii_v3 - - mii_v3.version = 1; - mii_v3.mii_information.gender.Assign(mii.gender); - mii_v3.mii_information.favorite_color.Assign(mii.favorite_color); - mii_v3.height = mii.height; - mii_v3.build = mii.build; - - // Copy name until string terminator - mii_v3.mii_name = {}; - for (std::size_t index = 0; index < mii.name.size() - 1; index++) { - mii_v3.mii_name[index] = mii.name[index]; - if (mii_v3.mii_name[index] == 0) { - break; - } - } - - mii_v3.region_information.character_set.Assign(mii.font_region); - - mii_v3.appearance_bits1.face_shape.Assign(mii.faceline_type); - mii_v3.appearance_bits2.wrinkles.Assign(mii.faceline_wrinkle); - mii_v3.appearance_bits2.makeup.Assign(mii.faceline_make); - - mii_v3.hair_style = mii.hair_type; - mii_v3.appearance_bits3.flip_hair.Assign(mii.hair_flip); - - mii_v3.appearance_bits4.eye_type.Assign(mii.eye_type); - mii_v3.appearance_bits4.eye_scale.Assign(mii.eye_scale); - mii_v3.appearance_bits4.eye_vertical_stretch.Assign(mii.eye_aspect); - mii_v3.appearance_bits4.eye_rotation.Assign(mii.eye_rotate); - mii_v3.appearance_bits4.eye_spacing.Assign(mii.eye_x); - mii_v3.appearance_bits4.eye_y_position.Assign(mii.eye_y); - - mii_v3.appearance_bits5.eyebrow_style.Assign(mii.eyebrow_type); - mii_v3.appearance_bits5.eyebrow_scale.Assign(mii.eyebrow_scale); - mii_v3.appearance_bits5.eyebrow_yscale.Assign(mii.eyebrow_aspect); - mii_v3.appearance_bits5.eyebrow_rotation.Assign(mii.eyebrow_rotate); - mii_v3.appearance_bits5.eyebrow_spacing.Assign(mii.eyebrow_x); - mii_v3.appearance_bits5.eyebrow_y_position.Assign(mii.eyebrow_y); - - mii_v3.appearance_bits6.nose_type.Assign(mii.nose_type); - mii_v3.appearance_bits6.nose_scale.Assign(mii.nose_scale); - mii_v3.appearance_bits6.nose_y_position.Assign(mii.nose_y); - - mii_v3.appearance_bits7.mouth_type.Assign(mii.mouth_type); - mii_v3.appearance_bits7.mouth_scale.Assign(mii.mouth_scale); - mii_v3.appearance_bits7.mouth_horizontal_stretch.Assign(mii.mouth_aspect); - mii_v3.appearance_bits8.mouth_y_position.Assign(mii.mouth_y); - - mii_v3.appearance_bits8.mustache_type.Assign(mii.mustache_type); - mii_v3.appearance_bits9.mustache_scale.Assign(mii.mustache_scale); - mii_v3.appearance_bits9.mustache_y_position.Assign(mii.mustache_y); - - mii_v3.appearance_bits9.bear_type.Assign(mii.beard_type); - - mii_v3.appearance_bits10.glasses_scale.Assign(mii.glasses_scale); - mii_v3.appearance_bits10.glasses_y_position.Assign(mii.glasses_y); - - mii_v3.appearance_bits11.mole_enabled.Assign(mii.mole_type); - mii_v3.appearance_bits11.mole_scale.Assign(mii.mole_scale); - mii_v3.appearance_bits11.mole_x_position.Assign(mii.mole_x); - mii_v3.appearance_bits11.mole_y_position.Assign(mii.mole_y); - - // These types are converted to V3 from a table - mii_v3.appearance_bits1.skin_color.Assign( - RawData::FromVer3GetFacelineColor(mii.faceline_color)); - mii_v3.appearance_bits3.hair_color.Assign(RawData::FromVer3GetHairColor(mii.hair_color)); - mii_v3.appearance_bits4.eye_color.Assign(RawData::FromVer3GetEyeColor(mii.eye_color)); - mii_v3.appearance_bits5.eyebrow_color.Assign(RawData::FromVer3GetHairColor(mii.eyebrow_color)); - mii_v3.appearance_bits7.mouth_color.Assign(RawData::FromVer3GetMouthlineColor(mii.mouth_color)); - mii_v3.appearance_bits9.facial_hair_color.Assign( - RawData::FromVer3GetHairColor(mii.beard_color)); - mii_v3.appearance_bits10.glasses_color.Assign( - RawData::FromVer3GetGlassColor(mii.glasses_color)); - mii_v3.appearance_bits10.glasses_type.Assign(RawData::FromVer3GetGlassType(mii.glasses_type)); - - mii_v3.crc = MiiUtil::CalculateCrc16(&mii_v3, sizeof(Ver3StoreData) - sizeof(u16)); - - // TODO: Validate mii_v3 data - - return mii_v3; + CharInfo char_info{}; + mii_v3.BuildToStoreData(char_info); + return char_info; } NfpStoreDataExtension MiiManager::SetFromStoreData(const CharInfo& mii) const { @@ -576,71 +412,6 @@ NfpStoreDataExtension MiiManager::SetFromStoreData(const CharInfo& mii) const { }; } -bool MiiManager::ValidateV3Info(const Ver3StoreData& mii_v3) const { - bool is_valid = mii_v3.version == 0 || mii_v3.version == 3; - - is_valid = is_valid && (mii_v3.mii_name[0] != 0); - - is_valid = is_valid && (mii_v3.mii_information.birth_month < 13); - is_valid = is_valid && (mii_v3.mii_information.birth_day < 32); - is_valid = is_valid && (mii_v3.mii_information.favorite_color < 12); - is_valid = is_valid && (mii_v3.height < 128); - is_valid = is_valid && (mii_v3.build < 128); - - is_valid = is_valid && (mii_v3.appearance_bits1.face_shape < 12); - is_valid = is_valid && (mii_v3.appearance_bits1.skin_color < 7); - is_valid = is_valid && (mii_v3.appearance_bits2.wrinkles < 12); - is_valid = is_valid && (mii_v3.appearance_bits2.makeup < 12); - - is_valid = is_valid && (mii_v3.hair_style < 132); - is_valid = is_valid && (mii_v3.appearance_bits3.hair_color < 8); - - is_valid = is_valid && (mii_v3.appearance_bits4.eye_type < 60); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_color < 6); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_scale < 8); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_vertical_stretch < 7); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_rotation < 8); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_spacing < 13); - is_valid = is_valid && (mii_v3.appearance_bits4.eye_y_position < 19); - - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_style < 25); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_color < 8); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_scale < 9); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_yscale < 7); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_rotation < 12); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_spacing < 12); - is_valid = is_valid && (mii_v3.appearance_bits5.eyebrow_y_position < 19); - - is_valid = is_valid && (mii_v3.appearance_bits6.nose_type < 18); - is_valid = is_valid && (mii_v3.appearance_bits6.nose_scale < 9); - is_valid = is_valid && (mii_v3.appearance_bits6.nose_y_position < 19); - - is_valid = is_valid && (mii_v3.appearance_bits7.mouth_type < 36); - is_valid = is_valid && (mii_v3.appearance_bits7.mouth_color < 5); - is_valid = is_valid && (mii_v3.appearance_bits7.mouth_scale < 9); - is_valid = is_valid && (mii_v3.appearance_bits7.mouth_horizontal_stretch < 7); - is_valid = is_valid && (mii_v3.appearance_bits8.mouth_y_position < 19); - - is_valid = is_valid && (mii_v3.appearance_bits8.mustache_type < 6); - is_valid = is_valid && (mii_v3.appearance_bits9.mustache_scale < 7); - is_valid = is_valid && (mii_v3.appearance_bits9.mustache_y_position < 17); - - is_valid = is_valid && (mii_v3.appearance_bits9.bear_type < 6); - is_valid = is_valid && (mii_v3.appearance_bits9.facial_hair_color < 8); - - is_valid = is_valid && (mii_v3.appearance_bits10.glasses_type < 9); - is_valid = is_valid && (mii_v3.appearance_bits10.glasses_color < 6); - is_valid = is_valid && (mii_v3.appearance_bits10.glasses_scale < 8); - is_valid = is_valid && (mii_v3.appearance_bits10.glasses_y_position < 21); - - is_valid = is_valid && (mii_v3.appearance_bits11.mole_enabled < 2); - is_valid = is_valid && (mii_v3.appearance_bits11.mole_scale < 9); - is_valid = is_valid && (mii_v3.appearance_bits11.mole_x_position < 17); - is_valid = is_valid && (mii_v3.appearance_bits11.mole_y_position < 31); - - return is_valid; -} - std::vector<CharInfoElement> MiiManager::GetDefault(SourceFlag source_flag) { std::vector<CharInfoElement> result; |