1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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;
- }
- }
|