Ejemplo n.º 1
0
        private static XElement CreateScreenElement(GameScreen screen)
        {
            XElement el = new XElement("screen");
            el.Add(new XElement("name", screen.ScreenName));
            el.Add(new XElement("script", screen.Script));

            XElement colorEl = new XElement("color");
            colorEl.Add(new XAttribute("r", screen.BackgroundColor.r));
            colorEl.Add(new XAttribute("g", screen.BackgroundColor.g));
            colorEl.Add(new XAttribute("b", screen.BackgroundColor.b));

            el.Add(colorEl);

            XElement spritesEl = new XElement("sprites");
            el.Add(spritesEl);

            for (uint i = 0; i < screen.GetNumberOfSprites(); i++)
            {
                Sprite s = screen.GetSpriteAt(i);

                spritesEl.Add(CreateSpriteElement(s));
            }

            XElement textsEl = new XElement("texts");
            el.Add(textsEl);

            for (uint i = 0; i < screen.GetNumberOfTexts(); i++)
            {
                Text t = screen.GetTextAt(i);
                textsEl.Add(CreateTextElement(t));
            }

            XElement lSpritesEl = new XElement("lSprites");
            el.Add(lSpritesEl);

            for (uint i = 0; i < screen.GetNumberOfLibrarySprites(); i++)
            {
                LibrarySprite ls = screen.GetLibrarySpriteAt(i);
                lSpritesEl.Add(CreateLSpriteElement(ls));
            }

            return el;
        }
Ejemplo n.º 2
0
        private static void CompileScreen(GameScreen screen)
        {
            string userScriptPath = GetFullDir() + "\\Scripts\\" + screen.Script + "_user.lua";
            if (File.Exists(userScriptPath) == false)
            {
                CreateEmptyUserScript(userScriptPath);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("function autogen_init()");
            sb.AppendLine("SetBackgroundColor(" + screen.BackgroundColor.r + "," + screen.BackgroundColor.g + "," + screen.BackgroundColor.b + ")");
            sb.AppendLine();

            uint i;
            for (i = 0; i < screen.GetNumberOfSprites(); i++)
            {
                Sprite sp = screen.GetSpriteAt(i);
                WriteSprite(sb, sp);
                sb.AppendLine();
            }

            for (i = 0; i < screen.GetNumberOfTexts(); i++)
            {
                Text text = screen.GetTextAt(i);
                WriteText(sb, text);
                sb.AppendLine();
            }

            for (i = 0; i < screen.GetNumberOfLibrarySprites(); i++)
            {
                LibrarySprite lSprite = screen.GetLibrarySpriteAt(i);
                WriteLSprite(sb, lSprite, i);
                sb.AppendLine();
            }

            sb.AppendLine("end");

            string autoGenPath = GetFullDir() + "\\Scripts\\" + screen.Script + "_autogen.lua";

            File.WriteAllText(autoGenPath, sb.ToString());
        }