Пример #1
1
		//シートの読み込み
		static StringGrid ReadSheet(ISheet sheet, string path)
		{
			int lastRowNum = sheet.LastRowNum;

			StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, CsvType.Tsv);
			for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
			{
				IRow row = sheet.GetRow(rowIndex);

				List<string> stringList = new List<string>();
				if (row != null)
				{
					foreach (var cell in row.Cells)
					{
						for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
						{
							stringList.Add("");
						}
						stringList.Add(cell.ToString());
					}
				}
				grid.AddRow(stringList);
			}
			grid.ParseHeader();
			return grid;
		}
Пример #2
0
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="name">シナリオ名</param>
 /// <param name="grid">シナリオデータ</param>
 /// <param name="dataManager">各種設定データ</param>
 public void Init(string name, StringGrid grid, AdvSettingDataManager dataManager)
 {
     this.name         = name;
     this.dataGridName = grid.Name;
     scenarioLabels.Add(name);
     ParseFromStringGrid(grid, dataManager);
 }
Пример #3
0
        //コマンドデータの解析・初期化
        void ParseFromStringGrid(StringGrid grid, AdvSettingDataManager dataManager)
        {
            AddCommandBegin();
            AdvCommand continuousCommand = null;                //連続的なコマンド処理

            foreach (StringGridRow row in grid.Rows)
            {
                if (row.RowIndex < grid.DataTopRow)
                {
                    continue;                                                                   //データの行じゃない
                }
                if (row.IsEmpty)
                {
                    continue;                                                                                           //データがない
                }
                AdvCommand command = AdvCommandParser.CreateCommand(row, dataManager);
                if (null != command)
                {
                    //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
                    TryAddContinusCommand(continuousCommand, command);
                    //コマンド追加
                    AddCommand(command);
                    //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
                    continuousCommand = GetNextContinusCommand(continuousCommand, command);
                }
            }
            //連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
            TryAddContinusCommand(continuousCommand, null);

            AddCommandEnd();
        }
Пример #4
0
 public override void ParseGrid(StringGrid grid)
 {
     base.ParseGrid(grid);
     InitDefault(AdvLayerSettingData.LayerType.Bg, 0);
     InitDefault(AdvLayerSettingData.LayerType.Character, 100);
     InitDefault(AdvLayerSettingData.LayerType.Sprite, 200);
 }
Пример #5
0
        void ParseData(TextAsset csv)
        {
            dataTbl.Clear();
            StringGrid data = new StringGrid(csv.name, CsvType.Tsv, csv.text);

            if (data.Rows.Count <= 0)
            {
                return;
            }

            foreach (StringGridRow row in data.Rows)
            {
                if (row.IsEmpty)
                {
                    continue;
                }
                dataTbl.Add(row.ParseCell <string>("Key"), row);
            }

            StringGridRow header = data.Rows[0];

            for (int i = 0; i < header.Length; ++i)
            {
                if (i == 0)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(header.Strings[i]))
                {
                    continue;
                }
                languages.Add(header.Strings[i]);
            }
        }
Пример #6
0
        //起動用CSVをコンバート
        CsvInfo ConvertBootSetting(List <AdvExcelSheets> excelSheets, string chapterName, int version)
        {
            if (string.IsNullOrEmpty(chapterName))
            {
                chapterName = AdvSheetParser.SheetNameBoot;
            }
            StringGrid grid = new StringGrid(chapterName, chapterName, CsvType.Tsv);

            grid.AddRow(new List <string> {
                AdvParser.Localize(AdvColumnName.Tag), AdvParser.Localize(AdvColumnName.Param1), AdvParser.Localize(AdvColumnName.Version)
            });
            ///起動用データをコンバート
            foreach (var excel in excelSheets)
            {
                string excelName = System.IO.Path.GetFileNameWithoutExtension(excel.Path);
                //シナリオ設定シートは個別にコンバート
                AddFileDataToTsv(grid, version, excelName, AdvSheetParser.SheetNameScenario);
                foreach (var sheet in excel.SettingsSheets)
                {
                    AddFileDataToTsv(grid, version, excelName, sheet.SheetName);
                }
            }

            string path = chapterName;

            return(new CsvInfo(grid, path));
        }
        //設定データをインポート
        void ImportSettingBook(StringGridDictionary book, string path)
        {
            //インポート後のスクリプタブルオブジェクトを作成
            string assetPath = Path.GetDirectoryName(path) + "/" + Path.GetFileNameWithoutExtension(path) + SettingAssetExt;

            foreach (var sheet in book.List)
            {
                StringGrid grid = sheet.Grid;
                //設定データか、シナリオデータかチェック
                if (AdvSettingDataManager.IsBootSheet(sheet.Name) || AdvSettingDataManager.IsSettingsSheet(sheet.Name))
                {
                    //設定データのアセットを作成
                    if (assetSetting == null)
                    {
                        assetSetting = UtageEditorToolKit.GetImportedAssetCreateIfMissing <AdvSettingDataManager>(assetPath);
                        assetSetting.Clear();
                    }
                    assetSetting.hideFlags = HideFlags.NotEditable;
                    assetSetting.ParseFromExcel(sheet.Name, grid);
                }
            }

            if (assetSetting != null)
            {
                assetSetting.EditorTestInit();
                Debug.Log(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.Import, assetPath));
                //変更を反映
                EditorUtility.SetDirty(assetSetting);
            }
        }
        //ファイルの書き込み
        void WriteStringGrid(StringGrid grid, string path)
        {
            string dir = System.IO.Path.GetDirectoryName(path);

            if (!System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.CreateDirectory(dir);
            }

            // ファイルにテキストを書き出し。
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(path))
            {
                char separator = grid.CsvSeparator;
                foreach (StringGridRow row in grid.Rows)
                {
                    for (int i = 0; i < row.Strings.Length; ++i)
                    {
                        //CSVの書式にあわせる
                        string line = row.Strings[i].Replace("\n", "\\n");
                        writer.Write(line);
                        if (i < row.Strings.Length - 1)
                        {
                            writer.Write(separator);
                        }
                    }
                    writer.Write("\n");
                }
            }
        }
