Exemplo n.º 1
0
        // Token: 0x06000066 RID: 102 RVA: 0x00007270 File Offset: 0x00005470
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            Maid       currentMaid = this._holder.CurrentMaid;
            PresetData presetData  = new PresetData
            {
                name = presetName
            };

            foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values)
            {
                if (slotInfo.enable)
                {
                    TBodySkin slot = currentMaid.body0.GetSlot((int)slotInfo.Id);
                    SlotState mask;
                    if (slot.obj == null)
                    {
                        mask = SlotState.NotLoaded;
                    }
                    else if (!slot.boVisible)
                    {
                        mask = SlotState.Masked;
                    }
                    else
                    {
                        mask = SlotState.Displayed;
                    }
                    Material[] materials = this._holder.GetMaterials(slot);
                    if (materials.Length != 0)
                    {
                        CCSlot ccslot = new CCSlot(slotInfo.Id)
                        {
                            mask = mask
                        };
                        foreach (Material material in materials)
                        {
                            ShaderType shaderType = ShaderType.Resolve(material.shader.name);
                            if (shaderType != ShaderType.UNKNOWN)
                            {
                                CCMaterial ccmaterial = new CCMaterial(material, shaderType);
                                ccslot.Add(ccmaterial);
                                foreach (ShaderPropTex shaderPropTex in shaderType.texProps)
                                {
                                    Texture2D texture2D = material.GetTexture(shaderPropTex.propId) as Texture2D;
                                    if (!(texture2D == null) && !string.IsNullOrEmpty(texture2D.name))
                                    {
                                        TextureInfo textureInfo = new TextureInfo();
                                        ccmaterial.Add(textureInfo);
                                        textureInfo.propName = shaderPropTex.keyName;
                                        textureInfo.texFile  = texture2D.name;
                                        TextureModifier.FilterParam filter = this._texModifier.GetFilter(currentMaid, slotInfo.Id.ToString(), material.name, texture2D.name);
                                        if (filter != null && !filter.HasNotChanged())
                                        {
                                            textureInfo.filter = new TexFilter(filter);
                                        }
                                        Vector2 textureOffset = material.GetTextureOffset(shaderPropTex.propId);
                                        if (Math.Abs(textureOffset.x) > 0.001f)
                                        {
                                            textureInfo.offsetX = new float?(textureOffset.x);
                                        }
                                        if (Math.Abs(textureOffset.y) > 0.001f)
                                        {
                                            textureInfo.offsetY = new float?(textureOffset.y);
                                        }
                                        Vector2 textureScale = material.GetTextureScale(shaderPropTex.propId);
                                        if (Math.Abs(textureScale.x) > 0.001f)
                                        {
                                            textureInfo.scaleX = new float?(textureScale.x);
                                        }
                                        if (Math.Abs(textureScale.y) > 0.001f)
                                        {
                                            textureInfo.scaleY = new float?(textureScale.y);
                                        }
                                    }
                                }
                            }
                        }
                        presetData.slots.Add(ccslot);
                    }
                }
            }
            for (int k = TypeUtil.BODY_START; k <= TypeUtil.BODY_END; k++)
            {
                MPN      mpn  = (MPN)Enum.ToObject(typeof(MPN), k);
                MaidProp prop = currentMaid.GetProp(mpn);
                if (prop != null)
                {
                    if (prop.type == 1 || prop.type == 2)
                    {
                        presetData.mpnvals.Add(new CCMPNValue(mpn, prop.value, prop.min, prop.max));
                    }
                    else if (prop.type == 3 && prop.nFileNameRID != 0)
                    {
                        presetData.mpns.Add(new CCMPN(mpn, prop.strFileName));
                    }
                }
            }
            for (int l = TypeUtil.WEAR_START; l <= TypeUtil.WEAR_END; l++)
            {
                MPN      mpn2  = (MPN)Enum.ToObject(typeof(MPN), l);
                MaidProp prop2 = currentMaid.GetProp(mpn2);
                if (prop2 != null && prop2.nFileNameRID != 0)
                {
                    presetData.mpns.Add(new CCMPN(mpn2, prop2.strFileName));
                }
            }
            for (MaidParts.PARTS_COLOR parts_COLOR = TypeUtil.PARTS_COLOR_START; parts_COLOR <= TypeUtil.PARTS_COLOR_END; parts_COLOR++)
            {
                MaidParts.PartsColor partsColor = currentMaid.Parts.GetPartsColor(parts_COLOR);
                presetData.partsColors[parts_COLOR.ToString()] = new CCPartsColor(partsColor);
            }
            presetData.delNodes = new Dictionary <string, bool>(dDelNodes);
            LogUtil.Debug(new object[]
            {
                "create preset...",
                fileName
            });
            this.SavePreset(fileName, presetData);
        }
