public static string GetUIFormattedText(FormattedText formattedText) { if (formattedText == null) { return string.Empty; } else if (formattedText.italic) { return "<i>" + formattedText.text + "</i>"; } else { return formattedText.text; } }
/// <summary> /// Initializes a new Subtitle. /// </summary> /// <param name="speakerInfo">Speaker info.</param> /// <param name="listenerInfo">Listener info.</param> /// <param name="formattedText">Formatted text.</param> /// <param name="sequence">Sequence.</param> /// <param name="responseMenuSequence">Response menu sequence.</param> /// <param name="dialogueEntry">Dialogue entry.</param> public Subtitle(CharacterInfo speakerInfo, CharacterInfo listenerInfo, FormattedText formattedText, string sequence, string responseMenuSequence, DialogueEntry dialogueEntry) { this.speakerInfo = speakerInfo; this.listenerInfo = listenerInfo; this.formattedText = formattedText; this.sequence = sequence; this.responseMenuSequence = responseMenuSequence; this.dialogueEntry = dialogueEntry; this.entrytag = null; CheckVariableInputPrompt(); }
/// <summary> /// Initializes a new Response. /// </summary> /// <param name='formattedText'> /// Formatted text. /// </param> /// <param name='destinationEntry'> /// Destination entry. /// </param> public Response(FormattedText formattedText, DialogueEntry destinationEntry, bool enabled = true) { this.formattedText = formattedText; this.destinationEntry = destinationEntry; this.enabled = enabled; }
/// <summary> /// Sets the button's text using the specified formatted text. /// </summary> /// <param name='formattedText'> /// The formatted text for the button label. /// </param> public void SetFormattedText(FormattedText formattedText) { if (formattedText != null) { Text = formattedText.text; SetColor((formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : defaultColor); } }
/// <summary> /// Sets a label with formatted text. /// </summary> /// <param name='label'> /// Label to set. /// </param> /// <param name='formattedText'> /// Formatted text. /// </param> private void SetFormattedText(UnityEngine.UI.Text label, FormattedText formattedText) { if (label != null) { if (formattedText != null) { label.text = UITools.GetUIFormattedText(formattedText); if (!haveSavedOriginalColor) { originalColor = label.color; haveSavedOriginalColor = true; } label.color = (formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : originalColor; } else { label.text = string.Empty; } } }
/// <summary> /// Sets the button's text using the specified formatted text. /// </summary> /// <param name='formattedText'> /// The formatted text for the button label. /// </param> public void SetFormattedText(FormattedText formattedText) { if (formattedText != null) { Text = UITools.GetUIFormattedText(formattedText); SetColor((formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : defaultColor); } }
protected virtual void SetFormattedText(UITextField textField, string previousText, FormattedText formattedText) { textField.text = previousText + UITools.GetUIFormattedText(formattedText); UITools.SendTextChangeMessage(textField); if (!haveSavedOriginalColor) { originalColor = textField.color; haveSavedOriginalColor = true; } textField.color = (formattedText.emphases != null && formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : originalColor; }
/// <summary> /// Sets a label with formatted text. /// </summary> /// <param name='label'> /// Label to set. /// </param> /// <param name='formattedText'> /// Formatted text. /// </param> private void SetFormattedText(Text label, FormattedText formattedText) { if (label != null) { if (formattedText != null) { label.text = formattedText.text; if (!haveSavedOriginalColor) { originalColor = label.color; haveSavedOriginalColor = true; } label.color = (formattedText.emphases.Length > 0) ? formattedText.emphases[0].color : originalColor; } else { label.text = string.Empty; } } }
private void EvaluateLinksAtPriority(ConditionPriority priority, DialogueEntry entry, List <Response> npcResponses, List <Response> pcResponses, List <DialogueEntry> visited, bool stopAtFirstValid = false) { if (entry != null) { for (int ol = 0; ol < entry.outgoingLinks.Count; ol++) { var link = entry.outgoingLinks[ol]; DialogueEntry destinationEntry = m_database.GetDialogueEntry(link); if ((destinationEntry != null) && (/*(destinationEntry.conditionPriority == priority) ||*/ (link.priority == priority))) // Note: Only observe link priority. Why does Chat Mapper even have conditionPriority? { CharacterType characterType = m_database.GetCharacterType(destinationEntry.ActorID); Lua.Run("thisID = " + destinationEntry.id); bool isValid = Lua.IsTrue(destinationEntry.conditionsString, DialogueDebug.logInfo, m_allowLuaExceptions) && ((isDialogueEntryValid == null) || isDialogueEntryValid(destinationEntry)); if (isValid || (m_includeInvalidEntries && (characterType == CharacterType.PC))) { // Condition is true (or blank), so add this link: if (destinationEntry.isGroup) { // For groups, evaluate their links (after running the group node's Lua code and OnExecute() event): if (DialogueDebug.logInfo) { Debug.Log(string.Format("{0}: Add Group ({1}): ID={2}:{3} '{4}' ({5})", new System.Object[] { DialogueDebug.Prefix, GetActorName(m_database.GetActor(destinationEntry.ActorID)), link.destinationConversationID, link.destinationDialogueID, destinationEntry.Title, isValid })); } Lua.Run(destinationEntry.userScript, DialogueDebug.logInfo, m_allowLuaExceptions); destinationEntry.onExecute.Invoke(); for (int i = (int)ConditionPriority.High; i >= 0; i--) { int originalResponseCount = npcResponses.Count + pcResponses.Count;; EvaluateLinksAtPriority((ConditionPriority)i, destinationEntry, npcResponses, pcResponses, visited); if ((npcResponses.Count + pcResponses.Count) > originalResponseCount) { break; } } } else { // For regular entries, just add them: if (DialogueDebug.logInfo) { Debug.Log(string.Format("{0}: Add Link ({1}): ID={2}:{3} '{4}' ({5})", new System.Object[] { DialogueDebug.Prefix, GetActorName(m_database.GetActor(destinationEntry.ActorID)), link.destinationConversationID, link.destinationDialogueID, GetLinkText(characterType, destinationEntry), isValid })); } if (characterType == CharacterType.NPC) { // Add NPC response: npcResponses.Add(new Response(FormattedText.Parse(destinationEntry.subtitleText, m_database.emphasisSettings), destinationEntry, isValid)); } else { // Add PC response, wrapping old responses in em tags if specified: string text = destinationEntry.responseButtonText; if (m_emTagForOldResponses != EmTag.None) { string simStatus = Lua.Run(string.Format("return Conversation[{0}].Dialog[{1}].SimStatus", new System.Object[] { destinationEntry.conversationID, destinationEntry.id })).asString; bool isOldResponse = string.Equals(simStatus, DialogueLua.WasDisplayed); if (isOldResponse) { text = string.Format("[em{0}]{1}[/em{0}]", (int)m_emTagForOldResponses, text); } } if (m_emTagForInvalidResponses != EmTag.None) { if (!isValid) { text = string.Format("[em{0}]{1}[/em{0}]", (int)m_emTagForInvalidResponses, text); } } var formattedText = FormattedText.Parse(text, m_database.emphasisSettings); if (!isValid) { formattedText.forceAuto = false; formattedText.forceMenu = false; } pcResponses.Add(new Response(formattedText, destinationEntry, isValid)); DialogueLua.MarkDialogueEntryOffered(destinationEntry); } } if (stopAtFirstValid) { return; } } else { // Condition is false, so block or pass through according to destination entry's setting: if (LinkUtility.IsPassthroughOnFalse(destinationEntry)) { if (DialogueDebug.logInfo) { Debug.Log(string.Format("{0}: Passthrough on False Link ({1}): ID={2}:{3} '{4}' Condition='{5}'", new System.Object[] { DialogueDebug.Prefix, GetActorName(m_database.GetActor(destinationEntry.ActorID)), link.destinationConversationID, link.destinationDialogueID, GetLinkText(characterType, destinationEntry), destinationEntry.conditionsString })); } List <Response> linkNpcResponses = new List <Response>(); List <Response> linkPcResponses = new List <Response>(); EvaluateLinks(destinationEntry, linkNpcResponses, linkPcResponses, visited); npcResponses.AddRange(linkNpcResponses); pcResponses.AddRange(linkPcResponses); } else { if (DialogueDebug.logInfo) { Debug.Log(string.Format("{0}: Block on False Link ({1}): ID={2}:{3} '{4}' Condition='{5}'", new System.Object[] { DialogueDebug.Prefix, GetActorName(m_database.GetActor(destinationEntry.ActorID)), link.destinationConversationID, link.destinationDialogueID, GetLinkText(characterType, destinationEntry), destinationEntry.conditionsString })); } } } } } } }
/// <summary> /// Initializes a new Response. /// </summary> /// <param name='formattedText'> /// Formatted text. /// </param> /// <param name='destinationEntry'> /// Destination entry. /// </param> public Response(FormattedText formattedText, DialogueEntry destinationEntry, bool enabled = true) { this.formattedText = formattedText; this.destinationEntry = destinationEntry; this.enabled = enabled; }
/// <summary> /// Sets the alert message UI Text. /// </summary> /// <param name='message'>Alert message.</param> /// <param name='duration'>Duration to show message.</param> public override void SetMessage(string message, float duration) { alertText.text = FormattedText.Parse(message).text; }
public QuestInfo(string title, FormattedText heading, FormattedText description, FormattedText[] entries, QuestState[] entryStates, bool trackable, bool track, bool abandonable) { this.Title = title; this.Heading = heading; this.Description = description; this.Entries = entries; this.EntryStates = entryStates; this.Trackable = trackable; this.Track = track; this.Abandonable = abandonable; }
private void ShowQuests(QuestState questStateMask) { currentQuestStateMask = questStateMask; NoQuestsMessage = GetNoQuestsMessage(questStateMask); List<QuestInfo> questList = new List<QuestInfo>(); string[] titles = QuestLog.GetAllQuests(questStateMask); foreach (var title in titles) { FormattedText description = FormattedText.Parse(QuestLog.GetQuestDescription(title), DialogueManager.MasterDatabase.emphasisSettings); FormattedText localizedTitle = FormattedText.Parse(QuestLog.GetQuestTitle(title), DialogueManager.MasterDatabase.emphasisSettings); FormattedText heading = (questHeadingSource == QuestHeadingSource.Description) ? description : localizedTitle; bool abandonable = QuestLog.IsQuestAbandonable(title) && IsShowingActiveQuests; bool trackable = QuestLog.IsQuestTrackingAvailable(title) && IsShowingActiveQuests; bool track = QuestLog.IsQuestTrackingEnabled(title); int entryCount = QuestLog.GetQuestEntryCount(title); FormattedText[] entries = new FormattedText[entryCount]; QuestState[] entryStates = new QuestState[entryCount]; for (int i = 0; i < entryCount; i++) { entries[i] = FormattedText.Parse(QuestLog.GetQuestEntry(title, i+1), DialogueManager.MasterDatabase.emphasisSettings); entryStates[i] = QuestLog.GetQuestEntryState(title, i+1); } questList.Add(new QuestInfo(title, heading, description, entries, entryStates, trackable, track, abandonable)); } Quests = questList.ToArray(); OnQuestListUpdated(); }