Exemplo n.º 1
0
        public void RandomizeType()
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileHair    hair        = Custom.hair;

            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_b);

            hair.parts[0].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_f);
            hair.parts[1].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));

            //Side hair
            if (RandomBool(10))
            {
                hair.parts[2].id = 0;
            }
            else
            {
                categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_s);
                hair.parts[2].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            }

            //Ahoge
            if (RandomBool(10))
            {
                hair.parts[3].id = 0;
            }
            else
            {
                categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_o);
                hair.parts[3].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            }
        }
Exemplo n.º 2
0
        public static List <CustomSelectInfo> CreateSelectList(
            ChaListDefine.CategoryNo cateNo,
            ChaListDefine.KeyType limitKey = ChaListDefine.KeyType.Unknown)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(cateNo);

            int[] array = categoryInfo.Keys.ToArray <int>();
            List <CustomSelectInfo> customSelectInfoList = new List <CustomSelectInfo>();

            for (int index = 0; index < categoryInfo.Count; ++index)
            {
                if (categoryInfo[array[index]].GetInfoInt(ChaListDefine.KeyType.Possess) != 99)
                {
                    bool flag = false;
                    if (chaListCtrl.CheckItemID(categoryInfo[array[index]].Category, categoryInfo[array[index]].Id) == (byte)1)
                    {
                        flag = true;
                    }
                    customSelectInfoList.Add(new CustomSelectInfo()
                    {
                        category    = categoryInfo[array[index]].Category,
                        id          = categoryInfo[array[index]].Id,
                        limitIndex  = limitKey != ChaListDefine.KeyType.Unknown ? categoryInfo[array[index]].GetInfoInt(limitKey) : -1,
                        name        = categoryInfo[array[index]].Name,
                        assetBundle = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbAB),
                        assetName   = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbTex),
                        newItem     = flag
                    });
                }
            }
            return(customSelectInfoList);
        }
Exemplo n.º 3
0
    private void Start()
    {
        this.ReloadChara(1);
        ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;

        this.dictFacePaintLayout = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.facepaint_layout).Select <KeyValuePair <int, ListInfoBase>, CreateThumbnail.FacePaintLayout>((Func <KeyValuePair <int, ListInfoBase>, CreateThumbnail.FacePaintLayout>)(dict => new CreateThumbnail.FacePaintLayout()
        {
            index = dict.Value.Id,
            x     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.PosX),
            y     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.PosY),
            s     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.Scale)
        })).ToDictionary <CreateThumbnail.FacePaintLayout, int, CreateThumbnail.FacePaintLayout>((Func <CreateThumbnail.FacePaintLayout, int>)(v => v.index), (Func <CreateThumbnail.FacePaintLayout, CreateThumbnail.FacePaintLayout>)(v => v));
        this.dictMoleLayout = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mole_layout).Select <KeyValuePair <int, ListInfoBase>, CreateThumbnail.MoleLayout>((Func <KeyValuePair <int, ListInfoBase>, CreateThumbnail.MoleLayout>)(dict => new CreateThumbnail.MoleLayout()
        {
            index = dict.Value.Id,
            x     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.PosX),
            y     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.PosY),
            s     = dict.Value.GetInfoFloat(ChaListDefine.KeyType.Scale)
        })).ToDictionary <CreateThumbnail.MoleLayout, int, CreateThumbnail.MoleLayout>((Func <CreateThumbnail.MoleLayout, int>)(v => v.index), (Func <CreateThumbnail.MoleLayout, CreateThumbnail.MoleLayout>)(v => v));
    }
        /// <summary>
        /// Randomize the body
        /// </summary>
        private static void RandomBody(ChaFileControl file)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileBody    body        = file.custom.body;

            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_body_detail);

            body.detailId    = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            body.detailPower = 0.5f;
            float h     = 0.06f;
            float s     = RandomFloat(0.13, 0.39);
            float v     = RandomFloat(0.66, 0.98);
            Color color = Color.HSVToRGB(h, s, v);

            body.skinMainColor = color;
            Color.RGBToHSV(body.skinMainColor, out h, out s, out v);
            s                   = Mathf.Min(1f, s + 0.1f);
            v                   = Mathf.Max(0f, v - 0.1f);
            color               = Color.HSVToRGB(h, s, v);
            color.r             = Mathf.Min(1f, color.r + 0.1f);
            body.skinSubColor   = color;
            body.skinGlossPower = RandomFloat();
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_sunburn);
            body.sunburnId      = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            Color.RGBToHSV(body.skinMainColor, out h, out s, out v);
            s = Mathf.Max(0f, s - 0.1f);
            body.sunburnColor = Color.HSVToRGB(h, s, v);
            categoryInfo      = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_nip);
            body.nipId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            Color.RGBToHSV(body.skinMainColor, out h, out s, out v);
            s                   = Mathf.Min(1f, s + 0.1f);
            body.nipColor       = Color.HSVToRGB(h, s, v);
            body.areolaSize     = RandomFloat();
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_underhair);
            body.underhairId    = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            body.underhairColor = file.custom.hair.parts[0].baseColor;
            body.nailColor      = RandomColor();
            body.nailGlossPower = RandomFloat();
            body.drawAddLine    = RandomBool();
        }
