コード例 #1
0
ファイル: ControlSystem.cs プロジェクト: geirsagberg/ecs-fun
        private void SetupGui()
        {
            var button = new TextButton {
                GridColumn = 0,
                GridRow    = 0,
                Text       = "Create entity",
                Padding    = new Thickness(8)
            };

            button.Click += delegate {
                sharedState.OnCreateEntity(random.Next(100, graphics.PreferredBackBufferWidth - 100),
                                           random.Next(100, graphics.PreferredBackBufferHeight - 100));
            };

            var stack = new VerticalStackPanel {
                Width = 150
            };

            stack.Widgets.Add(button);

            grid = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                Visible       = false
            };

            grid.Widgets.Add(new Label {
                Text       = "IsPlayer",
                GridRow    = 0,
                GridColumn = 0,
            });
            isPlayerCheckBox = new CheckBox {
                GridRow    = 0,
                GridColumn = 1,
            };
            isPlayerCheckBox.Click += (sender, args) => {
                if (sender is CheckBox checkBox)
                {
                    TogglePlayer(checkBox.IsPressed);
                }
                skipNextMouseClicked = true;
            };
            grid.Widgets.Add(isPlayerCheckBox);

            grid.Widgets.Add(new Label {
                Text       = "IsPhysical",
                GridRow    = 1,
                GridColumn = 0,
            });
            isPhysicalCheckBox = new CheckBox {
                GridRow    = 1,
                GridColumn = 1
            };
            isPhysicalCheckBox.Click += (sender, args) => {
                if (sender is CheckBox checkBox)
                {
                    TogglePhysical(checkBox.IsPressed);
                }
                skipNextMouseClicked = true;
            };
            grid.Widgets.Add(isPhysicalCheckBox);

            grid.Widgets.Add(new Label {
                Text       = "IsBronch",
                GridRow    = 2,
                GridColumn = 0,
            });
            isBronchCheckbox = new CheckBox {
                GridRow    = 2,
                GridColumn = 1
            };
            isBronchCheckbox.Click += (sender, args) => {
                if (sender is CheckBox checkBox)
                {
                    ToggleSprite(checkBox.IsPressed);
                }
                skipNextMouseClicked = true;
            };
            grid.Widgets.Add(isBronchCheckbox);

            stack.Widgets.Add(grid);

            Desktop.Root = stack;
        }