pluginlocalprofilescene.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. //Mission = "ChernarusPlus"
  3. typedef CfgParamString DefCfgParamString
  4. //InitTime = 220
  5. typedef CfgParamInt DefCfgParamInt
  6. //InitWeatherRain = 0.5
  7. typedef CfgParamFloat DefCfgParamFloat
  8. //InitWeatherFog = 0.3
  9. typedef CfgParamFloat DefCfgParamFloat
  10. //SceneObjectsCount = 1
  11. typedef CfgParamInt DefCfgParamInt
  12. */
  13. class PluginLocalProfileScene extends PluginLocalProfile
  14. {
  15. private const string FILE_ROOT = "$saves:";
  16. private const string FILE_ROOT_SCENES = "Scenes";
  17. private const string PARAM_MISSION = "Mission";
  18. private const string PARAM_TIME = "InitTime";
  19. private const string PARAM_RAIN = "InitWeatherRain";
  20. private const string PARAM_FOG = "InitWeatherFog";
  21. private const string PARAM_OBJ_COUNT = "SceneObjectsCount";
  22. private const string PARAM_OBJ_NAME = "SceneObject";
  23. private string m_FileSceneName;
  24. //========================================
  25. // GetPathScenes
  26. //========================================
  27. string GetPathScenes()
  28. {
  29. return FILE_ROOT+"\\"+FILE_ROOT_SCENES;
  30. }
  31. //========================================
  32. // GetFileName
  33. //========================================
  34. override string GetFileName()
  35. {
  36. string file_name = GetPathScenes()+"\\"+m_FileSceneName;
  37. return file_name;
  38. }
  39. //========================================
  40. // OnInit
  41. //========================================
  42. override void OnInit()
  43. {
  44. super.OnInit();
  45. }
  46. //========================================
  47. // GetSceneList
  48. //========================================
  49. TStringArray GetSceneList()
  50. {
  51. if ( !FileExist( GetPathScenes() ) )
  52. {
  53. MakeDirectory( GetPathScenes() );
  54. }
  55. string file_name;
  56. int file_attr;
  57. int flags;
  58. TStringArray list = new TStringArray;
  59. string path_find_pattern = GetPathScenes()+"/*.scene";
  60. FindFileHandle file_handler = FindFile(path_find_pattern, file_name, file_attr, flags);
  61. bool found = true;
  62. while ( found )
  63. {
  64. list.Insert(file_name);
  65. found = FindNextFile(file_handler, file_name, file_attr);
  66. }
  67. return list;
  68. }
  69. //========================================
  70. // SceneSave
  71. //========================================
  72. void SceneSave(SceneData scene)
  73. {
  74. m_FileSceneName = scene.GetNameScene()+".scene";
  75. array<ref SceneObject> objects = scene.GetSceneObjects();
  76. // Save Mission Name
  77. SetParameterString(PARAM_MISSION, scene.GetNameMission(), false);
  78. //Save Init Time
  79. SetParameterFloat(PARAM_TIME, scene.GetInitTime(), false);
  80. //Save Init Weather Rain
  81. SetParameterFloat(PARAM_RAIN, scene.GetInitRain(), false);
  82. //Save Init Weather Rain
  83. SetParameterFloat(PARAM_FOG, scene.GetInitFog(), false);
  84. // Save Count Of missions
  85. SetParameterInt(PARAM_OBJ_COUNT, objects.Count(), false);
  86. for ( int i = 0; i < objects.Count(); ++i )
  87. {
  88. SceneObject obj = objects.Get(i);
  89. string param_name = PARAM_OBJ_NAME+"_"+i.ToString();
  90. Print(param_name);
  91. SetSubParameterInArray (param_name, 0, "ClassName", obj.GetTypeName(), false);
  92. }
  93. SaveConfigToFile();
  94. }
  95. }