Exemplo n.º 5
0
        public void RandomizeEtc()
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileFace    face        = Custom.face;

            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_head);

            face.headId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_face_detail);
            face.detailId      = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            face.detailPower   = RandomFloat();
            face.lipGlossPower = RandomFloat();
            categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyebrow);
            face.eyebrowId     = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            face.eyebrowColor  = Custom.hair.parts[0].baseColor;
            categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_nose);
            face.noseId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_mole);
            face.moleId        = 0;
            categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_lipline);
            face.lipLineId     = RandomBool() ? categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)) : 0;
            face.lipLineColor  = Custom.body.skinSubColor;
            //Color.RGBToHSV(file.custom.body.skinMainColor, out float h2, out float s2, out float num3);
            //face.lipLineColor = Color.HSVToRGB(h2, s2, Mathf.Max(num3 - 0.3f, 0f));
            face.lipGlossPower = RandomFloat();
            face.doubleTooth   = RandomBool(5);
        }
Exemplo n.º 6
0
        public void RandomizeEtc()
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileHair    hair        = Custom.hair;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    hair.parts[i].acsColor[j] = RandomColor();
                }
            }
            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_hairgloss);

            hair.glossId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
        }
Exemplo n.º 7
0
        public void RandomizeEyes()
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileFace    face        = Custom.face;

            Dictionary <int, ListInfoBase> categoryInfo;

            for (int j = 0; j < 2; j++)
            {
                categoryInfo              = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye);
                face.pupil[j].id          = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.pupil[j].baseColor   = RandomColor();
                face.pupil[j].subColor    = RandomColor();
                categoryInfo              = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_gradation);
                face.pupil[j].gradMaskId  = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.pupil[j].gradBlend   = RandomFloat();
                face.pupil[j].gradOffsetY = RandomFloat();
                face.pupil[j].gradScale   = RandomFloat();
            }

            if (RandomBool(95))
            {
                face.pupil[1].Copy(face.pupil[0]);
            }

            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_up);
            face.hlUpId         = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            face.hlUpColor      = RandomBool(5) ? RandomColor() : Color.white;
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_down);
            face.hlDownId       = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            face.hlDownColor    = RandomBool(5) ? RandomColor() : Color.white;
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_white);
            face.whiteId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            face.whiteBaseColor = RandomBool(5) ? RandomColor() : Color.white;
            face.whiteSubColor  = RandomBool(5) ? RandomColor() : Color.white;
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_up);
            face.eyelineUpId    = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_down);
            face.eyelineDownId  = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            float h, s, v;

            Color.RGBToHSV(face.pupil[0].baseColor, out h, out s, out v);
            v = Mathf.Clamp(v - 0.3f, 0f, 1f);
            face.eyelineColor = Color.HSVToRGB(h, s, v);
        }
        /// <summary>
        /// Randomize the face
        /// </summary>
        private static void RandomFace(ChaFileControl file, bool eyes, bool etc)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileFace    face        = file.custom.face;

            if (eyes)
            {
                Dictionary <int, ListInfoBase> categoryInfo;
                for (int j = 0; j < 2; j++)
                {
                    categoryInfo              = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye);
                    face.pupil[j].id          = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                    face.pupil[j].baseColor   = RandomColor();
                    face.pupil[j].subColor    = RandomColor();
                    categoryInfo              = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_gradation);
                    face.pupil[j].gradMaskId  = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                    face.pupil[j].gradBlend   = RandomFloat();
                    face.pupil[j].gradOffsetY = RandomFloat();
                    face.pupil[j].gradScale   = RandomFloat();
                }

                if (RandomBool(95))
                {
                    face.pupil[1].Copy(face.pupil[0]);
                }

                categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_up);
                face.hlUpId         = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.hlUpColor      = RandomBool(5) ? RandomColor() : Color.white;
                categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_down);
                face.hlDownId       = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.hlDownColor    = RandomBool(5) ? RandomColor() : Color.white;
                categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_white);
                face.whiteId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.whiteBaseColor = RandomBool(5) ? RandomColor() : Color.white;
                face.whiteSubColor  = RandomBool(5) ? RandomColor() : Color.white;
                categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_up);
                face.eyelineUpId    = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                categoryInfo        = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_down);
                face.eyelineDownId  = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                Color.RGBToHSV(face.pupil[0].baseColor, out float h, out float s, out float v);
                v = Mathf.Clamp(v - 0.3f, 0f, 1f);
                face.eyelineColor = Color.HSVToRGB(h, s, v);
            }
            if (etc)
            {
                Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_head);
                face.headId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_face_detail);
                face.detailId      = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.detailPower   = RandomFloat();
                face.lipGlossPower = RandomFloat();
                categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyebrow);
                face.eyebrowId     = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                face.eyebrowColor  = file.custom.hair.parts[0].baseColor;
                categoryInfo       = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_nose);
                face.noseId        = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                //categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_mole);
                face.moleId       = 0;
                categoryInfo      = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_lipline);
                face.lipLineId    = RandomBool() ? categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)) : 0;
                face.lipLineColor = file.custom.body.skinSubColor;
                //Color.RGBToHSV(file.custom.body.skinMainColor, out float h2, out float s2, out float num3);
                //face.lipLineColor = Color.HSVToRGB(h2, s2, Mathf.Max(num3 - 0.3f, 0f));
                face.lipGlossPower = RandomFloat();
                face.doubleTooth   = RandomBool(5);
            }
        }
        /// <summary>
        /// Randomize the hair
        /// </summary>
        private static void RandomHair(ChaFileControl file, bool type, bool color, bool etc)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            ChaFileHair    hair        = file.custom.hair;

            if (type)
            {
                Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_b);
                hair.parts[0].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_f);
                hair.parts[1].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));

                //Side hair
                if (RandomBool(10))
                {
                    hair.parts[2].id = 0;
                }
                else
                {
                    categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_s);
                    hair.parts[2].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                }

                //Ahoge
                if (RandomBool(10))
                {
                    hair.parts[3].id = 0;
                }
                else
                {
                    categoryInfo     = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_o);
                    hair.parts[3].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
                }
            }

            if (color)
            {
                Color baseColor = RandomColor();
                Color.RGBToHSV(baseColor, out float h, out float s, out float v);
                Color startColor = Color.HSVToRGB(h, s, Mathf.Max(v - 0.3f, 0f));
                Color endColor   = Color.HSVToRGB(h, s, Mathf.Min(v + 0.15f, 1f));
                hair.parts[0].baseColor         = baseColor;
                hair.parts[0].startColor        = startColor;
                hair.parts[0].endColor          = endColor;
                hair.parts[1].baseColor         = baseColor;
                hair.parts[1].startColor        = startColor;
                hair.parts[1].endColor          = endColor;
                hair.parts[2].baseColor         = baseColor;
                hair.parts[2].startColor        = startColor;
                hair.parts[2].endColor          = endColor;
                hair.parts[3].baseColor         = baseColor;
                hair.parts[3].startColor        = startColor;
                hair.parts[3].endColor          = endColor;
                file.custom.face.eyebrowColor   = hair.parts[0].baseColor;
                file.custom.body.underhairColor = hair.parts[0].baseColor;
            }

            if (etc)
            {
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        hair.parts[i].acsColor[j] = RandomColor();
                    }
                }
                Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_hairgloss);
                hair.glossId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count));
            }
        }
