Example #1
0
    public void Init(Hashtable hash, hglTags_body hgltags)
    {
        try
        {
            m_method = (METHOD)System.Enum.Parse(typeof(METHOD), (string)hash["method"]);
        }
        catch { }

        m_hglTags = hgltags;
    }
Example #2
0
    IEnumerator HglReadFlow(string i_file, bool viewSrc)
    {
        m_winInfo.m_curRootElement = null;
        m_winInfo.m_curHeadElement = null;
        m_winInfo.m_curBodyElement = null;

        string file1;

        if (string.IsNullOrEmpty(i_file))
        {
            yield break;
        }


        if (hglEtc.check_head(i_file, "http"))
        {
            file1 = i_file;
        }
        else
        {
            file1 = (new System.IO.FileInfo(i_file)).FullName.Replace('\\', '/');
        }

        {
            var i = file1.LastIndexOf('/');
            m_winInfo.m_curBaseUrl = file1.Substring(0, i + 1);
            m_winInfo.m_curUrl     = file1;
        }

        string src = m_resman.GetText(file1);

        if (src == null)
        {
            if (m_winInfo.m_useText && m_winInfo.m_curUrlShort == m_winInfo.m_url)
            {
                src = m_winInfo.m_text;
                m_resman.Register(m_winInfo.m_url, file1, m_winInfo.m_text);
            }
            else
            {
                var fd = m_resman.Register(m_winInfo.m_curUrlShort, file1);
                if (fd.obj == null && fd.isNet)
                {
                    yield return(StartCoroutine(m_resman.ReadNet(fd, this)));
                }
                src = (string)fd.obj;
            }
        }

        hglParseStyleSheet hglStyleSheet = new hglParseStyleSheet();

        hglTags_head tagsHead     = new hglTags_head();
        hglWorkHead  hglwork_head = new hglWorkHead();

        hglWorkBody hglwork_body = new hglWorkBody();

        tagsHead.Init(hglwork_head, hglStyleSheet, m_resman, m_winInfo);

        if (ReadResource1(src))
        {
            yield return(StartCoroutine(m_resman.ReadAllNet(this)));
        }

        hglParser.Element root = null;
        hglParser.Element head = null;
        hglParser.Element body = null;

        if (!viewSrc)
        {
            yield return(StartCoroutine(m_xmlScript.Init()));

            string src_output = hglParserScript.ParserScript(src, (s) => m_xmlScript.RunProgram(s));
            if (ReadResource1(src_output))
            {
                yield return(StartCoroutine(m_resman.ReadAllNet(this)));
            }

            root = hglParser.Parser(src_output);

            head = hglParser.FindTag("head", root);
            body = hglParser.FindTag("body", root);

            if (head != null)
            {
                hglParser.TraverseHglWorkHead(head, hglwork_head);
            }
            if (body == null)
            {
                body = root;
            }
        }
        else
        {
            body = hglParser.CreateRowText(src);
            root = body;
        }
        root.thisStyle.Set(StyleKey.font_size, 20);
        root.thisStyle.SetColor(StyleKey.color, Color.black);
        root.thisStyle.SetColor(StyleKey.background_color, Color.white);
        root.thisStyle.Set(StyleKey.margin, "");
        root.thisStyle.Set(StyleKey.text_align, "");
        root.thisStyle.Set(StyleKey.line_height, 2f);
        root.thisStyle.Set(StyleKey.width, m_winInfo.m_fixedWidth);

        if (m_winInfo.m_winType == hglWindowType.MAIN)
        {
            m_winInfo.m_mainCamera.camera.backgroundColor = root.thisStyle.GetColor(StyleKey.background_color);
        }

        //while (true)
        {
            hgca.DestroyAllChildren(gameObject);
            yield return(null);

            CreateRenerObj();
            yield return(null); //create

            yield return(null); //exec start

            hglTags_body tagsBody = new hglTags_body();
            tagsBody.Init(hglwork_body, hglStyleSheet, m_winInfo, m_rendere.m_render, m_resman);
            hglParser.TraverseHglWorkBody(body, hglwork_body);
            m_rendere.m_render.OutputRendering(m_rendere.gameObject);
        }

        hglParser.SavePositions(body);

        m_winInfo.m_curRootElement = root;
        m_winInfo.m_curHeadElement = head;
        m_winInfo.m_curBodyElement = body;

        {
            var jsobjs = GetComponentsInChildren <xmlScriptObj>();
            foreach (var jo in jsobjs)
            {
                jo.m_valid = true;
            }
        }
    }