Пример #9
0
        protected override void OnParseGrid(StringGrid grid, AdvBootSetting bootSetting)
        {
            if (GridList.Count == 0)
            {
                Debug.LogError("Old Version Reimport Excel Scenario Data");
                return;
            }

            string            sheetName = grid.SheetName;
            AdvParamStructTbl data;

            if (!StructTbl.TryGetValue(sheetName, out data))
            {
                data = new AdvParamStructTbl();
                StructTbl.Add(sheetName, data);
            }

            if (sheetName == SheetNameParam)
            {
                data.AddSingle(grid);
            }
            else
            {
                data.AddTbl(grid);
            }
        }
Пример #10
0
        //構造体のパラメーターテーブルとしてデータ解析
        public void AddTbl(StringGrid grid)
        {
            if (grid.Rows.Count < 3)
            {
                Debug.LogError(grid.Name + " is not Param Sheet");
                return;
            }

            StringGridRow row0 = grid.Rows[0];
            StringGridRow row1 = grid.Rows[1];
            StringGridRow row2 = grid.Rows[2];

            AdvParamStruct header = new AdvParamStruct(row0, row1, row2);

            for (int i = 3; i < grid.Rows.Count; ++i)
            {
                StringGridRow row = grid.Rows[i];
                if (row.IsEmptyOrCommantOut)
                {
                    continue;
                }
                AdvParamStruct data = new AdvParamStruct(header, row);
                string         key  = row.Strings[0];
                if (Tbl.ContainsKey(key))
                {
                    row.ToErrorString(key + " is already contains ");
                }
                else
                {
                    Tbl.Add(key, data);
                }
            }
        }
Пример #11
0
        /// <summary>
        /// CSVにコンバートする際に、デフォルトで使用するsettings系のURLリストを追加する
        /// </summary>
        /// <param name="grid"></param>
        static void AddDefaultUrlSettingsOnCsvOnvert(StringGrid grid, int version)
        {
            const string format = "Settings/{0}.tsv";

            grid.AddRow(new List <string> {
                TagScenarioSetting, string.Format(format, AdvSettingDataManager.SheetNameScenario), "" + version
            });
            grid.AddRow(new List <string> {
                TagCharacterSetting, string.Format(format, AdvSettingDataManager.SheetNameCharacter), "" + version
            });
            grid.AddRow(new List <string> {
                TagTextureSetting, string.Format(format, AdvSettingDataManager.SheetNameTexture), "" + version
            });
            grid.AddRow(new List <string> {
                TagSoundSetting, string.Format(format, AdvSettingDataManager.SheetNameSound), "" + version
            });
            grid.AddRow(new List <string> {
                TagParamSetting, string.Format(format, AdvSettingDataManager.SheetNameParam), "" + version
            });
            grid.AddRow(new List <string> {
                TagLayerSetting, string.Format(format, AdvSettingDataManager.SheetNameLayer), "" + version
            });
            grid.AddRow(new List <string> {
                TagSceneGallerySetting, string.Format(format, AdvSettingDataManager.SheetNameSceneGallery), "" + version
            });
        }
