Ejemplo n.º 1
0
        public ConvoyDeploymentPage(
            ConvoyDeployment Deployment, UnitConfigurationRenderer Renderer, DeploymentPane Pane)
        {
            _Deployment = Deployment;
            _Renderer   = Renderer;

            _MoveUpButton.OnClick   += HandleMoveUp;
            _MoveDownButton.OnClick += HandleMoveDown;
            _LoadButton.OnClick     += HandleLoadButton;
            _UnloadButton.OnClick   += HandleUnloadButton;

            _Selection = new ValuedScrollCollection <SingularUnitSelectionOption, StackView>("deployment-select");

            var units = Deployment.Units.ToList();

            units.Sort(new FluentComparator <Unit>(i => i.Configuration.IsVehicle)
                       .ThenCompare(i => i.Configuration.IsArmored)
                       .ThenCompare(i => i.Configuration.UnitClass != UnitClass.TRANSPORT)
                       .ThenCompare(i => i.Configuration.Movement)
                       .Invert());
            foreach (Unit u in units)
            {
                u.OnLoad   += HandleLoad;
                u.OnUnload += HandleUnload;

                var option = new SingularUnitSelectionOption("deployment-selection-option", u, _Renderer);
                _Selection.Add(option);
            }

            _Selection.Position      = new Vector2f(0, 48);
            _LoadButton.Position     = new Vector2f(0, Pane.Size.Y - _LoadButton.Size.Y - 32);
            _UnloadButton.Position   = new Vector2f(_LoadButton.Size.X + 8, Pane.Size.Y - _UnloadButton.Size.Y - 32);
            _MoveUpButton.Position   = new Vector2f(0, Pane.Size.Y - _LoadButton.Size.Y - _MoveUpButton.Size.Y - 36);
            _MoveDownButton.Position = new Vector2f(
                _MoveUpButton.Size.X + 8, Pane.Size.Y - _UnloadButton.Size.Y - _MoveDownButton.Size.Y - 36);

            Add(_Selection);
            Add(_LoadButton);
            Add(_UnloadButton);
            Add(_MoveUpButton);
            Add(_MoveDownButton);
        }
        public PositionalDeploymentPage(PositionalDeployment Deployment, UnitConfigurationRenderer Renderer)
        {
            _Deployment = Deployment;
            _Renderer   = Renderer;

            _Selection =
                new ValuedScrollCollection <GroupedUnitSelectionOption, HomogenousStackView>("deployment-select");
            _Selection.OnChange +=
                (sender, e) => { if (OnSelectedStack != null)
                                 {
                                     OnSelectedStack(this, EventArgs.Empty);
                                 }
            };

            foreach (var g in Deployment.Units.Where(i => i.Position == null).GroupBy(i => i.Configuration))
            {
                _Selection.Add(
                    new GroupedUnitSelectionOption(
                        "deployment-selection-option", "deployment-selection-option-overlay", g, _Renderer));
            }

            _Selection.Position = new Vector2f(0, 48);
            Add(_Selection);
        }