123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using Newtonsoft.Json;
- namespace CacheReader
- {
- public class CachedItem
- {
- public string texName;
- public string m_strMenuName;
- public string m_strInfo;
- public string m_mpn;
- public string m_strCateName;
- public string m_eColorSetMPN;
- public string m_strMenuNameInColorSet;
- public string m_pcMultiColorID;
- public bool m_boDelOnly;
- public float m_fPriority;
- public bool m_bMan;
- }
-
- public class CacheData
- {
- public int version;
- public string menuHash;
- public string modMenuHash;
- public Dictionary<string, CachedItem> cachedItems;
- }
-
- internal class Program
- {
- private static List<string> mpnList = new List<string>
- {
- "null_mpn",
- "MuneL",
- "MuneS",
- "MuneTare",
- "RegFat",
- "ArmL",
- "Hara",
- "RegMeet",
- "KubiScl",
- "UdeScl",
- "EyeScl",
- "EyeSclX",
- "EyeSclY",
- "EyePosX",
- "EyePosY",
- "EyeClose",
- "EyeBallPosX",
- "EyeBallPosY",
- "EyeBallSclX",
- "EyeBallSclY",
- "EarNone",
- "EarElf",
- "EarRot",
- "EarScl",
- "NosePos",
- "NoseScl",
- "FaceShape",
- "FaceShapeSlim",
- "MayuShapeIn",
- "MayuShapeOut",
- "MayuX",
- "MayuY",
- "MayuRot",
- "HeadX",
- "HeadY",
- "DouPer",
- "sintyou",
- "koshi",
- "kata",
- "west",
- "MuneUpDown",
- "MuneYori",
- "MuneYawaraka",
- "body",
- "moza",
- "head",
- "hairf",
- "hairr",
- "hairt",
- "hairs",
- "hairaho",
- "haircolor",
- "skin",
- "acctatoo",
- "accnail",
- "underhair",
- "hokuro",
- "mayu",
- "lip",
- "eye",
- "eye_hi",
- "eye_hi_r",
- "chikubi",
- "chikubicolor",
- "eyewhite",
- "nose",
- "facegloss",
- "wear",
- "skirt",
- "mizugi",
- "bra",
- "panz",
- "stkg",
- "shoes",
- "headset",
- "glove",
- "acchead",
- "accha",
- "acchana",
- "acckamisub",
- "acckami",
- "accmimi",
- "accnip",
- "acckubi",
- "acckubiwa",
- "accheso",
- "accude",
- "accashi",
- "accsenaka",
- "accshippo",
- "accanl",
- "accvag",
- "megane",
- "accxxx",
- "handitem",
- "acchat",
- "onepiece",
- "set_maidwear",
- "set_mywear",
- "set_underwear",
- "set_body",
- "folder_eye",
- "folder_mayu",
- "folder_underhair",
- "folder_skin",
- "folder_eyewhite",
- "kousoku_upper",
- "kousoku_lower",
- "seieki_naka",
- "seieki_hara",
- "seieki_face",
- "seieki_mune",
- "seieki_hip",
- "seieki_ude",
- "seieki_ashi"
- };
- private static Dictionary<int, string> mpns =
- mpnList.ToDictionary(v => mpnList.IndexOf(v), v => v);
-
- private static Dictionary<int, string> parts = new Dictionary<int, string>
- {
- [-1] = "NONE",
- [0]="EYE_L",
- [1] = "EYE_R",
- [2]="HAIR",
- [3]="EYE_BROW",
- [4]="UNDER_HAIR",
- [5]="SKIN",
- [6]="NIPPLE",
- [7]="HAIR_OUTLINE",
- [8]="SKIN_OUTLINE",
- [9]="EYE_WHITE",
- [10]="MAX"
- };
-
- public static void Main(string[] args)
- {
- if (args.Length < 1)
- return;
- var path = args[0];
- if (!File.Exists(path))
- return;
-
- var data = new CacheData();
-
- using var br = new BinaryReader(File.OpenRead(path));
- try
- {
- data.version = br.ReadInt32();
- var menuFilesHashSize = br.ReadInt32();
- var menuFilesHash = br.ReadBytes(menuFilesHashSize);
- data.menuHash = Convert.ToBase64String(menuFilesHash);
- var modMenuFilesHashSize = br.ReadInt32();
- var modMenuFilesHash = br.ReadBytes(modMenuFilesHashSize);
- data.modMenuHash = Convert.ToBase64String(modMenuFilesHash);
-
- data.cachedItems = new Dictionary<string, CachedItem>();
- while (true)
- {
- var key = br.ReadNullableString();
- Console.WriteLine(key);
- var item = new CachedItem
- {
- texName = br.ReadNullableString(),
- m_strMenuName = br.ReadNullableString(),
- m_strInfo = br.ReadNullableString(),
- m_mpn =
- mpns.TryGetValue(br.ReadInt32(), out var val)
- ? val
- : "INVALID",
- m_strCateName = br.ReadNullableString(),
- m_eColorSetMPN =
- mpns.TryGetValue(br.ReadInt32(), out val)
- ? val
- : "INVALID",
- m_strMenuNameInColorSet = br.ReadNullableString(),
- m_pcMultiColorID =
- parts.TryGetValue(br.ReadInt32(), out val)
- ? val
- : "INVALID",
- m_boDelOnly = br.ReadBoolean(),
- m_fPriority = br.ReadSingle(),
- m_bMan = br.ReadBoolean()
- };
- data.cachedItems[key] = item;
- }
- }
- catch (FormatException e)
- {
- Console.WriteLine($"Failed to deserialize cache because {e.Message}");
- }
- catch (EndOfStreamException)
- {
- // End of file, no need to read more
- }
-
- File.WriteAllText("data.json", JsonConvert.SerializeObject(data, Formatting.Indented));
- }
- }
-
- internal static class BinaryExtensions
- {
- public static string ReadNullableString(this BinaryReader br)
- {
- return br.ReadBoolean() ? br.ReadString() : null;
- }
- public static void WriteNullableString(this BinaryWriter bw, string value)
- {
- bw.Write(value != null);
- if (value != null)
- bw.Write(value);
- }
- }
- }
|