-Reworked constant nodes better
-Added simple switch node, removed InputEventFilter
This commit is contained in:
parent
028171845f
commit
5567350e1b
8 changed files with 359 additions and 53 deletions
|
@ -58,6 +58,7 @@ void register_visual_script_types() {
|
|||
ObjectTypeDB::register_type<VisualScriptIndexGet>();
|
||||
ObjectTypeDB::register_type<VisualScriptIndexSet>();
|
||||
ObjectTypeDB::register_type<VisualScriptGlobalConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptClassConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptMathConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptEngineSingleton>();
|
||||
ObjectTypeDB::register_type<VisualScriptSceneNode>();
|
||||
|
@ -88,7 +89,7 @@ void register_visual_script_types() {
|
|||
ObjectTypeDB::register_type<VisualScriptIterator>();
|
||||
ObjectTypeDB::register_type<VisualScriptSequence>();
|
||||
ObjectTypeDB::register_type<VisualScriptInputFilter>();
|
||||
ObjectTypeDB::register_type<VisualScriptInputSelector>();
|
||||
ObjectTypeDB::register_type<VisualScriptSwitch >();
|
||||
|
||||
ObjectTypeDB::register_type<VisualScriptYield>();
|
||||
ObjectTypeDB::register_type<VisualScriptYieldSignal>();
|
||||
|
|
|
@ -35,6 +35,7 @@ void VisualScriptNode::ports_changed_notify(){
|
|||
default_input_values.resize( MAX(default_input_values.size(),get_input_value_port_count()) ); //let it grow as big as possible, we don't want to lose values on resize
|
||||
|
||||
emit_signal("ports_changed");
|
||||
|
||||
}
|
||||
|
||||
void VisualScriptNode::set_default_input_value(int p_port,const Variant& p_value) {
|
||||
|
@ -42,6 +43,13 @@ void VisualScriptNode::set_default_input_value(int p_port,const Variant& p_value
|
|||
ERR_FAIL_INDEX(p_port,default_input_values.size());
|
||||
|
||||
default_input_values[p_port]=p_value;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
for (Set<VisualScript*>::Element *E=scripts_used.front();E;E=E->next()) {
|
||||
E->get()->set_edited(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Variant VisualScriptNode::get_default_input_value(int p_port) const {
|
||||
|
@ -126,7 +134,6 @@ Ref<VisualScript> VisualScriptNode::get_visual_script() const {
|
|||
return Ref<VisualScript>(scripts_used.front()->get());
|
||||
|
||||
return Ref<VisualScript>();
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNode::VisualScriptNode() {
|
||||
|
@ -626,6 +633,7 @@ void VisualScript::set_variable_default_value(const StringName& p_name,const Var
|
|||
_update_placeholders();
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
Variant VisualScript::get_variable_default_value(const StringName& p_name) const{
|
||||
|
||||
|
@ -2120,9 +2128,12 @@ void VisualScriptInstance::create(const Ref<VisualScript>& p_script,Object *p_ow
|
|||
|
||||
instance->id=F->key();
|
||||
instance->input_port_count = node->get_input_value_port_count();
|
||||
instance->input_ports=NULL;
|
||||
instance->output_port_count = node->get_output_value_port_count();
|
||||
instance->output_ports=NULL;
|
||||
instance->sequence_output_count = node->get_output_sequence_port_count();
|
||||
instance->sequence_index=function.node_count++;
|
||||
instance->sequence_outputs=NULL;
|
||||
instance->pass_idx=-1;
|
||||
|
||||
if (instance->input_port_count) {
|
||||
|
@ -2591,7 +2602,7 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level,List<String>
|
|||
const StringName *f = _call_stack[l].function;
|
||||
|
||||
ERR_FAIL_COND(!_call_stack[l].instance->functions.has(*f));
|
||||
VisualScriptInstance::Function *func = &_call_stack[l].instance->functions[*f];
|
||||
// VisualScriptInstance::Function *func = &_call_stack[l].instance->functions[*f];
|
||||
|
||||
VisualScriptNodeInstance *node =_call_stack[l].instance->instances[*_call_stack[l].current_id];
|
||||
ERR_FAIL_COND(!node);
|
||||
|
|
|
@ -3115,6 +3115,7 @@ static void register_editor_callback() {
|
|||
EditorSettings::get_singleton()->set("visual_script_editor/color_operators",Color(0.9,0.9,1.0));
|
||||
EditorSettings::get_singleton()->set("visual_script_editor/color_flow_control",Color(1.0,1.0,0.8));
|
||||
EditorSettings::get_singleton()->set("visual_script_editor/color_custom",Color(0.8,1.0,1.0));
|
||||
EditorSettings::get_singleton()->set("visual_script_editor/color_constants",Color(1.0,0.8,1.0));
|
||||
|
||||
|
||||
ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"));
|
||||
|
|
|
@ -603,70 +603,60 @@ VisualScriptSequence::VisualScriptSequence() {
|
|||
////////////////EVENT TYPE FILTER///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
static const char* event_type_names[InputEvent::TYPE_MAX]={
|
||||
"None",
|
||||
"Key",
|
||||
"MouseMotion",
|
||||
"MouseButton",
|
||||
"JoystickMotion",
|
||||
"JoystickButton",
|
||||
"ScreenTouch",
|
||||
"ScreenDrag",
|
||||
"Action"
|
||||
};
|
||||
int VisualScriptSwitch::get_output_sequence_port_count() const {
|
||||
|
||||
int VisualScriptInputSelector::get_output_sequence_port_count() const {
|
||||
|
||||
return InputEvent::TYPE_MAX;
|
||||
return case_values.size();
|
||||
}
|
||||
|
||||
bool VisualScriptInputSelector::has_input_sequence_port() const{
|
||||
bool VisualScriptSwitch::has_input_sequence_port() const{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptInputSelector::get_input_value_port_count() const{
|
||||
int VisualScriptSwitch::get_input_value_port_count() const{
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptInputSelector::get_output_value_port_count() const{
|
||||
int VisualScriptSwitch::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptInputSelector::get_output_sequence_port_text(int p_port) const {
|
||||
String VisualScriptSwitch::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return event_type_names[p_port];
|
||||
if (case_values[p_port].value.get_type()==Variant::NIL)
|
||||
return "null";
|
||||
return case_values[p_port].value;
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptInputSelector::get_input_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptSwitch::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::INPUT_EVENT,"event");
|
||||
return PropertyInfo(Variant::NIL,"input");
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptInputSelector::get_output_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::INPUT_EVENT,"");
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptInputSelector::get_caption() const {
|
||||
String VisualScriptSwitch::get_caption() const {
|
||||
|
||||
return "InputSelector";
|
||||
return "Switch";
|
||||
}
|
||||
|
||||
String VisualScriptInputSelector::get_text() const {
|
||||
String VisualScriptSwitch::get_text() const {
|
||||
|
||||
return "";
|
||||
return "'input' is:";
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceInputSelector : public VisualScriptNodeInstance {
|
||||
class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptInstance* instance;
|
||||
InputEvent::Type type;
|
||||
Vector<Variant> case_values;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
|
@ -680,31 +670,114 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
InputEvent event = *p_inputs[0];
|
||||
for(int i=0;i<case_values.size();i++) {
|
||||
|
||||
*p_outputs[0] = event;
|
||||
if (*p_inputs[0]==case_values[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return event.type;
|
||||
return STEP_NO_ADVANCE_BIT;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptInputSelector::instance(VisualScriptInstance* p_instance) {
|
||||
VisualScriptNodeInstance* VisualScriptSwitch::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceInputSelector * instance = memnew(VisualScriptNodeInstanceInputSelector );
|
||||
VisualScriptNodeInstanceSwitch * instance = memnew(VisualScriptNodeInstanceSwitch );
|
||||
instance->instance=p_instance;
|
||||
instance->case_values.resize(case_values.size());
|
||||
for(int i=0;i<case_values.size();i++) {
|
||||
instance->case_values[i]=case_values[i].value;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool VisualScriptSwitch::_set(const StringName& p_name, const Variant& p_value) {
|
||||
|
||||
if (String(p_name)=="case_count") {
|
||||
case_values.resize(p_value);
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String(p_name).begins_with("case/")) {
|
||||
|
||||
int idx = String(p_name).get_slice("/",1).to_int();
|
||||
ERR_FAIL_INDEX_V(idx,case_values.size(),false);
|
||||
String what = String(p_name).get_slice("/",2);
|
||||
|
||||
if (what=="type") {
|
||||
case_values[idx].type=Variant::Type(int(p_value));
|
||||
Variant::CallError ce;
|
||||
case_values[idx].value=Variant::construct(case_values[idx].type,NULL,0,ce);
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (what=="value") {
|
||||
case_values[idx].value=p_value;
|
||||
ports_changed_notify();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VisualScriptSwitch::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
|
||||
if (String(p_name)=="case_count") {
|
||||
r_ret=case_values.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String(p_name).begins_with("case/")) {
|
||||
|
||||
int idx = String(p_name).get_slice("/",1).to_int();
|
||||
ERR_FAIL_INDEX_V(idx,case_values.size(),false);
|
||||
String what = String(p_name).get_slice("/",2);
|
||||
|
||||
if (what=="type") {
|
||||
r_ret=case_values[idx].type;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (what=="value") {
|
||||
r_ret=case_values[idx].value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
void VisualScriptSwitch::_get_property_list( List<PropertyInfo> *p_list) const {
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"case_count",PROPERTY_HINT_RANGE,"0,128"));
|
||||
|
||||
String argt="Any";
|
||||
for(int i=1;i<Variant::VARIANT_MAX;i++) {
|
||||
argt+=","+Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
for(int i=0;i<case_values.size();i++) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"case/"+itos(i)+"/type",PROPERTY_HINT_ENUM,argt));
|
||||
p_list->push_back(PropertyInfo(case_values[i].type,"case/"+itos(i)+"/value"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptInputSelector::_bind_methods() {
|
||||
void VisualScriptSwitch::_bind_methods() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
VisualScriptInputSelector::VisualScriptInputSelector() {
|
||||
VisualScriptSwitch::VisualScriptSwitch() {
|
||||
|
||||
|
||||
}
|
||||
|
@ -1359,6 +1432,19 @@ bool VisualScriptInputFilter::_get(const StringName& p_name,Variant &r_ret) cons
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* event_type_names[InputEvent::TYPE_MAX]={
|
||||
"None",
|
||||
"Key",
|
||||
"MouseMotion",
|
||||
"MouseButton",
|
||||
"JoystickMotion",
|
||||
"JoystickButton",
|
||||
"ScreenTouch",
|
||||
"ScreenDrag",
|
||||
"Action"
|
||||
};
|
||||
|
||||
void VisualScriptInputFilter::_get_property_list( List<PropertyInfo> *p_list) const {
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"filter_count",PROPERTY_HINT_RANGE,"0,64"));
|
||||
|
@ -1866,7 +1952,7 @@ void register_visual_script_flow_control_nodes() {
|
|||
VisualScriptLanguage::singleton->add_register_func("flow_control/while",create_node_generic<VisualScriptWhile>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator",create_node_generic<VisualScriptIterator>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/sequence",create_node_generic<VisualScriptSequence>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/input_select",create_node_generic<VisualScriptInputSelector>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/switch",create_node_generic<VisualScriptSwitch>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/input_filter",create_node_generic<VisualScriptInputFilter>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast",create_node_generic<VisualScriptTypeCast>);
|
||||
|
||||
|
|
|
@ -197,14 +197,25 @@ public:
|
|||
|
||||
|
||||
|
||||
class VisualScriptInputSelector : public VisualScriptNode {
|
||||
class VisualScriptSwitch : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptInputSelector,VisualScriptNode)
|
||||
OBJ_TYPE(VisualScriptSwitch,VisualScriptNode)
|
||||
|
||||
struct Case {
|
||||
Variant::Type type;
|
||||
Variant value;
|
||||
Case() { type=Variant::NIL; }
|
||||
};
|
||||
|
||||
Vector<Case> case_values;
|
||||
|
||||
friend class VisualScriptNodeInstanceSwitch;
|
||||
protected:
|
||||
|
||||
bool _set(const StringName& p_name, const Variant& p_value);
|
||||
bool _get(const StringName& p_name,Variant &r_ret) const;
|
||||
void _get_property_list( List<PropertyInfo> *p_list) const;
|
||||
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
|
@ -229,7 +240,7 @@ public:
|
|||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
|
||||
VisualScriptInputSelector();
|
||||
VisualScriptSwitch();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1434,6 +1434,141 @@ VisualScriptGlobalConstant::VisualScriptGlobalConstant() {
|
|||
index=0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////CLASSCONSTANT///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptClassConstant::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptClassConstant::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptClassConstant::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptClassConstant::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptClassConstant::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptClassConstant::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::INT,"value");
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptClassConstant::get_caption() const {
|
||||
|
||||
return "ClassConst";
|
||||
}
|
||||
|
||||
String VisualScriptClassConstant::get_text() const {
|
||||
|
||||
return String(base_type)+"."+String(name);
|
||||
}
|
||||
|
||||
void VisualScriptClassConstant::set_class_constant(const StringName& p_which) {
|
||||
|
||||
name=p_which;
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
StringName VisualScriptClassConstant::get_class_constant() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptClassConstant::set_base_type(const StringName& p_which) {
|
||||
|
||||
base_type=p_which;
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
StringName VisualScriptClassConstant::get_base_type() {
|
||||
return base_type;
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceClassConstant : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
int value;
|
||||
bool valid;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,StartMode p_start_mode,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (!valid) {
|
||||
r_error_str="Invalid constant name, pick a valid class constant.";
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
}
|
||||
|
||||
*p_outputs[0] = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptClassConstant::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceClassConstant * instance = memnew(VisualScriptNodeInstanceClassConstant );
|
||||
instance->value=ObjectTypeDB::get_integer_constant(base_type,name,&instance->valid);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void VisualScriptClassConstant::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
if (property.name=="constant") {
|
||||
|
||||
List<String> constants;
|
||||
ObjectTypeDB::get_integer_constant_list(base_type,&constants,true);
|
||||
|
||||
property.hint_string="";
|
||||
for(List<String>::Element *E=constants.front();E;E=E->next()) {
|
||||
if (property.hint_string!=String()) {
|
||||
property.hint_string+=",";
|
||||
}
|
||||
property.hint_string+=E->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptClassConstant::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_class_constant","name"),&VisualScriptClassConstant::set_class_constant);
|
||||
ObjectTypeDB::bind_method(_MD("get_class_constant"),&VisualScriptClassConstant::get_class_constant);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_base_type","name"),&VisualScriptClassConstant::set_base_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_type"),&VisualScriptClassConstant::get_base_type);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,""),_SCS("set_class_constant"),_SCS("get_class_constant"));
|
||||
}
|
||||
|
||||
VisualScriptClassConstant::VisualScriptClassConstant() {
|
||||
|
||||
base_type="Object";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
@ -3442,22 +3577,24 @@ void register_visual_script_nodes() {
|
|||
|
||||
VisualScriptLanguage::singleton->add_register_func("data/set_variable",create_node_generic<VisualScriptVariableSet>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/get_variable",create_node_generic<VisualScriptVariableGet>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/constant",create_node_generic<VisualScriptConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/global_constant",create_node_generic<VisualScriptGlobalConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/math_constant",create_node_generic<VisualScriptMathConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/engine_singleton",create_node_generic<VisualScriptEngineSingleton>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/scene_node",create_node_generic<VisualScriptSceneNode>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/scene_tree",create_node_generic<VisualScriptSceneTree>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/resource_path",create_node_generic<VisualScriptResourcePath>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/self",create_node_generic<VisualScriptSelf>);
|
||||
VisualScriptLanguage::singleton->add_register_func("custom/custom_node",create_node_generic<VisualScriptCustomNode>);
|
||||
VisualScriptLanguage::singleton->add_register_func("custom/sub_call",create_node_generic<VisualScriptSubCall>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/comment",create_node_generic<VisualScriptComment>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/get_local_variable",create_node_generic<VisualScriptLocalVar>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/set_local_variable",create_node_generic<VisualScriptLocalVarSet>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/preload",create_node_generic<VisualScriptPreload>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/action",create_node_generic<VisualScriptInputAction>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("constants/constant",create_node_generic<VisualScriptConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("constants/math_constant",create_node_generic<VisualScriptMathConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("constants/class_constant",create_node_generic<VisualScriptClassConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("constants/global_constant",create_node_generic<VisualScriptGlobalConstant>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("custom/custom_node",create_node_generic<VisualScriptCustomNode>);
|
||||
VisualScriptLanguage::singleton->add_register_func("custom/sub_call",create_node_generic<VisualScriptSubCall>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("index/get_index",create_node_generic<VisualScriptIndexGet>);
|
||||
VisualScriptLanguage::singleton->add_register_func("index/set_index",create_node_generic<VisualScriptIndexSet>);
|
||||
|
|
|
@ -219,7 +219,7 @@ public:
|
|||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
virtual String get_category() const { return "constants"; }
|
||||
|
||||
void set_constant_type(Variant::Type p_type);
|
||||
Variant::Type get_constant_type() const;
|
||||
|
@ -360,7 +360,7 @@ public:
|
|||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
virtual String get_category() const { return "constants"; }
|
||||
|
||||
void set_global_constant(int p_which);
|
||||
int get_global_constant();
|
||||
|
@ -371,6 +371,47 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class VisualScriptClassConstant : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptClassConstant,VisualScriptNode)
|
||||
|
||||
StringName base_type;
|
||||
StringName name;
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
virtual void _validate_property(PropertyInfo& property) const;
|
||||
|
||||
public:
|
||||
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "constants"; }
|
||||
|
||||
void set_class_constant(const StringName& p_which);
|
||||
StringName get_class_constant();
|
||||
|
||||
void set_base_type(const StringName& p_which);
|
||||
StringName get_base_type();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptClassConstant();
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptMathConstant : public VisualScriptNode {
|
||||
|
||||
|
@ -411,7 +452,7 @@ public:
|
|||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
virtual String get_category() const { return "constants"; }
|
||||
|
||||
void set_math_constant(MathConstant p_which);
|
||||
MathConstant get_math_constant();
|
||||
|
|
|
@ -91,6 +91,15 @@ void CustomPropertyEditor::_menu_option(int p_which) {
|
|||
|
||||
}
|
||||
} break;
|
||||
case Variant::STRING: {
|
||||
|
||||
if (hint==PROPERTY_HINT_ENUM) {
|
||||
|
||||
v=hint_text.get_slice(",",p_which);
|
||||
emit_signal("variant_changed");
|
||||
|
||||
}
|
||||
} break;
|
||||
case Variant::OBJECT: {
|
||||
|
||||
switch(p_which) {
|
||||
|
@ -446,7 +455,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
|
|||
config_action_buttons(names);
|
||||
} else if (hint==PROPERTY_HINT_ENUM) {
|
||||
|
||||
|
||||
menu->clear();
|
||||
Vector<String> options = hint_text.split(",");
|
||||
for(int i=0;i<options.size();i++) {
|
||||
menu->add_item(options[i],i);
|
||||
}
|
||||
menu->set_pos(get_pos());
|
||||
menu->popup();
|
||||
hide();
|
||||
updating=false;
|
||||
return false;
|
||||
|
||||
} else if (hint==PROPERTY_HINT_MULTILINE_TEXT) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue