forked from oldnapalm/CommunityRaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMissionSuccessfulScreen.cs
129 lines (106 loc) · 4.7 KB
/
MissionSuccessfulScreen.cs
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Drawing;
using GTA;
using GTA.Native;
using NativeUI;
using Font = GTA.Font;
namespace CommunityRaces
{
public delegate void EmptyArgs();
public class MissionPassedScreen
{
public event EmptyArgs OnContinueHit;
public string Title { get; set; }
private List<Tuple<string, string, TickboxState>> _items = new List<Tuple<string, string, TickboxState>>();
private int _completionRate;
private Medal _medal;
public bool Visible { get; set; }
public MissionPassedScreen(string title, int completionRate, Medal medal)
{
Title = title;
_completionRate = completionRate;
_medal = medal;
Visible = false;
}
public void AddItem(string label, string status, TickboxState state)
{
_items.Add(new Tuple<string, string, TickboxState>(label, status, state));
}
public void Show()
{
Visible = true;
}
public void Draw()
{
if (!Visible) return;
SizeF res = UIMenu.GetScreenResolutionMaintainRatio();
int middle = Convert.ToInt32(res.Width / 2);
new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size(Convert.ToInt32(res.Width), 450 + (_items.Count * 40)),
0f, Color.FromArgb(200, 255, 255, 255)).Draw();
new UIResText("race completed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, UIResText.Alignment.Centered).Draw();
new UIResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();
new UIResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();
for (int i = 0; i < _items.Count; i++)
{
new UIResText(_items[i].Item1, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Left).Draw();
new UIResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
if (_items[i].Item3 == TickboxState.None) continue;
string spriteName = "shop_box_blank";
switch (_items[i].Item3)
{
case TickboxState.Tick:
spriteName = "shop_box_tick";
break;
case TickboxState.Cross:
spriteName = "shop_box_cross";
break;
}
new Sprite("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48)).Draw();
}
new UIResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();
new UIResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
new UIResText(_completionRate + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
string medalSprite = "bronzemedal";
switch (_medal)
{
case Medal.Silver:
medalSprite = "silvermedal";
break;
case Medal.Gold:
medalSprite = "goldmedal";
break;
}
new Sprite("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * _items.Count)), new Size(32, 32)).Draw();
var scaleform = new Scaleform("instructional_buttons");
scaleform.CallFunction("CLEAR_ALL");
scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
scaleform.CallFunction("CREATE_CONTAINER");
scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
scaleform.Render2D();
if (Game.IsControlJustPressed(0, Control.FrontendAccept))
{
Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
ContinueHit();
}
}
public enum Medal
{
Bronze,
Silver,
Gold
}
public enum TickboxState
{
None,
Empty,
Tick,
Cross,
}
protected virtual void ContinueHit()
{
OnContinueHit?.Invoke();
}
}
}