コード例 #1
0
 public void SetActorPortraitTexture(string actorName, Texture2D portraitTexture)
 {
     if (portraitImage == null)
     {
         return;
     }
     portraitImage.sprite = UITools.CreateSprite(AbstractDialogueUI.GetValidPortraitTexture(actorName, portraitTexture));
 }
コード例 #2
0
 /// <summary>
 /// Sets the controls active/inactive, except this method never activates the timer. If the
 /// UI's display settings specify a timeout, then the UI will call StartTimer() to manually
 /// activate the timer.
 /// </summary>
 /// <param name='value'>
 /// Value (<c>true</c> for active; otherwise inactive).
 /// </param>
 public override void SetActive(bool value)
 {
     try
     {
         SubtitleReminder.SetActive(value && SubtitleReminder.HasText);
         Tools.SetGameObjectActive(buttonTemplate, false);
         foreach (var button in buttons)
         {
             if (button != null)
             {
                 Tools.SetGameObjectActive(button, value && button.visible);
             }
         }
         Tools.SetGameObjectActive(timer, false);
         Tools.SetGameObjectActive(pcName, value);
         Tools.SetGameObjectActive(pcImage, value);
         if (value == true)
         {
             if ((pcImage != null) && (pcPortraitTexture != null))
             {
                 pcImage.sprite = UITools.CreateSprite(pcPortraitTexture);
             }
             if ((pcName != null) && (pcPortraitName != null))
             {
                 pcName.text = pcPortraitName;
             }
             Tools.SetGameObjectActive(panel, true);
             if (!isVisible && CanTriggerAnimation(animationTransitions.showTrigger))
             {
                 animator.SetTrigger(animationTransitions.showTrigger);
             }
             if (explicitNavigationForTemplateButtons)
             {
                 SetupTemplateButtonNavigation();
             }
         }
         else
         {
             if (isVisible && CanTriggerAnimation(animationTransitions.hideTrigger))
             {
                 animator.SetTrigger(animationTransitions.hideTrigger);
                 DialogueManager.Instance.StartCoroutine(DisableAfterAnimation(panel));
             }
             else if (!isHiding)
             {
                 if (panel != null)
                 {
                     Tools.SetGameObjectActive(panel, false);
                 }
             }
         }
     }
     finally
     {
         isVisible = value;
     }
 }
