public override void Hide() { base.Hide(); _originalScreen.Parent = null; Global.CurrentScreen = _originalScreen; _originalScreen = null; _wrapperScreen = null; Global.FocusedConsoles = _inputConsoles; }
public ScoreBoard(ContainerConsole parent) { moveLists = new Dictionary <IPlayer, IList <Move> >(); scoreConsoles = new Dictionary <IPlayer, Console>(); scoreBoardContainer = new ContainerConsole() { Position = new Point(GlobalConstants.BoardWidth, 0), Parent = parent }; }
public ConsoleRenderer(ContainerConsole parent) { // load font var fontMaster = Global.LoadFont("Fonts/chess.font"); normalSizedFont = fontMaster.GetFont(Font.FontSizes.One); // create board console Console = new Console(GlobalConstants.BoardWidth, GlobalConstants.BoardHeight, normalSizedFont) { Parent = parent }; }
static void Init() { // wrapper var container = new ContainerConsole(); Global.CurrentScreen = container; // start the game var chessEngine = new StandardTwoPlayerEngine(container); var gameInitializationStrategy = new StandardStartGameInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy); }
public StandardTwoPlayerEngine(ContainerConsole container) { movementStrategy = new NormalMovementStrategy(); renderer = new ConsoleRenderer(container); selectedPositions = new List <Position>(); scoreBoard = new ScoreBoard(container); board = new Board(); // main event that drives the game renderer.Console.MouseMove += MouseClickOnBoard; // keyboard keyboardHandler = new KeyboardHandler(this); container.IsFocused = true; container.Components.Add(keyboardHandler); }
public DebugWindow(Font font) : base(78, 22, font) { var listboxTheme = (ListBoxTheme)Library.Default.GetControlTheme(typeof(ListBox)); listboxTheme.DrawBorder = true; Title = "Global.CurrentScreen Debugger"; IsModalDefault = true; CloseOnEscKey = true; _listConsoles = new ListBox(30, 15) { Position = new Point(2, 3) }; _listConsoles.SelectedItemChanged += Listbox_SelectedItemChanged; _listConsoles.Theme = listboxTheme; Add(_listConsoles); Label label = CreateLabel("Current Screen", new Point(_listConsoles.Bounds.Left, _listConsoles.Bounds.Top - 1)); label = CreateLabel("Selected Console: ", new Point(_listConsoles.Bounds.Right + 1, label.Bounds.Top)); { _labelConsoleTitle = new Label(Width - label.Bounds.Right - 1) { Position = new Point(label.Bounds.Right, label.Bounds.Top) }; Add(_labelConsoleTitle); } label = CreateLabel("Width: ", new Point(label.Bounds.Left, label.Bounds.Bottom)); { _labelConsoleWidth = new Label(5) { Position = new Point(label.Bounds.Right, label.Bounds.Top) }; _labelConsoleWidth.Alignment = HorizontalAlignment.Right; Add(_labelConsoleWidth); } label = CreateLabel("Height:", new Point(label.Bounds.Left, label.Bounds.Bottom)); { _labelConsoleHeight = new Label(5) { Position = new Point(label.Bounds.Right, label.Bounds.Top) }; _labelConsoleHeight.Alignment = HorizontalAlignment.Right; Add(_labelConsoleHeight); } _checkIsVisible = new CheckBox(15, 1) { Text = "Is Visible", Position = new Point(_listConsoles.Bounds.Right + 1, label.Bounds.Bottom) }; _checkIsVisible.IsSelectedChanged += _checkIsVisible_IsSelectedChanged; Add(_checkIsVisible); label = CreateLabel("Position: ", new Point(_labelConsoleWidth.Bounds.Right + 2, _labelConsoleWidth.Bounds.Top)); { _labelConsolePosition = new Label(7) { Position = new Point(label.Bounds.Right, label.Bounds.Top) }; Add(_labelConsolePosition); } _buttonSetPosition = new Button(5) { Text = "Set", Position = new Point(_labelConsolePosition.Bounds.Right + 1, _labelConsolePosition.Bounds.Top), }; Add(_buttonSetPosition); _buttonSetPosition.Click += _buttonSetPosition_Click; _surfaceView = new ScrollingSurfaceView(Width - 3 - _listConsoles.Bounds.Right + 1, Height - 6 - _checkIsVisible.Bounds.Bottom + 1) { Theme = new ScrollingSurfaceView.ScrollingSurfaceViewTheme(), Position = new Point(_listConsoles.Bounds.Right + 1, _checkIsVisible.Bounds.Bottom) }; Add(_surfaceView); // Position EDIT // Map View of surface // Cell peek of surface // Cell edit of surface // Save surface //label = CreateLabel("Visible: ", new Point(listbox.Bounds.Right + 1, _labelConsoleWidth.Bounds.Top)); //{ // _labelConsoleHeight = new Label(5) { Position = new Point(label.Bounds.Right, label.Bounds.Top) }; // Add(_labelConsoleHeight); //} Label CreateLabel(string text, Point position) { var labelTemp = new Label(text) { Position = position, TextColor = (ThemeColors?.TitleText ?? Library.Default.Colors.TitleText) }; Add(labelTemp); return(labelTemp); } // Setup the "steal the focus" system to pause the existing current screen _originalScreen = Global.CurrentScreen; _wrapperScreen = new ContainerConsole(); _inputConsoles = Global.FocusedConsoles; Global.FocusedConsoles = new ConsoleStack(); AddConsoleToList(_originalScreen); void AddConsoleToList(Console console, int indent = 0) { System.Diagnostics.DebuggerDisplayAttribute debugger = console.GetType().GetTypeInfo().GetCustomAttributes <System.Diagnostics.DebuggerDisplayAttribute>().FirstOrDefault(); string text = debugger != null ? debugger.Value : console.ToString(); _listConsoles.Items.Add(new ConsoleListboxItem(new string('-', indent) + text, console)); foreach (Console child in console.Children) { AddConsoleToList(child, indent + 1); } } _wrapperScreen.Children.Add(_originalScreen); _wrapperScreen.IsPaused = true; Global.CurrentScreen = new ContainerConsole(); Global.CurrentScreen.Children.Add(_wrapperScreen); _listConsoles.SelectedItem = _listConsoles.Items[0]; }