Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DrawValueBar()

static float Terraria.IngameOptions.DrawValueBar ( SpriteBatch sb,
float scale,
float perc,
int lockState = 0,
Utils::ColorLerpMethod colorMethod = null )
inlinestatic

Definition at line 1461 of file IngameOptions.cs.

1462 {
1463 if (colorMethod == null)
1464 {
1465 colorMethod = Utils.ColorLerp_BlackToWhite;
1466 }
1468 Vector2 vector = new Vector2(value.Width, value.Height) * scale;
1469 valuePosition.X -= (int)vector.X;
1470 Rectangle rectangle = new Rectangle((int)valuePosition.X, (int)valuePosition.Y - (int)vector.Y / 2, (int)vector.X, (int)vector.Y);
1471 Rectangle destinationRectangle = rectangle;
1473 int num = 167;
1474 float num2 = (float)rectangle.X + 5f * scale;
1475 float num3 = (float)rectangle.Y + 4f * scale;
1476 for (float num4 = 0f; num4 < (float)num; num4 += 1f)
1477 {
1478 float percent = num4 / (float)num;
1479 sb.Draw(TextureAssets.ColorBlip.Value, new Vector2(num2 + num4 * scale, num3), null, colorMethod(percent), 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
1480 }
1481 rectangle.Inflate((int)(-5f * scale), 0);
1482 bool flag = rectangle.Contains(new Point(Main.mouseX, Main.mouseY));
1483 if (lockState == 2)
1484 {
1485 flag = false;
1486 }
1487 if (flag || lockState == 1)
1488 {
1489 sb.Draw(TextureAssets.ColorHighlight.Value, destinationRectangle, Main.OurFavoriteColor);
1490 }
1491 sb.Draw(TextureAssets.ColorSlider.Value, new Vector2(num2 + 167f * scale * perc, num3 + 4f * scale), null, Color.White, 0f, new Vector2(0.5f * (float)TextureAssets.ColorSlider.Width(), 0.5f * (float)TextureAssets.ColorSlider.Height()), scale, SpriteEffects.None, 0f);
1492 if (Main.mouseX >= rectangle.X && Main.mouseX <= rectangle.X + rectangle.Width)
1493 {
1494 inBar = flag;
1495 return (float)(Main.mouseX - rectangle.X) / (float)rectangle.Width;
1496 }
1497 inBar = false;
1498 if (rectangle.X >= Main.mouseX)
1499 {
1500 return 0f;
1501 }
1502 return 1f;
1503 }
void Draw(Texture2D texture, Vector2 position, Color color)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static Asset< Texture2D > ColorHighlight
static Asset< Texture2D > ColorSlider
static Asset< Texture2D > ColorBlip
static Asset< Texture2D > ColorBar
static Vector2 valuePosition

References Terraria.GameContent.TextureAssets.ColorBar, Terraria.GameContent.TextureAssets.ColorBlip, Terraria.GameContent.TextureAssets.ColorHighlight, Terraria.Utils.ColorLerp_BlackToWhite(), Terraria.GameContent.TextureAssets.ColorSlider, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(), Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.OurFavoriteColor, Microsoft.Xna.Framework.Graphics.Point, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Color.White, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.IngameOptions.Draw(), Terraria.Main.DrawMenu(), and Terraria.GameContent.UI.Elements.UIKeybindingSliderItem.DrawSelf().