Example #1
0
        void HandleUnload(object Sender, ValuedEventArgs <Unit> E)
        {
            var u             = (Unit)Sender;
            var carrierOption = _Selection.FirstOrDefault(i => i.Unit == u);
            var option        = new SingularUnitSelectionOption("deployment-selection-option", E.Value, _Renderer);

            _Selection.Insert(Math.Min(_Selection.Count() - 1, _Selection.ToList().IndexOf(carrierOption) + 1), option);
            carrierOption.Value.Remove(E.Value);
        }
Example #2
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);
        }