예제 #1
0
    public static void Init(CE_WSB_Dialogue _ce, SerializedProperty _text, int _index)
    {
        if (popup)
        {
            popup.Close();
        }
        property = _text;
        index    = _index;
        ce       = _ce;
        popup    = ScriptableObject.CreateInstance <SizePopup>();
        Vector2 _pos = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

        popup.position = new Rect(_pos.x, _pos.y, 100, 75);
        popup.ShowPopup();
    }
예제 #2
0
    void RichTextButtons(SerializedProperty _text, int _index)
    {
        EditorGUILayout.BeginHorizontal();

        lastTextSelected = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

        // Adds <b> and </b> with the selected text between
        if (GUILayout.Button("Bold"))
        {
            if (!string.IsNullOrEmpty(lastTextSelected.text) && lastTextSelected.hasSelection)
            {
                lastTextSelected.ReplaceSelection($"<b>{lastTextSelected.SelectedText}</b>");
                _text.GetArrayElementAtIndex(_index).stringValue = lastTextSelected.text;
            }
        }

        // Adds <u> and </u> with the selected text between
        if (GUILayout.Button("Underline"))
        {
            if (!string.IsNullOrEmpty(lastTextSelected.text) && lastTextSelected.hasSelection)
            {
                lastTextSelected.ReplaceSelection($"<u>{lastTextSelected.SelectedText}</u>");
                _text.GetArrayElementAtIndex(_index).stringValue = lastTextSelected.text;
            }
        }

        // Adds <i> and </i> with the selected text between
        if (GUILayout.Button("Italic"))
        {
            if (!string.IsNullOrEmpty(lastTextSelected.text) && lastTextSelected.hasSelection)
            {
                lastTextSelected.ReplaceSelection($"<i>{lastTextSelected.SelectedText}</i>");
                _text.GetArrayElementAtIndex(_index).stringValue = lastTextSelected.text;
            }
        }

        if (GUILayout.Button("Color"))
        {
            ColorPopup.Init(this, _text, _index);
        }

        if (GUILayout.Button("Size"))
        {
            SizePopup.Init(this, _text, _index);
        }

        EditorGUILayout.EndHorizontal();
    }
 public PopupElement Popup(string id, string title, string onOkClickFunction, SizePopup sizePopup)
 {
     return new PopupElement(this.HtmlHelper, id, title, onOkClickFunction, null, sizePopup);
 }
 public PopupElement Popup(string id, string title, string onOkClickFunction, object htmlAttributes, SizePopup sizePopup)
 {
     return new PopupElement(this.HtmlHelper, id, title, onOkClickFunction, htmlAttributes, sizePopup);
 }
예제 #5
0
        public PopupElement(HtmlHelper helper, string id, string title, string okButtonId, string onOkClickFunction, object htmlAttributes, SizePopup sizePopup)
        {
            _helper            = helper;
            _onOkClickFunction = onOkClickFunction;
            _model             = new TagBuilder("div");
            _id         = id;
            _okButtonId = okButtonId;
            if (htmlAttributes != null)
            {
                _model.MergeAttributes(new RouteValueDictionary(htmlAttributes), true);
            }

            _model.GenerateId(id);
            _model.Attributes.Add("tabindex", "-1");
            _model.Attributes.Add("role", "dialog");
            _model.Attributes.Add("aria-labelledby", "myModalLabel");
            _model.Attributes.Add("aria-hidden", "true");
            _model.AddCssClass("modal fade");

            TagBuilder modelLoading = new TagBuilder("div");

            modelLoading.GenerateId(string.Concat(id, "-locked"));
            modelLoading.AddCssClass("popup-locked");

            TagBuilder modelLoadingContent = new TagBuilder("div");

            modelLoadingContent.AddCssClass("popup-locked-content");


            modelLoading.InnerHtml = modelLoadingContent.ToString();

            _dialog = new TagBuilder("div");
            _dialog.AddCssClass("modal-dialog");

            switch (sizePopup)
            {
            case SizePopup.Small:
                _dialog.AddCssClass("modal-sm");
                break;

            case SizePopup.Medium:
                _dialog.AddCssClass("modal-md");
                break;

            case SizePopup.Large:
                _dialog.AddCssClass("modal-lg");
                break;

            case SizePopup.ExtraLarge:
                _dialog.AddCssClass("modal-xlg");
                break;
            }

            _content = new TagBuilder("div");
            _content.AddCssClass("modal-content");

            TagBuilder header = new TagBuilder("div");

            header.AddCssClass("modal-header");

            TagBuilder button = new TagBuilder("button");

            button.AddCssClass("close");
            button.Attributes.Add("aria-hidden", "true");
            button.Attributes.Add("data-dismiss", "modal");
            button.InnerHtml = "<span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Cerrar</span>";

            TagBuilder mtitle = new TagBuilder("h5");

            mtitle.GenerateId(string.Concat(this._id, "-title"));
            mtitle.AddCssClass("modal-title");
            mtitle.InnerHtml = title;

            header.InnerHtml = string.Concat(button.ToString(), mtitle.ToString());

            _body = new TagBuilder("div");
            _body.AddCssClass("modal-body");

            helper.ViewContext.Writer.Write(string.Concat(_model.ToString(TagRenderMode.StartTag),
                                                          _dialog.ToString(TagRenderMode.StartTag),
                                                          _content.ToString(TagRenderMode.StartTag),
                                                          modelLoading.ToString(),
                                                          header.ToString(),
                                                          _body.ToString(TagRenderMode.StartTag)));
        }
예제 #6
0
 public PopupElement(HtmlHelper helper, string id, string title, string onOkClickFunction, object htmlAttributes, SizePopup sizePopup)
     : this(helper, id, title, "", onOkClickFunction, htmlAttributes, sizePopup)
 {
 }