/** * Displays the GUI of the class's entry within the Speech Manager. */ public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; string apiPrefix = "KickStarter.speechManager.GetLine (" + lineID + ")"; if (lineID == speechManager.activeLineID) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID #:", GUILayout.Width(85f)); EditorGUILayout.LabelField(lineID.ToString(), GUILayout.MaxWidth(570f)); if (textType == AC_TextType.Speech && GUILayout.Button("Locate source", GUILayout.MaxWidth(100))) { KickStarter.speechManager.LocateLine(this); } EditorGUILayout.EndHorizontal(); ShowField("Type:", textType.ToString(), false, apiPrefix + ".textType"); ShowField("Original text:", text, true, apiPrefix + ".text"); string sceneName = scene.Replace("Assets/", ""); sceneName = sceneName.Replace(".unity", ""); ShowField("Scene:", sceneName, true, apiPrefix + ".scene"); if (textType == AC_TextType.Speech) { ShowField("Speaker:", GetSpeakerName(), false, apiPrefix + ".owner"); } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { } else if (translationText.Count > (i - 1)) { translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { string language = ""; if (i > 0) { language = speechManager.languages[i]; } if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField(" (Lipsync path):", GetFolderName(language, true), false); } ShowField(" (Audio path):", GetFolderName(language), false); } else { if (i > 0) { SetCustomArraySizes(speechManager.languages.Count - 1); if (speechManager.UseFileBasedLipSyncing()) { customTranslationLipsyncFiles[i - 1] = EditField <Object> ("Lipsync file:", customTranslationLipsyncFiles[i - 1], apiPrefix + ".customTranslationLipsyncFiles[i-1]"); } customTranslationAudioClips[i - 1] = EditField <AudioClip> ("Audio clip:", customTranslationAudioClips[i - 1], apiPrefix + ".customTranslationAudioClips[i-1]"); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } EditorGUILayout.Space(); } } if (!speechManager.translateAudio && textType == AC_TextType.Speech) { if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } } else if (textType == AC_TextType.Speech) { //ShowField ("Text:", "'" + text + "'", true); if (KickStarter.speechManager.autoNameSpeechFiles) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path:", GetFolderName("", true), false); } ShowField("Audio Path:", GetFolderName(""), false); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } if (textType == AC_TextType.Speech) { if (speechManager.autoNameSpeechFiles) { ShowField("Filename:", GetFilename() + lineID.ToString(), false); } description = EditField("Description:", description, true, apiPrefix + ".description"); if (tagID >= 0 && KickStarter.speechManager.useSpeechTags) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { ShowField("Tag: ", speechTag.label, false, apiPrefix + ".tagID"); } } } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + text + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLineID = lineID; EditorGUIUtility.editingTextField = false; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
private void OnGUI() { if (AdvGame.GetReferences().speechManager == null) { EditorGUILayout.HelpBox("A Settings Manager must be assigned before this window can display correctly.", MessageType.Warning); return; } SpeechManager speechManager = AdvGame.GetReferences().speechManager; EditorGUILayout.HelpBox("Assign any labels you want to be able to tag 'Dialogue: Play speech' Actions as here.", MessageType.Info); EditorGUILayout.Space(); speechManager.useSpeechTags = EditorGUILayout.Toggle("Use speech tags?", speechManager.useSpeechTags); if (speechManager.useSpeechTags) { CustomGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(205f)); if (speechManager.speechTags.Count == 0) { speechManager.speechTags.Add(new SpeechTag("(Untagged)")); } for (int i = 0; i < speechManager.speechTags.Count; i++) { CustomGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); if (i == 0) { EditorGUILayout.TextField("Tag " + speechManager.speechTags[i].ID.ToString() + ": " + speechManager.speechTags[0].label, EditorStyles.boldLabel); } else { SpeechTag speechTag = speechManager.speechTags[i]; speechTag.label = EditorGUILayout.TextField("Tag " + speechManager.speechTags[i].ID.ToString() + ":", speechTag.label); speechManager.speechTags[i] = speechTag; if (GUILayout.Button("-", GUILayout.MaxWidth(20f))) { Undo.RecordObject(speechManager, "Delete tag"); speechManager.speechTags.RemoveAt(i); i = 0; return; } } EditorGUILayout.EndHorizontal(); CustomGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); CustomGUILayout.EndVertical(); if (GUILayout.Button("Add new tag")) { Undo.RecordObject(speechManager, "Delete tag"); speechManager.speechTags.Add(new SpeechTag(GetIDArray(speechManager.speechTags.ToArray()))); } } if (GUI.changed) { EditorUtility.SetDirty(speechManager); } }
private void CreateScript() { #if UNITY_WEBPLAYER ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again."); #else if (AdvGame.GetReferences() == null || AdvGame.GetReferences().speechManager == null) { ACDebug.LogError("Cannot create script sheet - no Speech Manager is assigned!"); return; } SpeechManager speechManager = AdvGame.GetReferences().speechManager; languageIndex = Mathf.Max(languageIndex, 0); string suggestedFilename = "Adventure Creator"; if (AdvGame.GetReferences().settingsManager) { suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName; } if (limitToCharacter && characterName != "") { suggestedFilename += " (" + characterName + ")"; } if (limitToTag && tagID >= 0) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { suggestedFilename += " (" + speechTag.label + ")"; } } suggestedFilename += " - "; if (languageIndex > 0) { suggestedFilename += speechManager.languages[languageIndex] + " "; } suggestedFilename += "script.html"; string fileName = EditorUtility.SaveFilePanel("Save script file", "Assets", suggestedFilename, "html"); if (fileName.Length == 0) { return; } string gameName = "Adventure Creator"; if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.saveFileName.Length > 0) { gameName = AdvGame.GetReferences().settingsManager.saveFileName; if (languageIndex > 0) { gameName += " (" + speechManager.languages[languageIndex] + ")"; } } System.Text.StringBuilder script = new System.Text.StringBuilder(); script.Append("<html>\n<head>\n"); script.Append("<meta http-equiv='Content-Type' content='text/html;charset=ISO-8859-1' charset='UTF-8'>\n"); script.Append("<title>" + gameName + "</title>\n"); script.Append("<style> body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; } footer { text-align: center; padding-top: 20px; font-size: 12px;} footer a { color: blue; text-decoration: none} </style>\n</head>\n"); script.Append("<body>\n"); script.Append("<h1>" + gameName + " - script sheet"); if (limitToCharacter && characterName != "") { script.Append(" (" + characterName + ")"); } script.Append("</h1>\n"); script.Append("<h2>Created: " + DateTime.UtcNow.ToString("HH:mm dd MMMM, yyyy") + "</h2>\n"); // By scene foreach (string sceneFile in speechManager.sceneFiles) { List <SpeechLine> sceneSpeechLines = new List <SpeechLine>(); int slashPoint = sceneFile.LastIndexOf("/") + 1; string sceneName = sceneFile.Substring(slashPoint); foreach (SpeechLine line in speechManager.lines) { if (line.textType == AC_TextType.Speech && (line.scene == sceneFile || sceneName == (line.scene + ".unity")) && (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) && (!limitToTag || line.tagID == tagID)) { if (!speechManager.autoNameSpeechFiles && limitToMissingAudio) { if (languageIndex == 0 && line.customAudioClip != null) { continue; } if (speechManager.translateAudio && languageIndex > 0 && line.customTranslationAudioClips.Count > (languageIndex - 1) && line.customTranslationAudioClips[languageIndex - 1] != null) { continue; } if (!speechManager.translateAudio && line.customAudioClip != null) { continue; } } sceneSpeechLines.Add(line); } } if (sceneSpeechLines != null && sceneSpeechLines.Count > 0) { sceneSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); }); script.Append("<hr/>\n<h3><b>Scene:</b> " + sceneName + "</h3>\n"); foreach (SpeechLine sceneSpeechLine in sceneSpeechLines) { script.Append(sceneSpeechLine.Print(languageIndex, includeDescriptions, removeTokens)); } } } // No scene List <SpeechLine> assetSpeechLines = new List <SpeechLine>(); foreach (SpeechLine line in speechManager.lines) { if (line.scene == "" && line.textType == AC_TextType.Speech && (!limitToCharacter || characterName == "" || line.owner == characterName || (line.isPlayer && characterName == "Player")) && (!limitToTag || line.tagID == tagID)) { assetSpeechLines.Add(line); } } if (assetSpeechLines != null && assetSpeechLines.Count > 0) { assetSpeechLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.OrderIdentifier.CompareTo(b.OrderIdentifier)); }); script.Append("<hr/>\n<h3>Scene-independent lines:</h3>\n"); foreach (SpeechLine assetSpeechLine in assetSpeechLines) { script.Append(assetSpeechLine.Print(languageIndex, includeDescriptions, removeTokens)); } } script.Append("<footer>Generated by <a href='http://adventurecreator.org' target=blank>Adventure Creator</a>, by Chris Burton</footer>\n"); script.Append("</body>\n</html>"); Serializer.SaveFile(fileName, script.ToString()); #endif this.Close(); }
/** * <summary>Displays the GUI of the class's entry within the Speech Manager.</summary> */ public void ShowGUI() { SpeechManager speechManager = AdvGame.GetReferences().speechManager; string apiPrefix = "KickStarter.speechManager.GetLine (" + lineID + ")"; if (lineID == speechManager.activeLineID) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ID #:", GUILayout.Width(85f)); EditorGUILayout.LabelField(lineID.ToString(), GUILayout.MaxWidth(570f)); if ((textType == AC_TextType.Speech || textType == AC_TextType.DialogueOption) && GUILayout.Button("Locate source", GUILayout.MaxWidth(100))) { KickStarter.speechManager.LocateLine(this); } EditorGUILayout.EndHorizontal(); ShowField("Type:", textType.ToString(), false, apiPrefix + ".textType"); ShowField("Original text:", text, true, apiPrefix + ".text"); string sceneName = scene.Replace("Assets/", string.Empty); sceneName = sceneName.Replace(".unity", string.Empty); ShowField("Scene:", sceneName, true, apiPrefix + ".scene"); if (textType == AC_TextType.Speech) { ShowField("Speaker:", GetSpeakerName(), false, apiPrefix + ".owner"); } if (speechManager.languages != null && speechManager.languages.Count > 1) { for (int i = 0; i < speechManager.languages.Count; i++) { if (i == 0) { if (speechManager.languages.Count > 1 && speechManager.translateAudio && !speechManager.ignoreOriginalText && textType == AC_TextType.Speech) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Original language:"); } } else if (translationText.Count > (i - 1)) { translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true); } else { ShowField(speechManager.languages[i] + ":", "(Not defined)", false); } if (speechManager.translateAudio && textType == AC_TextType.Speech) { string language = string.Empty; if (i > 0) { language = speechManager.languages[i]; } else if (speechManager.ignoreOriginalText && speechManager.languages.Count > 1) { continue; } if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders) { for (int j = 0; j < KickStarter.settingsManager.players.Count; j++) { if (KickStarter.settingsManager.players[j].playerOb) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path " + j.ToString() + ":", GetFolderName(language, true, KickStarter.settingsManager.players[j].playerOb.name), false); } ShowField("Audio Path " + j.ToString() + ":", GetFolderName(language, false, KickStarter.settingsManager.players[j].playerOb.name), false); } } } else { if (speechManager.useAssetBundles) { if (speechManager.UseFileBasedLipSyncing()) { if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[i])) { ShowField(" (Lipsync AB):", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[i], false); } } if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[i])) { ShowField(" (Audio AB):", "StreamingAssets/" + speechManager.languageAudioAssetBundles[i], false); } } else { if (speechManager.UseFileBasedLipSyncing()) { EditorGUILayout.BeginHorizontal(); ShowField(" (Lipsync path):", GetFolderName(language, true), false); ShowLocateButton(i, true); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); ShowField(" (Audio path):", GetFolderName(language), false); ShowLocateButton(i); EditorGUILayout.EndHorizontal(); } } } else { if (i > 0) { SetCustomArraySizes(speechManager.languages.Count - 1); if (speechManager.UseFileBasedLipSyncing()) { customTranslationLipsyncFiles[i - 1] = EditField <Object> ("Lipsync file:", customTranslationLipsyncFiles[i - 1], apiPrefix + ".customTranslationLipsyncFiles[i-1]"); } customTranslationAudioClips[i - 1] = EditField <AudioClip> ("Audio clip:", customTranslationAudioClips[i - 1], apiPrefix + ".customTranslationAudioClips[i-1]"); } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } EditorGUILayout.Space(); } } } // Original language if (textType == AC_TextType.Speech) { if (speechManager.languages == null || speechManager.languages.Count <= 1 || !speechManager.translateAudio) { if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders) { for (int i = 0; i < KickStarter.settingsManager.players.Count; i++) { if (KickStarter.settingsManager.players[i].playerOb) { if (speechManager.UseFileBasedLipSyncing()) { ShowField("Lipsync path " + i.ToString() + ":", GetFolderName(string.Empty, true, KickStarter.settingsManager.players[i].playerOb.name), false); } ShowField("Audio Path " + i.ToString() + ":", GetFolderName(string.Empty, false, KickStarter.settingsManager.players[i].playerOb.name), false); } } } else { if (speechManager.useAssetBundles) { if (speechManager.UseFileBasedLipSyncing()) { if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[0])) { ShowField("Lipsync AB:", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[0], false); } } if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[0])) { ShowField("Audio AB:", "StreamingAssets/" + speechManager.languageAudioAssetBundles[0], false); } } else { if (speechManager.UseFileBasedLipSyncing()) { EditorGUILayout.BeginHorizontal(); ShowField("Lipsync path:", GetFolderName(string.Empty, true), false); ShowLocateButton(0, true); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); ShowField("Audio Path:", GetFolderName(string.Empty), false); ShowLocateButton(0); EditorGUILayout.EndHorizontal(); } } } else { if (speechManager.UseFileBasedLipSyncing()) { customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile"); } customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip"); } } if (speechManager.autoNameSpeechFiles) { if (SeparatePlayerAudio()) { for (int i = 0; i < KickStarter.settingsManager.players.Count; i++) { if (KickStarter.settingsManager.players[i].playerOb) { ShowField("Filename " + i.ToString() + ":", GetFilename(KickStarter.settingsManager.players[i].playerOb.name) + lineID.ToString(), false); } } } else { ShowField("Filename:", GetFilename() + lineID.ToString(), false); } } if (tagID >= 0 && speechManager.useSpeechTags) { SpeechTag speechTag = speechManager.GetSpeechTag(tagID); if (speechTag != null && speechTag.label.Length > 0) { ShowField("Tag: ", speechTag.label, false, apiPrefix + ".tagID"); } } } if (SupportsDescriptions()) { description = EditField("Description:", description, true, apiPrefix + ".description"); } EditorGUILayout.EndVertical(); } else { if (GUILayout.Button(lineID.ToString() + ": '" + GetShortText() + "'", EditorStyles.label, GUILayout.MaxWidth(300))) { speechManager.activeLineID = lineID; EditorGUIUtility.editingTextField = false; } GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1)); } }
public string GetCellText(SpeechLine speechLine) { string cellText = " "; if (columnType == ColumnType.DisplayText) { if (language > 0) { int translation = language - 1; if (speechLine.translationText != null && speechLine.translationText.Count > translation) { cellText = speechLine.translationText[translation]; } } else { cellText = speechLine.text; } } else if (columnType == ColumnType.Type) { cellText = speechLine.textType.ToString(); } else if (columnType == ColumnType.AssociatedObject) { if (speechLine.isPlayer && speechLine.owner == "" && speechLine.textType == AC_TextType.Speech) { cellText = "Player"; } else { cellText = speechLine.owner; } } else if (columnType == ColumnType.Scene) { cellText = speechLine.scene; } else if (columnType == ColumnType.Description) { cellText = speechLine.description; } else if (columnType == ColumnType.TagID) { cellText = speechLine.tagID.ToString(); } else if (columnType == ColumnType.TagName) { SpeechTag speechTag = KickStarter.speechManager.GetSpeechTag(speechLine.tagID); cellText = (speechTag != null) ? speechTag.label : ""; } else if (columnType == ColumnType.SpeechOrder) { cellText = speechLine.OrderIdentifier; if (cellText == "-0001") { cellText = ""; } } if (cellText == "") { cellText = " "; } return(RemoveLineBreaks(cellText)); }
public string GetCellText(SpeechLine speechLine) { string cellText = " "; switch (columnType) { case ColumnType.DisplayText: if (language > 0) { int translation = language - 1; if (speechLine.translationText != null && speechLine.translationText.Count > translation) { cellText = speechLine.translationText[translation]; } } else { cellText = speechLine.text; } break; case ColumnType.Type: cellText = speechLine.textType.ToString(); break; case ColumnType.AssociatedObject: if (speechLine.isPlayer && string.IsNullOrEmpty(speechLine.owner) && speechLine.textType == AC_TextType.Speech) { cellText = "Player"; } else { cellText = speechLine.owner; } break; case ColumnType.Scene: cellText = speechLine.scene; break; case ColumnType.Description: cellText = speechLine.description; break; case ColumnType.TagID: cellText = speechLine.tagID.ToString(); break; case ColumnType.TagName: SpeechTag speechTag = KickStarter.speechManager.GetSpeechTag(speechLine.tagID); cellText = (speechTag != null) ? speechTag.label : ""; break; case ColumnType.SpeechOrder: cellText = speechLine.OrderIdentifier; if (cellText == "-0001") { cellText = string.Empty; } break; case ColumnType.AudioFilePresence: if (speechLine.textType == AC_TextType.Speech) { bool hasAllAudio = speechLine.HasAllAudio(); if (hasAllAudio) { cellText = "Has all audio"; } else { if (speechLine.HasAudio(0)) { string missingLabel = "Missing "; for (int i = 1; i < KickStarter.speechManager.languages.Count; i++) { if (!speechLine.HasAudio(i)) { missingLabel += KickStarter.speechManager.languages[i] + ", "; } } if (missingLabel.EndsWith(", ")) { missingLabel = missingLabel.Substring(0, missingLabel.Length - 2); } cellText = missingLabel; } else { cellText = "Missing main audio"; } } } break; } if (string.IsNullOrEmpty(cellText)) { cellText = " "; } return(RemoveLineBreaks(cellText)); }