Пример #12
0
        //シートの読み込み
        static StringGrid ReadSheet(ISheet sheet, string path)
        {
            int lastRowNum = sheet.LastRowNum;

            StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, sheet.SheetName, CsvType.Tsv);

            for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
            {
                IRow row = sheet.GetRow(rowIndex);

                List <string> stringList = new List <string>();
                if (row != null)
                {
                    foreach (var cell in row.Cells)
                    {
                        for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
                        {
                            stringList.Add("");
                        }
                        stringList.Add(cell.ToString());
                    }
                }
                grid.AddRow(stringList);
            }
            grid.ParseHeader();
            return(grid);
        }
Пример #13
0
        /// <summary>
        /// エラーチェックのために実際にデータを作成
        /// エクスポートするときに使用。
        /// </summary>
        /// <param name="sheetName">シート名</param>
        /// <param name="grid">チェックするシナリオを記述したStringGrid</param>
        /// <param name="settingDataManger">データ管理の大本</param>
        /// <returns>シナリオデータ</returns>
        public AdvScenarioData ErrorCheck(string sheetName, StringGrid grid, AdvSettingDataManager settingDataManger)
        {
            AdvScenarioData scenario = new AdvScenarioData();

            scenario.Init(sheetName, grid, settingDataManger);
            return(scenario);
        }
        //シートをCSVにコンバート
        void ConvertSheet(StringGridDictionaryKeyValue sheet, string folderPath)
        {
            string outPutPath = folderPath + "/";

            if (AdvSettingDataManager.IsBootSheet(sheet.Name))
            {
                ///起動用データは個別にコンバート
                bootSettingGrid = sheet.Grid;
                return;
            }
            else if (AdvSettingDataManager.IsScenarioSettingSheet(sheet.Name))
            {
                ///シナリオ設定データは個別にコンバート
                scenarioSettingGrid = sheet.Grid;
                return;
            }
            else if (AdvSettingDataManager.IsSettingsSheet(sheet.Name))
            {
                outPutPath += "Settings";
            }
            else
            {
                scenarioSheetDictionary.Add(sheet);
                outPutPath += "Scenario";
            }
            outPutPath += "/" + sheet.Key + extConvert;
            WriteFile(sheet.Grid, outPutPath);
        }
        //起動用CSVをコンバート
        void WriteBootSetting(string folderPath, int version)
        {
            StringGrid grid       = AdvBootSetting.CreateOnCsvOnvert(bootSettingGrid, version);
            string     outPutPath = folderPath + "/" + AdvSettingDataManager.SheetNameBoot + extConvert;

            WriteFile(grid, outPutPath);
        }
 /// <summary>
 /// 文字列グリッドから、データ解析
 /// </summary>
 /// <param name="grid"></param>
 protected virtual void ParseFromStringGrid(StringGrid grid)
 {
     foreach (StringGridRow row in grid.Rows)
     {
         if (row.RowIndex < grid.DataTopRow)
         {
             continue;                                                                   //データの行じゃない
         }
         if (row.IsEmpty)
         {
             continue;                                                                                           //データがない
         }
         T data = new T();
         if (data.InitFromStringGridRow(row))
         {
             if (!ContainsKey(data.Key))
             {
                 Add(data);
             }
             else
             {
                 string errorMsg = "";
                 errorMsg += row.ToErrorString(ColorUtil.AddColorTag(data.Key, Color.red) + "  is already contains");
                 Debug.LogError(errorMsg);
             }
         }
     }
 }
 /// <summary>
 /// 文字列グリッドから、データ初期化
 /// </summary>
 /// <param name="grid">初期化するための文字列グリッド</param>
 public virtual void InitFromStringGrid(StringGrid grid)
 {
     Clear();
     ParseBeign();
     ParseFromStringGrid(grid);
     ParseEnd();
 }
Пример #18
0
        /// <summary>
        /// リソースをアンロードして、メモリを解放(Resourcesでロードしたもの)
        /// </summary>
        void UnloadResources()
        {
            switch (FileType)
            {
            case AssetFileType.Text:                                    //テキスト
                text = null;
                break;

            case AssetFileType.Bytes:                                   //バイナリ
                bytes = null;
                break;

            case AssetFileType.Texture:                                 //テクスチャ
                Resources.UnloadAsset(texture);
                texture = null;
                break;

            case AssetFileType.Sound:                                   //サウンド
                Resources.UnloadAsset(sound);
                sound = null;
                break;

            case AssetFileType.Csv:                             //CSV
                csv = null;
                break;

            case AssetFileType.UnityObject:                             //Unityオブジェクト
//					Resources.UnloadAsset(unityObject);
                unityObject = null;
                break;

            default:
                break;
            }
        }
