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(); }
/** * 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)); } }
/** * <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)); } }