//----- field ----- //----- property ----- //----- method ----- public static void Generate(string scriptPath, string rootFolderPath) { var infos = LoadUsmInfo(rootFolderPath); var enums = new StringBuilder(); var contents = new StringBuilder(); for (var i = 0; i < infos.Length; i++) { var info = infos[i]; var assetPath = info.Usm.Replace(rootFolderPath + PathUtility.PathSeparator, string.Empty); var enumName = ScriptGenerateUtility.GetCSharpName(PathUtility.GetPathWithoutExtension(assetPath), false); enums.Append("\t\t\t").AppendFormat(EnumTemplate, enumName); contents.Append("\t\t\t").AppendFormat(ContentsTemplate, enumName, info.UsmPath); if (i < infos.Length - 1) { enums.AppendLine(); contents.AppendLine(); } } var script = ScriptTemplate; script = Regex.Replace(script, "@ENUMS", enums.ToString()); script = Regex.Replace(script, "@CONTENTS", contents.ToString()); var folderPath = PathUtility.Combine(scriptPath, @"Constants"); ScriptGenerateUtility.GenerateScript(folderPath, @"Movies.cs", script); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(SheetData[] sheets, string scriptFolderPath) { var categorys = new StringBuilder(); var getMethods = new StringBuilder(); for (var i = 0; i < sheets.Length; i++) { var sheet = sheets[i]; categorys.Append("\t\t\t\t").AppendFormat(CategoryDefinitionTemplate, sheet.sheetName, sheet.guid); getMethods.Append("\t\t").AppendFormat(GetMethodTemplate, sheet.sheetName); // 最終行は改行しない. if (i < sheets.Length - 1) { categorys.AppendLine(); getMethods.AppendLine().AppendLine(); } } var script = TextDataScriptTemplate; script = Regex.Replace(script, "#CATEGORY_DEFINITION_ITEMS#", categorys.ToString()); script = Regex.Replace(script, "#GETTEXT_METHODS#", getMethods.ToString()); script = script.FixLineEnd(); ScriptGenerateUtility.GenerateScript(scriptFolderPath, TextDataScriptFileName, script); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(SheetData[] sheets, string scriptFolderPath) { var enums = new StringBuilder(); var contents = new StringBuilder(); for (var i = 0; i < sheets.Length; ++i) { var sheet = sheets[i]; enums.Append("\t\t").AppendFormat(EnumContentsTemplate, sheet.sheetName); contents.Append("\t\t\t").AppendFormat(TableElementTemplate, sheet.sheetName, sheet.guid); // 最終行は改行しない. if (i < sheets.Length - 1) { enums.AppendLine(); enums.AppendLine(); contents.AppendLine(); } } var script = CategoryScriptTemplate; script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = Regex.Replace(script, "#ELEMENTS#", contents.ToString()); script = script.FixLineEnd(); ScriptGenerateUtility.GenerateScript(scriptFolderPath, CategoryScriptFileName, script); }
private static string GetSheetEnumName(SheetEntity spreadsheet, GameTextConfig config) { var sheetDefinitionRow = config.SheetDefinitionRow.GetValueOrDefault(); var sheetNameColumn = config.SheetNameColumn.GetValueOrDefault(); var sheetEnumName = spreadsheet.GetValue(sheetNameColumn, sheetDefinitionRow); var enumName = ScriptGenerateUtility.RemoveInvalidChars(sheetEnumName); return(enumName); }
private static void GenerateCategoryFile(SheetEntity[] spreadsheets, GameTextConfig config) { var exportPath = config.TableScriptFolderPath; var sheetDefinitionRow = config.SheetDefinitionRow.GetValueOrDefault(); var sheetIdColumn = config.SheetIdColumn.GetValueOrDefault(); var ignoreSheets = config.IgnoreSheets; var enums = new StringBuilder(); var contents = new StringBuilder(); var targetSheets = spreadsheets.Where(x => !ignoreSheets.Contains(x.Title)).ToArray(); for (var i = 0; i < targetSheets.Length; ++i) { var spreadsheet = targetSheets[i]; var enumName = GetSheetEnumName(spreadsheet, config); var sheetId = spreadsheet.GetValue(sheetIdColumn, sheetDefinitionRow); enums.Append("\t\t").AppendFormat(CategoryLabelTemplate, spreadsheet.Title).AppendLine(); enums.Append("\t\t").AppendFormat(EnumContentsTemplate, enumName, sheetId); contents.Append("\t\t\t").AppendFormat(SheetIdTableContentsTemplate, enumName, enumName); // 最終行は改行しない. if (i < targetSheets.Length - 1) { enums.AppendLine(); enums.AppendLine(); contents.AppendLine(); } } var script = SheetIdTableScriptTemplate; script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = Regex.Replace(script, "#TABLES#", contents.ToString()); script = script.FixLineEnd(); ScriptGenerateUtility.GenerateScript(exportPath, SheetIdTableScriptFileName, script); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(string scriptPath, string assetFolderPath, string rootFolderName) { var projectFolders = ProjectFolders.Instance; var infos = LoadAcbInfo(assetFolderPath); var enums = new StringBuilder(); var contents = new StringBuilder(); for (var i = 0; i < infos.Length; i++) { var info = infos[i]; if (!string.IsNullOrEmpty(info.Summary)) { enums.Append("\t\t\t").AppendFormat(SummaryTemplate, info.Summary).AppendLine(); } var assetPath = info.CueSheet.Replace(assetFolderPath + PathUtility.PathSeparator, string.Empty); var enumName = ScriptGenerateUtility.GetCSharpName(assetPath) + "_" + ScriptGenerateUtility.GetCSharpName(info.Cue, false); var cueSheetPath = PathUtility.Combine(rootFolderName, info.CueSheet); enums.Append("\t\t\t").AppendFormat(EnumTemplate, enumName); contents.Append("\t\t\t").AppendFormat(ContentsTemplate, enumName, cueSheetPath, info.Cue, info.Summary); if (i < infos.Length - 1) { enums.AppendLine(); contents.AppendLine(); } } var editorStreamingAssetsFolderPath = projectFolders.StreamingAssetPath; var script = ScriptTemplate; script = Regex.Replace(script, "@ENUMS", enums.ToString()); script = Regex.Replace(script, "@CONTENTS", contents.ToString()); script = Regex.Replace(script, "@EDITOR_STREAMING_ASSETS_FOLDER_PATH", @"""" + editorStreamingAssetsFolderPath + @""""); ScriptGenerateUtility.GenerateScript(scriptPath, @"Sounds.cs", script); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(string scriptPath, string rootFolderPath) { var projectFolders = ProjectFolders.Instance; var infos = LoadUsmInfo(rootFolderPath); var enums = new StringBuilder(); var contents = new StringBuilder(); for (var i = 0; i < infos.Length; i++) { var info = infos[i]; var assetPath = info.Usm.Replace(rootFolderPath + PathUtility.PathSeparator, string.Empty); var enumName = ScriptGenerateUtility.GetCSharpName(PathUtility.GetPathWithoutExtension(assetPath), false); enums.Append("\t\t\t").AppendFormat(EnumTemplate, enumName); contents.Append("\t\t\t").AppendFormat(ContentsTemplate, enumName, info.UsmPath); if (i < infos.Length - 1) { enums.AppendLine(); contents.AppendLine(); } } var editorStreamingAssetsFolderPath = projectFolders.StreamingAssetPath; var script = ScriptTemplate; script = Regex.Replace(script, "@ENUMS", enums.ToString()); script = Regex.Replace(script, "@CONTENTS", contents.ToString()); script = Regex.Replace(script, "@EDITOR_STREAMING_ASSETS_FOLDER_PATH", @"""" + editorStreamingAssetsFolderPath + @""""); ScriptGenerateUtility.GenerateScript(scriptPath, @"Movies.cs", script); }
private static string[] GenerateEnumFiles(SheetEntity[] spreadsheets, GameTextConfig config, int textColumn) { var exportPath = config.EnumScriptFolderPath; var startRow = config.DefinitionStartRow.GetValueOrDefault(); var idColumn = config.IdColumn.GetValueOrDefault(); var enumColumn = config.EnumColumn.GetValueOrDefault(); var ignoreSheets = config.IgnoreSheets; var generatedScripts = new List <string>(); var targetSheets = spreadsheets.Where(x => !ignoreSheets.Contains(x.Title)).ToArray(); foreach (var spreadsheet in targetSheets) { var enums = new StringBuilder(); for (var i = startRow; i < spreadsheet.Rows.Length; ++i) { var idValue = 0; var id = spreadsheet.GetValue(idColumn, i); var name = ScriptGenerateUtility.RemoveInvalidChars(spreadsheet.GetValue(enumColumn, i)); // 空文字、数値に変換出来ない値の場合はEnumを追加しない. if (string.IsNullOrEmpty(name) || !int.TryParse(id, out idValue)) { continue; } var text = spreadsheet.GetValue(textColumn, i); var summary = string.Format(SummaryTemplate, string.IsNullOrEmpty(text) ? string.Empty : text.Replace("\r\n", "").Replace("\n", "")); enums.Append("\t\t\t").AppendLine(summary); enums.Append("\t\t\t").AppendFormat(EnumContentsTemplate, name, idValue); // 最終行は改行しない. if (i < spreadsheet.Rows.Length - 1) { enums.AppendLine(); enums.AppendLine(); } } var enumName = GetSheetEnumName(spreadsheet, config); var script = EnumScriptTemplate; script = Regex.Replace(script, "#ENUMNAME#", enumName); script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = script.FixLineEnd(); var fileName = string.Format(@"{0}.cs", enumName); if (ScriptGenerateUtility.GenerateScript(exportPath, fileName, script)) { generatedScripts.Add(fileName); } } return(generatedScripts.ToArray()); }
//----- field ----- //----- property ----- //----- method ----- public static void Generate(SheetData[] sheets, string scriptFolderPath, int textIndex) { var generatedScripts = new List <string>(); foreach (var sheet in sheets) { var enums = new StringBuilder(); var elements = new StringBuilder(); var sheetRecords = sheet.records; for (var i = 0; i < sheetRecords.Length; ++i) { var record = sheetRecords[i]; var enumName = ScriptGenerateUtility.RemoveInvalidChars(record.enumName); if (string.IsNullOrEmpty(enumName)) { continue; } var text = record.texts.ElementAtOrDefault(textIndex); var summary = string.Format(SummaryTemplate, string.IsNullOrEmpty(text) ? string.Empty : text.Replace("\r\n", "").Replace("\n", "")); enums.Append("\t\t\t").AppendLine(summary); enums.Append("\t\t\t").AppendFormat(EnumElementTemplate, record.enumName); elements.Append("\t\t\t").AppendFormat(TableElementTemplate, sheet.sheetName, record.enumName, record.guid); // 最終行は改行しない. if (i < sheetRecords.Length - 1) { enums.AppendLine(); enums.AppendLine(); elements.AppendLine(); } } var script = ContentsScriptTemplate; script = Regex.Replace(script, "#SUMMARY#", string.Format(SummaryTemplate, sheet.displayName)); script = Regex.Replace(script, "#ENUMNAME#", ScriptGenerateUtility.RemoveInvalidChars(sheet.sheetName)); script = Regex.Replace(script, "#ENUMS#", enums.ToString()); script = Regex.Replace(script, "#ELEMENTS#", elements.ToString()); script = script.FixLineEnd(); var fileName = string.Format(@"{0}.cs", sheet.sheetName); if (ScriptGenerateUtility.GenerateScript(scriptFolderPath, fileName, script)) { generatedScripts.Add(fileName); } } // 定義が消えたファイルを削除. DeleteUnusedFiles(generatedScripts.ToArray(), scriptFolderPath); }