示例#1
0
        /// <summary> Attaches event handlers to enable highligting vehicles required for unlocking the currenly highlighted one. </summary>
        /// <param name="cell"> The research tree cell to whose content attach event handlers to. </param>
        private void AttachEventHandlers(ResearchTreeCellControl cell)
        {
            foreach (var vehicleControl in cell.VehicleControls.Values)
            {
                _cellVehicleControls.Add(vehicleControl.Vehicle.GaijinId, vehicleControl);

                if (string.IsNullOrWhiteSpace(vehicleControl.Vehicle.RequiredVehicleGaijinId))
                {
                    continue;
                }

                vehicleControl.MouseEnter += OnMouseEnter;
                vehicleControl.MouseLeave += OnMouseLeave;
            }
        }
示例#2
0
        /// <summary> Adds the given cell to the grid, adding a border at the bottom if the current row is the last one in the specified rank. </summary>
        /// <param name="cell"> The research tree cell to add. </param>
        /// <param name="rank"> The current vehicle rank. </param>
        /// <param name="rowIndex"> The index of the current row. </param>
        /// <param name="columnIndex"> The index of the current column. </param>
        private void AddCell(ResearchTreeCellControl cell, ResearchTreeRank rank, int rowIndex, int columnIndex)
        {
            var rowNumber = rowIndex + EInteger.Number.One;

            if (rowNumber == rank.MaximumRowNumber)
            {
                var cellWithBottomBorder = new Border()
                {
                    Style = this.GetStyle(EStyleKey.Border.RankDivider),
                    Child = cell,
                };

                _grid.Add(cellWithBottomBorder, columnIndex, rowIndex);
            }
            else
            {
                _grid.Add(cell, columnIndex, rowIndex);
            }
        }
示例#3
0
        /// <summary> Populates the <see cref="_grid"/> with content cells. </summary>
        /// <param name="branch"> The research tree branch to create cells with. </param>
        /// <param name="enabledVehicleGaijinIds"> Gaijin IDs of vehicles enabled by dafault. </param>
        /// <param name="loadingTracker"> An instance of a presenter to communicate with the GUI loading window. </param>
        internal void Populate(ResearchTreeBranch branch, IEnumerable <string> enabledVehicleGaijinIds, IGuiLoadingWindowPresenter loadingTracker)
        {
            if (branch is null || IsPopulated)
            {
                return;
            }

            _researchTreeBranch = branch;

            loadingTracker.RanksPopulated  = EInteger.Number.Zero;
            loadingTracker.RanksToPopulate = _researchTreeBranch.Count;

            foreach (var rankKeyValuePair in _researchTreeBranch)
            {
                var rankKey = rankKeyValuePair.Key;
                var rank    = rankKeyValuePair.Value;

                loadingTracker.CurrentlyPopulatedRank = rankKey.ToString();
                loadingTracker.RowsPopulated          = EInteger.Number.Zero;
                loadingTracker.RowsToPopulate         = rank.MaximumRowNumber - rank.StartingRowNumber.Value + EInteger.Number.One;

                PopulateRankHeader(rankKey, rank);

                for (var rowNumber = rank.StartingRowNumber.Value; rowNumber <= rank.MaximumRowNumber; rowNumber++)
                {
                    var rowIndex = rowNumber - EInteger.Number.One;

                    loadingTracker.ColumnsPopulated  = EInteger.Number.Zero;
                    loadingTracker.ColumnsToPopulate = _researchTreeBranch.ColumnCount;

                    for (var columnNumber = EInteger.Number.One; columnNumber <= _researchTreeBranch.ColumnCount; columnNumber++)
                    {
                        var rowNumberRelativeToRank = rowNumber - rank.StartingRowNumber.Value + EInteger.Number.One;
                        var columnIndex             = columnNumber;
                        var cell = new ResearchTreeCellControl()
                        {
                            Style = this.GetStyle(_styleKeys[rankKey]),
                        }.With(_presenter);

                        var cellVehicles = rank
                                           .GetVehicles(columnNumber, rowNumberRelativeToRank)
                                           .OrderBy(vehicle => vehicle.ResearchTreeData.FolderIndex)
                        ;

                        loadingTracker.CurrentlyProcessedVehicle = cellVehicles.FirstOrDefault()?.ResearchTreeName?.GetLocalisation(WpfSettings.LocalizationLanguage);

                        foreach (var vehicle in cellVehicles)
                        {
                            cell.AddVehicle(vehicle, vehicle.GaijinId.IsIn(enabledVehicleGaijinIds));
                        }

                        AttachEventHandlers(cell);
                        AddCell(cell, rank, rowIndex, columnIndex);

                        _cells.Add(new Tuple <int, int>(columnIndex, rowIndex), cell);

                        loadingTracker.ColumnsPopulated++;
                    }
                    loadingTracker.RowsPopulated++;
                }
                loadingTracker.CurrentlyProcessedVehicle = string.Empty;
                loadingTracker.CurrentlyPopulatedRank    = string.Empty;
                loadingTracker.RanksPopulated++;
            }

            _grid.ColumnDefinitions.First().Width = new GridLength(EInteger.Number.Thirty, GridUnitType.Pixel);

            InitialiseButtons();
        }