Exemplo n.º 1
0
        public StageSelector() : base()
        {
            int init_x = 30, init_y = 40;
            int gap_y = 20, gap_x = 20;
            int width = 200, height = 80;
            var files = new DirectoryInfo("Stages").GetFiles("*.json");
            var iter  = CoordIter();

            btns = new Button[files.Length];
            int i = 0;

            foreach (var file in files)
            {
                var name = Path.GetFileNameWithoutExtension(file.Name);
                iter.MoveNext();
                var coord = iter.Current;
                var b     = new Button(coord.X, coord.Y, width, height, name)
                {
                    ClickStyle = ClickStyle.Popup
                };
                SceneGUI.Add(b);
                btns[i++] = b;
            }
            iter.MoveNext();
            var c = iter.Current;

            editorBtn = new Button(c.X, c.Y, width, height, "+")
            {
                ClickStyle = ClickStyle.Popup
            };
            SceneGUI.Add(editorBtn);

            IEnumerator <Point> CoordIter()
            {
                for (int y = init_y; ; y += height + gap_y)
                {
                    for (int x = 1; x <= 4; x++)
                    {
                        yield return(new Point(init_x + (x - 1) * width + x * gap_x, y));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public StageEditor() : base()
        {
            statusLabel = new Label(20, 20, "");
            runBtn      = new Button(800, 20, 130, 60, "Run")
            {
                ClickStyle = ClickStyle.Popup
            };
            SceneGUI.Add(runBtn);
            SceneGUI.Add(statusLabel);
            stage = Stage.New(this);

            int i = 0;

            for (; ; i++)
            {
                if (!System.IO.File.Exists($@"Stages\{i}.json"))
                {
                    break;
                }
            }

            path = $@"Stages\{i}.json";
        }
Exemplo n.º 3
0
 public StageEditor(string path) : this()
 {
     this.path = path;
     stage     = Stage.Load(this, SerializeHelper.LoadFromFile(path));
     SceneGUI.Add(stage.Visualizer);
 }