Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 9e8f60af439..4a081147dd8 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include "RNA_define.h"
#include "RNA_access.h"
@@ -254,16 +255,24 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp)
/* XXX python now has invalid pointer? */
}
-Image *rna_Main_images_new(Main *bmain, char* name, int width, int height, int float_buffer)
+Image *rna_Main_images_new(Main *bmain, char* name, int width, int height, int alpha, int float_buffer)
{
float color[4]= {0.0, 0.0, 0.0, 1.0};
- Image *image= BKE_add_image_size(width, height, name, float_buffer, 0, color);
+ Image *image= BKE_add_image_size(width, height, name, alpha ? 32:24, float_buffer, 0, color);
image->id.us--;
return image;
}
-Image *rna_Main_images_load(Main *bmain, char *filepath)
+Image *rna_Main_images_load(Main *bmain, ReportList *reports, char *filepath)
{
- return BKE_add_image_file(filepath, 0);
+ Image *ima;
+
+ errno= 0;
+ ima= BKE_add_image_file(filepath, 0);
+
+ if(!ima)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unsupported image format");
+
+ return ima;
}
void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
{
@@ -317,9 +326,18 @@ void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall
BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" must have zero users to be removed, found %d.", mb->id.name+2, ID_REAL_USERS(mb));
}
-VFont *rna_Main_fonts_load(Main *bmain, char *filepath)
+VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, char *filepath)
{
- return load_vfont(filepath);
+ VFont *font;
+
+ errno= 0;
+ font= load_vfont(filepath);
+
+ if(!font)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unsupported font format");
+
+ return font;
+
}
void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
{
@@ -395,11 +413,16 @@ void rna_Main_texts_remove(Main *bmain, ReportList *reports, Text *text)
free_libblock(&bmain->text, text);
/* XXX python now has invalid pointer? */
}
-Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* path)
+
+Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* filepath)
{
- Text *txt= add_text(path, bmain->name);
- if(txt==NULL)
- BKE_reportf(reports, RPT_ERROR, "Couldn't load text from path \"%s\".", path);
+ Text *txt;
+
+ errno= 0;
+ txt= add_text(filepath, bmain->name);
+
+ if(!txt)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unable to load text");
return txt;
}
@@ -702,12 +725,14 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_int(func, "width", 1024, 1, INT_MAX, "", "Width of the image.", 0, INT_MAX);
parm= RNA_def_int(func, "height", 1024, 1, INT_MAX, "", "Height of the image.", 0, INT_MAX);
+ parm= RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel");
parm= RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
/* return type */
parm= RNA_def_pointer(func, "image", "Image", "", "New image datablock.");
RNA_def_function_return(func, parm);
func= RNA_def_function(srna, "load", "rna_Main_images_load");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new image into the main database");
parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the file to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -807,6 +832,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_ui_text(srna, "Main Fonts", "Collection of fonts");
func= RNA_def_function(srna, "load", "rna_Main_fonts_load");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new font into the main database");
parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the font to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);