Exemplo n.º 10
0
        private IEnumerator MakerDump()
        {
            NotificationMessage = "Collecting Maker Mod Strings, please wait...";
            ChaListControl chaListCtrl = null;

            while (chaListCtrl == null)
            {
                yield return(null);

#if !KKS
                Character.Instance.SafeProc(i => chaListCtrl = i.chaListCtrl);
#else
                if (Character.Instance == null || !Character.Instance.isActiveAndEnabled)
                {
                    continue;
                }
                chaListCtrl = Character.chaListCtrl;
#endif
            }

            var categories = Enum.GetValues(typeof(ChaListDefine.CategoryNo)).Cast <ChaListDefine.CategoryNo>();

            foreach (var category in categories)
            {
                try
                {
                    var results      = GetTranslationsForPath(CombinePaths(MakerRoot, $"{category}.txt"));
                    var categoryInfo = chaListCtrl.GetCategoryInfo(category);
                    foreach (var grouping in categoryInfo.Values.Where(IsMod).GroupBy(GetMakerGrouping)
                             .OrderBy(g => g.Key, StringComparer.OrdinalIgnoreCase))
                    {
                        try
                        {
                            var names = grouping.Select(i => i.Name).Where(n => !results.ContainsKey(n)).Select(
                                origName =>
                            {
                                var shouldInclude = ShouldIncludeEntry(origName, out var translatedName);
                                var result        = new { origName, translatedName };
                                return(new { shouldInclude, result });
                            }).Where(r => r.shouldInclude && r.result.origName != r.result.translatedName)
                                        .Select(r => r.result)
                                        .OrderBy(n => n.origName, StringComparer.OrdinalIgnoreCase)
                                        .ToList();

                            if (names.Count < 1)
                            {
                                continue;
                            }

                            TextResourceHelper.AddLocalizationToResults(results, $"{FilePattern}{grouping.Key}",
                                                                        FilePattern);
                            foreach (var entry in names)
                            {
                                TextResourceHelper.AddLocalizationToResults(results, entry.origName,
                                                                            entry.translatedName);
                            }
                        }
                        catch (Exception err)
                        {
                            Logger.LogError($"Looping {grouping}: {err.Message}");
                            UnityDebug.LogException(err);
                        }
                    }
                }
                catch (Exception err)
                {
                    Logger.LogError($"Looping {category}: {err.Message}");
                    UnityDebug.LogException(err);
                }
            }

            DumpCompleted = true;
        }