forked from Guad/NativeUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerBars.cs
More file actions
115 lines (92 loc) · 3.34 KB
/
TimerBars.cs
File metadata and controls
115 lines (92 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System.Collections.Generic;
using System.Drawing;
using GTA;
using GTA.UI;
using Font = GTA.UI.Font;
namespace NativeUI
{
public abstract class TimerBarBase
{
public string Label { get; set; }
public TimerBarBase(string label)
{
Label = label;
}
public virtual void Draw(int interval)
{
SizeF res = UIMenu.GetScreenResolutionMantainRatio();
Point safe = UIMenu.GetSafezoneBounds();
new UIResText(Label, new Point((int)res.Width - safe.X - 180, (int)res.Height - safe.Y - (30 + (4 * interval))), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
new Sprite("timerbars", "all_black_bg", new Point((int)res.Width - safe.X - 298, (int)res.Height - safe.Y - (40 + (4 * interval))), new Size(300, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();
Screen.HideHudComponentThisFrame(HudComponent.AreaName);
Screen.HideHudComponentThisFrame(HudComponent.StreetName);
Screen.HideHudComponentThisFrame(HudComponent.VehicleName);
}
}
public class TextTimerBar : TimerBarBase
{
public string Text { get; set; }
public TextTimerBar(string label, string text) : base(label)
{
Text = text;
}
public override void Draw(int interval)
{
SizeF res = UIMenu.GetScreenResolutionMantainRatio();
Point safe = UIMenu.GetSafezoneBounds();
base.Draw(interval);
new UIResText(Text, new Point((int)res.Width - safe.X - 10, (int)res.Height - safe.Y - (42 + (4 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
}
}
public class BarTimerBar : TimerBarBase
{
public string Text { get; set; }
/// <summary>
/// Bar percentage. Goes from 0 to 1.
/// </summary>
public float Percentage { get; set; }
public Color BackgroundColor { get; set; }
public Color ForegroundColor { get; set; }
public BarTimerBar(string label) : base(label)
{
BackgroundColor = Color.DarkRed;
ForegroundColor = Color.Red;
}
public override void Draw(int interval)
{
SizeF res = UIMenu.GetScreenResolutionMantainRatio();
Point safe = UIMenu.GetSafezoneBounds();
base.Draw(interval);
var start = new Point((int)res.Width - safe.X - 160, (int)res.Height - safe.Y - (28 + (4 * interval)));
new UIResRectangle(start, new Size(150, 15), BackgroundColor).Draw();
new UIResRectangle(start, new Size((int)(150 * Percentage), 15), ForegroundColor).Draw();
}
}
public class TimerBarPool
{
private static List<TimerBarBase> _bars = new List<TimerBarBase>();
public TimerBarPool()
{
_bars = new List<TimerBarBase>();
}
public List<TimerBarBase> ToList()
{
return _bars;
}
public void Add(TimerBarBase timer)
{
_bars.Add(timer);
}
public void Remove(TimerBarBase timer)
{
_bars.Remove(timer);
}
public void Draw()
{
for (int i = 0; i < _bars.Count; i++)
{
_bars[i].Draw(i * 10);
}
}
}
}