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:
authorCampbell Barton <ideasman42@gmail.com>2013-10-01 06:51:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-10-01 06:51:39 +0400
commit6067fa682b0c70778f614ab68af20455befe5a76 (patch)
tree8c943cd9a579825198b406b11fc89e2c4c638d11 /source/blender/editors/render/render_shading.c
parentaaba317c763657d7c309a1c3e96b58f5924afd29 (diff)
de-duplicate report strings for freestyle error checks
Diffstat (limited to 'source/blender/editors/render/render_shading.c')
-rw-r--r--source/blender/editors/render/render_shading.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index c19c5a38517..d04639f95e7 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -588,6 +588,20 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
#ifdef WITH_FREESTYLE
+static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports)
+{
+ if (!lineset) {
+ BKE_report(reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ return false;
+ }
+ if (!lineset->linestyle) {
+ BKE_report(reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ return false;
+ }
+
+ return true;
+}
+
static int freestyle_active_module_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
@@ -894,14 +908,10 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
+
if (BKE_add_linestyle_color_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
return OPERATOR_CANCELLED;
@@ -937,14 +947,10 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
+
if (BKE_add_linestyle_alpha_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
return OPERATOR_CANCELLED;
@@ -980,14 +986,10 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
+
if (BKE_add_linestyle_thickness_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
return OPERATOR_CANCELLED;
@@ -1023,14 +1025,10 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
+
if (BKE_add_linestyle_geometry_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
return OPERATOR_CANCELLED;
@@ -1080,12 +1078,7 @@ static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
LineStyleModifier *modifier = ptr.data;
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
@@ -1134,12 +1127,7 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
LineStyleModifier *modifier = ptr.data;
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
@@ -1189,12 +1177,7 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
LineStyleModifier *modifier = ptr.data;
int dir = RNA_enum_get(op->ptr, "direction");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
- return OPERATOR_CANCELLED;
- }
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}