示例#1
0
        private static Texture2D Load(string texfile)
        {
            if (!outUtil.Exists(texfile))
            {
                return(null);
            }
            Texture2D tex = null;

            LogUtil.Debug("load tex:", texfile);
            try {
                tex = outUtil.LoadTexture(texfile);
                // サイズ変更
                if (tex.width <= 1 || tex.height <= 1)
                {
                    TextureScale.Point(tex, IMG_WIDTH, IMG_HEIGHT);
                }
                else
                {
                    TextureScale.Bilinear(tex, IMG_WIDTH, IMG_HEIGHT);
                }
            } catch (Exception e) {
                LogUtil.Debug(e);
            }
            return(tex);
        }
示例#2
0
        // TODO ファイル名となりうるフィールドの文字列検証(入力フィールドの変更時に行う)
        //private bool isSavable;
        // private void CheckFileName(string filename) {
        //     isSavable &= filename.IndexOfAny(INVALID_FILENAMECHARS) < 0;
        //}

        // ファイルの重複確認
        private bool IsWritable(ACCMenu menu, bool ignoreExists)
        {
            if (menu.editfile.Length == 0)
            {
                return(false);
            }

            var registed = false;

            var outDir = fileUtil.GetACCDirectory();

            outDir = Path.Combine(outDir, trgtMenu.editfile);
            if (!ignoreExists && Directory.Exists(outDir))
            {
                LogUtil.Debug("output directory already exist :", outDir);
                menu.editfileExist = true;
                return(false);
            }

            var hasDuplicate = false;
            // 別々の情報ファイルが重複しないか + 登録済みファイルが存在するかをチェック
            var writeFiles = new HashSet <string> ();

            var menufile = menu.EditFileName();

            writeFiles.Add(menufile);
            menu.editfileExist = false;
            if (fileUtil.Exists(menufile))
            {
                LogUtil.Debug("already exist:", menufile);
                registed           = true;
                menu.editfileExist = true;
            }

            // icon
            menu.editiconExist = false;
            var iconfilepath = menu.EditIconFileName();

            if (fileUtil.Exists(iconfilepath))
            {
                LogUtil.Debug("already exist:", iconfilepath);
                registed           = true;
                menu.editiconExist = true;
            }
            writeFiles.Add(iconfilepath);

            // modelファイル
            foreach (var pair in menu.itemFiles)
            {
                var item = pair.Value;
                if (!item.needUpdate)
                {
                    continue;
                }
                item.editnameExist = false; // clear
                var filename = item.EditFileName();
                if (HasAlreadyWritten(writeFiles, filename))
                {
                    hasDuplicate       = true;
                    item.editnameExist = true; // フラグを分けるべきか?
                    continue;
                }

                if (!fileUtil.Exists(filename))
                {
                    continue;
                }
                LogUtil.Debug("already exist:", filename);
                registed           = true;
                item.editnameExist = true;
            }
            // mateファイル
            foreach (var tm in menu.slotMaterials.Values)
            {
                foreach (var trgtMat in tm.materials)
                {
                    // modelファイルのみの場合は好み ⇒変更する場合はmenuにマテリアル変更を追加する必要あり
                    if (trgtMat.onlyModel)
                    {
                        continue;
                    }

                    trgtMat.editfileExist = false;
                    var filename = trgtMat.EditFileName();
                    if (HasAlreadyWritten(writeFiles, filename))
                    {
                        hasDuplicate          = true;
                        trgtMat.editfileExist = true; // フラグを分けるべきか?
                        continue;
                    }
                    if (fileUtil.Exists(filename))
                    {
                        LogUtil.Debug("already exist:", filename);
                        registed = true;
                        trgtMat.editfileExist = true;
                    }
                    // pmat
                    if (trgtMat.needPmatChange)
                    {
                        var name     = Path.GetFileNameWithoutExtension(filename);
                        var pmatfile = name + FileConst.EXT_PMAT;
                        if (HasAlreadyWritten(writeFiles, pmatfile))
                        {
                            hasDuplicate          = true;
                            trgtMat.editfileExist = true; // フラグを分けるべきか?
                            continue;
                        }
                        if (fileUtil.Exists(pmatfile))
                        {
                            LogUtil.Debug("already exist:", pmatfile);
                            registed = true;
                            trgtMat.editfileExist = true;
                        }
                    }

                    // texファイル
                    foreach (var trgtTex in trgtMat.texDic.Values)
                    {
                        if (!trgtTex.needOutput)
                        {
                            continue;
                        }
                        trgtTex.editnameExist = false;

                        var texfilename = trgtTex.EditFileName();
                        if (HasAlreadyWritten(writeFiles, texfilename))
                        {
                            hasDuplicate          = true;
                            trgtTex.editnameExist = true; // フラグを分けるべきか?
                            continue;
                        }

                        if (!fileUtil.Exists(texfilename))
                        {
                            continue;
                        }
                        LogUtil.Debug("already exist:", texfilename);
                        registed = true;
                        trgtTex.editnameExist = true;
                    }
                }
            }

            // めくれ、ずらし用menuファイルの出力
            foreach (var res in menu.resFiles.Values)
            {
                res.editfileExist = false;
                var filename = res.EditFileName();
                if (HasAlreadyWritten(writeFiles, filename))
                {
                    hasDuplicate      = true;
                    res.editfileExist = true; // フラグを分けるべきか?
                    continue;
                }

                if (!fileUtil.Exists(filename))
                {
                    continue;
                }
                LogUtil.Debug("already exist:", filename);
                registed          = true;
                res.editfileExist = true;
            }
            // 出力ファイルの重複は無視できない
            if (hasDuplicate)
            {
                return(false);
            }
            return(ignoreExists || !registed);
        }
