#if FIVEM
using CitizenFX.Core.UI;
#elif RAGEMP
using RAGE.Game;
#elif SHVDN3
using GTA.UI;
#endif
using LemonUI.Elements;
using System.Drawing;
namespace LemonUI.TimerBars
{
///
/// Represents a Bar with text information shown in the bottom right.
///
public class TimerBar : IDrawable
{
#region Constant Fields
///
/// The separation between the different timer bars.
///
internal const float separation = 6.25f;
///
/// The width of the background.
///
internal const float backgroundWidth = 220;
///
/// The height of the background.
///
internal const float backgroundHeight = 37;
#endregion
#region Private Fields
private string rawTitle = string.Empty;
private string rawInfo = string.Empty;
#endregion
#region Internal Fields
///
/// The background of the timer bar.
///
internal protected readonly ScaledTexture background = new ScaledTexture("timerbars", "all_black_bg")
{
Color = Color.FromArgb(160, 255, 255, 255)
};
///
/// The title of the timer bar.
///
internal protected readonly ScaledText title = new ScaledText(PointF.Empty, string.Empty, 0.29f)
{
Alignment = Alignment.Right,
WordWrap = 1000
};
///
/// The information of the Timer Bar.
///
internal protected readonly ScaledText info = new ScaledText(PointF.Empty, string.Empty, 0.5f)
{
Alignment = Alignment.Right,
WordWrap = 1000
};
#endregion
#region Public Properties
///
/// The title of the bar, shown on the left.
///
public string Title
{
get => rawTitle;
set
{
rawTitle = value;
title.Text = value.ToUpperInvariant();
}
}
///
/// The information shown on the right.
///
public string Info
{
get => rawInfo;
set
{
rawInfo = value;
info.Text = value.ToUpperInvariant();
}
}
///
/// The Width of the information text.
///
public float InfoWidth => info.Width;
///
/// The color of the information text.
///
public Color Color
{
get => info.Color;
set => info.Color = value;
}
#endregion
#region Constructors
///
/// Creates a new with the specified Title and Value.
///
/// The title of the bar.
/// The information shown on the bar.
public TimerBar(string title, string info)
{
Title = title;
Info = info;
}
#endregion
#region Public Functions
///
/// Recalculates the position of the timer bar elements based on the location of it on the screen.
///
/// The Top Left position of the Timer Bar.
public virtual void Recalculate(PointF pos)
{
background.Position = pos;
background.Size = new SizeF(backgroundWidth, backgroundHeight);
title.Position = new PointF(pos.X + 91, pos.Y + 8);
info.Position = new PointF(pos.X + 218, pos.Y - 3);
}
///
/// Draws the timer bar information.
///
public virtual void Draw()
{
background.Draw();
title.Draw();
info.Draw();
}
#endregion
}
}