Пример #19
0
        //マクロ処理した行データを取得
        public List <StringGridRow> MakeMacroRows(StringGridRow args)
        {
            List <StringGridRow> list = new List <StringGridRow>();

            if (DataList.Count <= 0)
            {
                return(list);
            }

            StringGrid macroGrid = DataList[0].Grid;
            string     gridName  = args.Grid.Name + ":" + (args.RowIndex + 1).ToString() + "-> Macro : " + macroGrid.Name;
            StringGrid grid      = new StringGrid(gridName, args.Grid.SheetName, macroGrid.Type);

            grid.Macro          = new StringGrid.MacroInfo(args);
            grid.ColumnIndexTbl = macroGrid.ColumnIndexTbl;
            List <int> ignoreIndexArray = AdvParser.CreateMacroOrEntityIgnoreIndexArray(grid);

            for (int i = 0; i < DataList.Count; ++i)
            {
                StringGridRow macroData = DataList[i].Clone(() => (grid));
                macroData.Macro(args, Header, ignoreIndexArray);
                list.Add(macroData);
            }
            return(list);
        }
Пример #20
0
        StringGridDictionary ConvertToLocalized(StringGridDictionary gridTbl)
        {
            List <string> languageNameList = LanguageNameList();

            StringGridDictionary localizedGirdTbl = new StringGridDictionary();

            foreach (var keyValue in gridTbl.List)
            {
                int        index;
                StringGrid grid = keyValue.Grid;
                if (grid.TryGetColumnIndex(TextKey, out index))
                {
                    StringGrid localizedGird = new StringGrid(grid.Name, grid.SheetName, CsvType.Tsv);
                    localizedGird.AddRow(languageNameList);
                    for (int i = 0; i < grid.Rows.Count; ++i)
                    {
                        if (i == 0)
                        {
                            continue;
                        }
                        string text = grid.Rows[i].ParseCellOptional <string>(TextKey, "");
                        localizedGird.AddRow(new List <string>(new string[] { text }));
                    }
                    localizedGirdTbl.Add(new StringGridDictionaryKeyValue(grid.SheetName, localizedGird));
                }
            }
            return(localizedGirdTbl);
        }
        //シナリオ設定シートを個別にコンバート
        void WriteScenarioSetting(string folderPath, int version)
        {
            scenarioSettingGrid = AdvScenarioSetting.MargeScenarioData(scenarioSettingGrid, scenarioSheetDictionary, version);
            string path = folderPath + "/Settings/" + AdvSettingDataManager.SheetNameScenario + extConvert;

            WriteFile(scenarioSettingGrid, path);
        }
Пример #22
0
        //起動用CSVをコンバート
        CsvInfo ConvertBootSetting(int version)
        {
            StringGrid grid = AdvBootSetting.CreateOnCsvOnvert(bootSettingGrid, version);
            string     path = AdvSettingDataManager.SheetNameBoot;

            return(new CsvInfo(grid, path));
        }
        //ブックのインポート
        void ImportScenarioBook(StringGridDictionary book, string path)
        {
            //シナリオデータ用のスクリプタブルオブジェクトを宣言
            string scenarioAssetPath = Path.ChangeExtension(path, ScenarioAssetExt);
            AdvScenarioDataExported assetScenario = null;

            foreach (var sheet in book.List)
            {
                StringGrid grid = sheet.Grid;
                //設定データか、シナリオデータかチェック
                if (!AdvSettingDataManager.IsBootSheet(sheet.Name) && !AdvSettingDataManager.IsSettingsSheet(sheet.Name))
                {
                    //シナリオデータのアセットを作成
                    if (assetScenario == null)
                    {
                        assetScenario = UtageEditorToolKit.GetImportedAssetCreateIfMissing <AdvScenarioDataExported>(scenarioAssetPath);
                        assetScenario.Clear();
                    }
                    assetScenario.hideFlags = HideFlags.NotEditable;
                    assetScenario.ParseFromExcel(sheet.Name, grid);
                    if (assetSetting != null)
                    {
                        AdvScenarioData scenarioData = assetScenario.ErrorCheck(sheet.Name, grid, assetSetting);
                        scenarioDataTbl.Add(sheet.Name, scenarioData);
                    }
                }
            }

            //変更を反映
            if (assetScenario != null)
            {
                Debug.Log(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.Import, scenarioAssetPath));
                EditorUtility.SetDirty(assetScenario);
            }
        }
Пример #24
0
        //シナリオ設定シートを個別にコンバート
        CsvInfo ConvertScenarioSetting(int version)
        {
            scenarioSettingGrid = AdvScenarioSetting.MargeScenarioData(scenarioSettingGrid, scenarioSheetDictionary, version);
            string path = "Settings/" + AdvSettingDataManager.SheetNameScenario;

            return(new CsvInfo(scenarioSettingGrid, path));
        }
