Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / rna_main.c
index 06a7b4aa11be957d30b2d596bc6530ec82dc994a..d5d6f609a037c6b339f1e09b2ecc89bd5b30c1d2 100644 (file)
 
 /* all the list begin functions are added manually here, Main is not in SDNA */
 
+static int rna_Main_use_autopack_get(PointerRNA *UNUSED(ptr))
+{
+       if (G.fileflags & G_AUTOPACK)
+               return 1;
+
+       return 0;
+}
+
+static void rna_Main_use_autopack_set(PointerRNA *UNUSED(ptr), int value)
+{
+       if (value)
+               G.fileflags |= G_AUTOPACK;
+       else
+               G.fileflags &= ~G_AUTOPACK;
+}
+
 static int rna_Main_is_saved_get(PointerRNA *UNUSED(ptr))
 {
        return G.relbase_valid;
@@ -56,7 +72,7 @@ static int rna_Main_is_dirty_get(PointerRNA *ptr)
                return !wm->file_saved;
        }
 
-       return TRUE;
+       return true;
 }
 
 static void rna_Main_filepath_get(PointerRNA *ptr, char *value)
@@ -169,12 +185,6 @@ static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *
        rna_iterator_listbase_begin(iter, &bmain->screen, NULL);
 }
 
-static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
-       Main *bmain = (Main *)ptr->data;
-       rna_iterator_listbase_begin(iter, &bmain->script, NULL);
-}
-
 static void rna_Main_font_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Main *bmain = (Main *)ptr->data;
@@ -229,10 +239,10 @@ static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *p
        rna_iterator_listbase_begin(iter, &bmain->brush, NULL);
 }
 
-static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Main_palettes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Main *bmain = (Main *)ptr->data;
-       rna_iterator_listbase_begin(iter, &bmain->particle, NULL);
+       rna_iterator_listbase_begin(iter, &bmain->palettes, NULL);
 }
 
 static void rna_Main_gpencil_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -259,13 +269,31 @@ static void rna_Main_masks_begin(CollectionPropertyIterator *iter, PointerRNA *p
        rna_iterator_listbase_begin(iter, &bmain->mask, NULL);
 }
 
-#ifdef WITH_FREESTYLE
 static void rna_Main_linestyle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
-       Main *bmain = (Main*)ptr->data;
+       Main *bmain = (Main *)ptr->data;
        rna_iterator_listbase_begin(iter, &bmain->linestyle, NULL);
 }
-#endif
+
+static void rna_Main_cachefiles_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+       Main *bmain = (Main *)ptr->data;
+       rna_iterator_listbase_begin(iter, &bmain->cachefiles, NULL);
+}
+
+static void rna_Main_paintcurves_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+       Main *bmain = (Main *)ptr->data;
+       rna_iterator_listbase_begin(iter, &bmain->paintcurves, NULL);
+}
+
+static void rna_Main_version_get(PointerRNA *ptr, int *value)
+{
+       Main *bmain = (Main *)ptr->data;
+       value[0] = bmain->versionfile / 100;
+       value[1] = bmain->versionfile % 100;
+       value[2] = bmain->subversionfile;
+}
 
 #ifdef UNIT_TEST
 
