コード例 #1
0
    public string GetStyle_class_tag(string classname, hglParser.Element xe)
    {
        var curTag = xe != null ? xe.text : null;

        if (curTag == null)
        {
            return(null);
        }

        string s = null;

        if (string.IsNullOrEmpty(classname))
        {
            s = KEYVAL.Find(curTag, m_list);
        }
        if (s == null)
        {
            s = KEYVAL.Find(curTag + "." + classname, m_list);
        }
        if (s == null)
        {
            s = KEYVAL.Find("." + classname, m_list);
        }

        return(s);
    }
コード例 #2
0
    public bool GetLinkStyleColor(string kind, out Color col)
    {
        col = Color.black;
        var s = KEYVAL.Find(kind, m_list);

        if (string.IsNullOrEmpty(s))
        {
            return(false);
        }
        hglStyle style = new hglStyle(null);

        style.Parse(s);
        col = style.GetColor(StyleKey.color);
        return(true);
    }
コード例 #3
0
    public void Parse(string istr)
    {
        const int mode_none = 0;
        const int mode_name = 1;
        const int mode_data = 2;

        var str = commentout(istr);

        if (string.IsNullOrEmpty(str))
        {
            return;
        }
        if (!str.Contains(":"))
        {
            return;
        }

        var words = hglEtc.BreakUpStyleString(str);// foreach(var w in words) Debug.Log(w);
        int mode  = mode_none;

        KEYVAL kv = null;

        for (var n = 0; n < words.Length; n++)
        {
            var w = words[n];
            var c = words[n][0];
            if (mode == mode_none)
            {
                mode = mode_name;
                if (kv == null)
                {
                    kv = new KEYVAL()
                    {
                        keys = new List <string>(), val = ""
                    }
                }
                ;
                kv.keys.Add(w);
            }
            else if (mode == mode_name)
            {
                if (c == '{')
                {
                    if (kv == null)
                    {
                        Debug.LogError("Unexpected!");
                    }
                    mode = mode_data;
                }
                else
                {
                    //w =w.ToLower();
                    kv.keys.Add(w);
                }
            }
            else // if (mode == mode_data)
            {
                if (c == '}')
                {
                    mode = mode_none;
                    if (kv == null)
                    {
                        Debug.LogError("Unexpected!");
                    }
                    kv.MakeKeyGroups();
                    m_list.Add(kv); kv = null;
                }
                else
                {
                    kv.val += w + " ";
                }
            }
        }
    }

    string commentout(string str)
    {
        if (string.IsNullOrEmpty(str))
        {
            return(null);
        }
        string s     = "";
        int    index = 0;
        bool   inCmt = false;

        while (index < str.Length)
        {
            if (inCmt)
            {
                var i = str.IndexOf("*/", index);
                inCmt = false;
                s    += " ";
                index = i + 2;
            }
            else
            {
                var i = str.IndexOf("/*", index);
                if (i > 0)
                {
                    inCmt = true;
                    s    += str.Substring(index, i - index);
                    index = i + 2;
                }
                else
                {
                    s += str.Substring(index);
                    break;
                }
            }
        }
        return(s);
    }