示例#3
0
        public void ApplyPresetMPN(Maid maid, PresetData preset, bool applyBody, bool applyWear, bool castoff)
        {
            // 衣装チェンジ
            foreach (var mpn in preset.mpns)
            {
                if (!applyBody)
                {
                    // bodyのMPNをスキップ
                    if (TypeUtil.IsBody(mpn.name))
                    {
                        continue;
                    }
                }
                if (!applyWear)
                {
                    // wearのMPNをスキップ
                    if (TypeUtil.IsWear(mpn.name))
                    {
                        continue;
                    }
                }

                if (mpn.filename.EndsWith("_del.menu", StringComparison.OrdinalIgnoreCase))
                {
                    if (castoff)
                    {
                        if (SetProp != null)
                        {
                            SetProp(maid, mpn.name, mpn.filename, 0);
                        }
                        else
                        {
                            LogUtil.Error("failed to apply preset. mpn=", mpn.name);
                        }
                    }
                    continue;
                    // } else if (mpn.filename.EndsWith(".mod", StringComparison.OrdinalIgnoreCase)) {
                }
                // menuファイルが存在しない場合はスキップ
                if (!fileUtil.Exists(mpn.filename))
                {
                    continue;
                }

                if (SetProp != null)
                {
                    SetProp(maid, mpn.name, mpn.filename, 0);
                }
                else
                {
                    LogUtil.Error("failed to apply preset. mpn=", mpn.name);
                }
            }

            if (applyBody)
            {
                // 設定プロパティ反映
                foreach (var mpn in preset.mpnvals)
                {
                    var mp = maid.GetProp(mpn.name);
                    if (mp != null)
                    {
                        mp.value = mpn.value;
                        if (mp.min > mpn.min)
                        {
                            mp.min = mpn.min;
                        }
                        if (mp.max < mpn.max)
                        {
                            mp.max = mpn.max;
                        }
                    }
                    else
                    {
                        LogUtil.Debug("failed to apply MaidProp. mpn:", mpn.name);
                    }
                }
            }
            //maid.AllProcPropSeqStart();
        }
        public void ApplyPresetMPN(Maid maid, PresetData preset, bool applyBody, bool applyWear, bool castoff)
        {
            // 衣装チェンジ
            foreach (var mpn in preset.mpns)
            {
                if (!applyBody)
                {
                    // bodyのMPNをスキップ
                    if (TypeUtil.IsBody(mpn.name))
                    {
                        continue;
                    }
                }
                if (!applyWear)
                {
                    // wearのMPNをスキップ
                    if (TypeUtil.IsWear(mpn.name))
                    {
                        continue;
                    }
                }
                // menuファイルが存在しない場合はスキップ
                if (!_fileUtil.Exists(mpn.filename))
                {
                    continue;
                }

                var prop = maid.GetProp(mpn.name);
                if (mpn.filename.Equals(prop.strFileName, StringComparison.OrdinalIgnoreCase))
                {
                    LogUtil.Debug("apply preset skip. mpn:", mpn.name, ", file:", mpn.filename);
                    continue;
                }

                if (mpn.name == MPN.body)
                {
                    LogUtil.Log("ACCexプリセットのbodyメニューの適用は現在未対応です。スキップします。", mpn.filename);
                    continue;
                }

                if (mpn.filename.EndsWith("_del.menu", StringComparison.OrdinalIgnoreCase))
                {
                    if (castoff)
                    {
                        // 対象のMPNが空でかつ、指定アイテムが削除アイテムと同一であればスキップ
                        if (prop.nFileNameRID == 0)
                        {
                            if (CM3.dicDelItem[mpn.name].Equals(mpn.filename, StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                        }
                        // LogUtil.Debug("apply prop(del): ", mpn.filename, ", old:", prop.strFileName);
                        if (SetProp != null)
                        {
                            SetProp(maid, mpn.name, mpn.filename, 0);
                        }
                    }
                    continue;
                    // } else if (mpn.filename.EndsWith(".mod", StringComparison.OrdinalIgnoreCase)) {
                }

                // LogUtil.Debug("apply prop: ", mpn.filename, ", old:", prop.strFileName);
                if (SetProp != null)
                {
                    SetProp(maid, mpn.name, mpn.filename, 0);
                }
            }
        }
示例#5
0
 // Token: 0x060001A5 RID: 421 RVA: 0x0000FC7C File Offset: 0x0000DE7C
 public bool Write(ACCMaterial target, string mateText, int apply)
 {
     using (StringReader stringReader = new StringReader(mateText))
     {
         FileUtilEx instance = FileUtilEx.Instance;
         stringReader.ReadLine();
         Material material = target.material;
         stringReader.ReadLine();
         stringReader.ReadLine();
         string text = stringReader.ReadLine();
         stringReader.ReadLine();
         if ((apply & MateHandler.MATE_SHADER) > 0 && material.shader.name != text)
         {
             target.ChangeShader(text, -1);
         }
         ShaderType    type  = target.type;
         string        text2 = stringReader.ReadLine();
         List <string> list  = new List <string>();
         while (text2 != null)
         {
             if (text2.Length != 0 && text2[0] != '\t')
             {
                 list.Clear();
                 string text3 = text2.Trim();
                 while ((text2 = stringReader.ReadLine()) != null)
                 {
                     if (text2.Length != 0)
                     {
                         if (text2[0] != '\t')
                         {
                             break;
                         }
                         string text4 = text2.Trim();
                         if (text4.Length > 0)
                         {
                             list.Add(text4);
                         }
                     }
                 }
                 string a;
                 if (list.Count != 0 && (a = text3) != null)
                 {
                     if (!(a == "tex"))
                     {
                         if (!(a == "col") && !(a == "vec"))
                         {
                             if (a == "f")
                             {
                                 if ((apply & MateHandler.MATE_FLOAT) > 0 && list.Count >= 2)
                                 {
                                     string     text5      = list[0];
                                     ShaderProp shaderProp = type.GetShaderProp(text5);
                                     float      value;
                                     if (shaderProp == null)
                                     {
                                         LogUtil.Log(new object[]
                                         {
                                             "シェーダに対応していないプロパティのためスキップします.propName=",
                                             text5
                                         });
                                     }
                                     else if (!float.TryParse(list[1], out value))
                                     {
                                         LogUtil.Log(new object[]
                                         {
                                             "指定文字列はfloatに変換できません。スキップします。propName={0}, text={1}",
                                             text5,
                                             list[1]
                                         });
                                     }
                                     else
                                     {
                                         material.SetFloat(shaderProp.propId, value);
                                         LogUtil.DebugF("float set({0})", new object[]
                                         {
                                             text5
                                         });
                                     }
                                 }
                             }
                         }
                         else if ((apply & MateHandler.MATE_COLOR) > 0 && list.Count >= 2)
                         {
                             string     text6       = list[0];
                             ShaderProp shaderProp2 = type.GetShaderProp(text6);
                             if (shaderProp2 == null)
                             {
                                 LogUtil.Log(new object[]
                                 {
                                     "シェーダに対応していないプロパティのためスキップします.propName=",
                                     text6
                                 });
                             }
                             else
                             {
                                 float[] array = this.ParseVals(list[1], text6, 4);
                                 if (array != null)
                                 {
                                     Color value2 = new Color(array[0], array[1], array[2], array[3]);
                                     material.SetColor(shaderProp2.propId, value2);
                                     LogUtil.DebugF("color set ({0})", new object[]
                                     {
                                         text6
                                     });
                                 }
                             }
                         }
                     }
                     else if ((apply & MateHandler.MATE_TEX) > 0)
                     {
                         if (list.Count == 2)
                         {
                             if (list[1] == "null")
                             {
                                 material.SetTexture(list[0], null);
                             }
                         }
                         else if (list.Count < 5)
                         {
                             string text7 = string.Empty;
                             if (list.Count >= 1)
                             {
                                 text7 = "propName=" + list[0];
                             }
                             LogUtil.Log(new object[]
                             {
                                 "指定パラメータが不足しているためtexの適用をスキップします.",
                                 text7
                             });
                         }
                         else
                         {
                             string     text8       = list[0];
                             string     text9       = list[2];
                             ShaderProp shaderProp3 = type.GetShaderProp(text8);
                             if (shaderProp3 == null)
                             {
                                 LogUtil.Log(new object[]
                                 {
                                     "シェーダに対応していないプロパティのためスキップします.propName=",
                                     text8
                                 });
                             }
                             else
                             {
                                 Texture texture = material.GetTexture(shaderProp3.propId);
                                 if (texture == null || texture.name != text9)
                                 {
                                     if (!text9.ToLower().EndsWith(FileConst.EXT_TEXTURE, StringComparison.Ordinal))
                                     {
                                         text9 += FileConst.EXT_TEXTURE;
                                     }
                                     if (!instance.Exists(text9))
                                     {
                                         LogUtil.LogF("tex({0}) not found. (propName={1})", new object[]
                                         {
                                             text9,
                                             text8
                                         });
                                         continue;
                                     }
                                     Texture2D value3 = instance.LoadTexture(text9);
                                     material.SetTexture(shaderProp3.propId, value3);
                                 }
                                 float[] array2 = this.ParseVals(list[4], text8, 4);
                                 if (array2 == null)
                                 {
                                     LogUtil.DebugF("tex({0}) prop is null", new object[]
                                     {
                                         text9
                                     });
                                 }
                                 else
                                 {
                                     material.SetTextureOffset(shaderProp3.propId, new Vector2(array2[0], array2[1]));
                                     material.SetTextureScale(shaderProp3.propId, new Vector2(array2[2], array2[3]));
                                     LogUtil.DebugF("tex({0}) loaded to {1}", new object[]
                                     {
                                         text9,
                                         shaderProp3.keyName
                                     });
                                 }
                             }
                         }
                     }
                 }
             }
             else
             {
                 text2 = stringReader.ReadLine();
             }
         }
     }
     return(true);
 }