Editor Interface.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /******************************************************************************/
  2. namespace Edit{
  3. /******************************************************************************/
  4. enum ELM_TYPE : Byte // Project Element Type
  5. {
  6. ELM_NONE , // None
  7. ELM_FOLDER , // Folder
  8. ELM_ENUM , // Enum
  9. ELM_IMAGE , // Image
  10. ELM_IMAGE_ATLAS, // Image Atlas
  11. ELM_FONT , // Font
  12. ELM_TEXT_STYLE , // Text Style
  13. ELM_PANEL , // Panel
  14. ELM_GUI , // Gui Objects
  15. ELM_SHADER , // Shader
  16. ELM_MTRL , // Material
  17. ELM_WATER_MTRL , // Water Material
  18. ELM_PHYS_MTRL , // Physical Material
  19. ELM_OBJ_CLASS , // Object Class
  20. ELM_OBJ , // Object
  21. ELM_MESH , // Mesh
  22. ELM_SKEL , // Skeleton
  23. ELM_PHYS , // Physical Body
  24. ELM_ANIM , // Animation
  25. ELM_PANEL_IMAGE, // Panel Image
  26. ELM_ICON , // Icon
  27. ELM_ENV , // Environment
  28. ELM_WORLD , // World
  29. ELM_SOUND , // Sound
  30. ELM_VIDEO , // Video
  31. ELM_FILE , // Raw File
  32. ELM_CODE , // Code
  33. ELM_LIB , // Code Library
  34. ELM_APP , // Code Application
  35. ELM_ICON_SETTS , // Icon Settings
  36. ELM_MINI_MAP , // World Mini Map
  37. ELM_GUI_SKIN , // Gui Skin
  38. ELM_NUM , // Number of Element Types
  39. };
  40. /******************************************************************************/
  41. enum RELOAD_RESULT : Byte // Element Reload Result
  42. {
  43. RELOAD_ELM_NOT_FOUND, // element was not found
  44. RELOAD_NOT_REQUESTED, // reloading was not requested
  45. RELOAD_IN_PROGRESS , // reloading is still in progress
  46. RELOAD_CANCELED , // reloading was canceled
  47. RELOAD_FAILED , // reloading failed
  48. RELOAD_SUCCESS , // reloading succeeded
  49. };
  50. /******************************************************************************/
  51. struct Elm // Project Element
  52. {
  53. ELM_TYPE type ; // type of the element
  54. Bool removed, // if this element is marked as removed (this does not include parents state which may affect the final result, see 'final_removed' for final value)
  55. publish, // if this element is included in publishing (this does not include parents state which may affect the final result, see 'final_publish' for final value)
  56. final_removed, // if this element or its parents are marked as removed
  57. final_publish; // if this element and its parents are included in publishing
  58. UID id, // ID of the element
  59. parent_id; // ID of the element's parent ('UIDZero' means no parent)
  60. Str name, // name of the element
  61. full_name, // full name of the element (including its parents)
  62. src_file; // source file from which this element was created
  63. Bool save(File &f)C {f<<type<<removed<<publish<<id<<parent_id<<name<<src_file; return f.ok();}
  64. Bool load(File &f) {f>>type>>removed>>publish>>id>>parent_id>>name>>src_file; return f.ok();}
  65. };
  66. /******************************************************************************/
  67. struct Project // Project
  68. {
  69. UID id ; // ID of the project
  70. Str name; // name of the project
  71. Project& set(C UID &id, C Str &name) {T.id=id; T.name=name; return T;}
  72. Bool save(File &f)C {f<<id<<name; return f.ok();}
  73. Bool load(File &f) {f>>id>>name; return f.ok();}
  74. };
  75. /******************************************************************************/
  76. T1(TYPE) struct IDParam // ID with a custom parameter
  77. {
  78. UID id;
  79. TYPE value;
  80. Bool save(File &f)C {f<<id<<value; return f.ok();}
  81. Bool load(File &f) {f>>id>>value; return f.ok();}
  82. IDParam(C UID &id=UIDZero ) : id(id) {}
  83. IDParam(C UID &id, C TYPE &value) : id(id), value(value) {}
  84. };
  85. /******************************************************************************/
  86. struct ObjData
  87. {
  88. struct Param : EE::Param
  89. {
  90. UID id ; // ID of the parameter (each parameter has its unique ID)
  91. bool removed , // if this parameter is currently removed
  92. inherited; // if this parameter is inherited from a base object or object class (if this is true then the parameter does not directly exist in the object itself, but it exists in the base/class of the object)
  93. Bool save(File &f)C {if(EE::Param::save(f)){f<<id<<removed<<inherited; return f.ok();} return false;}
  94. Bool load(File &f) {if(EE::Param::load(f)){f>>id>>removed>>inherited; return f.ok();} return false;}
  95. Param() {id.zero(); removed=inherited=false;}
  96. };
  97. UID elm_obj_class_id; // ID of ELM_OBJ_CLASS element in the project (this is the project element object class of this object)
  98. OBJ_ACCESS access; // access mode of the object
  99. OBJ_PATH path ; // path mode of the object
  100. Memc<Param> params; // parameters of the object
  101. Param* findParam(C Str &name, PARAM_TYPE type=PARAM_NUM, Bool include_removed=false, Bool include_inherited=true); // find the first parameter from 'params' of 'name' and 'type' (use PARAM_NUM to accept all parameter types), 'include_removed'=if return removed parameters as well, 'include_inherited'=if return inherited parameters as well, null on fail (if not found)
  102. Bool save(File &f)C;
  103. Bool load(File &f);
  104. ObjData& reset(); // reset to default values
  105. ObjData() {reset();}
  106. };
  107. /******************************************************************************/
  108. struct ObjChange
  109. {
  110. void removeParam(C UID &param_id ); // remove parameter by specifying its ID , if this parameter does not exist then nothing will happen
  111. void removeParam(C Str &param_name, PARAM_TYPE param_type=PARAM_NUM); // remove parameter by specifying its name and optionally type (setting PARAM_NUM will make the 'type' ignored), if this parameter does not exist then nothing will happen
  112. void restoreParam(C UID &param_id ); // restore parameter by specifying its ID , if this parameter does not exist then nothing will happen
  113. void restoreParam(C Str &param_name, PARAM_TYPE param_type=PARAM_NUM); // restore parameter by specifying its name and optionally type (setting PARAM_NUM will make the 'type' ignored), if this parameter does not exist then nothing will happen
  114. void renameParam(C UID &param_id , C Str &param_new_name ); // rename parameter by specifying its ID and new name, if this parameter does not exist then nothing will happen
  115. void renameParam(C Str &param_old_name, C Str &param_new_name, PARAM_TYPE param_type=PARAM_NUM); // rename parameter by specifying its old name, optionally type (setting PARAM_NUM will make the 'param_type' ignored) and new name, if this parameter does not exist then nothing will happen
  116. void setParamTypeValue(C UID &param_id , C Param &type_value ); // change parameter type and value to 'type_value', parameter is specified by its ID , if this parameter is removed then this method will restore it, if this parameter does not exist then nothing will happen
  117. void setParamTypeValue(C Str &param_name, C Param &type_value, PARAM_TYPE param_old_type=PARAM_NUM); // change parameter type and value to 'type_value', parameter is specified by its name and optionally 'param_old_type' type (setting PARAM_NUM will make the 'param_old_type' ignored), if this parameter is removed then this method will restore it, if this parameter does not exist then it will be automatically created
  118. Bool save(File &f, CChar *path=null)C;
  119. Bool load(File &f, CChar *path=null) ;
  120. ObjChange();
  121. Byte cmd;
  122. PARAM_TYPE type;
  123. UID id;
  124. Str name;
  125. Param param;
  126. };
  127. /******************************************************************************/
  128. struct WorldObjParams // World Object parameters
  129. {
  130. UID id; // ID of ELM_OBJ element in the project
  131. Matrix matrix; // object matrix (its scale determines the object size)
  132. Bool align_to_terrain; // if align vertical position of the object to the terrain at that location (in that case 'matrix.pos.y' will be ignored)
  133. Flt align_to_terrain_normal; // factor 0..1 of how much to align the object to the terrain surface normal vector (if this is enabled then the object will be additionally rotated according to the terrain shape)
  134. WorldObjParams& set(C UID &id, C Matrix &matrix, Bool align_to_terrain=false, Flt align_to_terrain_normal=0) {T.id=id; T.matrix=matrix; T.align_to_terrain=align_to_terrain; T.align_to_terrain_normal=align_to_terrain_normal; return T;}
  135. Bool save(File &f)C {f<<id<<matrix<<align_to_terrain<<align_to_terrain_normal; return f.ok();}
  136. Bool load(File &f) {f>>id>>matrix>>align_to_terrain>>align_to_terrain_normal; return f.ok();}
  137. WorldObjParams(C UID &id=UIDZero, C Matrix &matrix=MatrixIdentity, Bool align_to_terrain=false, Flt align_to_terrain_normal=0) {set(id, matrix, align_to_terrain, align_to_terrain_normal);}
  138. };
  139. struct WorldObjDesc // Basic Description of a World Object
  140. {
  141. UID instance_id, // ID of world object instance (each object in the world has its unique ID)
  142. elm_obj_id; // ID of ELM_OBJ element in the project (this is the project element object on which the world object is based)
  143. Matrix matrix ; // matrix of the world object (its scale determines the object size)
  144. Bool selected , // if the object is currently selected
  145. removed ; // if the object is currently marked as removed
  146. Bool save(File &f)C {f<<instance_id<<elm_obj_id<<matrix<<selected<<removed; return f.ok();}
  147. Bool load(File &f) {f>>instance_id>>elm_obj_id>>matrix>>selected>>removed; return f.ok();}
  148. WorldObjDesc() {instance_id.zero(); elm_obj_id.zero(); matrix.identity(); selected=removed=false;}
  149. };
  150. struct WorldObjData : WorldObjDesc, ObjData // Full Data of a World Object
  151. {
  152. Bool save(File &f)C {return WorldObjDesc::save(f) && ObjData::save(f);}
  153. Bool load(File &f) {return WorldObjDesc::load(f) && ObjData::load(f);}
  154. };
  155. /******************************************************************************/
  156. struct MaterialMap
  157. {
  158. void create(Int resolution); // create using specified image resolution (the image will be created as square "resolution x resolution")
  159. Int resolution()C;
  160. void set(Int x, Int y, C UID &m0, C UID &m1, C UID &m2, C UID &m3, C VecB4 &blend); // set 'm0 m1 m2 m3' ID's of project ELM_MTRL materials, with their corresponding 'blend' intensities (range of 0..255), at 'x, y' image coordinates
  161. void set(Int x, Int y, C UID &m0, C UID &m1, C UID &m2, C UID &m3, C Vec4 &blend); // set 'm0 m1 m2 m3' ID's of project ELM_MTRL materials, with their corresponding 'blend' intensities (range of 0.. 1), at 'x, y' image coordinates
  162. void get(Int x, Int y, UID &m0, UID &m1, UID &m2, UID &m3, VecB4 &blend); // get 'm0 m1 m2 m3' ID's of project ELM_MTRL materials, with their corresponding 'blend' intensities (range of 0..255), at 'x, y' image coordinates
  163. void get(Int x, Int y, UID &m0, UID &m1, UID &m2, UID &m3, Vec4 &blend); // get 'm0 m1 m2 m3' ID's of project ELM_MTRL materials, with their corresponding 'blend' intensities (range of 0.. 1), at 'x, y' image coordinates
  164. void resize(Int resolution);
  165. Bool save(File &f)C; // save to file, false on fail
  166. Bool load(File &f) ; // load from file, false on fail
  167. void del(); // delete manually
  168. ~MaterialMap() {del();}
  169. private:
  170. Image _m, _i;
  171. IDPalette _ip;
  172. };
  173. /******************************************************************************/
  174. struct FileParams
  175. {
  176. Str name;
  177. Mems<TextParam> params;
  178. Bool is()C {return name.is() || params.elms();}
  179. TextParam* findParam(C Str &name);
  180. C TextParam* findParam(C Str &name)C;
  181. TextParam& getParam(C Str &name);
  182. Str encode( )C; // encode into string
  183. void decode(C Str &s) ; // decode from string
  184. FileParams( ) {}
  185. FileParams(C Str &s) {decode(s);}
  186. static Str Encode(C MemPtr<FileParams> &file_params); // encode 'file_params' array into string
  187. static Mems<FileParams> Decode(C Str &str ); // decode 'str' string into file params array
  188. static Str Merge (C Str &a, C Str &b); // merge 'a' 'b' strings
  189. };
  190. /******************************************************************************/
  191. struct Material
  192. {
  193. MATERIAL_TECHNIQUE technique;
  194. Bool cull, flip_normal_y,
  195. high_quality_ios; // if use higher quality texture format on iOS platform
  196. Byte downsize_tex_mobile; // how much to downsize textures for Mobile platforms, 0=full size, 1=half size, 2=quarter size, ..
  197. Vec4 color;
  198. Vec ambient;
  199. Flt specular, glow, roughness, bump, reflection;
  200. Mems<FileParams> color_map, alpha_map,
  201. bump_map, normal_map,
  202. specular_map,
  203. glow_map,
  204. reflection_map,
  205. detail_color, detail_bump, detail_normal,
  206. macro_map,
  207. light_map;
  208. Bool hasColorMap ()C {return color_map .elms()>0;}
  209. Bool hasBumpMap ()C {return bump_map .elms()>0;}
  210. Bool hasNormalMap()C {return normal_map .elms()>0 || hasBumpMap();}
  211. Bool hasDetailMap()C {return detail_color.elms()>0 || detail_bump.elms()>0 || detail_normal.elms()>0;}
  212. void save(File &f)C;
  213. Bool load(File &f);
  214. Material& reset(); // reset to default values
  215. Material() {reset();}
  216. };
  217. /******************************************************************************/
  218. struct EditorInterface
  219. {
  220. static Str ElmFileName(C UID &elm_id, C Str &data_path=S) {return elm_id.valid() ? Str(data_path).tailSlash(true)+EncodeFileName(elm_id) : S;} // get path to the element file, you can use it to access resources in read-only mode, do not write to the files under no condition
  221. // connection
  222. Bool connected( ); // if connected
  223. void disconnect ( ); // disconnect
  224. Bool connect (Str &message, Int timeout=-1); // connect to a running instance of Esenthel Editor, 'timeout'=time in milliseconds (-1=default) to wait for a connection, false on fail
  225. // projects
  226. Str projectsPath( ); // get path where your projects are located
  227. Bool projectsPath(C Str &path); // set path where your projects are located
  228. Bool getProjects(MemPtr<Project> projects); // get list of projects, false on fail
  229. UID curProject ( ); // get ID of currently opened project, 'UIDZero' is returned if no project is opened
  230. Bool openProject (C UID &proj_id=UIDZero ); // change active project to the one specified by its ID, if 'UIDZero' is passed then editor will open the project list menu, false on fail
  231. // following methods operate on currently opened project
  232. // settings
  233. Str dataPath(); // get project game data path, you can use it to access resources in read-only mode, do not write data to the path under no condition, "" on fail
  234. // elements
  235. Bool getElms ( MemPtr<Elm> elms, Bool include_removed=false); // get list of elements (elements will be sorted by their ID ), false on fail, 'include_removed'=if include elements that were removed
  236. Bool selectedElms ( MemPtr<UID> elms ); // get list of selected element ID's (ID's will be sorted by which was selected first), false on fail
  237. Bool selectElms (C MemPtr<UID> &elms ); // select elements based on their ID's , false on fail
  238. UID newElm (ELM_TYPE type, C Str &name, C UID &parent_id=UIDZero); // create a new element in the project of 'type', 'name' and assigned to 'parent_id' parent (use 'UIDZero' for no parent), this method does not support following types: ELM_MESH, ELM_SKEL, ELM_PHYS, ELM_WORLD (for creating worlds please use 'newWorld' method) , ID of the newly created element will be returned or 'UIDZero' if failed
  239. UID newWorld( C Str &name, Int area_size=64, Int terrain_res=64, C UID &parent_id=UIDZero); // create a new world in the project 'name' and assigned to 'parent_id' parent (use 'UIDZero' for no parent), 'area_size'=size of a single area (in meters, valid values are: 32, 64, 128), 'terrain_res'=terrain resolution (valid values are: 32, 64, 128), ID of the newly created element will be returned or 'UIDZero' if failed
  240. Bool setElmName (C MemPtr< IDParam<Str > > &elms); // set 'name' for elements, where 'IDParam.id'=element ID, 'IDParam.value'=element name
  241. Bool setElmRemoved(C MemPtr< IDParam<Bool> > &elms); // set 'removed' state for elements, where 'IDParam.id'=element ID, 'IDParam.value'=element removed state
  242. Bool setElmPublish(C MemPtr< IDParam<Bool> > &elms); // set 'publish' state for elements, where 'IDParam.id'=element ID, 'IDParam.value'=element publish state
  243. Bool setElmParent (C MemPtr< IDParam<UID > > &elms); // set 'parent' for elements, where 'IDParam.id'=element ID, 'IDParam.value'=parent ID (use 'UIDZero' for no parent)
  244. Bool setElmSrcFile(C MemPtr< IDParam<Str > > &elms); // set 'src_file' for elements, where 'IDParam.id'=element ID, 'IDParam.value'=element source file (this does not reload the element, it only adjusts the source file for it)
  245. Bool reloadElms (C MemPtr<UID> &elms, Bool remember_result ); // reload elements specified by their ID, elements will be reloaded from their current 'Elm.src_file', which can be changed using the 'setElmSrcFile' method. This method does not wait until elements finish reloading, it only requests the reload, and returns true if the request was accepted, and false if request failed. Which means that even if this method returns true, reload may still fail, for example if the element 'src_file' was not found. 'remember_result'=if this is set to true, then upon completion of reload process, the Editor will remember reload result for each element, which can be obtained later using 'reloadResult' method, while 'forgetReloadResult' can be called to forget those results.
  246. Bool cancelReloadElms (C MemPtr<UID> &elms ); // cancel reloading elements specified by their ID
  247. Bool reloadResult(C MemPtr<UID> &elms, MemPtr< IDParam<RELOAD_RESULT> > results); // get element reload result for each element, you can call this after calling 'reloadElms' with 'remember_result' set to true
  248. Bool forgetReloadResult(C MemPtr<UID> &elms ); // if you've called 'reloadElms' with 'remember_result' set to true then the Editor will remember reload result for specified elements, with this function you can forget those results
  249. // world
  250. UID curWorld( ); // get ID of currently opened ELM_WORLD element, 'UIDZero' is returned if no world is opened
  251. Bool openWorld(C UID &world_id=UIDZero); // open world in the world editor, 'world_id'=ID of ELM_WORLD element in the project, if 'UIDZero' is passed then editor will close the world editor, false on fail
  252. Int worldAreaSize(C UID &world_id); // get size (in meters) of a single area in specified world, 'world_id'=ID of ELM_WORLD element in the project, 0 on fail
  253. // world terrain
  254. Int worldTerrainRes (C UID &world_id ); // get terrain resolution of a single area in specified world, 'world_id'=ID of ELM_WORLD element in the project, 0 on fail
  255. Bool worldTerrainAreas(C UID &world_id, RectI &areas); // get coverage of all areas in the world which have terrain, coordinates are from 'areas.min' to 'areas.max' inclusive, if no areas in the world have terrain then 'RectI(0, 0, -1, -1)' will be returned, 'world_id'=ID of ELM_WORLD element in the project, false on fail
  256. Bool worldTerrainDel (C UID &world_id, C VecI2 &area_xy ); // delete terrain at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail
  257. Bool worldTerrainExists (C UID &world_id, C VecI2 &area_xy ); // test if there's terrain at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail
  258. Bool worldTerrainGetHeight (C UID &world_id, C VecI2 &area_xy, Image &height ); // get terrain height at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'height' =height map (its resolution will be "worldTerrainRes(world_id)", IMAGE_F32 type, IMAGE_SOFT mode)
  259. Bool worldTerrainSetHeight (C UID &world_id, C VecI2 &area_xy, C Image &height, C UID &material_id=UIDZero); // set terrain height at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'height' =height map (recommended resolution is "worldTerrainRes(world_id)" however it will be automatically resized if different, recommended format is IMAGE_F32 ), each terrain must have a material set, if there is already a terrain at that location, then its material will not be modified, if there is no terrain yet, then 'material_id' will be used (which is ID of ELM_MTRL element in the project), if the material was not found or it was set to 'UIDZero', then default material from the editor terrain material slot will be used, if that material was not set, then the method will fail and the terrain will not be created
  260. Bool worldTerrainGetColor (C UID &world_id, C VecI2 &area_xy, Image &color ); // get terrain color at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'color' =color map (its resolution will be "worldTerrainRes(world_id)", IMAGE_R8G8B8 type, IMAGE_SOFT mode)
  261. Bool worldTerrainSetColor (C UID &world_id, C VecI2 &area_xy, C Image &color, C UID &material_id=UIDZero); // set terrain color at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'color' =color map (recommended resolution is "worldTerrainRes(world_id)" however it will be automatically resized if different, recommended format is IMAGE_R8G8B8), each terrain must have a material set, if there is already a terrain at that location, then its material will not be modified, if there is no terrain yet, then 'material_id' will be used (which is ID of ELM_MTRL element in the project), if the material was not found or it was set to 'UIDZero', then default material from the editor terrain material slot will be used, if that material was not set, then the method will fail and the terrain will not be created
  262. Bool worldTerrainGetMaterial(C UID &world_id, C VecI2 &area_xy, MaterialMap &material ); // get terrain material at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'material' =material map (its resolution will be "worldTerrainRes(world_id)")
  263. Bool worldTerrainSetMaterial(C UID &world_id, C VecI2 &area_xy, C MaterialMap &material ); // set terrain material at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, 'material' =material map (recommended resolution is "worldTerrainRes(world_id)" however it will be automatically resized if different)
  264. Bool worldTerrainGet (C UID &world_id, C VecI2 &area_xy, Image &height, MaterialMap &material, Image *color=null ); // get terrain at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, this method gets terrain height, material and color all at the same time
  265. Bool worldTerrainSet (C UID &world_id, C VecI2 &area_xy, C Image &height, C MaterialMap &material, C Image *color=null ); // set terrain at 'area_xy' area coordinates in specified world, 'world_id'=ID of ELM_WORLD element in the project, false on fail, this method sets terrain height, material and color all at the same time, if 'color' is null then it will be set as fully white, each terrain must have a material specified
  266. // world objects
  267. Bool worldObjCreate (C UID &world_id, C MemPtr<WorldObjParams> &objs ); // create objects in world, 'world_id'=ID of ELM_WORLD element in the project, 'objs'=array of objects to create, false on fail
  268. Bool worldObjGetDesc(C UID &world_id, MemPtr<WorldObjDesc > objs, C MemPtr<UID> &world_obj_instance_ids=null, C RectI *areas=null, Bool only_selected=false, Bool include_removed=false ); // get objects in world, 'world_id'=ID of ELM_WORLD element in the project, 'objs'=array of objects to fill with those from the world, 'world_obj_instance_ids'=if get data only from the objects specified in this container (use null for all objects), 'areas'=get objects only from the specified world areas (use null for all areas), 'only_selected'=if get only objects that are currently selected, 'include_removed'=if include objects that were removed, this method is much faster than the one below as it returns only basic data, false on fail
  269. Bool worldObjGetData(C UID &world_id, MemPtr<WorldObjData > objs, C MemPtr<UID> &world_obj_instance_ids=null, C RectI *areas=null, Bool only_selected=false, Bool include_removed=false, Bool include_removed_params=false); // get objects in world, 'world_id'=ID of ELM_WORLD element in the project, 'objs'=array of objects to fill with those from the world, 'world_obj_instance_ids'=if get data only from the objects specified in this container (use null for all objects), 'areas'=get objects only from the specified world areas (use null for all areas), 'only_selected'=if get only objects that are currently selected, 'include_removed'=if include objects that were removed, 'include_removed_params'=if include object parameters that were removed, this method is slower than the one above as it returns full data, false on fail
  270. // world waypoints
  271. Bool worldWaypointGetList(C UID &world_id, MemPtr<UID> waypoint_ids); // get list of all waypoint ID's in world, 'world_id'=ID of ELM_WORLD element in the project, false on fail
  272. // world camera
  273. Bool worldCamGet( Camera &cam); // get camera settings in the world editor, false on fail
  274. Bool worldCamSet(C Camera &cam); // set camera settings in the world editor, false on fail
  275. // world draw
  276. struct Line
  277. {
  278. Color color;
  279. Edge edge;
  280. Bool save(File &f)C {f<<color<<edge; return f.ok();}
  281. Bool load(File &f) {f>>color>>edge; return f.ok();}
  282. Line& set(C Color &color, C Edge &edge) {T.color=color; T.edge=edge; return T;}
  283. Line( ) {}
  284. Line(C Color &color, C Edge &edge) {set(color, edge);}
  285. };
  286. Bool worldDrawLines(C MemPtr<Line> &lines); // request the world editor to draw specified lines, after you make this call, the world editor will draw the lines in each frame, if you no longer wish to draw lines, then call this method with empty container, false on fail
  287. // image
  288. Bool getImage(C UID &elm_id, Image &image); // get image of 'elm_id' ELM_IMAGE element in the project, false on fail
  289. Bool setImage(C UID &elm_id, C Image &image); // set image of 'elm_id' ELM_IMAGE element in the project, false on fail
  290. // code
  291. Bool getCode(C UID &elm_id, Str &code); // get source code of 'elm_id' ELM_CODE element in the project, false on fail
  292. Bool setCode(C UID &elm_id, C Str &code); // set source code of 'elm_id' ELM_CODE element in the project, false on fail
  293. Bool codeSyncImport(); // import all codes into active Project from the Code Synchronization folder, false on fail
  294. Bool codeSyncExport(); // export all codes from active Project into the Code Synchronization folder, false on fail
  295. // file
  296. Bool getFile(C UID &elm_id, File &data); // get data of 'elm_id' ELM_FILE ELM_SOUND ELM_VIDEO elements in the project, 'data' must be already opened for writing as the method will write to it, false on fail
  297. Bool setFile(C UID &elm_id, File &data); // set data of 'elm_id' ELM_FILE ELM_SOUND ELM_VIDEO elements in the project, 'data' must be already opened for reading as the method will read from it, false on fail
  298. // material
  299. UID curMaterial ( ); // get ID of currently opened ELM_MTRL element, 'UIDZero' is returned if no material is opened
  300. Bool curMaterial (C UID &elm_id ); // open material editor of 'elm_id' ELM_MTRL element in the project, if 'UIDZero' is passed then editor will close the material editor, false on fail
  301. Bool getMaterial (C UID &elm_id, Material &material ); // get material parameters of 'elm_id' ELM_MTRL ELM_WATER_MTRL element in the project, false on fail
  302. Bool setMaterial (C UID &elm_id, C Material &material, Bool reload_textures, Bool adjust_params ); // set material parameters of 'elm_id' ELM_MTRL ELM_WATER_MTRL element in the project, false on fail, 'reload_textures'=if reload the textures that were changed during this update (if this is set to false, then texture files names will get updated, however the texture images will remain the same), 'adjust_params'=if automatically adjust some parameters based on detected texture change (for example default specular value is 0, however if a specular map was added to the material in this change, then specular intensity value should be set to value >0 so the specular effect is visible, in this case 'adjust_params'=will automatically adjust specular intensity to 1 if a specular map was added and the intensity was 0. 'adjust_params' may adjust some other parameters as well)
  303. Bool reloadMaterialTextures (C UID &elm_id, bool base, bool reflection, bool detail, bool macro, bool light); // reload material textures of 'elm_id' ELM_MTRL ELM_WATER_MTRL element in the project, false on fail
  304. Bool mulMaterialTextureByColor(C UID &elm_id ); // multiply material textures by color of 'elm_id' ELM_MTRL ELM_WATER_MTRL element in the project, false on fail
  305. // mesh
  306. Bool getMesh(C UID &elm_id, Mesh &mesh, Matrix *matrix=null); // get mesh of 'elm_id' ELM_OBJ ELM_MESH elements in the project, false on fail, 'matrix'=matrix by which the mesh is going to be transformed by the editor
  307. Bool setMesh(C UID &elm_id, C Mesh &mesh ); // set mesh of 'elm_id' ELM_OBJ ELM_MESH elements in the project, false on fail
  308. // animation
  309. UID curAnimation( ); // get ID of currently opened ELM_ANIM element, 'UIDZero' is returned if no animation is opened
  310. Bool curAnimation(C UID &elm_id ); // open animation editor of 'elm_id' ELM_ANIM element in the project, if 'UIDZero' is passed then editor will close the animation editor, false on fail
  311. Bool getAnimation(C UID &elm_id, Animation &anim); // get animation of 'elm_id' ELM_ANIM element in the project, false on fail
  312. Bool setAnimation(C UID &elm_id, C Animation &anim); // set animation of 'elm_id' ELM_ANIM element in the project, false on fail
  313. // object
  314. UID curObject( ); // get ID of currently opened ELM_OBJ element, 'UIDZero' is returned if no object is opened
  315. Bool curObject(C UID &elm_id ); // open object editor of 'elm_id' ELM_OBJ element in the project, if 'UIDZero' is passed then editor will close the object editor, false on fail
  316. Bool getObject(C UID &elm_id, ObjData &obj, Bool include_removed_params=false); // get object data of 'elm_id' ELM_OBJ ELM_OBJ_CLASS elements in the project, 'include_removed_params'=if include object parameters that were removed, false on fail
  317. Bool modifyObject(C UID &elm_id, C MemPtr<ObjChange> &changes ); // modify object data of 'elm_id' ELM_OBJ ELM_OBJ_CLASS elements in the project according to specified list of 'changes', false on fail
  318. // application
  319. Bool activeApp(C UID &elm_id ); // set active application of 'elm_id' ELM_APP element in the project, false on fail
  320. Bool exportApp(EXPORT_MODE mode, Bool data); // export active application, 'data'=if export project data according to selected mode (if mode is Visual Studio then data for Universal Windows will be exported, if mode is Xcode then data for iOS will be exported, if mode is Android then data for Android will be exported), false on fail
  321. // build settings
  322. Bool buildDebug(Bool debug ); // set build debug/release configuration (true=debug , false=release )
  323. Bool build32Bit(Bool bit32 ); // set build 32/64 bit configuration (true=32 , false=64 )
  324. Bool buildDX9 (Bool dx9 ); // set build DX9/DX10+ configuration (true=DX9 , false=DX10+ )
  325. Bool buildExe (EXE_TYPE type ); // set build executable type configuration
  326. Bool buildPaths(Bool relative); // set build export paths configuration (true=relative, false=absolute)
  327. #if !EE_PRIVATE
  328. private:
  329. #endif
  330. Connection _conn;
  331. };
  332. /******************************************************************************/
  333. Elm* FindElm(MemPtr<Elm> elms, C UID &elm_id ); // find element with 'elm_id' ID , this function assumes that 'elms' is sorted by element ID's, null is returned if element was not found
  334. Elm* FindElm(MemPtr<Elm> elms, C UID &elm_id, ELM_TYPE type); // find element with 'elm_id' ID and 'type' ELM_TYPE, this function assumes that 'elms' is sorted by element ID's, null is returned if element was not found or it had different type than requested
  335. Elm* FindElm(MemPtr<Elm> elms, C Str &full_name, ELM_TYPE type); // find element with 'full_name' path and name and 'type' ELM_TYPE, null is returned if element was not found or it had different type than requested
  336. Bool ContainsElm(MemPtr<Elm> elms, C UID &parent_id, C UID &child_id); // if element with 'parent_id' ID contains element with 'child_id' ID, this function assumes that 'elms' is sorted by element ID's
  337. /******************************************************************************/
  338. // SERVER SIDE
  339. /******************************************************************************/
  340. struct EditorServer : ConnectionServer
  341. {
  342. STRUCT(Client , ConnectionServer::Client)
  343. //{
  344. Bool connection_version_ok;
  345. virtual Bool update();
  346. Client() {connection_version_ok=false;}
  347. };
  348. Client& client(Int i) {return (Client&)clients[i];}
  349. EditorServer() {clients.replaceClass<Client>();}
  350. };
  351. /******************************************************************************/
  352. enum EDITOR_INTERFACE_COMMANDS
  353. {
  354. EI_VERSION_CHECK,
  355. EI_GET_PROJECTS,
  356. EI_GET_PROJECT,
  357. EI_SET_PROJECT,
  358. EI_GET_DATA_PATH,
  359. EI_GET_ELMS,
  360. EI_GET_ELMS_SELECTED,
  361. EI_SET_ELMS_SELECTED,
  362. EI_RLD_ELMS,
  363. EI_RLD_ELMS_CANCEL,
  364. EI_RLD_ELMS_GET_RESULT,
  365. EI_RLD_ELMS_FORGET_RESULT,
  366. EI_NEW_ELM,
  367. EI_NEW_WORLD,
  368. EI_SET_ELM_NAME,
  369. EI_SET_ELM_REMOVED,
  370. EI_SET_ELM_PUBLISH,
  371. EI_SET_ELM_PARENT,
  372. EI_SET_ELM_SRC_FILE,
  373. EI_GET_WORLD,
  374. EI_SET_WORLD,
  375. EI_GET_WORLD_AREA_SIZE,
  376. EI_GET_WORLD_TERRAIN_RES,
  377. EI_GET_WORLD_TERRAIN_AREAS,
  378. EI_DEL_WORLD_TERRAIN,
  379. EI_GET_WORLD_TERRAIN_IS,
  380. EI_GET_WORLD_TERRAIN_HEIGHT,
  381. EI_SET_WORLD_TERRAIN_HEIGHT,
  382. EI_GET_WORLD_TERRAIN_COLOR,
  383. EI_SET_WORLD_TERRAIN_COLOR,
  384. EI_GET_WORLD_TERRAIN_MATERIAL,
  385. EI_SET_WORLD_TERRAIN_MATERIAL,
  386. EI_GET_WORLD_TERRAIN,
  387. EI_SET_WORLD_TERRAIN,
  388. EI_NEW_WORLD_OBJ,
  389. EI_GET_WORLD_OBJ_BASIC,
  390. EI_GET_WORLD_OBJ_FULL,
  391. EI_GET_WORLD_WAYPOINT_LIST,
  392. EI_GET_WORLD_CAM,
  393. EI_SET_WORLD_CAM,
  394. EI_DRAW_WORLD_LINES,
  395. EI_GET_IMAGE,
  396. EI_SET_IMAGE,
  397. EI_GET_CODE,
  398. EI_SET_CODE,
  399. EI_GET_FILE,
  400. EI_SET_FILE,
  401. EI_GET_MTRL_CUR,
  402. EI_SET_MTRL_CUR,
  403. EI_GET_MTRL,
  404. EI_SET_MTRL,
  405. EI_RLD_MTRL_TEX,
  406. EI_MUL_MTRL_TEX_COL,
  407. EI_GET_MESH,
  408. EI_SET_MESH,
  409. EI_GET_ANIM_CUR,
  410. EI_SET_ANIM_CUR,
  411. EI_GET_ANIM,
  412. EI_SET_ANIM,
  413. EI_GET_OBJ_CUR,
  414. EI_SET_OBJ_CUR,
  415. EI_GET_OBJ,
  416. EI_MODIFY_OBJ,
  417. EI_SET_ACTIVE_APP,
  418. EI_EXPORT_APP,
  419. EI_CODE_SYNC_IMPORT,
  420. EI_CODE_SYNC_EXPORT,
  421. EI_GET_PROJECTS_PATH,
  422. EI_SET_PROJECTS_PATH,
  423. EI_BUILD_DEBUG,
  424. EI_BUILD_32BIT,
  425. EI_BUILD_DX9 ,
  426. EI_BUILD_EXE ,
  427. EI_BUILD_PATHS,
  428. EI_NUM,
  429. #if EE_PRIVATE
  430. // !! when changing this, don't forget to increment EI_VER !!
  431. #endif
  432. };
  433. enum EDITOR_INTERFACE_OBJ_COMMANDS : Byte
  434. {
  435. EI_OBJ_NONE,
  436. EI_OBJ_PARAM_REMOVE_ID,
  437. EI_OBJ_PARAM_REMOVE_NAME,
  438. EI_OBJ_PARAM_RESTORE_ID,
  439. EI_OBJ_PARAM_RESTORE_NAME,
  440. EI_OBJ_PARAM_RENAME_ID,
  441. EI_OBJ_PARAM_RENAME_NAME,
  442. EI_OBJ_PARAM_SET_TYPE_VALUE_ID,
  443. EI_OBJ_PARAM_SET_TYPE_VALUE_NAME,
  444. };
  445. /******************************************************************************/
  446. } // namespace
  447. /******************************************************************************/