Exemplo n.º 2
0
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            Maid maid = holder.currentMaid;
            // カレントのメイドデータからプリセットデータを抽出
            var preset = new PresetData();

            preset.name = presetName;
            foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values)
            {
                if (!slotInfo.enable)
                {
                    continue;
                }

                TBodySkin slot = maid.body0.GetSlot((int)slotInfo.Id);
                // マスク情報を抽出
                SlotState maskState;
                if (slot.obj == null)
                {
                    maskState = SlotState.NotLoaded;
                }
                else if (!slot.boVisible)
                {
                    maskState = SlotState.Masked;
                }
                else
                {
                    maskState = SlotState.Displayed;
                }

                Material[] materialList = holder.GetMaterials(slot);
                if (materialList.Length == 0)
                {
                    continue;
                }

                var slotItem = new CCSlot(slotInfo.Id);
                slotItem.mask = maskState;

                foreach (Material material in materialList)
                {
                    var type = ShaderType.Resolve(material.shader.name);
                    if (type == ShaderType.UNKNOWN)
                    {
                        continue;
                    }
                    var cmat = new CCMaterial(material, type);
                    slotItem.Add(cmat);
                    foreach (var texProp in type.texProps)
                    {
                        var tex2d = material.GetTexture(texProp.propId) as Texture2D;
                        if (tex2d == null || string.IsNullOrEmpty(tex2d.name))
                        {
                            continue;
                        }

                        var ti = new TextureInfo();
                        cmat.Add(ti);
                        ti.propName = texProp.keyName;
                        ti.texFile  = tex2d.name;
                        var fp = texModifier.GetFilter(maid, slotInfo.Id.ToString(), material.name, tex2d.name);
                        if (fp != null && !fp.hasNotChanged())
                        {
                            ti.filter = new TexFilter(fp);
                        }
                    }
                }
                preset.slots.Add(slotItem);
            }

            for (int i = TypeUtil.BODY_START; i <= TypeUtil.BODY_END; i++)
            {
                var      mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                MaidProp mp  = maid.GetProp(mpn);
                if (mp != null)
                {
                    if (!String.IsNullOrEmpty(mp.strFileName))
                    {
                        preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                    }
                    else
                    {
                        preset.mpnvals.Add(new CCMPNValue(mpn, mp.value, mp.min, mp.max));
                    }
                }
            }

            for (int i = TypeUtil.WEAR_START; i <= TypeUtil.WEAR_END; i++)
            {
                var      mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                MaidProp mp  = maid.GetProp(mpn);
                if (mp != null && !String.IsNullOrEmpty(mp.strFileName))
                {
                    preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                }
            }
