示例#1
0
    protected JSONObject parseCommon(JSONObject raw, Vector2 containerSize, MagicUIControl.ControlType type)
    {
        JSONObject control = JSONObject.obj;

        Rect bounds = raw.GetRect();

        bounds.x      /= containerSize.x;
        bounds.width  /= containerSize.x;
        bounds.y      /= containerSize.y;
        bounds.height /= containerSize.y;
        control.SetRect(bounds);

        control.SetAnchors(raw.GetAnchors());

        control.AddField("zOrder", raw.GetFloatSafely("zOrder", 0));

        int link = raw.GetIntSafely("pageLink", -1);

        if (link > 0)
        {
            control.AddField("link", link);
        }

        control.SetControlType(type);

        return(control);
    }
示例#2
0
    public void Initialize(string text, bool isButton, JSONObject markup)
    {
        _isTextBox = false;

        _label.text                = text;
        _label.trueTypeFont        = MagicUIManager.Instance.Skin.FontParameters.Font;
        _label.color               = Color.black;
        _label.keepCrispWhenShrunk = UILabel.Crispness.Always;

        if (isButton)
        {
            _isButton    = true;
            _isMultiline = false;
            _horizontal  = NGUIText.Alignment.Center;
            // _vertical
            _fontSize = 999;
        }
        else
        {
            _isButton = false;

            bool?multiline = markup.GetBoolSafely("multiline", false);
            if (multiline.HasValue)
            {
                _isMultiline = multiline.Value;
            }

            switch (markup.GetStringSafely("halign", "center").ToLower()[0])
            {
            case 'l':
                _horizontal = NGUIText.Alignment.Left;
                break;

            case 'r':
                _horizontal = NGUIText.Alignment.Right;
                break;

            case 'c':
            default:
                _horizontal = NGUIText.Alignment.Center;
                break;
            }
            _label.alignment = _horizontal;

            //control.AddField("valign", valign);

            _fontSize = markup.GetFloatSafely("fontsize", 25);
        }
    }
示例#3
0
    protected JSONObject parseSubIcon(string key, string source, JSONObject raw, Vector2 containerSize)
    {
        JSONObject obj = JSONObject.obj;

        float h = raw.GetFloatSafely(string.Format("{0}.height", key), containerSize.y);

        h = h / containerSize.y;
        obj.AddField("height", h);

        float w = raw.GetFloatSafely(string.Format("{0}.width", key), containerSize.y);

        w = w / containerSize.x;
        obj.AddField("width", w);

        string url = source;

        if (url.StartsWith("/"))
        {
            url = _kServer + url;
        }
        obj.AddField("frame", url);

        return(obj);
    }
示例#4
0
    protected JSONObject parseLabel(JSONObject raw, Vector2 containerSize)
    {
        JSONObject control = parseCommon(raw, containerSize, MagicUIControl.ControlType.Label);

        string text = raw.GetStringSafely("text", null);

        if (text == null)
        {
            text = raw.GetStringSafely("name", "unnamed");
        }
        control.AddField("name", text);

        string align = null;
        bool?  scale = raw.GetBoolSafely("scaleWithFontSize", false);

        if (scale.HasValue && scale.Value)
        {
            align = "center";
        }
        else
        {
            align = raw.GetStringSafely("textalign", "left");
        }
        control.AddField("halign", align);

        bool?multiline = raw.GetBoolSafely("multiline", false);

        control.AddField("multiline", multiline.HasValue ? multiline.Value : false);

        string valign = raw.GetStringSafely("textverticalalign", "top");

        control.AddField("valign", valign);

        float size = raw.GetFloatSafely("font.size", 25);

        control.AddField("fontsize", size);

        return(control);
    }