2017-03-05 15:47:28 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* visual_script_flow_control.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2017-03-05 15:47:28 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2016-08-03 00:11:05 +02:00
|
|
|
#include "visual_script_flow_control.h"
|
2017-03-05 15:47:28 +01:00
|
|
|
|
2017-02-21 04:05:15 +01:00
|
|
|
#include "global_config.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "os/keyboard.h"
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2016-08-03 00:11:05 +02:00
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////RETURN////////////////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptReturn::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptReturn::has_input_sequence_port() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptReturn::get_input_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return with_value ? 1 : 0;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptReturn::get_output_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
|
|
|
return String();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptReturn::get_input_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
PropertyInfo pinfo;
|
2017-03-05 16:44:50 +01:00
|
|
|
pinfo.name = "result";
|
|
|
|
pinfo.type = type;
|
2016-08-03 00:11:05 +02:00
|
|
|
return pinfo;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
return PropertyInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptReturn::get_caption() const {
|
|
|
|
|
|
|
|
return "Return";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptReturn::get_text() const {
|
|
|
|
|
|
|
|
return get_name();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptReturn::set_return_type(Variant::Type p_type) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (type == p_type)
|
2016-08-03 00:11:05 +02:00
|
|
|
return;
|
2017-03-05 16:44:50 +01:00
|
|
|
type = p_type;
|
2016-08-04 03:06:39 +02:00
|
|
|
ports_changed_notify();
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant::Type VisualScriptReturn::get_return_type() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptReturn::set_enable_return_value(bool p_enable) {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (with_value == p_enable)
|
2016-08-03 00:11:05 +02:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
with_value = p_enable;
|
2016-08-04 03:06:39 +02:00
|
|
|
ports_changed_notify();
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VisualScriptReturn::is_return_value_enabled() const {
|
|
|
|
|
|
|
|
return with_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptReturn::_bind_methods() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_return_type", "type"), &VisualScriptReturn::set_return_type);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_return_type"), &VisualScriptReturn::get_return_type);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_enable_return_value", "enable"), &VisualScriptReturn::set_enable_return_value);
|
|
|
|
ClassDB::bind_method(D_METHOD("is_return_value_enabled"), &VisualScriptReturn::is_return_value_enabled);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String argt = "Any";
|
|
|
|
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
argt += "," + Variant::get_type_name(Variant::Type(i));
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "return_value/enabled"), "set_enable_return_value", "is_return_value_enabled");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "return_value/type", PROPERTY_HINT_ENUM, argt), "set_return_type", "get_return_type");
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
class VisualScriptNodeInstanceReturn : public VisualScriptNodeInstance {
|
|
|
|
public:
|
|
|
|
VisualScriptReturn *node;
|
|
|
|
VisualScriptInstance *instance;
|
|
|
|
bool with_value;
|
|
|
|
|
|
|
|
virtual int get_working_memory_size() const { return 1; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
if (with_value) {
|
|
|
|
*p_working_mem = *p_inputs[0];
|
|
|
|
} else {
|
|
|
|
*p_working_mem = Variant();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_instance) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
|
|
|
|
instance->node = this;
|
|
|
|
instance->instance = p_instance;
|
|
|
|
instance->with_value = with_value;
|
2016-08-06 03:46:45 +02:00
|
|
|
return instance;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptReturn::VisualScriptReturn() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
with_value = false;
|
|
|
|
type = Variant::NIL;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
template <bool with_value>
|
|
|
|
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
Ref<VisualScriptReturn> node;
|
|
|
|
node.instance();
|
|
|
|
node->set_enable_return_value(with_value);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////CONDITION/////////////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptCondition::get_output_sequence_port_count() const {
|
|
|
|
|
2016-08-29 01:57:27 +02:00
|
|
|
return 3;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptCondition::has_input_sequence_port() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptCondition::get_input_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptCondition::get_output_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptCondition::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_port == 0)
|
2016-08-03 00:11:05 +02:00
|
|
|
return "true";
|
2017-03-05 16:44:50 +01:00
|
|
|
else if (p_port == 1)
|
2016-08-03 00:11:05 +02:00
|
|
|
return "false";
|
2016-08-29 01:57:27 +02:00
|
|
|
else
|
|
|
|
return "done";
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptCondition::get_input_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
PropertyInfo pinfo;
|
2017-03-05 16:44:50 +01:00
|
|
|
pinfo.name = "cond";
|
|
|
|
pinfo.type = Variant::BOOL;
|
2016-08-03 00:11:05 +02:00
|
|
|
return pinfo;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
return PropertyInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptCondition::get_caption() const {
|
|
|
|
|
|
|
|
return "Condition";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptCondition::get_text() const {
|
|
|
|
|
|
|
|
return "if (cond) is: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptCondition::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
class VisualScriptNodeInstanceCondition : public VisualScriptNodeInstance {
|
|
|
|
public:
|
|
|
|
VisualScriptCondition *node;
|
|
|
|
VisualScriptInstance *instance;
|
|
|
|
|
|
|
|
//virtual int get_working_memory_size() const { return 1; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE)
|
2016-08-29 01:57:27 +02:00
|
|
|
return 2;
|
|
|
|
else if (p_inputs[0]->operator bool())
|
|
|
|
return 0 | STEP_FLAG_PUSH_STACK_BIT;
|
2016-08-06 03:46:45 +02:00
|
|
|
else
|
2016-08-29 01:57:27 +02:00
|
|
|
return 1 | STEP_FLAG_PUSH_STACK_BIT;
|
2016-08-06 03:46:45 +02:00
|
|
|
}
|
|
|
|
};
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptCondition::instance(VisualScriptInstance *p_instance) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
|
|
|
|
instance->node = this;
|
|
|
|
instance->instance = p_instance;
|
2016-08-06 03:46:45 +02:00
|
|
|
return instance;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptCondition::VisualScriptCondition() {
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////WHILE/////////////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptWhile::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptWhile::has_input_sequence_port() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptWhile::get_input_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptWhile::get_output_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptWhile::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_port == 0)
|
2016-08-03 00:11:05 +02:00
|
|
|
return "repeat";
|
|
|
|
else
|
|
|
|
return "exit";
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptWhile::get_input_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
PropertyInfo pinfo;
|
2017-03-05 16:44:50 +01:00
|
|
|
pinfo.name = "cond";
|
|
|
|
pinfo.type = Variant::BOOL;
|
2016-08-03 00:11:05 +02:00
|
|
|
return pinfo;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
return PropertyInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptWhile::get_caption() const {
|
|
|
|
|
|
|
|
return "While";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptWhile::get_text() const {
|
|
|
|
|
|
|
|
return "while (cond): ";
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptWhile::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
class VisualScriptNodeInstanceWhile : public VisualScriptNodeInstance {
|
|
|
|
public:
|
|
|
|
VisualScriptWhile *node;
|
|
|
|
VisualScriptInstance *instance;
|
|
|
|
|
|
|
|
//virtual int get_working_memory_size() const { return 1; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
bool keep_going = p_inputs[0]->operator bool();
|
|
|
|
|
|
|
|
if (keep_going)
|
2017-03-05 16:44:50 +01:00
|
|
|
return 0 | STEP_FLAG_PUSH_STACK_BIT;
|
2016-08-06 03:46:45 +02:00
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptWhile::instance(VisualScriptInstance *p_instance) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
|
|
|
|
instance->node = this;
|
|
|
|
instance->instance = p_instance;
|
2016-08-06 03:46:45 +02:00
|
|
|
return instance;
|
|
|
|
}
|
2016-08-03 00:11:05 +02:00
|
|
|
VisualScriptWhile::VisualScriptWhile() {
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////ITERATOR/////////////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptIterator::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptIterator::has_input_sequence_port() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptIterator::get_input_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptIterator::get_output_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptIterator::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_port == 0)
|
2016-08-03 00:11:05 +02:00
|
|
|
return "each";
|
|
|
|
else
|
|
|
|
return "exit";
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptIterator::get_input_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
PropertyInfo pinfo;
|
2017-03-05 16:44:50 +01:00
|
|
|
pinfo.name = "input";
|
|
|
|
pinfo.type = Variant::NIL;
|
2016-08-03 00:11:05 +02:00
|
|
|
return pinfo;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
PropertyInfo pinfo;
|
2017-03-05 16:44:50 +01:00
|
|
|
pinfo.name = "elem";
|
|
|
|
pinfo.type = Variant::NIL;
|
2016-08-03 00:11:05 +02:00
|
|
|
return pinfo;
|
|
|
|
}
|
|
|
|
String VisualScriptIterator::get_caption() const {
|
|
|
|
|
|
|
|
return "Iterator";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptIterator::get_text() const {
|
|
|
|
|
|
|
|
return "for (elem) in (input): ";
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptIterator::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
class VisualScriptNodeInstanceIterator : public VisualScriptNodeInstance {
|
|
|
|
public:
|
|
|
|
VisualScriptIterator *node;
|
|
|
|
VisualScriptInstance *instance;
|
|
|
|
|
|
|
|
virtual int get_working_memory_size() const { return 2; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
|
|
|
|
p_working_mem[0] = *p_inputs[0];
|
2016-08-06 03:46:45 +02:00
|
|
|
bool valid;
|
2017-03-05 16:44:50 +01:00
|
|
|
bool can_iter = p_inputs[0]->iter_init(p_working_mem[1], valid);
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
if (!valid) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = RTR("Input type not iterable: ") + Variant::get_type_name(p_inputs[0]->get_type());
|
2016-08-06 03:46:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
if (!can_iter)
|
|
|
|
return 1; //nothing to iterate
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
if (!valid) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = RTR("Iterator became invalid");
|
2016-08-06 03:46:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-08 00:22:33 +02:00
|
|
|
} else { //continue sequence
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
bool valid;
|
2017-03-05 16:44:50 +01:00
|
|
|
bool can_iter = p_working_mem[0].iter_next(p_working_mem[1], valid);
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
if (!valid) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = RTR("Iterator became invalid: ") + Variant::get_type_name(p_inputs[0]->get_type());
|
2016-08-06 03:46:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!can_iter)
|
|
|
|
return 1; //nothing to iterate
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
|
2016-08-06 03:46:45 +02:00
|
|
|
|
|
|
|
if (!valid) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = RTR("Iterator became invalid");
|
2016-08-06 03:46:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return 0 | STEP_FLAG_PUSH_STACK_BIT; //go around
|
2016-08-06 03:46:45 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptIterator::instance(VisualScriptInstance *p_instance) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
|
|
|
|
instance->node = this;
|
|
|
|
instance->instance = p_instance;
|
2016-08-06 03:46:45 +02:00
|
|
|
return instance;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptIterator::VisualScriptIterator() {
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////SEQUENCE/////////////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptSequence::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return steps;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptSequence::has_input_sequence_port() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptSequence::get_input_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptSequence::get_output_value_port_count() const {
|
2016-08-03 00:11:05 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptSequence::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return itos(p_port + 1);
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptSequence::get_input_value_port_info(int p_idx) const {
|
2016-08-03 00:11:05 +02:00
|
|
|
return PropertyInfo();
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
|
|
|
|
return PropertyInfo(Variant::INT, "current");
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
String VisualScriptSequence::get_caption() const {
|
|
|
|
|
|
|
|
return "Sequence";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptSequence::get_text() const {
|
|
|
|
|
|
|
|
return "in order: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptSequence::set_steps(int p_steps) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(p_steps < 1);
|
|
|
|
if (steps == p_steps)
|
2016-08-03 00:11:05 +02:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
steps = p_steps;
|
2016-08-04 03:06:39 +02:00
|
|
|
ports_changed_notify();
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int VisualScriptSequence::get_steps() const {
|
|
|
|
|
|
|
|
return steps;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptSequence::_bind_methods() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_steps", "steps"), &VisualScriptSequence::set_steps);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_steps"), &VisualScriptSequence::get_steps);
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "steps", PROPERTY_HINT_RANGE, "1,64,1"), "set_steps", "get_steps");
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2016-08-06 03:46:45 +02:00
|
|
|
class VisualScriptNodeInstanceSequence : public VisualScriptNodeInstance {
|
|
|
|
public:
|
|
|
|
VisualScriptSequence *node;
|
|
|
|
VisualScriptInstance *instance;
|
|
|
|
int steps;
|
|
|
|
|
|
|
|
virtual int get_working_memory_size() const { return 1; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_working_mem[0] = 0;
|
2016-08-06 03:46:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int step = p_working_mem[0];
|
2016-08-03 00:11:05 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
*p_outputs[0] = step;
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (step + 1 == steps)
|
2016-08-06 03:46:45 +02:00
|
|
|
return step;
|
|
|
|
else {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_working_mem[0] = step + 1;
|
|
|
|
return step | STEP_FLAG_PUSH_STACK_BIT;
|
2016-08-06 03:46:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptSequence::instance(VisualScriptInstance *p_instance) {
|
2016-08-06 03:46:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
|
|
|
|
instance->node = this;
|
|
|
|
instance->instance = p_instance;
|
|
|
|
instance->steps = steps;
|
2016-08-06 03:46:45 +02:00
|
|
|
return instance;
|
|
|
|
}
|
2016-08-03 00:11:05 +02:00
|
|
|
VisualScriptSequence::VisualScriptSequence() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
steps = 1;
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|
|
|
|
|
2016-08-08 00:22:33 +02:00
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////EVENT TYPE FILTER///////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
int VisualScriptSwitch::get_output_sequence_port_count() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return case_values.size() + 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptSwitch::has_input_sequence_port() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptSwitch::get_input_value_port_count() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return case_values.size() + 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptSwitch::get_output_value_port_count() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
return 0;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
String VisualScriptSwitch::get_output_sequence_port_text(int p_port) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_port == case_values.size())
|
2016-08-31 22:58:51 +02:00
|
|
|
return "done";
|
|
|
|
|
2016-09-02 01:04:17 +02:00
|
|
|
return String();
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptSwitch::get_input_value_port_info(int p_idx) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_idx < case_values.size()) {
|
|
|
|
return PropertyInfo(case_values[p_idx].type, " =");
|
2016-09-02 01:04:17 +02:00
|
|
|
} else
|
2017-03-05 16:44:50 +01:00
|
|
|
return PropertyInfo(Variant::NIL, "input");
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
return PropertyInfo();
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
String VisualScriptSwitch::get_caption() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
return "Switch";
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
String VisualScriptSwitch::get_text() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
return "'input' is:";
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
|
2016-08-08 00:22:33 +02:00
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptInstance *instance;
|
2016-09-02 01:04:17 +02:00
|
|
|
int case_count;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
//virtual int get_working_memory_size() const { return 0; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
|
2016-09-02 01:04:17 +02:00
|
|
|
return case_count; //exit
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < case_count; i++) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (*p_inputs[i] == *p_inputs[case_count]) {
|
|
|
|
return i | STEP_FLAG_PUSH_STACK_BIT;
|
2016-08-31 17:49:45 +02:00
|
|
|
}
|
|
|
|
}
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-09-02 01:04:17 +02:00
|
|
|
return case_count;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_instance) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
|
|
|
|
instance->instance = p_instance;
|
|
|
|
instance->case_count = case_values.size();
|
2016-08-08 00:22:33 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) {
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (String(p_name) == "case_count") {
|
2016-08-31 17:49:45 +02:00
|
|
|
case_values.resize(p_value);
|
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String(p_name).begins_with("case/")) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int idx = String(p_name).get_slice("/", 1).to_int();
|
|
|
|
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
case_values[idx].type = Variant::Type(int(p_value));
|
2016-09-02 01:04:17 +02:00
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2016-09-02 01:04:17 +02:00
|
|
|
return true;
|
2016-08-31 17:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptSwitch::_get(const StringName &p_name, Variant &r_ret) const {
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (String(p_name) == "case_count") {
|
|
|
|
r_ret = case_values.size();
|
2016-08-31 17:49:45 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String(p_name).begins_with("case/")) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int idx = String(p_name).get_slice("/", 1).to_int();
|
|
|
|
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
r_ret = case_values[idx].type;
|
2016-09-02 01:04:17 +02:00
|
|
|
return true;
|
2016-08-31 17:49:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const {
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, "case_count", PROPERTY_HINT_RANGE, "0,128"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String argt = "Any";
|
|
|
|
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
argt += "," + Variant::get_type_name(Variant::Type(i));
|
2016-08-31 17:49:45 +02:00
|
|
|
}
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < case_values.size(); i++) {
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, "case/" + itos(i), PROPERTY_HINT_ENUM, argt));
|
2016-08-31 17:49:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptSwitch::_bind_methods() {
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-31 17:49:45 +02:00
|
|
|
VisualScriptSwitch::VisualScriptSwitch() {
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
////////////////EVENT ACTION FILTER///////////
|
|
|
|
//////////////////////////////////////////
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
#if 0
|
2016-08-08 00:22:33 +02:00
|
|
|
int VisualScriptInputFilter::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return filters.size();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptInputFilter::has_input_sequence_port() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptInputFilter::get_input_value_port_count() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptInputFilter::get_output_value_port_count() const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
|
|
|
String text;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (filters[p_port].type) {
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::NONE: {
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "None";
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::KEY: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
InputEventKey k = filters[p_port].key;
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_scancode() == 0 && k.unicode == 0) {
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "No Key";
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_scancode() != 0) {
|
|
|
|
text = "KeyCode: " + keycode_get_string(k->get_scancode());
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (k.unicode != 0) {
|
|
|
|
text = "Uniode: " + String::chr(k.unicode);
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->is_pressed())
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Pressed";
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Released";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (k.echo)
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Echo";
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_alt())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Alt+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_shift())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Shift+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_control())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Ctrl+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_metakey())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Meta+" + text;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventMouseMotion mm = filters[p_port].mouse_motion;
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Mouse Motion";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < 7; i++) {
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_button_mask() & (1 << i)) {
|
2017-03-05 16:44:50 +01:00
|
|
|
text = b.get_slice(",", i) + "+" + text;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_alt())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Alt+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_shift())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Shift+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_control())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Ctrl+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_metakey())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Meta+" + text;
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
InputEventMouseButton mb = filters[p_port].mouse_button;
|
|
|
|
|
|
|
|
String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
text = b.get_slice(",", mb->get_button_index()) + " Mouse Button";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->is_pressed())
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Pressed";
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Released";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (mb.doubleclick)
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", DblClick";
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->get_alt())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Alt+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->get_shift())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Shift+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->get_control())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Ctrl+" + text;
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->get_metakey())
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Meta+" + text;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-01-08 21:05:51 +01:00
|
|
|
InputEventJoypadMotion jm = filters[p_port].joy_motion;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "JoyMotion Axis " + itos(jm.axis >> 1);
|
|
|
|
if (jm.axis & 1)
|
|
|
|
text += " > " + rtos(jm.axis_value);
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += " < " + rtos(-jm.axis_value);
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_BUTTON: {
|
2017-01-08 21:05:51 +01:00
|
|
|
InputEventJoypadButton jb = filters[p_port].joy_button;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
text = "JoyButton " + itos(jb->get_button_index());
|
|
|
|
if (jb->is_pressed())
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Pressed";
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Released";
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_TOUCH: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventScreenTouch sd = filters[p_port].screen_touch;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Touch Finger " + itos(sd.index);
|
2017-05-20 17:38:03 +02:00
|
|
|
if (sd->is_pressed())
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Pressed";
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Released";
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_DRAG: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventScreenDrag sd = filters[p_port].screen_drag;
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "Drag Finger " + itos(sd.index);
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::ACTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
List<PropertyInfo> pinfo;
|
2017-01-05 13:16:00 +01:00
|
|
|
GlobalConfig::get_singleton()->get_property_list(&pinfo);
|
2017-03-05 16:44:50 +01:00
|
|
|
int index = 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
text = "No Action";
|
|
|
|
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
|
|
|
const PropertyInfo &pi = E->get();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (!pi.name.begins_with("input/"))
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (filters[p_port].action.action == index) {
|
|
|
|
text = "Action " + pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
2016-08-08 00:22:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (filters[p_port].action->is_pressed())
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Pressed";
|
2016-08-08 00:22:33 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
text += ", Released";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return text + " - " + itos(p_port);
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptInputFilter::get_input_value_port_info(int p_idx) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return PropertyInfo(Variant::INPUT_EVENT, "event");
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptInputFilter::get_output_value_port_info(int p_idx) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return PropertyInfo(Variant::INPUT_EVENT, "");
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptInputFilter::get_caption() const {
|
|
|
|
|
|
|
|
return "InputFilter";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptInputFilter::get_text() const {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_value) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_name == "filter_count") {
|
2016-08-08 00:22:33 +02:00
|
|
|
filters.resize(p_value);
|
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String(p_name).begins_with("filter_")) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int idx = String(p_name).replace_first("filters_", "").get_slice("/", 0).to_int();
|
|
|
|
|
|
|
|
ERR_FAIL_INDEX_V(idx, filters.size(), false);
|
|
|
|
|
|
|
|
String what = String(p_name).get_slice("/", 1);
|
|
|
|
|
|
|
|
if (what == "type") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx] = Ref<InputEvent>();
|
|
|
|
filters[idx].type = Ref<InputEvent>::Type(int(p_value));
|
|
|
|
if (filters[idx].type == Ref<InputEvent>::JOYPAD_MOTION) {
|
2017-03-05 16:44:50 +01:00
|
|
|
filters[idx].joy_motion.axis_value = 0.5; //for treshold
|
2017-05-20 17:38:03 +02:00
|
|
|
} else if (filters[idx].type == Ref<InputEvent>::KEY) {
|
|
|
|
filters[idx]->is_pressed() = true; //put these as true to make it more user friendly
|
|
|
|
} else if (filters[idx].type == Ref<InputEvent>::MOUSE_BUTTON) {
|
|
|
|
filters[idx]->is_pressed() = true;
|
|
|
|
} else if (filters[idx].type == Ref<InputEvent>::JOYPAD_BUTTON) {
|
|
|
|
filters[idx].joy_button->is_pressed() = true;
|
|
|
|
} else if (filters[idx].type == Ref<InputEvent>::SCREEN_TOUCH) {
|
|
|
|
filters[idx].screen_touch->is_pressed() = true;
|
|
|
|
} else if (filters[idx].type == Ref<InputEvent>::ACTION) {
|
|
|
|
filters[idx].action->is_pressed() = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "device") {
|
|
|
|
filters[idx].device = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (filters[idx].type) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::KEY: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "scancode") {
|
2016-08-08 00:22:33 +02:00
|
|
|
String sc = p_value;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (sc == String()) {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_scancode() = 0;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_scancode() = find_keycode(p_value);
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "unicode") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
String uc = p_value;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (uc == String()) {
|
|
|
|
filters[idx].key.unicode = 0;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
filters[idx].key.unicode = uc[0];
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->is_pressed() = p_value;
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "echo") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->is_echo() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_alt() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_shift() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_control() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_metakey() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_mask") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_button_mask() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_motion->get_alt() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_motion->get_shift() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_motion->get_control() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_motion->get_metakey() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_index") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->get_button_index() = p_value;
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx]->is_pressed() = p_value;
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "doubleclicked") {
|
|
|
|
filters[idx].mouse_button.doubleclick = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_button->get_alt() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_button->get_shift() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_button->get_control() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].mouse_button->get_metakey() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "axis") {
|
|
|
|
filters[idx].joy_motion.axis = int(p_value) << 1 | filters[idx].joy_motion.axis;
|
|
|
|
} else if (what == "mode") {
|
|
|
|
filters[idx].joy_motion.axis |= int(p_value);
|
|
|
|
} else if (what == "treshold") {
|
|
|
|
filters[idx].joy_motion.axis_value = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_index") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].joy_button->get_button_index() = p_value;
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].joy_button->is_pressed() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_TOUCH: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "finger_index") {
|
|
|
|
filters[idx].screen_touch.index = p_value;
|
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].screen_touch->is_pressed() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_DRAG: {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "finger_index") {
|
|
|
|
filters[idx].screen_drag.index = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::ACTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "action_name") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
List<PropertyInfo> pinfo;
|
2017-01-05 13:16:00 +01:00
|
|
|
GlobalConfig::get_singleton()->get_property_list(&pinfo);
|
2017-03-05 16:44:50 +01:00
|
|
|
int index = 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
|
|
|
const PropertyInfo &pi = E->get();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (!pi.name.begins_with("input/"))
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
|
|
|
if (name == String(p_value)) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
filters[idx].action.action = index;
|
2016-08-08 00:22:33 +02:00
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
filters[idx].action.action = 0;
|
2016-08-08 00:22:33 +02:00
|
|
|
ports_changed_notify();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
filters[idx].action->is_pressed() = p_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
ports_changed_notify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_name == "filter_count") {
|
|
|
|
r_ret = filters.size();
|
2016-08-08 00:22:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (String(p_name).begins_with("filter_")) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int idx = String(p_name).replace_first("filters_", "").get_slice("/", 0).to_int();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_INDEX_V(idx, filters.size(), false);
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String what = String(p_name).get_slice("/", 1);
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "type") {
|
|
|
|
r_ret = filters[idx].type;
|
2016-08-08 00:22:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "device") {
|
|
|
|
r_ret = filters[idx].device;
|
2016-08-08 00:22:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (filters[idx].type) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::KEY: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "scancode") {
|
2017-05-20 17:38:03 +02:00
|
|
|
if (filters[idx]->get_scancode() == 0)
|
2017-03-05 16:44:50 +01:00
|
|
|
r_ret = String();
|
2016-08-08 00:22:33 +02:00
|
|
|
else {
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = keycode_get_string(filters[idx]->get_scancode());
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "unicode") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (filters[idx].key.unicode == 0) {
|
|
|
|
r_ret = String();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
CharType str[2] = { (CharType)filters[idx].key.unicode, 0 };
|
|
|
|
r_ret = String(str);
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->is_pressed();
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "echo") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->is_echo();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_alt();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_shift();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_control();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_metakey();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_mask") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_button_mask();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_motion->get_alt();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_motion->get_shift();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_motion->get_control();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_motion->get_metakey();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_index") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->get_button_index();
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx]->is_pressed();
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "doubleclicked") {
|
|
|
|
r_ret = filters[idx].mouse_button.doubleclick;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_alt") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_button->get_alt();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_shift") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_button->get_shift();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_ctrl") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_button->get_control();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "mod_meta") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].mouse_button->get_metakey();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "axis_index") {
|
|
|
|
r_ret = filters[idx].joy_motion.axis >> 1;
|
|
|
|
} else if (what == "mode") {
|
|
|
|
r_ret = filters[idx].joy_motion.axis & 1;
|
|
|
|
} else if (what == "treshold") {
|
|
|
|
r_ret = filters[idx].joy_motion.axis_value;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "button_index") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].joy_button->get_button_index();
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].joy_button->is_pressed();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_TOUCH: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "finger_index") {
|
|
|
|
r_ret = filters[idx].screen_touch.index;
|
|
|
|
} else if (what == "pressed") {
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].screen_touch->is_pressed();
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_DRAG: {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "finger_index") {
|
|
|
|
r_ret = filters[idx].screen_drag.index;
|
2016-08-08 00:22:33 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::ACTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (what == "action_name") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
List<PropertyInfo> pinfo;
|
2017-01-05 13:16:00 +01:00
|
|
|
GlobalConfig::get_singleton()->get_property_list(&pinfo);
|
2017-03-05 16:44:50 +01:00
|
|
|
int index = 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
|
|
|
const PropertyInfo &pi = E->get();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (!pi.name.begins_with("input/"))
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (filters[idx].action.action == index) {
|
|
|
|
r_ret = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
2016-08-08 00:22:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
r_ret = "None"; //no index
|
2016-08-08 00:22:33 +02:00
|
|
|
return false;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (what == "pressed") {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
r_ret = filters[idx].action->is_pressed();
|
2016-08-08 00:22:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-31 17:49:45 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
static const char *event_type_names[Ref<InputEvent>::TYPE_MAX] = {
|
2016-08-31 17:49:45 +02:00
|
|
|
"None",
|
|
|
|
"Key",
|
|
|
|
"MouseMotion",
|
|
|
|
"MouseButton",
|
2017-01-08 21:05:51 +01:00
|
|
|
"JoypadMotion",
|
|
|
|
"JoypadButton",
|
2016-08-31 17:49:45 +02:00
|
|
|
"ScreenTouch",
|
|
|
|
"ScreenDrag",
|
|
|
|
"Action"
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) const {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, "filter_count", PROPERTY_HINT_RANGE, "0,64"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
String et;
|
2017-05-20 17:38:03 +02:00
|
|
|
for (int i = 0; i < Ref<InputEvent>::TYPE_MAX; i++) {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i > 0)
|
|
|
|
et += ",";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
et += event_type_names[i];
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String kc;
|
|
|
|
String actions;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < filters.size(); i++) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String base = "filter_" + itos(i) + "/";
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "type", PROPERTY_HINT_ENUM, et));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "device"));
|
|
|
|
switch (filters[i].type) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::NONE: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::KEY: {
|
2017-03-05 16:44:50 +01:00
|
|
|
if (kc == String()) {
|
2016-08-08 00:22:33 +02:00
|
|
|
int kcc = keycode_get_count();
|
2017-03-05 16:44:50 +01:00
|
|
|
kc = "None";
|
|
|
|
for (int i = 0; i < kcc; i++) {
|
|
|
|
kc += ",";
|
|
|
|
kc += String(keycode_get_name_by_index(i));
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::STRING, base + "scancode", PROPERTY_HINT_ENUM, kc));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::STRING, base + "unicode"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "echo"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_MOTION: {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "button_mask", PROPERTY_HINT_FLAGS, "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_BUTTON: {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "button_index", PROPERTY_HINT_ENUM, "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "doubleclicked"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_alt"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_ctrl"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "axis_index"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "mode", PROPERTY_HINT_ENUM, "Min,Max"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::REAL, base + "treshold", PROPERTY_HINT_RANGE, "0,1,0.01"));
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_BUTTON: {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "button_index"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_TOUCH: {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_DRAG: {
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::ACTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (actions == String()) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
actions = "None";
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
List<PropertyInfo> pinfo;
|
2017-01-05 13:16:00 +01:00
|
|
|
GlobalConfig::get_singleton()->get_property_list(&pinfo);
|
2016-08-08 00:22:33 +02:00
|
|
|
Vector<String> al;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
|
|
|
const PropertyInfo &pi = E->get();
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
if (!pi.name.begins_with("input/"))
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
al.push_back(name);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < al.size(); i++) {
|
|
|
|
actions += ",";
|
|
|
|
actions += al[i];
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_list->push_back(PropertyInfo(Variant::STRING, base + "action_name", PROPERTY_HINT_ENUM, actions));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VisualScriptNodeInstanceInputFilter : public VisualScriptNodeInstance {
|
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptInstance *instance;
|
2017-05-20 17:38:03 +02:00
|
|
|
Vector<Ref<InputEvent>> filters;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
//virtual int get_working_memory_size() const { return 0; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_inputs[0]->get_type() != Variant::INPUT_EVENT) {
|
|
|
|
r_error_str = "Input value not of type event";
|
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
2016-08-08 00:22:33 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
Ref<InputEvent> event = *p_inputs[0];
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < filters.size(); i++) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
const Ref<InputEvent> &ie = filters[i];
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ie.type != event.type)
|
2016-08-08 00:22:33 +02:00
|
|
|
continue;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool match = false;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (ie.type) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::NONE: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::KEY: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
InputEventKey k = ie.key;
|
|
|
|
InputEventKey k2 = event.key;
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (k->get_scancode() == 0 && k.unicode == 0 && k2->get_scancode() == 0 && k2.unicode == 0) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if ((k->get_scancode() != 0 && k->get_scancode() == k2->get_scancode()) || (k.unicode != 0 && k.unicode == k2.unicode)) {
|
2016-08-08 00:22:33 +02:00
|
|
|
//key valid
|
|
|
|
|
|
|
|
if (
|
2017-05-20 17:38:03 +02:00
|
|
|
k->is_pressed() == k2->is_pressed() &&
|
2017-03-05 16:44:50 +01:00
|
|
|
k.echo == k2.echo &&
|
|
|
|
k.mod == k2.mod) {
|
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventMouseMotion mm = ie.mouse_motion;
|
|
|
|
InputEventMouseMotion mm2 = event.mouse_motion;
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mm->get_button_mask() == mm2->get_button_mask() &&
|
2017-03-05 16:44:50 +01:00
|
|
|
mm.mod == mm2.mod) {
|
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::MOUSE_BUTTON: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
InputEventMouseButton mb = ie.mouse_button;
|
|
|
|
InputEventMouseButton mb2 = event.mouse_button;
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (mb->get_button_index() == mb2->get_button_index() &&
|
|
|
|
mb->is_pressed() == mb2->is_pressed() &&
|
2017-03-05 16:44:50 +01:00
|
|
|
mb.doubleclick == mb2.doubleclick &&
|
|
|
|
mb.mod == mb2.mod) {
|
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_MOTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-01-08 21:05:51 +01:00
|
|
|
InputEventJoypadMotion jm = ie.joy_motion;
|
|
|
|
InputEventJoypadMotion jm2 = event.joy_motion;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int axis = jm.axis >> 1;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (axis == jm2.axis) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (jm.axis & 1) {
|
2016-08-08 00:22:33 +02:00
|
|
|
//greater
|
|
|
|
if (jm2.axis_value > jm.axis_value) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//less
|
|
|
|
if (jm2.axis_value < -jm.axis_value) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::JOYPAD_BUTTON: {
|
2017-01-08 21:05:51 +01:00
|
|
|
InputEventJoypadButton jb = ie.joy_button;
|
|
|
|
InputEventJoypadButton jb2 = event.joy_button;
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
if (jb->get_button_index() == jb2->get_button_index() &&
|
|
|
|
jb->is_pressed() == jb2->is_pressed()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_TOUCH: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventScreenTouch st = ie.screen_touch;
|
|
|
|
InputEventScreenTouch st2 = event.screen_touch;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (st.index == st2.index &&
|
2017-05-20 17:38:03 +02:00
|
|
|
st->is_pressed() == st2->is_pressed()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::SCREEN_DRAG: {
|
2016-08-08 00:22:33 +02:00
|
|
|
InputEventScreenDrag sd = ie.screen_drag;
|
|
|
|
InputEventScreenDrag sd2 = event.screen_drag;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (sd.index == sd2.index) {
|
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
} break;
|
2017-05-20 17:38:03 +02:00
|
|
|
case Ref<InputEvent>::ACTION: {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
|
|
|
InputEventAction ia = ie.action;
|
|
|
|
InputEventAction ia2 = event.action;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ia.action == ia2.action &&
|
2017-05-20 17:38:03 +02:00
|
|
|
ia->is_pressed() == ia2->is_pressed()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
match = true;
|
2016-08-08 00:22:33 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p_outputs[0] = event;
|
|
|
|
|
|
|
|
if (match)
|
|
|
|
return i; //go through match output
|
|
|
|
}
|
|
|
|
|
|
|
|
return STEP_NO_ADVANCE_BIT; //none found, don't advance
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptInputFilter::instance(VisualScriptInstance *p_instance) {
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceInputFilter *instance = memnew(VisualScriptNodeInstanceInputFilter);
|
|
|
|
instance->instance = p_instance;
|
|
|
|
instance->filters = filters;
|
2016-08-08 00:22:33 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptInputFilter::VisualScriptInputFilter() {
|
|
|
|
}
|
2017-05-20 17:38:03 +02:00
|
|
|
#endif
|
2016-08-25 22:45:20 +02:00
|
|
|
//////////////////////////////////////////
|
2016-08-29 01:57:27 +02:00
|
|
|
////////////////TYPE CAST///////////
|
2016-08-25 22:45:20 +02:00
|
|
|
//////////////////////////////////////////
|
|
|
|
|
|
|
|
int VisualScriptTypeCast::get_output_sequence_port_count() const {
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool VisualScriptTypeCast::has_input_sequence_port() const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptTypeCast::get_input_value_port_count() const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
int VisualScriptTypeCast::get_output_value_port_count() const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptTypeCast::get_output_sequence_port_text(int p_port) const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return p_port == 0 ? "yes" : "no";
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptTypeCast::get_input_value_port_info(int p_idx) const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return PropertyInfo(Variant::OBJECT, "instance");
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
return PropertyInfo(Variant::OBJECT, "");
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptTypeCast::get_caption() const {
|
|
|
|
|
|
|
|
return "TypeCast";
|
|
|
|
}
|
|
|
|
|
|
|
|
String VisualScriptTypeCast::get_text() const {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (script != String())
|
|
|
|
return "Is " + script.get_file() + "?";
|
2016-08-25 22:45:20 +02:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
return "Is " + base_type + "?";
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void VisualScriptTypeCast::set_base_type(const StringName &p_type) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (base_type == p_type)
|
2016-08-25 22:45:20 +02:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
base_type = p_type;
|
2016-08-25 22:45:20 +02:00
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
StringName VisualScriptTypeCast::get_base_type() const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
return base_type;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void VisualScriptTypeCast::set_base_script(const String &p_path) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (script == p_path)
|
2016-08-25 22:45:20 +02:00
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
script = p_path;
|
2016-08-25 22:45:20 +02:00
|
|
|
_change_notify();
|
|
|
|
ports_changed_notify();
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
String VisualScriptTypeCast::get_base_script() const {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
|
|
|
class VisualScriptNodeInstanceTypeCast : public VisualScriptNodeInstance {
|
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptInstance *instance;
|
2016-08-25 22:45:20 +02:00
|
|
|
StringName base_type;
|
|
|
|
String script;
|
|
|
|
|
|
|
|
//virtual int get_working_memory_size() const { return 0; }
|
|
|
|
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
|
|
|
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
Object *obj = *p_inputs[0];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
*p_outputs[0] = Variant();
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
if (!obj) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = "Instance is null";
|
2016-08-25 22:45:20 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (script != String()) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
Ref<Script> obj_script = obj->get_script();
|
|
|
|
if (!obj_script.is_valid()) {
|
|
|
|
return 1; //well, definitely not the script because object we got has no script.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ResourceCache::has(script)) {
|
|
|
|
//if the script is not in use by anyone, we can safely assume whathever we got is not casting to it.
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
Ref<Script> cast_script = Ref<Resource>(ResourceCache::get(script));
|
|
|
|
if (!cast_script.is_valid()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
|
|
|
r_error_str = "Script path is not a script: " + script;
|
2016-08-25 22:45:20 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (obj_script.is_valid()) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cast_script == obj_script) {
|
|
|
|
*p_outputs[0] = *p_inputs[0]; //copy
|
2016-08-25 22:45:20 +02:00
|
|
|
return 0; // it is the script, yey
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
obj_script = obj_script->get_base_script();
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1; //not found sorry
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (ClassDB::is_parent_class(obj->get_class_name(), base_type)) {
|
|
|
|
*p_outputs[0] = *p_inputs[0]; //copy
|
2016-08-25 22:45:20 +02:00
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p_instance) {
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
|
|
|
|
instance->instance = p_instance;
|
|
|
|
instance->base_type = base_type;
|
|
|
|
instance->script = script;
|
2016-08-25 22:45:20 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualScriptTypeCast::_bind_methods() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_base_type", "type"), &VisualScriptTypeCast::set_base_type);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptTypeCast::get_base_type);
|
2016-08-25 22:45:20 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("set_base_script", "path"), &VisualScriptTypeCast::set_base_script);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptTypeCast::get_base_script);
|
2016-08-25 22:45:20 +02:00
|
|
|
|
|
|
|
List<String> script_extensions;
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i > ScriptServer::get_language_count(); i++) {
|
2016-08-25 22:45:20 +02:00
|
|
|
ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions);
|
|
|
|
}
|
|
|
|
|
|
|
|
String script_ext_hint;
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
|
|
|
|
if (script_ext_hint != String())
|
|
|
|
script_ext_hint += ",";
|
|
|
|
script_ext_hint += "*." + E->get();
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "function/base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VisualScriptTypeCast::VisualScriptTypeCast() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
base_type = "Object";
|
2016-08-25 22:45:20 +02:00
|
|
|
}
|
2016-08-08 00:22:33 +02:00
|
|
|
|
2016-08-03 00:11:05 +02:00
|
|
|
void register_visual_script_flow_control_nodes() {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("flow_control/return", create_return_node<false>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("flow_control/return_with_value", create_return_node<true>);
|
|
|
|
VisualScriptLanguage::singleton->add_register_func("flow_control/condition", create_node_generic<VisualScriptCondition>);
|
|
|
|
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/switch", create_node_generic<VisualScriptSwitch>);
|
2017-05-20 17:38:03 +02:00
|
|
|
//VisualScriptLanguage::singleton->add_register_func("flow_control/input_filter", create_node_generic<VisualScriptInputFilter>);
|
2017-03-05 16:44:50 +01:00
|
|
|
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
|
2016-08-03 00:11:05 +02:00
|
|
|
}
|