コード例 #3
0
        /// <summary>
        /// Sets the controls active/inactive, except this method never activates the timer. If the
        /// UI's display settings specify a timeout, then the UI will call StartTimer() to manually
        /// activate the timer.
        /// </summary>
        /// <param name='value'>
        /// Value (<c>true</c> for active; otherwise inactive).
        /// </param>
        public override void SetActive(bool value)
        {
            subtitleReminder.SetActive(value && subtitleReminder.HasText);
            Tools.SetGameObjectActive(buttonTemplate, false);
            foreach (var button in buttons)
            {
                if (button != null)
                {
                    if (value == true)
                    {
                        Tools.SetGameObjectActive(button, button.visible);
                    }
                    else
                    {
                        button.clickable = false;
                    }
                }
            }
            Tools.SetGameObjectActive(timer, false);
            Tools.SetGameObjectActive(pcName, value);
            Tools.SetGameObjectActive(pcImage, value);
            if (value == true)
            {
                if ((pcImage != null) && (pcPortraitTexture != null))
                {
                    pcImage.sprite = UITools.CreateSprite(pcPortraitTexture);
                }
                if ((pcName != null) && (pcPortraitName != null))
                {
                    pcName.text = pcPortraitName;
                }
                Tools.SetGameObjectActive(panel, true);

                animationTransitions.ClearTriggers(showHideController);
                showHideController.Show(animationTransitions.showTrigger, false, null);
                if (explicitNavigationForTemplateButtons)
                {
                    SetupTemplateButtonNavigation();
                }
            }
            else
            {
                if (isVisible && CanTriggerAnimation(animationTransitions.hideTrigger))
                {
                    animationTransitions.ClearTriggers(showHideController);
                    showHideController.Hide(animationTransitions.hideTrigger, DeactivateUIElements);
                }
                else
                {
                    if (panel != null)
                    {
                        Tools.SetGameObjectActive(panel, false);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Sets the portrait texture to use in the subtitle if the named actor is the speaker.
 /// This is used to immediately update the GUI control if the SetPortrait() sequencer
 /// command changes the portrait texture.
 /// </summary>
 /// <param name="actorName">Actor name in database.</param>
 /// <param name="portraitTexture">Portrait texture.</param>
 public override void SetActorPortraitTexture(string actorName, Texture2D portraitTexture)
 {
     if ((currentSubtitle != null) && string.Equals(currentSubtitle.speakerInfo.nameInDatabase, actorName))
     {
         if (portraitImage != null)
         {
             portraitImage.sprite = UITools.CreateSprite(AbstractDialogueUI.GetValidPortraitTexture(actorName, portraitTexture));                                         //---Was: .texture = AbstractDialogueUI.GetValidPortraitTexture(actorName, portraitTexture);
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Sets the portrait texture to use in the response menu if the named actor is the player.
 /// This is used to immediately update the GUI control if the SetPortrait() sequencer
 /// command changes the portrait texture.
 /// </summary>
 /// <param name="actorName">Actor name in database.</param>
 /// <param name="portraitTexture">Portrait texture.</param>
 public override void SetActorPortraitTexture(string actorName, Texture2D portraitTexture)
 {
     if (string.Equals(actorName, m_pcPortraitName))
     {
         Texture2D actorPortraitTexture = AbstractDialogueUI.GetValidPortraitTexture(actorName, portraitTexture);
         m_pcPortraitTexture = actorPortraitTexture;
         if (m_currentPanel != null && m_currentPanel.pcImage != null && DialogueManager.masterDatabase.IsPlayer(actorName))
         {
             m_currentPanel.pcImage.sprite = UITools.CreateSprite(actorPortraitTexture);
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Sets the portrait texture to use in the response menu if the named actor is the player.
 /// This is used to immediately update the GUI control if the SetPortrait() sequencer
 /// command changes the portrait texture.
 /// </summary>
 /// <param name="actorName">Actor name in database.</param>
 /// <param name="portraitTexture">Portrait texture.</param>
 public override void SetActorPortraitTexture(string actorName, Texture2D portraitTexture)
 {
     if (string.Equals(actorName, pcPortraitName))
     {
         Texture2D actorPortraitTexture = AbstractDialogueUI.GetValidPortraitTexture(actorName, portraitTexture);
         pcPortraitTexture = actorPortraitTexture;
         if ((pcImage != null) && (DialogueManager.MasterDatabase.IsPlayer(actorName)))
         {
             pcImage.sprite = UITools.CreateSprite(actorPortraitTexture);
         }
     }
 }
コード例 #7
0
ファイル: CharacterInfo.cs プロジェクト: mentalpop/GrabbyPaws
        /// <summary>
        /// Gets the pic override portrait. Dialogue text can include <c>[pic=#]</c> tags.
        /// This number corresponds to the actor's portrait (if picNum == 1) or
        /// alternatePortraits (if picNum >= 2).
        /// </summary>
        /// <returns>The pic override portrait.</returns>
        /// <param name="picNum">Pic number.</param>
        public Sprite GetPicOverride(int picNum)
        {
            if (picNum < 2)
            {
                return(portrait);
            }
            int   alternatePortraitIndex = picNum - 2;
            Actor actor = DialogueManager.masterDatabase.GetActor(id);

            return(((actor != null) && (alternatePortraitIndex < actor.alternatePortraits.Count))
                ? UITools.CreateSprite(actor.alternatePortraits[alternatePortraitIndex])
                : ((actor != null) && (alternatePortraitIndex < actor.spritePortraits.Count)) ? actor.spritePortraits[alternatePortraitIndex]
                : portrait);
        }
コード例 #8
0
 /// <summary>
 /// Barks a subtitle. Does not observe formatting codes in the subtitle's FormattedText,
 /// instead using the formatting settings defined on this component.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle to bark.
 /// </param>
 public override void Bark(Subtitle subtitle)
 {
     if (ShouldShowText(subtitle))
     {
         SetUIElementsActive(false);
         string subtitleText = subtitle.formattedText.text;
         if (includeName)
         {
             if (nameText != null)
             {
                 nameText.text = subtitle.speakerInfo.Name;
             }
             else
             {
                 subtitleText = string.Format("{0}: {1}", subtitleText, subtitle.formattedText.text);
             }
         }
         if (showPortraitImage && subtitle.speakerInfo.portrait != null)
         {
             Tools.SetGameObjectActive(portraitImage, true);
             portraitImage.sprite = UITools.CreateSprite(subtitle.speakerInfo.portrait);
         }
         else
         {
             Tools.SetGameObjectActive(portraitImage, false);
         }
         if (barkText != null)
         {
             barkText.text = subtitleText;
         }
         SetUIElementsActive(true);
         if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.showTrigger))
         {
             animator.SetTrigger(animationTransitions.showTrigger);
         }
         CancelInvoke("Hide");
         var barkDuration = Mathf.Approximately(0, duration) ? DialogueManager.GetBarkDuration(subtitleText) : duration;
         if (!(waitUntilSequenceEnds || waitForContinueButton))
         {
             Invoke("Hide", barkDuration);
         }
         if (waitUntilSequenceEnds)
         {
             numSequencesActive++;
         }
         doneTime = DialogueTime.time + barkDuration;
     }
 }
コード例 #9
0
 /// <summary>
 /// Sets the subtitle.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle.
 /// </param>
 public override void SetSubtitle(Subtitle subtitle)
 {
     if ((subtitle != null) && !string.IsNullOrEmpty(subtitle.formattedText.text))
     {
         if (portraitImage != null)
         {
             portraitImage.sprite = UITools.CreateSprite(subtitle.GetSpeakerPortrait());
         }
         if (portraitName != null)
         {
             portraitName.text = subtitle.speakerInfo.Name;
             UITools.SendTextChangeMessage(portraitName);
         }
         if (line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.Stop();
                 typewriterEffect.playOnEnable = false;
             }
             SetFormattedText(line, subtitle.formattedText);
             //---Was: if (typewriterEffect != null && typewriterEffect.enabled) typewriterEffect.OnEnable();
             //---Now manually start Play for more precise control.
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.PlayText(subtitle.formattedText.text);
             }
         }
         Show();
         if (alwaysVisible && line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null)
             {
                 typewriterEffect.OnEnable();
             }
         }
     }
     else
     {
         if ((line != null) && (subtitle != null))
         {
             SetFormattedText(line, subtitle.formattedText);
         }
         Hide();
     }
 }
コード例 #10
0
 /// <summary>
 /// Shows the panel at the start of the conversation; called if it's configured to be visible at the start.
 /// </summary>
 /// <param name="portraitImage">The image of the first actor who will use this panel.</param>
 /// <param name="portraitName">The name of the first actor who will use this panel.</param>
 /// <param name="dialogueActor">The actor's DialogueActor component, or null if none.</param>
 public virtual void OpenOnStartConversation(Texture2D portraitImage, string portraitName, DialogueActor dialogueActor)
 {
     Open();
     SetUIElementsActive(true);
     if (this.portraitImage != null)
     {
         this.portraitImage.sprite = UITools.CreateSprite(portraitImage);
     }
     if (this.portraitName != null)
     {
         this.portraitName.text = portraitName;
     }
     if (subtitleText.text != null)
     {
         subtitleText.text = string.Empty;
     }
     CheckDialogueActorAnimator(dialogueActor);
 }
コード例 #11
0
 /// <summary>
 /// Sets the subtitle.
 /// </summary>
 /// <param name='subtitle'>
 /// Subtitle.
 /// </param>
 public override void SetSubtitle(Subtitle subtitle)
 {
     if ((subtitle != null) && !string.IsNullOrEmpty(subtitle.formattedText.text))
     {
         if (portraitImage != null)
         {
             portraitImage.sprite = UITools.CreateSprite(subtitle.GetSpeakerPortrait());
         }
         if (portraitName != null)
         {
             portraitName.text = subtitle.speakerInfo.Name;
         }
         if (line != null)
         {
             var typewriterEffect = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.Stop();
             }
             SetFormattedText(line, subtitle.formattedText);
             if (typewriterEffect != null && typewriterEffect.enabled)
             {
                 typewriterEffect.OnEnable();
             }
         }
         Show();
         if (alwaysVisible && line != null)
         {
             var typewriter = line.GetComponent <UnityUITypewriterEffect>();
             if (typewriter != null)
             {
                 typewriter.OnEnable();
             }
         }
     }
     else
     {
         if ((line != null) && (subtitle != null))
         {
             SetFormattedText(line, subtitle.formattedText);
         }
         Hide();
     }
 }
コード例 #12
0
ファイル: Actor.cs プロジェクト: marafrass/Prototype3
        public void AssignPortraitSprite(AssignSpriteDelegate assignSprite)
        {
            var originalDebugLevel = DialogueDebug.level; // Suppress logging for Lua return Actor[].Current_Portrait.

            DialogueDebug.level = DialogueDebug.DebugLevel.Warning;
            string imageName = DialogueLua.GetActorField(Name, DialogueSystemFields.CurrentPortrait).asString;

            DialogueDebug.level = originalDebugLevel;
            if (string.IsNullOrEmpty(imageName))
            {
                assignSprite(GetPortraitSprite(1));
            }
            else if (imageName.StartsWith("pic="))
            {
                assignSprite(GetPortraitSprite(Tools.StringToInt(imageName.Substring("pic=".Length))));
            }
            else
            {
                DialogueManager.LoadAsset(imageName, typeof(Texture2D),
                                          (asset) => { assignSprite(UITools.CreateSprite(asset as Texture2D)); });
            }
        }
コード例 #13
0
ファイル: Actor.cs プロジェクト: marafrass/Prototype3
        public Sprite GetPortraitSprite()
        {
            //--- Was: return UITools.GetSprite(portrait, spritePortrait);
            //--- Instead, check for override set by SetPortrait():
            var originalDebugLevel = DialogueDebug.level; // Suppress logging for Lua return Actor[].Current_Portrait.

            DialogueDebug.level = DialogueDebug.DebugLevel.Warning;
            string imageName = DialogueLua.GetActorField(Name, DialogueSystemFields.CurrentPortrait).asString;

            DialogueDebug.level = originalDebugLevel;
            if (string.IsNullOrEmpty(imageName))
            {
                return(GetPortraitSprite(1));
            }
            else if (imageName.StartsWith("pic="))
            {
                return(GetPortraitSprite(Tools.StringToInt(imageName.Substring("pic=".Length))));
            }
            else
            {
                return(UITools.CreateSprite(DialogueManager.LoadAsset(imageName) as Texture2D));
            }
        }
コード例 #14
0
 public virtual void SetPCPortrait(Texture2D portraitTexture, string portraitName)
 {
     dialogueControls.responseMenuControls.SetPCPortrait(UITools.CreateSprite(portraitTexture), portraitName);
 }
コード例 #15
0
 public virtual void OpenOnStartConversation(Texture2D portraitTexture, string portraitName, DialogueActor dialogueActor)
 {
     OpenOnStartConversation(UITools.CreateSprite(portraitTexture), portraitName, dialogueActor);
 }
コード例 #16
0
 /// <summary>
 /// Given a Texture2D and/or Sprite, returns whichever one is not null.
 /// Gives preference to the Texture2D.
 public static Sprite GetSprite(Texture2D texture, Sprite sprite)
 {
     return((texture != null) ? UITools.CreateSprite(texture) : sprite);
 }
コード例 #17
0
 public virtual void SetPCPortrait(Texture2D portraitTexture, string portraitName)
 {
     SetPCPortrait(UITools.CreateSprite(portraitTexture), portraitName);
 }
コード例 #18
0
        /// <summary>
        /// Sets the controls active/inactive, except this method never activates the timer. If the
        /// UI's display settings specify a timeout, then the UI will call StartTimer() to manually
        /// activate the timer.
        /// </summary>
        /// <param name='value'>
        /// Value (<c>true</c> for active; otherwise inactive).
        /// </param>
        public override void SetActive(bool value)
        {
            SubtitleReminder.SetActive(value && SubtitleReminder.HasText);
            Tools.SetGameObjectActive(buttonTemplate, false);
            foreach (var button in buttons)
            {
                if (button != null)
                {
                    Tools.SetGameObjectActive(button, value && button.visible);
                }
            }
            Tools.SetGameObjectActive(timer, false);
            Tools.SetGameObjectActive(pcName, value);
            Tools.SetGameObjectActive(pcImage, value);
            if (value == true)
            {
                if ((pcImage != null) && (pcPortraitTexture != null))
                {
                    pcImage.sprite = UITools.CreateSprite(pcPortraitTexture);
                }
                if ((pcName != null) && (pcPortraitName != null))
                {
                    pcName.text = pcPortraitName;
                }
                Tools.SetGameObjectActive(panel, true);

                animationTransitions.ClearTriggers(showHideController);
                showHideController.Show(animationTransitions.showTrigger, false, null);

                //--- Replaced by code above:
                //if (!isVisible && CanTriggerAnimation(animationTransitions.showTrigger))
                //{
                //    switch (animationTransitions.transitionMode)
                //    {
                //        case UIShowHideController.TransitionMode.State:
                //            animator.Play(animationTransitions.showTrigger);
                //            break;
                //        case UIShowHideController.TransitionMode.Trigger:
                //            animator.SetTrigger(animationTransitions.showTrigger);
                //            break;
                //    }
                //}

                if (explicitNavigationForTemplateButtons)
                {
                    SetupTemplateButtonNavigation();
                }
            }
            else
            {
                if (isVisible && CanTriggerAnimation(animationTransitions.hideTrigger))
                {
                    animationTransitions.ClearTriggers(showHideController);
                    showHideController.Hide(animationTransitions.hideTrigger, DeactivateUIElements);

                    //--- Replaced by code above:
                    //switch (animationTransitions.transitionMode)
                    //{
                    //    case UIShowHideController.TransitionMode.State:
                    //        animator.Play(animationTransitions.hideTrigger);
                    //        break;
                    //    case UIShowHideController.TransitionMode.Trigger:
                    //        animator.SetTrigger(animationTransitions.hideTrigger);
                    //        break;
                    //}
                    //DialogueManager.Instance.StartCoroutine(DisableAfterAnimation(panel));
                }
                else if (!isHiding)
                {
                    if (panel != null)
                    {
                        Tools.SetGameObjectActive(panel, false);
                    }
                }
            }
        }