示例#1
0
        public static void AddScreen(GameScreen screen)
        {
            tNode.Nodes.Add(screen.GetTreeNode());
            screen.OnAddToTree();

            screens.Add(screen);
        }
示例#2
0
        private void ctPanel_onItemSelected(object sender, CreateTabArgs e)
        {
            if (e.Item == CreateTabItem.GameScreen)
            {
                NewScreen dialog = new NewScreen();

                dialog.ShowDialog();
                if (dialog.IsCanceled == false)
                {
                    GameScreen screen = new GameScreen();
                    screen.ScreenName = dialog.ScreenName;
                    screen.Script = dialog.ScriptName;

                    screen.BackgroundColor = dialog.BackgroundColor;

                    screen.ShowPropsPanel();

                    GameApp.AddScreen(screen);
                    GameApp.SetCurrentScreen(screen);

                }
            }

            else if (e.Item == CreateTabItem.Sprite && GameApp.GetGurrentScreen() != null)
            {
                ToolManager.SetCurrentTool(new CreateScreenObjectTool(ObjectType.Sprite));
            }

            else if (e.Item == CreateTabItem.Text && GameApp.GetGurrentScreen() != null)
            {
                ToolManager.SetCurrentTool(new CreateScreenObjectTool(ObjectType.Text));
            }
        }
示例#3
0
        public static void RunEditScriptDialog(GameScreen screen)
        {
            string filePath = GetFullDir() + "\\Scripts\\" + screen.Script + "_user.lua";

            if (File.Exists(filePath) == false)
            {
                CreateEmptyUserScript(filePath);
            }

            EditScript dialog = new EditScript();
            dialog.TextValue = File.ReadAllText(filePath);

            System.Windows.Forms.DialogResult res = dialog.ShowDialog();

            if (res == System.Windows.Forms.DialogResult.OK)
            {
                File.WriteAllText(filePath, dialog.TextValue);
            }
        }
示例#4
0
        private static GameScreen CreateScreenFromElement(XElement el)
        {
            GameScreen screen = new GameScreen();
            screen.ScreenName = el.Element("name").Value;
            screen.Script = el.Element("script").Value;
            screen.BackgroundColor = CreateColorFromElement(el.Element("color"));

            XElement spritesEl = el.Element("sprites");

            foreach (XElement spriteEl in spritesEl.Elements())
            {
                Sprite sprite = CreateSpriteFromElement(spriteEl);
                screen.AddSprite(sprite);
            }

            XElement textsEl = el.Element("texts");

            foreach (XElement textEl in textsEl.Elements())
            {
                Text text = CreateTextFromElement(textEl);
                screen.AddText(text);
            }

            XElement lSpritesEl = el.Element("lSprites");

            foreach (XElement lSpriteEl in lSpritesEl.Elements())
            {
                LibrarySprite lSprite = CreateLSpriteFromElement(lSpriteEl);
                screen.AddLibrarySprite(lSprite);
            }

            return screen;
        }
示例#5
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;
        }
示例#6
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());
        }
示例#7
0
        public static void Init()
        {
            currentScreen = null;
            screens = new List<GameScreen>();
            startUpScreen = "";
            textsHeapSize = 0;
            texturesHeapSize = 0;
            spritesHeapSize = 0;
            SetFPS(24);
            tNode = new System.Windows.Forms.TreeNode("app : Application");

            propPanel = new AppPropPanel();
            propPanel.TextsHeapSize = "0";
            propPanel.TexturesHeapSize = "0";
            propPanel.SpritesHeapSize = "0";
            propPanel.FPS = "24";
            propPanel.AppName = AppManager.GetAppName();

            propPanel.OnPropChange += PropPanel_OnPropChange;
        }
示例#8
0
 public static void SetCurrentScreen(GameScreen screen)
 {
     currentScreen = screen;
 }
示例#9
0
        public static void RemoveScreen(GameScreen screen)
        {
            ShowPropsPanel();
            tNode.Nodes.Remove(screen.GetTreeNode());

            screens.Remove(screen);

            if (screens.Count > 0)
                SetCurrentScreen(screens[0]);
            else currentScreen = null;
        }