Пример #25
0
        //シートをCSVにコンバート
        bool TryConvertSheet(StringGridDictionaryKeyValue sheet, out CsvInfo csvInfo)
        {
            csvInfo = null;
            string outPutPath;

            if (AdvSettingDataManager.IsBootSheet(sheet.Name))
            {
                ///起動用データは個別にコンバート
                bootSettingGrid = sheet.Grid;
                return(false);
            }
            else if (AdvSettingDataManager.IsScenarioSettingSheet(sheet.Name))
            {
                ///シナリオ設定データは個別にコンバート
                scenarioSettingGrid = sheet.Grid;
                return(false);
            }
            else if (AdvSettingDataManager.IsSettingsSheet(sheet.Name))
            {
                outPutPath = "Settings";
            }
            else
            {
                scenarioSheetDictionary.Add(sheet);
                outPutPath = "Scenario";
            }
            csvInfo = new CsvInfo(sheet.Grid, outPutPath + "/" + sheet.Key);
            return(true);
        }
Пример #26
0
 public void AddTbl(StringGrid grid)
 {
     if (grid.Rows.Count < 3)
     {
         Debug.LogError(grid.Name + " is not Param Sheet");
     }
     else
     {
         StringGridRow  names     = grid.Rows[0];
         StringGridRow  types     = grid.Rows[1];
         StringGridRow  fileTypes = grid.Rows[2];
         AdvParamStruct header    = new AdvParamStruct(names, types, fileTypes);
         for (int i = 3; i < grid.Rows.Count; i++)
         {
             StringGridRow values = grid.Rows[i];
             if (!values.IsEmptyOrCommantOut)
             {
                 AdvParamStruct struct3 = new AdvParamStruct(header, values);
                 string         key     = values.Strings[0];
                 if (this.Tbl.ContainsKey(key))
                 {
                     values.ToErrorString(key + " is already contains ");
                 }
                 else
                 {
                     this.Tbl.Add(key, struct3);
                 }
             }
         }
     }
 }
Пример #27
0
 //通常のパラメーターを追加
 public void AddData(StringGrid grid)
 {
     foreach (StringGridRow row in grid.Rows)
     {
         if (row.RowIndex < grid.DataTopRow)
         {
             continue;
         }
         if (row.IsEmptyOrCommantOut)
         {
             continue;
         }
         AdvParamData data = new AdvParamData();
         if (!data.TryParse(row))
         {
             Debug.LogError(row.ToErrorString(" Parse Error"));
             continue;
         }
         else
         {
             if (Tbl.ContainsKey(data.Key))
             {
                 Debug.LogError(row.ToErrorString(data.Key + " is already contaisn"));
             }
             else
             {
                 Tbl.Add(data.Key, data);
             }
         }
     }
 }
Пример #28
0
        internal void OverwriteData(StringGrid grid)
        {
            Dictionary <int, int> dictionary = new Dictionary <int, int>();
            StringGridRow         row        = grid.Rows[0];

            for (int i = 0; i < row.Length; i++)
            {
                if (i != 0)
                {
                    string str = row.Strings[i];
                    if (!string.IsNullOrEmpty(str))
                    {
                        if (!this.languages.Contains(str))
                        {
                            this.languages.Add(str);
                        }
                        int index = this.languages.IndexOf(str);
                        if (dictionary.ContainsKey(index))
                        {
                            Debug.LogError(str + " already exists in  " + grid.Name);
                        }
                        else
                        {
                            dictionary.Add(index, i);
                        }
                    }
                }
            }
            foreach (StringGridRow row2 in grid.Rows)
            {
                if (!row2.IsEmptyOrCommantOut && (row2.RowIndex != 0))
                {
                    string str2 = row2.Strings[0];
                    if (!string.IsNullOrEmpty(str2))
                    {
                        if (!this.dataTbl.ContainsKey(str2))
                        {
                            this.dataTbl.Add(str2, new LanguageStrings());
                        }
                        int           count   = this.languages.Count;
                        List <string> strings = new List <string>(count);
                        for (int j = 0; j < count; j++)
                        {
                            string item = string.Empty;
                            if (dictionary.ContainsKey(j))
                            {
                                int num5 = dictionary[j];
                                if (num5 < row2.Strings.Length)
                                {
                                    item = row2.Strings[num5].Replace(@"\n", "\n");
                                }
                            }
                            strings.Add(item);
                        }
                        this.dataTbl[str2].SetData(strings);
                    }
                }
            }
        }
 protected override void OnParseGrid(StringGrid grid)
 {
     LanguageManagerBase instance = LanguageManagerBase.Instance;
     if (instance != null)
     {
         instance.OverwriteData(grid);
     }
 }
