コード例 #1
0
        public override void Start()
        {
            UIElements.Clear();
            Console.Clear();
            Console.CursorVisible = false;

            UIElements.Add(new UIText("LoadAndSave", $"select a game to load or enter filename for new savegame", 10, 5, true));
            UIElements.Add(new UIInput("Filename", "Filename", 10, 7, true, () => { }));
            UIElements.Add(new UIButton("Load", "Load", 10, 11, true, () => { LoadGame(UIElements[1].input); }));
            UIElements.Add(new UIButton("Save", "Save", 10, 12, true, () => { SaveGame(UIElements[1].input + ".xml"); }));

            UIElements.Add(new UIText("Found", $"found savegames:", 30, 9, true));
            fileNames = Directory.GetFiles(@".\", "*.xml");

            for (int i = 0; i < 10; i++)
            {
                //int e = new int();
                //e = i;
                //UIElements.Add(new UIButton($"File {i}", $"{fileNames[i]}", 30, 11 + i, true, () => { if (UIElements[1].input == fileNames[e]) LoadGame(UIElements[1].input); else UIElements[1].input = fileNames[e]; }));
                UIElements.Add(new UIButton($"File {i}", $"{i}.", 30, 11 + i, true, () => { }));
            }

            cursor = new UICursor("Cursor", " ", 12, 7, true, () => { }); // TODO: set cursor at input position
            UIElements.Add(cursor);
            activeElement = 1;
            ListFiles();
        }
コード例 #2
0
        public override void Start()
        {
            UIElements.Clear();
            Console.Clear();
            Console.CursorVisible = false;
            autoCycleMode         = false;

            UIElements.Add(new UILogo("Logo", "Logo.txt", 5, 1, 88, 3));
            UIElements.Add(new UIText("Titel", "(c) by TobiH ", 99, 3));
            UIElements.Add(new UIText("Status", $"cycle #: {gameLogic.cycleNumber}", 10, 0, true));

            UIElements.Add(new UIInput("X", "X-Size", 5, gameLogic.height + 6, true, Next));
            UIElements.Add(new UIInput("Y", "Y-Size", 20, gameLogic.height + 6, true, Restart));

            UIElements.Add(new UIButton("Empty", "[  E Empty  ]", 5, gameLogic.height + 8, true, Restart));
            UIElements.Add(new UIButton("Cycle", "[  C Cycle  ]", 19, gameLogic.height + 8, true, Cycle));
            UIElements.Add(new UIButton("LoadSave", "[D Load/Save]", 33, gameLogic.height + 8, true, () => { Program.Scenes.Push(new LoadAndSaveScene(ref gameLogic)); }));
            UIElements.Add(new UIButton("Auto", "[  A Auto   ]", 47, gameLogic.height + 8, true, () => { autoCycleMode = !autoCycleMode; }));
            UIElements.Add(new UIButton("Random", "[ R Random  ]", 61, gameLogic.height + 8, true, Random));
            UIElements.Add(new UIButton("Load", "[L QuickLoad]", 75, gameLogic.height + 8, true, Load));
            UIElements.Add(new UIButton("Save", "[S QuickSave]", 89, gameLogic.height + 8, true, Save));
            UIElements.Add(new UIButton("Quit", "[ ESC Quit  ]", 103, gameLogic.height + 8, true, Quit));

            UIElements.Add(new UIField("Field", "GameOfLife", 5, 5, gameLogic.fieldAB[gameLogic.currentField ? 1 : 0], gameLogic.width, gameLogic.height));

            #region entfernte Buttons
            //for (byte yb = 0; yb < gameLogic.height; yb++) // alle Buttons auf dem Feld entfernt, dafür ein Cursor im Bereich aktiv wenn cursorMode = true
            //{
            //    for (byte xb = 0; xb < gameLogic.width; xb++)
            //    {
            //        UIElements.Add(new UIButton($"Button {xb},{yb}", "", 5 + xb, 5 + yb, true, Toggle));
            //    }
            //}
            #endregion
            cursor = new UICursor("Cursor", " ", 5, 5, true, () => { Click(cursor.fieldX, cursor.fieldY); });
            UIElements.Add(cursor);

            activeElement = 3;
        }