/// <inheritdoc /> protected override void InitContent() { base.InitContent(); var person = _uiState.ActiveActor?.Actor?.Person; if (person is null) { throw new InvalidOperationException("Active person must be selected before this dialog was opened."); } var evolutionModule = person.GetModuleSafe <IEvolutionModule>(); if (evolutionModule is null) { throw new InvalidOperationException( "Active person must have attributes to shown in this dialog."); } var currentAttributeItemList = new List <PersonPerkUiItem>(); var colWidth = ContentRect.Width / 2; var MAX_ITEM_IN_ROW = 8; var MAX_ITEM_COUNT = MAX_ITEM_IN_ROW * 2; var profession = CreateProfession( ((HumanPerson)person).PersonEquipmentTemplate, ((HumanPerson)person).PersonEquipmentDescriptionTemplate); var perks = evolutionModule.GetArchievedPerks().Take(MAX_ITEM_COUNT).ToArray(); var allPerks = new[] { profession }.Concat(perks).ToArray(); for (var itemIndex = 0; itemIndex < allPerks.Length; itemIndex++) { var perk = allPerks[itemIndex]; var colIndex = itemIndex / MAX_ITEM_IN_ROW; var rowIndex = itemIndex % MAX_ITEM_IN_ROW; var relativeX = colWidth * colIndex; var relativeY = rowIndex * (ATTRIBUTE_ITEM_SIZE + ATTRIBUTE_ITEM_SPACING); var uiRect = new Rectangle( ContentRect.Left + relativeX, ContentRect.Top + relativeY, ATTRIBUTE_ITEM_SIZE, ATTRIBUTE_ITEM_SIZE); var uiItem = new PersonPerkUiItem(perk, itemIndex, uiRect); currentAttributeItemList.Add(uiItem); } _currentAttributesItems = currentAttributeItemList.ToArray(); }
private void DrawPerk(PersonPerkUiItem item, SpriteBatch spriteBatch) { var sourceRect = GetPerkIcon(item.Perk); spriteBatch.Draw(_uiContentStorage.GetAttributeBackgroundTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), Color.White); spriteBatch.Draw(_uiContentStorage.GetAttributeIconsTexture(), new Vector2(item.UiRect.Left, item.UiRect.Top), sourceRect, Color.White); var attributeTitle = GetPerkTitle(item.Perk); spriteBatch.DrawString( _uiContentStorage.GetButtonFont(), attributeTitle, new Vector2(item.UiRect.Right + ATTRIBUTE_ITEM_SPACING, item.UiRect.Top), new Color(195, 180, 155)); }