Пример #30
0
        public StringGridRow(StringGrid gird, int rowIndex)
        {
            int num = rowIndex;

            this.DebugIndex = num;
            this.rowIndex   = num;
            this.InitLink(gird);
        }
Пример #31
0
        public AdvAnimationData(StringGrid grid, ref int index, bool legacy)
        {
            this.Clip = new AnimationClip();
            this.Clip.set_legacy(legacy);
            this.ParseHeader(grid.Rows[index++]);
            List <float> timeTbl = this.ParseTimeTbl(grid.Rows[index++]);

            if (!this.Clip.get_legacy())
            {
                this.AddDummyCurve(timeTbl);
            }
            while (index < grid.Rows.Count)
            {
                StringGridRow row = grid.Rows[index];
                try
                {
                    if (row.IsEmptyOrCommantOut)
                    {
                        index++;
                    }
                    else
                    {
                        PropertyType type;
                        if (this.IsHeader(row))
                        {
                            break;
                        }
                        if (!row.TryParseCellTypeOptional <PropertyType>(0, PropertyType.Custom, out type))
                        {
                            string str2;
                            string str3;
                            row.ParseCell <string>(0).Separate('.', false, out str2, out str3);
                            Type type2 = Type.GetType(str2);
                            if (type2 == null)
                            {
                                Debug.LogError(str2 + "is not class name");
                            }
                            this.Clip.SetCurve(string.Empty, type2, str3, this.ParseCurve(timeTbl, row));
                        }
                        else if (this.IsEvent(type))
                        {
                            this.AddEvent(type, timeTbl, row);
                        }
                        else
                        {
                            this.AddCurve(type, this.ParseCurve(timeTbl, row));
                        }
                        index++;
                    }
                    continue;
                }
                catch (Exception exception)
                {
                    Debug.LogError(row.ToErrorString(exception.Message));
                    continue;
                }
            }
        }
		/// <summary>
		/// CSVにコンバートする際に、デフォルトで使用するsettings系のURLリストを追加する
		/// </summary>
		/// <param name="grid"></param>
		static void AddDefaultUrlSettingsOnCsvOnvert( StringGrid grid, int version ){

			const string format = "Settings/{0}.tsv";
			grid.AddRow(new List<string> { TagScenarioSetting, string.Format(format, AdvSettingDataManager.SheetNameScenario), ""+version });
			grid.AddRow(new List<string> { TagCharacterSetting, string.Format(format, AdvSettingDataManager.SheetNameCharacter), "" + version });
			grid.AddRow(new List<string> { TagTextureSetting, string.Format(format, AdvSettingDataManager.SheetNameTexture), "" + version });
			grid.AddRow(new List<string> { TagSoundSetting, string.Format(format, AdvSettingDataManager.SheetNameSound), "" + version });
			grid.AddRow(new List<string> { TagParamSetting, string.Format(format, AdvSettingDataManager.SheetNameParam), "" + version });
			grid.AddRow(new List<string> { TagLayerSetting, string.Format(format, AdvSettingDataManager.SheetNameLayer), "" + version });
			grid.AddRow(new List<string> { TagSceneGallerySetting, string.Format(format, AdvSettingDataManager.SheetNameSceneGallery), "" + version });
		}
		/// <summary>
		/// CSVにコンバートする際起動用のBootファイルを作成
		/// </summary>
		/// <param name="grid">エクセル側のデータ</param>
		public static StringGrid CreateOnCsvOnvert(StringGrid grid, int version)
		{
			if( grid == null )
			{
				grid = new StringGrid(AdvSettingDataManager.SheetNameBoot, CsvType.Tsv);
				grid.AddRow(new List<string> { AdvParser.Localize(AdvColumnName.Tag), AdvParser.Localize(AdvColumnName.Param1), AdvParser.Localize(AdvColumnName.Version) });
			}
			///起動用データをコンバート
			AdvBootSetting.AddDefaultUrlSettingsOnCsvOnvert(grid, version);
			return grid;
		}
		/// <summary>
		/// CSVからデータ初期化
		/// </summary>
		/// <param name="row">初期化するためのデータ</param>
		/// <returns>成否</returns>
		public void InitFromCsv(StringGrid grid, string url )
		{
			string csvDir = url.Replace(System.IO.Path.GetFileName(url), "");
			scenarioDirInfo = new DefaultDirInfo { defaultDir = @"Scenario", defaultExt = ".tsv" };

			InitDefaultDirInfo(csvDir, scenarioDirInfo);
			foreach (StringGridRow row in grid.Rows)
			{
				if (row.RowIndex < grid.DataTopRow) continue;			//データの行じゃない
				if (row.IsEmpty) continue;								//データがない
				ParseFromCsvStringGridRow(row, csvDir);
			}
		}
		/// <summary>
		/// StringGridから基本的なデータ初期化
		/// </summary>
		/// <param name="row">初期化するためのデータ</param>
		/// <returns>成否</returns>
		public void InitFromStringGrid(StringGrid grid  )
		{
			foreach (StringGridRow row in grid.Rows)
			{
				if (row.RowIndex < grid.DataTopRow) continue;			//データの行じゃない
				if (row.IsEmpty) continue;								//データがない
			}
			//今のところ何も処置なし
		}
		/// <summary>
		/// 設定データのエクセルシートを読み込む
		/// </summary>
		/// <param name="sheetName">シート名</param>
		/// <param name="grid">シートのStringGridデータ</param>
		public void ParseFromExcel(string sheetName, StringGrid grid)
		{
			importVersion = Version;
			switch (sheetName)
			{
				case SheetNameBoot:
					SettingData.InitFromStringGrid(grid);
					break;
				case SheetNameScenario:
					ScenarioSetting.InitFromStringGrid(grid);
					break;
				case SheetNameCharacter:
					CharacterSetting.InitFromStringGrid(grid);
					break;
				case SheetNameTexture:
					TextureSetting.InitFromStringGrid(grid);
					break;
				case SheetNameSound:
					SoundSetting.InitFromStringGrid(grid);
					break;
				case SheetNameLayer:
					LayerSetting.InitFromStringGrid(grid);
					break;
				case SheetNameParam:
					DefaultParam.InitFromStringGrid(grid);
					break;
				case SheetNameSceneGallery:
					SceneGallerySetting.InitFromStringGrid(grid);
					break;
				default:
					Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.NotSettingSheet, sheetName));
					break;
			}
		}
		//シナリオ設定シートを個別にコンバート
		void WriteScenarioSetting(string folderPath, int version)
		{
			scenarioSettingGrid = AdvScenarioSetting.MargeScenarioData(scenarioSettingGrid, scenarioSheetDictionary, version);
			string path = folderPath + "/Settings/" + AdvSettingDataManager.SheetNameScenario + extConvert;
			WriteFile(scenarioSettingGrid, path);
		}
		//CSVを書き込み
		void WriteFile(StringGrid grid, string path)
		{
			WriteStringGrid(grid,path);

			string relativePath = FileUtil.GetProjectRelativePath(path);
			Object assetObject = AssetDatabase.LoadAssetAtPath(relativePath, typeof(Object));
			if (assetObject!=null)
			{
				EditorUtility.SetDirty(assetObject);
			}
		}
		//ファイルの書き込み
		void WriteStringGrid(StringGrid grid, string path)
		{
			string dir = System.IO.Path.GetDirectoryName(path);
			if (!System.IO.Directory.Exists(dir))
			{
				System.IO.Directory.CreateDirectory(dir);
			}

			// ファイルにテキストを書き出し。
			using (System.IO.StreamWriter writer = new System.IO.StreamWriter(path))
			{
				char separator = grid.CsvSeparator;
				foreach (StringGridRow row in grid.Rows)
				{
					for (int i = 0; i < row.Strings.Length; ++i)
					{
						//CSVの書式にあわせる
						string line = row.Strings[i].Replace("\n", "\\n");
						writer.Write(line);
						if (i < row.Strings.Length - 1)
						{
							writer.Write(separator);
						}
					}
					writer.Write("\n");
				}
			}
		}
		//シートをCSVにコンバート
		void ConvertSheet(StringGridDictionaryKeyValue sheet, string folderPath)
		{
			string outPutPath = folderPath + "/";
			if (AdvSettingDataManager.IsBootSheet(sheet.Name))
			{
				///起動用データは個別にコンバート
				bootSettingGrid = sheet.Grid;
				return;
			}
			else if (AdvSettingDataManager.IsScenarioSettingSheet(sheet.Name))
			{
				///シナリオ設定データは個別にコンバート
				scenarioSettingGrid = sheet.Grid;
				return;
			}
			else if (AdvSettingDataManager.IsSettingsSheet(sheet.Name))
			{
				outPutPath += "Settings";
			}
			else
			{
				scenarioSheetDictionary.Add(sheet);
				outPutPath += "Scenario";
			}
			outPutPath += "/" + sheet.Key + extConvert;
			WriteFile(sheet.Grid, outPutPath);
		}
		/// <summary>
		/// エクセルからデータ解析
		/// </summary>
		/// <param name="sheetName">シート名</param>
		/// <param name="grid">エクセルの1シートから作成したStringGrid</param>
		public void ParseFromExcel(string sheetName, StringGrid grid)
		{
			dictionary.Add( sheetName, grid );
		}
