/// <summary>
        /// Overrides a DialogueActor's subtitle panel.
        /// </summary>
        /// <param name="dialogueActor">DialogueActor whose panel to override for this conversation.</param>
        /// <param name="subtitlePanelNumber">New subtitle panel number.</param>
        /// <param name="customPanel">Only used if subtitlePanelNumber is Custom.</param>
        public void OverrideActorPanel(DialogueActor dialogueActor, SubtitlePanelNumber subtitlePanelNumber, StandardUISubtitlePanel customPanel = null)
        {
            if (dialogueActor == null)
            {
                return;
            }
            var actor = DialogueManager.masterDatabase.GetActor(dialogueActor.actor);
            StandardUISubtitlePanel panel = null;

            switch (subtitlePanelNumber)
            {
            case SubtitlePanelNumber.Default:
                panel = (actor != null && actor.IsPlayer) ? m_defaultPCPanel : m_defaultNPCPanel;
                break;

            case SubtitlePanelNumber.UseBarkUI:
                break;

            default:
            case SubtitlePanelNumber.Custom:
                panel = GetPanelFromNumber(subtitlePanelNumber, customPanel);
                break;
            }
            if (panel != null)
            {
                m_actorPanelCache[dialogueActor.transform] = panel;
                if (actor != null && m_actorIdOverridePanel.ContainsKey(actor.id))
                {
                    m_actorIdOverridePanel.Remove(actor.id);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Shows a subtitle. Opens a subtitle panel and sets the content. If the speaker
        /// has a DialogueActor component, this may dictate which panel opens.
        /// </summary>
        /// <param name="subtitle">Subtitle to show.</param>
        public override void ShowSubtitle(Subtitle subtitle)
        {
            if (subtitle == null)
            {
                return;
            }
            DialogueActor dialogueActor;
            var           panel = GetPanel(subtitle, out dialogueActor);

            if (SubtitleUsesBarkUI(subtitle))
            {
                DialogueManager.BarkString(subtitle.formattedText.text, subtitle.speakerInfo.transform, subtitle.listenerInfo.transform, subtitle.sequence);
            }
            else if (panel == null)
            {
                if (DialogueDebug.logWarnings)
                {
                    Debug.LogWarning("Dialogue System: Can't find subtitle panel for " + GetSubtitleTextSummary(subtitle) + ".");
                }
            }
            else if (string.IsNullOrEmpty(subtitle.formattedText.text))
            {
                HideSubtitle(subtitle);
            }
            else
            {
                // If actor is currently displaying on another panel, close that panel:
                var actorID = subtitle.speakerInfo.id;
                if (m_lastPanelUsedByActor.ContainsKey(actorID) && m_lastPanelUsedByActor[actorID] != panel)
                {
                    var previousPanel = m_lastPanelUsedByActor[actorID];
                    if (m_lastActorToUsePanel.ContainsKey(previousPanel) && m_lastActorToUsePanel[previousPanel] == actorID)
                    {
                        if (previousPanel.hasFocus)
                        {
                            previousPanel.Unfocus();
                        }
                        if (previousPanel.isOpen)
                        {
                            previousPanel.Close();
                        }
                    }
                }
                m_lastActorToUsePanel[panel]    = actorID;
                m_lastPanelUsedByActor[actorID] = panel;

                // Focus the panel and show the subtitle:
                m_focusedPanel = panel;
                if (panel.addSpeakerName)
                {
                    subtitle.formattedText.text = string.Format(panel.addSpeakerNameFormat, new object[] { subtitle.speakerInfo.Name, subtitle.formattedText.text });
                }
                if (dialogueActor != null && dialogueActor.standardDialogueUISettings.setSubtitleColor)
                {
                    subtitle.formattedText.text = dialogueActor.AdjustSubtitleColor(subtitle);
                }
                panel.ShowSubtitle(subtitle);
                SupercedeOtherPanels(panel);
            }
        }
Exemple #3
0
 protected virtual SubtitlePanelNumber GetSubtitlePanelNumberFromPanel(StandardUISubtitlePanel panel)
 {
     if (panel == m_defaultNPCPanel || panel == m_defaultPCPanel)
     {
         return(SubtitlePanelNumber.Default);
     }
     for (int i = 0; i < m_builtinPanels.Count; i++)
     {
         if (panel == m_builtinPanels[i])
         {
             return(PanelNumberUtility.IntToSubtitlePanelNumber(i));
         }
     }
     return(SubtitlePanelNumber.Custom);
 }
Exemple #4
0
 private StandardUISubtitlePanel GetActorTransformPanel(Transform speakerTransform, StandardUISubtitlePanel defaultPanel, out DialogueActor dialogueActor)
 {
     dialogueActor = null;
     if (speakerTransform == null)
     {
         return(defaultPanel);
     }
     if (m_dialogueActorCache.ContainsKey(speakerTransform))
     {
         dialogueActor = m_dialogueActorCache[speakerTransform];
     }
     else
     {
         dialogueActor = DialogueActor.GetDialogueActorComponent(speakerTransform);
         m_dialogueActorCache.Add(speakerTransform, dialogueActor);
     }
     if (m_actorPanelCache.ContainsKey(speakerTransform))
     {
         return(m_actorPanelCache[speakerTransform]);
     }
     if (m_useBarkUIs.Contains(speakerTransform))
     {
         return(null);
     }
     if (DialogueActorUsesBarkUI(dialogueActor))
     {
         m_useBarkUIs.Add(speakerTransform);
         return(null);
     }
     else
     {
         var panel = GetDialogueActorPanel(dialogueActor);
         if (panel == null)
         {
             panel = defaultPanel;
         }
         m_actorPanelCache.Add(speakerTransform, panel);
         return(panel);
     }
 }
Exemple #5
0
 protected virtual void SupercedeOtherPanels(StandardUISubtitlePanel newPanel)
 {
     for (int i = 0; i < m_builtinPanels.Count; i++)
     {
         var panel = m_builtinPanels[i];
         if (panel == null || panel == newPanel)
         {
             continue;
         }
         if (panel.isOpen)
         {
             if (panel.visibility == UIVisibility.UntilSuperceded)
             {
                 panel.Close();
             }
             else
             {
                 panel.Unfocus();
             }
         }
     }
 }
Exemple #6
0
 public void Initialize(StandardUISubtitlePanel[] subtitlePanels, StandardUISubtitlePanel defaultNPCSubtitlePanel, StandardUISubtitlePanel defaultPCSubtitlePanel)
 {
     m_builtinPanels.Clear();
     m_builtinPanels.AddRange(subtitlePanels);
     m_defaultNPCPanel = (defaultNPCSubtitlePanel != null) ? defaultNPCSubtitlePanel : (m_builtinPanels.Count > 0) ? m_builtinPanels[0] : null;
     m_defaultPCPanel  = (defaultPCSubtitlePanel != null) ? defaultPCSubtitlePanel : (m_builtinPanels.Count > 0) ? m_builtinPanels[0] : null;
     if (m_defaultNPCPanel != null)
     {
         m_defaultNPCPanel.isDefaultNPCPanel = true;
     }
     if (m_defaultPCPanel != null)
     {
         m_defaultPCPanel.isDefaultPCPanel = true;
     }
     for (int i = 0; i < m_builtinPanels.Count; i++)
     {
         if (m_builtinPanels[i] != null)
         {
             m_builtinPanels[i].panelNumber = i;
         }
     }
     ClearCache();
 }
Exemple #7
0
 private AbstractTypewriterEffect GetTypewriter(StandardUISubtitlePanel panel)
 {
     return((panel != null) ? TypewriterUtility.GetTypewriter(panel.subtitleText) : null);
 }
Exemple #8
0
 protected virtual void SupercedeOtherPanels(StandardUISubtitlePanel newPanel)
 {
     SupercedeOtherPanelsInList(m_builtinPanels, newPanel);
     SupercedeOtherPanelsInList(m_customPanels, newPanel);
 }
Exemple #9
0
        private StandardUISubtitlePanel GetPanelFromNumber(SubtitlePanelNumber subtitlePanelNumber, StandardUISubtitlePanel customPanel)
        {
            switch (subtitlePanelNumber)
            {
            case SubtitlePanelNumber.Default:
                return(null);

            case SubtitlePanelNumber.Custom:
                if (!m_customPanels.Contains(customPanel))
                {
                    m_customPanels.Add(customPanel);
                }
                return(customPanel);

            case SubtitlePanelNumber.UseBarkUI:
                return(null);

            default:
                var index = PanelNumberUtility.GetSubtitlePanelIndex(subtitlePanelNumber);
                return((0 <= index && index < m_builtinPanels.Count) ? m_builtinPanels[index] : null);
            }
        }
 /// <summary>
 /// For speakers who do not have DialogueActor components, this method overrides the
 /// actor's default panel.
 /// </summary>
 public void OverrideActorPanel(Actor actor, SubtitlePanelNumber subtitlePanelNumber, StandardUISubtitlePanel customPanel = null)
 {
     if (actor == null)
     {
         return;
     }
     if (customPanel == null)
     {
         customPanel = actor.IsPlayer ? m_defaultPCPanel : m_defaultNPCPanel;
     }
     m_actorIdOverridePanel[actor.id] = GetPanelFromNumber(subtitlePanelNumber, customPanel);
 }
 public void ForceOverrideSubtitlePanel(StandardUISubtitlePanel customPanel)
 {
     m_forcedOverridePanel = customPanel;
 }
 public virtual void ForceOverrideSubtitlePanel(StandardUISubtitlePanel customPanel)
 {
     conversationUIElements.standardSubtitleControls.ForceOverrideSubtitlePanel(customPanel);
 }