コード例 #1
0
        /// <summary>
        /// 指定したパスの descript.txt を読み込む
        /// </summary>
        public static DescriptText Load(string path)
        {
            var descript = new DescriptText()
            {
                Path = path
            };

            descript.Load();
            return(descript);
        }
コード例 #2
0
ファイル: Shell.cs プロジェクト: tetradice/niseseriko
        /// <summary>
        /// ファイルを検索してシェル情報を読み込む
        /// </summary>
        protected virtual void LoadFiles()
        {
            // descript.txt 読み込み
            Descript = DescriptText.Load(DescriptPath);

            // sakura側、kero側それぞれのbindgroup情報 (着せ替え情報) 読み込み
            var sakuraEnabledBindGroupIds = GetEnabledBindGroupIds("sakura");
            var keroEnabledBindGroupIds   = GetEnabledBindGroupIds("kero");

            // 存在する surfaces*.txt を全て読み込み
            SurfacesTextList = new List <SurfacesText>();
            var surfaceTxtPathList = Directory.GetFiles(DirPath, "surface*.txt").OrderBy(path => path); // ファイル名順ソート

            foreach (var surfaceTextPath in surfaceTxtPathList)
            {
                var surfaceText = SurfacesText.Load(surfaceTextPath);
                SurfacesTextList.Add(surfaceText);
            }

            // descript.txt, surface.txt の情報を元に、sakura側とkero側それぞれの
            // サーフェス情報 (使用する画像のファイルパス、ファイル更新日時など) を読み込む
            try
            {
                SakuraSurfaceModel = LoadSurfaceModel(SakuraSurfaceId, "sakura", sakuraEnabledBindGroupIds);
            }
            catch (UnhandlableShellException ex)
            {
                ex.Scope = 0; // sakura側のエラー

                Debug.WriteLine(ex.ToString());
                throw ex; // エラーメッセージを表示するため外に投げる
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }

            try
            {
                KeroSurfaceModel = LoadSurfaceModel(KeroSurfaceId, "kero", keroEnabledBindGroupIds);
            }
            catch (UnhandlableShellException ex)
            {
                ex.Scope = 1; // kero側のエラー

                Debug.WriteLine(ex.ToString());
                throw ex; // エラーメッセージを表示するため外に投げる
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
コード例 #3
0
        public virtual void Load()
        {
            // descript.txt 読み込み
            MasterGhostDescript = DescriptText.Load(MasterGhostDesciptParh);


            // 現在シェルの決定
            {
                CurrentShellRelDirPath = null; // 一度初期化

                // profile\ghost.dat が存在すれば、その中から最終選択シェルを取得
                var ghostProfPath = Path.Combine(DirPath, @"ghost/master/profile/ghost.dat");
                if (File.Exists(ghostProfPath))
                {
                    try
                    {
                        var lines = File.ReadAllLines(ghostProfPath);
                        foreach (var line in lines)
                        {
                            if (line.StartsWith("shell,"))
                            {
                                var tokens = line.TrimEnd().Split(',');
                                CurrentShellRelDirPath = tokens[1].TrimEnd('\\').Replace('\\', '/'); // 最後の\を除去し、\を/に変換
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                }

                // 最終選択シェルの情報がない場合は、デフォルトシェル (通常は shell\master) を現在シェルとする
                // デフォルトシェルが存在しない場合は、shellフォルダ内にあるシェル1つを現在シェルとする(SSP準拠)。この場合の優先順は不定
                if (CurrentShellRelDirPath == null)
                {
                    if (File.Exists(DefaultShellDescriptPath))
                    {
                        // デフォルトシェルが存在する場合は、デフォルトシェルを選択
                        CurrentShellRelDirPath = "shell/" + DefaultShellDirName;
                    }
                    else
                    {
                        // デフォルトシェルが存在しない場合は、shellフォルダの中を探して最初に見つかったシェルを使う
                        var shellDir = Path.Combine(DirPath, "shell");
                        foreach (var shellSubDir in Directory.GetDirectories(shellDir))
                        {
                            var descriptPath = Path.Combine(shellSubDir, "descript.txt");
                            if (File.Exists(descriptPath))
                            {
                                CurrentShellRelDirPath = "shell/" + Path.GetFileName(shellSubDir);
                                break;
                            }
                        }
                    }
                }
            }

            // descript.txt 更新日時の設定
            UpdateDescriptLastModified();
        }