[Bf-blender-cvs] [12a0ccc] master: BGE: Add level mode to property actuator

HG1 noreply at git.blender.org
Fri Jul 18 07:50:16 CEST 2014


Commit: 12a0cccfbf188425153514b3b821198cae558992
Author: HG1
Date:   Thu Jul 17 22:27:58 2014 -0700
https://developer.blender.org/rB12a0cccfbf188425153514b3b821198cae558992

BGE: Add level mode to property actuator

This patch adds to the existing property actuator a level mode, which is switching the property depending on the input level.

Reviewers: moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D652

===================================================================

M	source/blender/editors/space_logic/logic_window.c
M	source/blender/makesdna/DNA_actuator_types.h
M	source/blender/makesrna/intern/rna_actuator.c
M	source/gameengine/GameLogic/SCA_PropertyActuator.cpp
M	source/gameengine/GameLogic/SCA_PropertyActuator.h

===================================================================

diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index c3a3dda..3254727 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -1939,6 +1939,7 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
 
 	switch (RNA_enum_get(ptr, "mode")) {
 		case ACT_PROP_TOGGLE:
+		case ACT_PROP_LEVEL:
 			break;
 		case ACT_PROP_ADD:
 			uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE);
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 7698d67..dcde900 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -397,6 +397,7 @@ typedef struct bActuator {
 #define ACT_PROP_ADD		1
 #define ACT_PROP_COPY		2
 #define ACT_PROP_TOGGLE		3
+#define ACT_PROP_LEVEL		4
 
 /* constraint flag */
 #define ACT_CONST_NONE		0
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index 9d26978..9560770 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -1090,6 +1090,7 @@ static void rna_def_property_actuator(BlenderRNA *brna)
 		{ACT_PROP_ADD, "ADD", 0, "Add", ""},
 		{ACT_PROP_COPY, "COPY", 0, "Copy", ""},
 		{ACT_PROP_TOGGLE, "TOGGLE", 0, "Toggle", "For bool/int/float/timer properties only"},
+		{ACT_PROP_LEVEL, "LEVEL", 0, "Level", "For bool/int/float/timer properties only"},
 		{0, NULL, 0, NULL, NULL}
 	};
 
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 0eab618..ea1b2a2 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -69,13 +69,24 @@ bool SCA_PropertyActuator::Update()
 
 	bool bNegativeEvent = IsNegativeEvent();
 	RemoveAllEvents();
-
+	CValue* propowner = GetParent();
 
 	if (bNegativeEvent)
-		return false; // do nothing on negative events
+	{
+		if (m_type==KX_ACT_PROP_LEVEL)
+		{
+			CValue* newval = new CBoolValue(false);
+			CValue* oldprop = propowner->GetProperty(m_propname);
+			if (oldprop)
+			{
+				oldprop->SetValue(newval);
+			}
+			newval->Release();
+		}
+		return false;
+	}
 
 
-	CValue* propowner = GetParent();
 	CParser parser;
 	parser.SetContext( propowner->AddRef());
 	
@@ -97,6 +108,19 @@ bool SCA_PropertyActuator::Update()
 		}
 		newval->Release();
 	}
+	else if (m_type==KX_ACT_PROP_LEVEL)
+	{
+		CValue* newval = new CBoolValue(true);
+		CValue* oldprop = propowner->GetProperty(m_propname);
+		if (oldprop)
+		{
+			oldprop->SetValue(newval);
+		} else
+		{
+			propowner->SetProperty(m_propname,newval);
+		}
+		newval->Release();
+	}
 	else if ((userexpr = parser.ProcessText(m_exprtxt))) {
 		switch (m_type)
 		{
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 83a6d05..228ecf9 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -44,6 +44,7 @@ class SCA_PropertyActuator : public SCA_IActuator
 		KX_ACT_PROP_ADD,
 		KX_ACT_PROP_COPY,
 		KX_ACT_PROP_TOGGLE,
+		KX_ACT_PROP_LEVEL,
 		KX_ACT_PROP_MAX
 	};




More information about the Bf-blender-cvs mailing list