/*
		/// <summary>
		/// 指定インデックスのコマンドを取得
		/// </summary>
		/// <param name="index">インデックス</param>
		/// <returns>コマンド</returns>
		public AdvCommand GetCommand(int index)
		{
			return null;
		}
		
		/// <summary>
		/// 指定シナリオラベルの指定ページのコマンドインデックスを取得
		/// </summary>
		/// <param name="scenarioLabel">シナリオラベル</param>
		/// <param name="page">ページ</param>
		/// <returns>ページのコマンドインデックス</returns>
		public int SeekPageIndex(string scenarioLabel, int page)
		{
			int index = 0;

			if (Name == scenarioLabel)
			{
				//シナリオ名そのものだった場合は一番最初から
				index = 0;
			}
			else
			{
				//シナリオラベルをシーク
				while (true)
				{
					AdvCommand command = GetCommand(index);
					if (null == GetCommand(index))
					{
						Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.NotFoundScnarioLabel,scenarioLabel));
						return 0;
					}

					if ( command.GetScenarioLabel() == scenarioLabel)
					{
						break;
					}
					++index;
				}
			}
			if (page < 0)
			{	//シナリオラベル冒頭
				return index;
			}

			int pageCount = 0;
			//シナリオラベルからの指定のページまでシーク
			while (true)
			{
				AdvCommand command = GetCommand(index);
				if (null == command)
				{
					//指定のページ数がなかったので、ここまでで終了
					return index-1;
				}
				if (command.IsTypePageEnd())
				{
					if (pageCount >= page)
					{
						return index;
					}
					++pageCount;
				}
				++index;
			}
		}
*/
		//コマンドデータの解析・初期化
		void ParseFromStringGrid(StringGrid grid, AdvSettingDataManager dataManager)
		{
			isInit = false;
			List<AdvCommand> commandList = new List<AdvCommand>();
			AdvCommand continuousCommand = null;	//連続的なコマンド処理

			foreach (StringGridRow row in grid.Rows)
			{
				if (row.RowIndex < grid.DataTopRow ) continue;			//データの行じゃない
				if (row.IsEmpty) continue;								//データがない

				AdvCommand command = AdvCommandParser.CreateCommand( row, dataManager);
				if (null != command)
				{
					//連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
					TryAddContinusCommand(continuousCommand, command, commandList, dataManager);
					//コマンド追加
					if (null != command) commandList.Add(command);
					//連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
					continuousCommand = command.IsContinusCommand ? command : null; ;
				}
			}
			//連続するコマンドの場合は、連続が途切れたら終了コマンドを追加
			TryAddContinusCommand(continuousCommand, null, commandList, dataManager);

			MakeScanerioLabelData(commandList);
			isInit = true;
		}
		/// <summary>
		/// 初期化
		/// </summary>
		/// <param name="name">シナリオ名</param>
		/// <param name="grid">シナリオデータ</param>
		/// <param name="dataManager">各種設定データ</param>
		public void Init(string name, StringGrid grid, AdvSettingDataManager dataManager)
		{
			this.name = name;
			this.dataGridName = grid.Name;
			ParseFromStringGrid(grid, dataManager);
		}
