File size: 1,477 Bytes
24b81cb |
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 |
class CreditsLoader
{
protected static const string JSON_FILE_PATH = "scripts/data/credits.json";
static void CreateTestJson()
{
string nameDepartment = "Department";
string nameSection = "Section";
string nameLine = "Line";
JsonDataCredits data = new JsonDataCredits();
data.Departments = new array<ref JsonDataCreditsDepartment>;
for (int index_dep = 0; index_dep < 3; ++index_dep)
{
JsonDataCreditsDepartment department = new JsonDataCreditsDepartment();
department.Sections = new array<ref JsonDataCreditsSection>();
department.DepartmentName = (nameDepartment +" "+ index_dep);
for (int index_sec = 0; index_sec < 4; ++index_sec)
{
JsonDataCreditsSection section = new JsonDataCreditsSection();
section.SectionLines = new array<string>;
section.SectionName = (nameSection +" "+ index_sec);
int linesCount = Math.RandomInt(3, 10);
for (int i = 0; i < linesCount; ++i)
{
section.SectionLines.Insert(nameLine +" "+ i);
}
department.Sections.Insert(section);
}
data.Departments.Insert(department);
}
string errorMessage;
if (!JsonFileLoader<ref JsonDataCredits>.SaveFile(JSON_FILE_PATH, data, errorMessage))
ErrorEx(errorMessage);
}
static JsonDataCredits GetData()
{
string errorMessage;
JsonDataCredits data;
if (!JsonFileLoader<ref JsonDataCredits>.LoadFile(JSON_FILE_PATH, data, errorMessage))
ErrorEx(errorMessage);
return data;
}
}
|