//////////////// public override void Draw(SpriteBatch sb) { base.Draw(sb); // float perc = this.Objective.PercentComplete.HasValue ? this.Objective.PercentComplete.Value : 0f; CalculatedStyle style = this.GetDimensions(); Rectangle rect = style.ToRectangle(); if (perc > 0f && perc < 1f) { rect.X += 8; rect.Y += 56; rect.Width -= 16; rect.Height -= 64; Rectangle percRect = rect; percRect.Width = (int)((float)percRect.Width * perc); DrawLibraries.DrawBorderedRect( sb: sb, bgColor: Color.Lime, borderColor: null, rect: percRect, borderWidth: 2 ); DrawLibraries.DrawBorderedRect( sb: sb, bgColor: null, borderColor: Color.White, rect: rect, borderWidth: 2 ); } if (perc >= 1f) { Vector2 dim = Main.fontDeathText.MeasureString("Complete"); sb.DrawString( spriteFont: Main.fontDeathText, text: "Complete", position: new Vector2( rect.X + (rect.Width / 2), rect.Y + (rect.Height / 2) ), color: Color.Lime * 0.5f, rotation: 0f, origin: dim * 0.5f, scale: 1.25f, effects: SpriteEffects.None, layerDepth: 0f ); } }
//////////////// /// @private protected override void DrawSelf(SpriteBatch sb) { Rectangle fullRect = this.GetSliderRectangle(); Rectangle leftRect = this.LeftArrowElem.GetInnerDimensions().ToRectangle(); bool?highlight = null; if (leftRect.Contains(Main.mouseX, Main.mouseY)) { highlight = false; } if (!highlight.HasValue) { Rectangle rightRect = this.RightArrowElem.GetInnerDimensions().ToRectangle(); if (rightRect.Contains(Main.mouseX, Main.mouseY)) { highlight = false; } } Rectangle textRect = this.NumericInput.GetInnerDimensions().ToRectangle(); textRect.X -= 12; textRect.Width += 12; if (!highlight.HasValue) { if (textRect.Contains(Main.mouseX, Main.mouseY)) { this.NumericInput.TextColor = Color.Yellow; highlight = false; } } if (highlight != false) { this.NumericInput.TextColor = Color.White; } if (this.NumericInput.HasFocus) { highlight = false; } float percentValue = UISlider.GetPercentOfSliderValue(this.RememberedInputValue, this.Range.Min, this.Range.Max); base.DrawSelf(sb); UISlider.DrawSlider(sb, fullRect, percentValue, this.InnerBarShader, highlight); if (textRect.Contains(Main.mouseX, Main.mouseY)) { if (!this.NumericInput.HasFocus) { var inputLitRect = textRect; inputLitRect.Y += 6; inputLitRect.Height -= 6; DrawLibraries.DrawBorderedRect(sb, null, Color.Yellow * 0.5f, inputLitRect, 2); } } }