//            for (int i = (int)MPN_TYPE_RANGE.FOLDER_BODY_START; i <= (int)MPN_TYPE_RANGE.FOLDER_BODY_END; i++) {
//                var mpn = (MPN)Enum.ToObject(typeof(MPN), i);
//                MaidProp mp = maid.GetProp(mpn);
//                if (mp != null) {
//                    LogUtil.Debug(mpn,":", mp.type, ", value=", mp.value, ", temp=", mp.temp_value, ", file=", mp.strFileName);
//                }
//            }

            // 無限色
            for (int j = TypeUtil.PARTSCOLOR_START; j <= TypeUtil.PARTSCOLOR_END; j++)
            {
                var pcEnum = (MaidParts.PARTS_COLOR)j;
                MaidParts.PartsColor part = maid.Parts.GetPartsColor(pcEnum);
                preset.partsColors[pcEnum.ToString()] = new CCPartsColor(part);
            }

            // 表示ノード
            preset.delNodes = new Dictionary <string, bool>(dDelNodes);

            LogUtil.Debug("create preset...", fileName);
            SavePreset(fileName, preset);
        }
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            var maid = _holder.CurrentMaid;
            // カレントのメイドデータからプリセットデータを抽出
            var preset = new PresetData {
                name = presetName
            };

            foreach (var slotInfo in ACConstants.SlotNames.Values)
            {
                if (!slotInfo.enable)
                {
                    continue;
                }

                var slot = maid.body0.GetSlot((int)slotInfo.Id);
                // マスク情報を抽出
                SlotState maskState;
                if (slot.obj == null)
                {
                    maskState = SlotState.NotLoaded;
                }
                else if (!slot.boVisible)
                {
                    maskState = SlotState.Masked;
                }
                else
                {
                    maskState = SlotState.Displayed;
                }

                var materialList = _holder.GetMaterials(slot);
                if (materialList.Length == 0)
                {
                    continue;
                }

                var slotItem = new CCSlot(slotInfo.Id)
                {
                    mask = maskState
                };

                foreach (var material in materialList)
                {
                    var type = ShaderType.Resolve(material.shader.name);
                    if (type == ShaderType.UNKNOWN)
                    {
                        continue;
                    }
                    var cmat = new CCMaterial(material, type);
                    slotItem.Add(cmat);
                    foreach (var texProp in type.texProps)
                    {
                        var tex2D = material.GetTexture(texProp.propId) as Texture2D;
                        if (tex2D == null || string.IsNullOrEmpty(tex2D.name))
                        {
                            continue;
                        }

                        var ti = new TextureInfo();
                        cmat.Add(ti);
                        ti.propName = texProp.keyName;
                        ti.texFile  = tex2D.name;
                        var fp = _texModifier.GetFilter(maid, slotInfo.Id.ToString(), material.name, tex2D.name);
                        if (fp != null && !fp.HasNotChanged())
                        {
                            ti.filter = new TexFilter(fp);
                        }
#if UNITY_5_6_OR_NEWER
                        var offset = material.GetTextureOffset(texProp.propId);
#else
                        var offset = material.GetTextureOffset(texProp.keyName);
#endif
                        if (Math.Abs(offset.x) > ConstantValues.EPSILON_3)
                        {
                            ti.offsetX = offset.x;
                        }
                        if (Math.Abs(offset.y) > ConstantValues.EPSILON_3)
                        {
                            ti.offsetY = offset.y;
                        }

#if UNITY_5_6_OR_NEWER
                        var scale = material.GetTextureScale(texProp.propId);
#else
                        var scale = material.GetTextureScale(texProp.keyName);
#endif
                        if (Math.Abs(scale.x) > ConstantValues.EPSILON_3)
                        {
                            ti.scaleX = scale.x;
                        }
                        if (Math.Abs(scale.y) > ConstantValues.EPSILON_3)
                        {
                            ti.scaleY = scale.y;
                        }
                    }
                }
                preset.slots.Add(slotItem);
            }

            for (var i = TypeUtil.BODY_START; i <= TypeUtil.BODY_END; i++)
            {
                var mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                var mp  = maid.GetProp(mpn);
                if (mp == null)
                {
                    continue;
                }
                // 身体パラメータ
                if (mp.type == 1 || mp.type == 2)
                {
                    preset.mpnvals.Add(new CCMPNValue(mpn, mp.value, mp.min, mp.max));
                    continue;
                }
                // スロットアイテム
                if (mp.type == 3 && mp.nFileNameRID != 0)
                {
                    preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                }
            }

            // FOLDER_BODYは自動で0にリセットされるためプリセットの保持する必要はない
            // for (var i = MPN_TYPE_RANGE.FOLDER_BODY_START; i <= MPN_TYPE_RANGE.FOLDER_BODY_END; i++) {
            //     var mpn = (MPN)Enum.ToObject(typeof(MPN), i);
            //     var mp = maid.GetProp(mpn);
            //     if (mp == null || mp.nFileNameRID == 0) continue;
            //     preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
            // }
            for (var i = TypeUtil.WEAR_START; i <= TypeUtil.WEAR_END; i++)
            {
                var mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                var mp  = maid.GetProp(mpn);
                if (mp != null && mp.nFileNameRID != 0)
                {
                    preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                }
            }

            // 無限色
            for (var pcEnum = TypeUtil.PARTS_COLOR_START; pcEnum <= TypeUtil.PARTS_COLOR_END; pcEnum++)
            {
                var part = maid.Parts.GetPartsColor(pcEnum);
                preset.partsColors[pcEnum.ToString()] = new CCPartsColor(part);
            }

            // 表示ノード
            preset.delNodes = new Dictionary <string, bool>(dDelNodes);

            LogUtil.Debug("create preset...", fileName);
            SavePreset(fileName, preset);
        }