Пример #44
0
		void ParseData(TextAsset csv)
		{
			dataTbl.Clear();
			StringGrid data = new StringGrid(csv.name, CsvType.Tsv, csv.text);
			if (data.Rows.Count <= 0) return;

			foreach (StringGridRow row in data.Rows)
			{
				if (row.IsEmpty) continue;
				dataTbl.Add(row.ParseCell<string>("Key"), row);
			}

			StringGridRow header = data.Rows[0];
			for (int i = 0; i < header.Length; ++i)
			{
				if (i == 0) continue;
				if (string.IsNullOrEmpty(header.Strings[i])) continue;
				languages.Add(header.Strings[i]);
			}
		}
		/// <summary>
		/// エラーチェックのために実際にデータを作成
		/// エクスポートするときに使用。
		/// </summary>
		/// <param name="sheetName">シート名</param>
		/// <param name="grid">チェックするシナリオを記述したStringGrid</param>
		/// <param name="settingDataManger">データ管理の大本</param>
		/// <returns>シナリオデータ</returns>
		public AdvScenarioData ErrorCheck(string sheetName, StringGrid grid, AdvSettingDataManager settingDataManger)
		{
			AdvScenarioData scenario = new AdvScenarioData();
			scenario.Init( sheetName, grid, settingDataManger);
			return scenario;
		}