Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginlocalprofilescene.c
Go to the documentation of this file.
1 /*
2 //Mission = "ChernarusPlus"
3 typedef CfgParamString DefCfgParamString
4 
5 //InitTime = 220
6 typedef CfgParamInt DefCfgParamInt
7 
8 //InitWeatherRain = 0.5
9 typedef CfgParamFloat DefCfgParamFloat
10 
11 //InitWeatherFog = 0.3
12 typedef CfgParamFloat DefCfgParamFloat
13 
14 //SceneObjectsCount = 1
15 typedef CfgParamInt DefCfgParamInt
16 */
17 
18 class PluginLocalProfileScene extends PluginLocalProfile
19 {
20  private const string FILE_ROOT = "$saves:";
21  private const string FILE_ROOT_SCENES = "Scenes";
22  private const string PARAM_MISSION = "Mission";
23  private const string PARAM_TIME = "InitTime";
24  private const string PARAM_RAIN = "InitWeatherRain";
25  private const string PARAM_FOG = "InitWeatherFog";
26  private const string PARAM_OBJ_COUNT = "SceneObjectsCount";
27  private const string PARAM_OBJ_NAME = "SceneObject";
28 
29  private string m_FileSceneName;
30 
31  //========================================
32  // GetPathScenes
33  //========================================
34  string GetPathScenes()
35  {
36  return FILE_ROOT+"\\"+FILE_ROOT_SCENES;
37  }
38 
39  //========================================
40  // GetFileName
41  //========================================
42  override string GetFileName()
43  {
44  string file_name = GetPathScenes()+"\\"+m_FileSceneName;
45  return file_name;
46  }
47 
48  //========================================
49  // OnInit
50  //========================================
51  override void OnInit()
52  {
53  super.OnInit();
54  }
55 
56  //========================================
57  // GetSceneList
58  //========================================
59  TStringArray GetSceneList()
60  {
61  if ( !FileExist( GetPathScenes() ) )
62  {
63  MakeDirectory( GetPathScenes() );
64  }
65 
66  string file_name;
67  int file_attr;
68  int flags;
69  TStringArray list = new TStringArray;
70 
71  string path_find_pattern = GetPathScenes()+"/*.scene";
72  FindFileHandle file_handler = FindFile(path_find_pattern, file_name, file_attr, flags);
73 
74  bool found = true;
75  while ( found )
76  {
77  list.Insert(file_name);
78 
79  found = FindNextFile(file_handler, file_name, file_attr);
80  }
81 
82  return list;
83  }
84 
85  //========================================
86  // SceneSave
87  //========================================
88  void SceneSave(SceneData scene)
89  {
90  m_FileSceneName = scene.GetNameScene()+".scene";
91 
92  array<ref SceneObject> objects = scene.GetSceneObjects();
93 
94  // Save Mission Name
95  SetParameterString(PARAM_MISSION, scene.GetNameMission(), false);
96  //Save Init Time
97  SetParameterFloat(PARAM_TIME, scene.GetInitTime(), false);
98  //Save Init Weather Rain
99  SetParameterFloat(PARAM_RAIN, scene.GetInitRain(), false);
100  //Save Init Weather Rain
101  SetParameterFloat(PARAM_FOG, scene.GetInitFog(), false);
102  // Save Count Of missions
103  SetParameterInt(PARAM_OBJ_COUNT, objects.Count(), false);
104 
105 
106  for ( int i = 0; i < objects.Count(); ++i )
107  {
108  SceneObject obj = objects.Get(i);
109 
110  string param_name = PARAM_OBJ_NAME+"_"+i.ToString();
111  Print(param_name);
112  SetSubParameterInArray (param_name, 0, "ClassName", obj.GetTypeName(), false);
113  }
114 
115 
116  SaveConfigToFile();
117  }
118 }
GetFileName
override string GetFileName()
Definition: pluginlocalenscripthistory.c:7
MakeDirectory
proto native bool MakeDirectory(string name)
Makes a directory.
TStringArray
array< string > TStringArray
Definition: enscript.c:685
PluginLocalProfile
Definition: pluginadditionalinfo.c:1
FileExist
proto bool FileExist(string name)
Check existence of file.
Print
proto void Print(void var)
Prints content of variable to console/log.
FindNextFile
proto bool FindNextFile(FindFileHandle handle, out string fileName, out FileAttr fileAttributes)
SceneObject
Definition: sceneobject.c:1
FindFileHandle
int[] FindFileHandle
Definition: ensystem.c:503
FindFile
enum FindFileFlags FindFile(string pattern, out string fileName, out FileAttr fileAttributes, FindFileFlags flags)
array< string >
OnInit
void OnInit()
Definition: aibehaviour.c:49
SceneData
Definition: scenedata.c:1