コード例 #1
0
    public virtual void Tips(string body)
    {
        UIDialogeOption option = UIDialogeOption.StyleTips;

        option.body = body;
        Show(option);
    }
コード例 #2
0
    public virtual void Response(string body, OnUIDialogueButtonClick onclose)
    {
        UIDialogeOption option = UIDialogeOption.StyleResponse;

        option.body    = body;
        option.onClose = onclose ?? option.onClose;
        Show(option);
    }
コード例 #3
0
    public virtual void Prompt(string body, OnUIDialogueButtonClick onclose)
    {
        UIDialogeOption option = UIDialogeOption.StylePrompt;

        option.body    = body;
        option.onClose = onclose;
        Show(option);
    }
コード例 #4
0
    protected static IEnumerator Close(UIDialogue dialogue, eUIDialogueButtons button, UIDialogeOption option)
    {
        dialogue.mClearQueue = false;
        dialogue.Close();

        yield return(null);

        option.onClose(button, option);
    }
コード例 #5
0
 protected static void DefaultOnClose(eUIDialogueButtons button, UIDialogeOption option)
 {
 }
コード例 #6
0
    public virtual void Show(UIDialogeOption option)
    {
        if (IsOpen())
        {
            mQueue.Enqueue(option);
            return;
        }

        if (mQueue.Count > 0)
        {
            mQueue.Enqueue(option);
            return;
        }

        mClearQueue = true;
        Option      = option;
        Open();

        if (header != null)
        {
            header.SetActive(option.title != null);
            if (header.activeSelf)
            {
                UILabel titleLabel = header.GetComponentInChildren <UILabel>();
                titleLabel.text = option.title;
            }
        }

        if (body != null)
        {
            body.SetActive(option.body != null);
            if (body.activeSelf)
            {
                UILabel   bodyLabel = body.GetComponentInChildren <UILabel>();
                string [] strs      = option.body.Split('\n');
                if (strs.Length > 5)
                {
                    bodyLabel.text = strs[0];
                }
                else
                {
                    bodyLabel.text = option.body;
                }
            }
        }

        if (input != null)
        {
            input.SetActive(option.input != null);
            if (input.activeSelf)
            {
                UIInput inputComponent = input.GetComponentInChildren <UIInput>();
                inputComponent.value = option.input;
            }
        }

        if (acceptButton != null)
        {
            acceptObject.SetActive((option.buttons & eUIDialogueButtons.Accept) == eUIDialogueButtons.Accept);
            acceptButton.onClick.Clear();
            if (acceptObject.activeSelf)
            {
                acceptButton.onClick.Add(new EventDelegate(OnAcceptButtonClick));
            }
        }

        if (declineButton != null)
        {
            declineObject.SetActive((option.buttons & eUIDialogueButtons.Decline) == eUIDialogueButtons.Decline);
            declineButton.onClick.Clear();
            if (declineObject.activeSelf)
            {
                declineButton.onClick.Add(new EventDelegate(OnDeclineButtonClick));
            }
        }

        if (cancelButton != null)
        {
            cancelObject.SetActive((option.buttons & eUIDialogueButtons.Cancel) == eUIDialogueButtons.Cancel);
            cancelButton.onClick.Clear();
            if (cancelObject.activeSelf)
            {
                cancelButton.onClick.Add(new EventDelegate(OnCancelButtonClick));
            }
        }
    }
コード例 #7
0
    public override void Show(UIDialogeOption option)
    {
        base.Show(option);

        if (Option != option)
        {
            // queued
            return;
        }

        if (option is UICustomeDialogueOption == false)
        {
            return;
        }

        mCustomOption = option as UICustomeDialogueOption;

        // set style
        if (mCustomOption.accept != null && acceptButton != null && acceptObject != null && acceptObject.activeSelf)
        {
            UILabel acceptLabel = acceptButton.GetComponentInChildren <UILabel>();
            if (acceptLabel != null)
            {
                mOriginAccept    = acceptLabel.text;
                acceptLabel.text = mCustomOption.accept;
            }
        }

        if (mCustomOption.decline != null && declineButton != null && declineObject != null && declineObject.activeSelf)
        {
            UILabel declineLabel = declineButton.GetComponentInChildren <UILabel>();
            if (declineLabel != null)
            {
                mOriginDecline    = declineLabel.text;
                declineLabel.text = mCustomOption.decline;
            }
        }

        if (mCustomOption.cancel != null && cancelButton != null && cancelObject != null && cancelObject.activeSelf)
        {
            UILabel cancelLabel = cancelButton.GetComponentInChildren <UILabel>();
            if (cancelLabel != null)
            {
                mOriginCancel    = cancelLabel.text;
                cancelLabel.text = mCustomOption.cancel;
            }
        }

        if (body != null && body.activeSelf)
        {
            UILabel bodyLabel = body.GetComponentInChildren <UILabel>();

            mOriginAllianment = bodyLabel.alignment;
            mOriginOverflow   = bodyLabel.overflowMethod;
            mOriginHeight     = bodyLabel.height;
            mOriginSpace      = bodyLabel.spacingY;

            //bodyLabel.alignment = mCustomOption.alignment;
            if (mCustomOption.lineSpace != 0)
            {
                bodyLabel.spacingY = mCustomOption.lineSpace;
            }
            if (mCustomOption.minHeight != 0)
            {
                bodyLabel.ProcessText();
                if (bodyLabel.height < mCustomOption.minHeight)
                {
                    bodyLabel.overflowMethod = UILabel.Overflow.ShrinkContent;
                    bodyLabel.height         = Mathf.Max(bodyLabel.height, mCustomOption.minHeight);
                }
            }

            UISprite bodyBackground = body.GetComponentInChildren <UISprite>(true);
            if (bodyBackground != null)
            {
                mOriginBodyBackgroundEnabled = bodyBackground.enabled;
                bodyBackground.enabled       = !mCustomOption.hideBodyBackground;
            }
        }
    }