/// <summary> /// Constructs a HPIconSpriteGroup instance. /// </summary> /// <param name="metadataView">Reference to the metadata view.</param> /// <param name="condition">The condition for which this sprite group is created.</param> public HPIconSpriteGroup(IMetadataView metadataView, MapObjectConditionEnum condition) { if (metadataView == null) { throw new ArgumentNullException("metadataView"); } this.metadataView = metadataView; this.condition = condition; }
/// <see cref="UIObject.Render_i"/> protected override void Render_i(IUIRenderContext renderContext) { if (this.layoutIndex >= this.selectionDetailsView.SelectionCount) { return; } int objectID = this.selectionDetailsView.GetObjectID(this.layoutIndex); MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(objectID); if (!this.hpIndicatorSprites.ContainsKey(hpCondition)) { return; } SpriteRenderInfo hpSprite = this.mapObjectDetailsView.GetSmallHPIcon(objectID); renderContext.RenderSprite(this.hpIndicatorSprites[hpCondition][hpSprite.Index], hpSprite.DisplayCoords, hpSprite.Section); }
/// <see cref="UIObject.Render_i"/> protected sealed override void Render_i(IUIRenderContext renderContext) { base.Render_i(renderContext); /// Check if we are online and in single selection mode. if (this.ConnectionStatus != ConnectionStatusEnum.Online) { return; } if (this.selectionDetailsView.SelectionCount != 1) { return; } /// Retrieve the ID and the HP condition of the object. int mapObjectID = this.selectionDetailsView.GetObjectID(0); MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(mapObjectID); if (!this.hpIndicatorSprites.ContainsKey(hpCondition)) { return; } /// Render the big icon of the selected object. SpriteRenderInfo hpSprite = this.mapObjectDetailsView.GetBigHPIcon(mapObjectID); renderContext.RenderSprite(this.hpIndicatorSprites[hpCondition][hpSprite.Index], RCDetailsPanel.ICON_POS + hpSprite.DisplayCoords, hpSprite.Section); /// Render the typename of the selected object. UIString typeTextToRender = this.objectTypeTexts[this.mapObjectDetailsView.GetObjectTypeID(mapObjectID)]; RCIntVector typeNameStringPos = TYPENAME_STRING_MIDDLE_POS - new RCIntVector(typeTextToRender.Width / 2, 0); renderContext.RenderString(typeTextToRender, typeNameStringPos); /// Render the HP of the selected object. int currentHP = this.mapObjectDetailsView.GetCurrentHP(mapObjectID); if (currentHP != -1) { int maxHP = this.mapObjectDetailsView.GetMaxHP(mapObjectID); UIString hpTextToRender = this.hpTexts[hpCondition]; hpTextToRender[0] = currentHP; hpTextToRender[1] = maxHP; RCIntVector hpStringPos = HP_STRING_MIDDLE_POS - new RCIntVector(hpTextToRender.Width / 2, 0); renderContext.RenderString(hpTextToRender, hpStringPos); } /// Render the energy of the selected object. int currentEnergy = this.mapObjectDetailsView.GetCurrentEnergy(mapObjectID); if (currentEnergy != -1) { int maxEnergy = this.mapObjectDetailsView.GetMaxEnergy(mapObjectID); this.energyText[0] = currentEnergy; this.energyText[1] = maxEnergy; RCIntVector energyStringPos = ENERGY_STRING_MIDDLE_POS - new RCIntVector(this.energyText.Width / 2, 0); renderContext.RenderString(this.energyText, energyStringPos); } }
/// <see cref="RCMapDisplayExtension.RenderEx_i"/> protected override void RenderEx_i(IUIRenderContext renderContext) { /// Render the selection indicators of the selected map objects. List <SelIndicatorRenderInfo> selectionIndicators = this.selectionIndicatorView.GetVisibleSelIndicators(); foreach (SelIndicatorRenderInfo selIndicator in selectionIndicators) { /// Render the indicator rectangle. if (selIndicator.SelIndicatorType == SelIndicatorTypeEnum.Friendly) { renderContext.RenderRectangle(this.greenBrush, selIndicator.IndicatorRect); } else if (selIndicator.SelIndicatorType == SelIndicatorTypeEnum.Neutral) { renderContext.RenderRectangle(this.yellowBrush, selIndicator.IndicatorRect); } else if (selIndicator.SelIndicatorType == SelIndicatorTypeEnum.Enemy) { renderContext.RenderRectangle(this.redBrush, selIndicator.IndicatorRect); } /// Render the shield if exists. int indicatorIndex = 0; if (selIndicator.ShieldNormalized != -1) { int lineWidth = (int)(selIndicator.IndicatorRect.Width * selIndicator.ShieldNormalized); if (lineWidth > 0) { renderContext.RenderRectangle(this.lightBlueBrush, new RCIntRectangle(selIndicator.IndicatorRect.Left, selIndicator.IndicatorRect.Bottom + indicatorIndex, lineWidth, 1)); } indicatorIndex++; } /// Render the HP if exists. if (selIndicator.HpNormalized != -1) { int lineWidth = (int)(selIndicator.IndicatorRect.Width * selIndicator.HpNormalized); if (lineWidth > 0) { MapObjectConditionEnum hpCondition = this.mapObjectDetailsView.GetHPCondition(selIndicator.ObjectID); renderContext.RenderRectangle(this.hpConditionBrushes[hpCondition], new RCIntRectangle(selIndicator.IndicatorRect.Left, selIndicator.IndicatorRect.Bottom + indicatorIndex, lineWidth, 1)); } indicatorIndex++; } /// Render the energy if exists in case of friendly objects. if (selIndicator.EnergyNormalized != -1 && selIndicator.SelIndicatorType == SelIndicatorTypeEnum.Friendly) { int lineWidth = (int)(selIndicator.IndicatorRect.Width * selIndicator.EnergyNormalized); if (lineWidth > 0) { renderContext.RenderRectangle(this.lightMagentaBrush, new RCIntRectangle(selIndicator.IndicatorRect.Left, selIndicator.IndicatorRect.Bottom + indicatorIndex, lineWidth, 1)); } } } }