@@ -301,39 +329,38 @@ void RNA_def_main(BlenderRNA *brna)
 
        /* plural must match idtypes in readblenentry.c */
        MainCollectionDef lists[] = {
-               {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks", RNA_def_main_cameras},
-               {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks", RNA_def_main_scenes},
-               {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks", RNA_def_main_objects},
-               {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks", RNA_def_main_materials},
-               {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks", RNA_def_main_node_groups},
-               {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks", RNA_def_main_meshes},
-               {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks", RNA_def_main_lamps},
-               {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks", RNA_def_main_libraries},
-               {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks", RNA_def_main_screens},
-               {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks", RNA_def_main_window_managers},
-               {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks", RNA_def_main_images},
-               {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks", RNA_def_main_lattices},
-               {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks", RNA_def_main_curves},
-               {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks", RNA_def_main_metaballs},
-               {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font datablocks", RNA_def_main_fonts},
-               {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks", RNA_def_main_textures},
-               {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks", RNA_def_main_brushes},
-               {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks", RNA_def_main_worlds},
-               {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks", RNA_def_main_groups},
-               {"shape_keys", "Key", "rna_Main_key_begin", "Shape Keys", "Shape Key datablocks", NULL},
-               {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)", NULL},
-               {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks", RNA_def_main_texts},
-               {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker datablocks", RNA_def_main_speakers},
-               {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks", RNA_def_main_sounds},
-               {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks", RNA_def_main_armatures},
-               {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks", RNA_def_main_actions},
-               {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks", RNA_def_main_particles},
-               {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks", RNA_def_main_gpencil},
-               {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks", RNA_def_main_movieclips},
-               {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks datablocks", RNA_def_main_masks},
-#ifdef WITH_FREESTYLE
-               {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style datablocks", RNA_def_main_linestyles},
-#endif
+               {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera data-blocks", RNA_def_main_cameras},
+               {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene data-blocks", RNA_def_main_scenes},
+               {"objects", "Object", "rna_Main_object_begin", "Objects", "Object data-blocks", RNA_def_main_objects},
+               {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material data-blocks", RNA_def_main_materials},
+               {"node_groups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group data-blocks", RNA_def_main_node_groups},
+               {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh data-blocks", RNA_def_main_meshes},
+               {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp data-blocks", RNA_def_main_lamps},
+               {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library data-blocks", RNA_def_main_libraries},
+               {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen data-blocks", RNA_def_main_screens},
+               {"window_managers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager data-blocks", RNA_def_main_window_managers},
+               {"images", "Image", "rna_Main_image_begin", "Images", "Image data-blocks", RNA_def_main_images},
+               {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice data-blocks", RNA_def_main_lattices},
+               {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve data-blocks", RNA_def_main_curves},
+               {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball data-blocks", RNA_def_main_metaballs},
+               {"fonts", "VectorFont", "rna_Main_font_begin", "Vector Fonts", "Vector font data-blocks", RNA_def_main_fonts},
+               {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture data-blocks", RNA_def_main_textures},
+               {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush data-blocks", RNA_def_main_brushes},
+               {"worlds", "World", "rna_Main_world_begin", "Worlds", "World data-blocks", RNA_def_main_worlds},
+               {"groups", "Group", "rna_Main_group_begin", "Groups", "Group data-blocks", RNA_def_main_groups},
+               {"shape_keys", "Key", "rna_Main_key_begin", "Shape Keys", "Shape Key data-blocks", NULL},
+               {"texts", "Text", "rna_Main_text_begin", "Texts", "Text data-blocks", RNA_def_main_texts},
+               {"speakers", "Speaker", "rna_Main_speaker_begin", "Speakers", "Speaker data-blocks", RNA_def_main_speakers},
+               {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound data-blocks", RNA_def_main_sounds},
+               {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature data-blocks", RNA_def_main_armatures},
+               {"actions", "Action", "rna_Main_action_begin", "Actions", "Action data-blocks", RNA_def_main_actions},
+               {"palettes", "Palette", "rna_Main_palettes_begin", "Palettes", "Palette data-blocks", RNA_def_main_palettes},
+               {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil data-blocks", RNA_def_main_gpencil},
+               {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip data-blocks", RNA_def_main_movieclips},
+               {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks data-blocks", RNA_def_main_masks},
+               {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style data-blocks", RNA_def_main_linestyles},
+               {"cache_files", "CacheFile", "rna_Main_cachefiles_begin", "Cache Files", "Cache Files data-blocks", RNA_def_main_cachefiles},
+               {"paint_curves", "PaintCurve", "rna_Main_paintcurves_begin", "Paint Curves", "Paint Curves data-blocks", RNA_def_main_paintcurves},
                {NULL, NULL, NULL, NULL, NULL, NULL}
        };
 
@@ -341,7 +368,7 @@ void RNA_def_main(BlenderRNA *brna)
        
        srna = RNA_def_struct(brna, "BlendData", NULL);
        RNA_def_struct_ui_text(srna, "Blendfile Data",
-                              "Main data structure representing a .blend file and all its datablocks");
+                              "Main data structure representing a .blend file and all its data-blocks");
        RNA_def_struct_ui_icon(srna, ICON_BLENDER);
 
        prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
@@ -360,6 +387,16 @@ void RNA_def_main(BlenderRNA *brna)
        RNA_def_property_boolean_funcs(prop, "rna_Main_is_saved_get", NULL);
        RNA_def_property_ui_text(prop, "File is Saved", "Has the current session been saved to disk as a .blend file");
 
+       prop = RNA_def_property(srna, "use_autopack", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Main_use_autopack_get", "rna_Main_use_autopack_set");
+       RNA_def_property_ui_text(prop, "Use Autopack", "Automatically pack all external data into .blend file");
+
+       prop = RNA_def_int_vector(srna, "version", 3, NULL, 0, INT_MAX,
+                          "Version", "Version of Blender the .blend was saved with", 0, INT_MAX);
+       RNA_def_property_int_funcs(prop, "rna_Main_version_get", NULL, NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_flag(prop, PROP_THICK_WRAP);
+
        for (i = 0; lists[i].name; i++) {
                prop = RNA_def_property(srna, lists[i].identifier, PROP_COLLECTION, PROP_NONE);
                RNA_def_property_struct_type(prop, lists[i].type);