-
Notifications
You must be signed in to change notification settings - Fork 78
/
ObjectPreview.cs
48 lines (44 loc) · 1.31 KB
/
ObjectPreview.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
using System;
using System.Collections.Generic;
using System.Drawing;
using GTA;
using GTA.Native;
using NativeUI;
namespace MapEditor
{
public static class ObjectPreview
{
private static int globalCounter = 0;
public static Model LoadObject(int hash)
{
int counter = 0;
var res = UIMenu.GetScreenResolutionMantainRatio();
var m = new Model(hash);
if (!m.IsValid || !m.IsInCdImage)
{
if (!ObjectDatabase.InvalidHashes.Contains(hash))
{
ObjectDatabase.InvalidHashes.Add(hash);
ObjectDatabase.SaveInvalidHashes();
}
return null;
}
globalCounter++;
var sc = new Scaleform(0);
sc.Load("instructional_buttons");
sc.CallFunction("CLEAR_ALL");
sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
sc.CallFunction("CREATE_CONTAINER");
sc.CallFunction("SET_DATA_SLOT", 0, "b_50", Translation.Translate("Loading Model"));
sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
while (!m.IsLoaded && counter < 200)
{
m.Request();
Script.Yield();
counter++;
sc.Render2D();
}
return m;
}
}
}