Removal of InputEvent as built-in Variant type..

this might cause bugs I haven't found yet..
This commit is contained in:
Juan Linietsky
2017-05-20 12:38:03 -03:00
parent 8d37f9d38f
commit e113ce6546
10 changed files with 160 additions and 304 deletions

View File

@@ -88,7 +88,7 @@ void register_visual_script_types() {
ClassDB::register_class<VisualScriptWhile>(); ClassDB::register_class<VisualScriptWhile>();
ClassDB::register_class<VisualScriptIterator>(); ClassDB::register_class<VisualScriptIterator>();
ClassDB::register_class<VisualScriptSequence>(); ClassDB::register_class<VisualScriptSequence>();
ClassDB::register_class<VisualScriptInputFilter>(); //ClassDB::register_class<VisualScriptInputFilter>();
ClassDB::register_class<VisualScriptSwitch>(); ClassDB::register_class<VisualScriptSwitch>();
ClassDB::register_class<VisualScriptYield>(); ClassDB::register_class<VisualScriptYield>();

View File

@@ -89,13 +89,11 @@ public:
struct TypeGuess { struct TypeGuess {
Variant::Type type; Variant::Type type;
InputEvent::Type ev_type;
StringName GDCLASS; StringName GDCLASS;
Ref<Script> script; Ref<Script> script;
TypeGuess() { TypeGuess() {
type = Variant::NIL; type = Variant::NIL;
ev_type = InputEvent::NONE;
} }
}; };

View File

@@ -349,7 +349,6 @@ static Color _color_from_type(Variant::Type p_type) {
case Variant::NODE_PATH: color = Color::html("6993ec"); break; case Variant::NODE_PATH: color = Color::html("6993ec"); break;
case Variant::_RID: color = Color::html("69ec9a"); break; case Variant::_RID: color = Color::html("69ec9a"); break;
case Variant::OBJECT: color = Color::html("79f3e8"); break; case Variant::OBJECT: color = Color::html("79f3e8"); break;
case Variant::INPUT_EVENT: color = Color::html("adf18f"); break;
case Variant::DICTIONARY: color = Color::html("77edb1"); break; case Variant::DICTIONARY: color = Color::html("77edb1"); break;
case Variant::ARRAY: color = Color::html("e0e0e0"); break; case Variant::ARRAY: color = Color::html("e0e0e0"); break;
@@ -453,7 +452,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Control::get_icon("MiniPath", "EditorIcons"), Control::get_icon("MiniPath", "EditorIcons"),
Control::get_icon("MiniRid", "EditorIcons"), Control::get_icon("MiniRid", "EditorIcons"),
Control::get_icon("MiniObject", "EditorIcons"), Control::get_icon("MiniObject", "EditorIcons"),
Control::get_icon("MiniInput", "EditorIcons"),
Control::get_icon("MiniDictionary", "EditorIcons"), Control::get_icon("MiniDictionary", "EditorIcons"),
Control::get_icon("MiniArray", "EditorIcons"), Control::get_icon("MiniArray", "EditorIcons"),
Control::get_icon("MiniRawArray", "EditorIcons"), Control::get_icon("MiniRawArray", "EditorIcons"),
@@ -736,7 +734,6 @@ void VisualScriptEditor::_update_members() {
Control::get_icon("MiniPath", "EditorIcons"), Control::get_icon("MiniPath", "EditorIcons"),
Control::get_icon("MiniRid", "EditorIcons"), Control::get_icon("MiniRid", "EditorIcons"),
Control::get_icon("MiniObject", "EditorIcons"), Control::get_icon("MiniObject", "EditorIcons"),
Control::get_icon("MiniInput", "EditorIcons"),
Control::get_icon("MiniDictionary", "EditorIcons"), Control::get_icon("MiniDictionary", "EditorIcons"),
Control::get_icon("MiniArray", "EditorIcons"), Control::get_icon("MiniArray", "EditorIcons"),
Control::get_icon("MiniRawArray", "EditorIcons"), Control::get_icon("MiniRawArray", "EditorIcons"),
@@ -1419,9 +1416,11 @@ void VisualScriptEditor::_on_nodes_duplicate() {
} }
} }
void VisualScriptEditor::_input(const InputEvent &p_event) { void VisualScriptEditor::_input(const Ref<InputEvent> &p_event) {
if (p_event.type == InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index == BUTTON_LEFT) { Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
revert_on_drag = String(); //so we can still drag functions revert_on_drag = String(); //so we can still drag functions
} }
} }
@@ -2640,7 +2639,7 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
} else { } else {
n->set_call_mode(VisualScriptPropertySet::CALL_MODE_BASIC_TYPE); n->set_call_mode(VisualScriptPropertySet::CALL_MODE_BASIC_TYPE);
n->set_basic_type(tg.type); n->set_basic_type(tg.type);
new_connect_node_select->select_property_from_basic_type(tg.type, tg.ev_type); new_connect_node_select->select_property_from_basic_type(tg.type);
} }
} break; } break;
case CREATE_GET: { case CREATE_GET: {
@@ -2670,7 +2669,7 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
} else { } else {
n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_BASIC_TYPE); n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_BASIC_TYPE);
n->set_basic_type(tg.type); n->set_basic_type(tg.type);
new_connect_node_select->select_property_from_basic_type(tg.type, tg.ev_type); new_connect_node_select->select_property_from_basic_type(tg.type);
} }
} break; } break;

View File

@@ -196,7 +196,7 @@ class VisualScriptEditor : public ScriptEditorBase {
String revert_on_drag; String revert_on_drag;
void _input(const InputEvent &p_event); void _input(const Ref<InputEvent> &p_event);
void _on_nodes_delete(); void _on_nodes_delete();
void _on_nodes_duplicate(); void _on_nodes_duplicate();

View File

@@ -734,6 +734,7 @@ VisualScriptSwitch::VisualScriptSwitch() {
////////////////EVENT ACTION FILTER/////////// ////////////////EVENT ACTION FILTER///////////
////////////////////////////////////////// //////////////////////////////////////////
#if 0
int VisualScriptInputFilter::get_output_sequence_port_count() const { int VisualScriptInputFilter::get_output_sequence_port_count() const {
return filters.size(); return filters.size();
@@ -758,86 +759,86 @@ String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const
String text; String text;
switch (filters[p_port].type) { switch (filters[p_port].type) {
case InputEvent::NONE: { case Ref<InputEvent>::NONE: {
text = "None"; text = "None";
} break; } break;
case InputEvent::KEY: { case Ref<InputEvent>::KEY: {
InputEventKey k = filters[p_port].key; InputEventKey k = filters[p_port].key;
if (k.scancode == 0 && k.unicode == 0) { if (k->get_scancode() == 0 && k.unicode == 0) {
text = "No Key"; text = "No Key";
} else { } else {
if (k.scancode != 0) { if (k->get_scancode() != 0) {
text = "KeyCode: " + keycode_get_string(k.scancode); text = "KeyCode: " + keycode_get_string(k->get_scancode());
} else if (k.unicode != 0) { } else if (k.unicode != 0) {
text = "Uniode: " + String::chr(k.unicode); text = "Uniode: " + String::chr(k.unicode);
} }
if (k.pressed) if (k->is_pressed())
text += ", Pressed"; text += ", Pressed";
else else
text += ", Released"; text += ", Released";
if (k.echo) if (k.echo)
text += ", Echo"; text += ", Echo";
if (k.mod.alt) if (k->get_alt())
text = "Alt+" + text; text = "Alt+" + text;
if (k.mod.shift) if (k->get_shift())
text = "Shift+" + text; text = "Shift+" + text;
if (k.mod.control) if (k->get_control())
text = "Ctrl+" + text; text = "Ctrl+" + text;
if (k.mod.meta) if (k->get_metakey())
text = "Meta+" + text; text = "Meta+" + text;
} }
} break; } break;
case InputEvent::MOUSE_MOTION: { case Ref<InputEvent>::MOUSE_MOTION: {
InputEventMouseMotion mm = filters[p_port].mouse_motion; InputEventMouseMotion mm = filters[p_port].mouse_motion;
text = "Mouse Motion"; text = "Mouse Motion";
String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
if (mm.button_mask & (1 << i)) { if (mm->get_button_mask() & (1 << i)) {
text = b.get_slice(",", i) + "+" + text; text = b.get_slice(",", i) + "+" + text;
} }
} }
if (mm.mod.alt) if (mm->get_alt())
text = "Alt+" + text; text = "Alt+" + text;
if (mm.mod.shift) if (mm->get_shift())
text = "Shift+" + text; text = "Shift+" + text;
if (mm.mod.control) if (mm->get_control())
text = "Ctrl+" + text; text = "Ctrl+" + text;
if (mm.mod.meta) if (mm->get_metakey())
text = "Meta+" + text; text = "Meta+" + text;
} break; } break;
case InputEvent::MOUSE_BUTTON: { case Ref<InputEvent>::MOUSE_BUTTON: {
InputEventMouseButton mb = filters[p_port].mouse_button; InputEventMouseButton mb = filters[p_port].mouse_button;
String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";
text = b.get_slice(",", mb.button_index) + " Mouse Button"; text = b.get_slice(",", mb->get_button_index()) + " Mouse Button";
if (mb.pressed) if (mb->is_pressed())
text += ", Pressed"; text += ", Pressed";
else else
text += ", Released"; text += ", Released";
if (mb.doubleclick) if (mb.doubleclick)
text += ", DblClick"; text += ", DblClick";
if (mb.mod.alt) if (mb->get_alt())
text = "Alt+" + text; text = "Alt+" + text;
if (mb.mod.shift) if (mb->get_shift())
text = "Shift+" + text; text = "Shift+" + text;
if (mb.mod.control) if (mb->get_control())
text = "Ctrl+" + text; text = "Ctrl+" + text;
if (mb.mod.meta) if (mb->get_metakey())
text = "Meta+" + text; text = "Meta+" + text;
} break; } break;
case InputEvent::JOYPAD_MOTION: { case Ref<InputEvent>::JOYPAD_MOTION: {
InputEventJoypadMotion jm = filters[p_port].joy_motion; InputEventJoypadMotion jm = filters[p_port].joy_motion;
@@ -848,29 +849,29 @@ String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const
text += " < " + rtos(-jm.axis_value); text += " < " + rtos(-jm.axis_value);
} break; } break;
case InputEvent::JOYPAD_BUTTON: { case Ref<InputEvent>::JOYPAD_BUTTON: {
InputEventJoypadButton jb = filters[p_port].joy_button; InputEventJoypadButton jb = filters[p_port].joy_button;
text = "JoyButton " + itos(jb.button_index); text = "JoyButton " + itos(jb->get_button_index());
if (jb.pressed) if (jb->is_pressed())
text += ", Pressed"; text += ", Pressed";
else else
text += ", Released"; text += ", Released";
} break; } break;
case InputEvent::SCREEN_TOUCH: { case Ref<InputEvent>::SCREEN_TOUCH: {
InputEventScreenTouch sd = filters[p_port].screen_touch; InputEventScreenTouch sd = filters[p_port].screen_touch;
text = "Touch Finger " + itos(sd.index); text = "Touch Finger " + itos(sd.index);
if (sd.pressed) if (sd->is_pressed())
text += ", Pressed"; text += ", Pressed";
else else
text += ", Released"; text += ", Released";
} break; } break;
case InputEvent::SCREEN_DRAG: { case Ref<InputEvent>::SCREEN_DRAG: {
InputEventScreenDrag sd = filters[p_port].screen_drag; InputEventScreenDrag sd = filters[p_port].screen_drag;
text = "Drag Finger " + itos(sd.index); text = "Drag Finger " + itos(sd.index);
} break; } break;
case InputEvent::ACTION: { case Ref<InputEvent>::ACTION: {
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
GlobalConfig::get_singleton()->get_property_list(&pinfo); GlobalConfig::get_singleton()->get_property_list(&pinfo);
@@ -890,7 +891,7 @@ String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const
index++; index++;
} }
if (filters[p_port].action.pressed) if (filters[p_port].action->is_pressed())
text += ", Pressed"; text += ", Pressed";
else else
text += ", Released"; text += ", Released";
@@ -939,20 +940,20 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
String what = String(p_name).get_slice("/", 1); String what = String(p_name).get_slice("/", 1);
if (what == "type") { if (what == "type") {
filters[idx] = InputEvent(); filters[idx] = Ref<InputEvent>();
filters[idx].type = InputEvent::Type(int(p_value)); filters[idx].type = Ref<InputEvent>::Type(int(p_value));
if (filters[idx].type == InputEvent::JOYPAD_MOTION) { if (filters[idx].type == Ref<InputEvent>::JOYPAD_MOTION) {
filters[idx].joy_motion.axis_value = 0.5; //for treshold filters[idx].joy_motion.axis_value = 0.5; //for treshold
} else if (filters[idx].type == InputEvent::KEY) { } else if (filters[idx].type == Ref<InputEvent>::KEY) {
filters[idx].key.pressed = true; //put these as true to make it more user friendly filters[idx]->is_pressed() = true; //put these as true to make it more user friendly
} else if (filters[idx].type == InputEvent::MOUSE_BUTTON) { } else if (filters[idx].type == Ref<InputEvent>::MOUSE_BUTTON) {
filters[idx].mouse_button.pressed = true; filters[idx]->is_pressed() = true;
} else if (filters[idx].type == InputEvent::JOYPAD_BUTTON) { } else if (filters[idx].type == Ref<InputEvent>::JOYPAD_BUTTON) {
filters[idx].joy_button.pressed = true; filters[idx].joy_button->is_pressed() = true;
} else if (filters[idx].type == InputEvent::SCREEN_TOUCH) { } else if (filters[idx].type == Ref<InputEvent>::SCREEN_TOUCH) {
filters[idx].screen_touch.pressed = true; filters[idx].screen_touch->is_pressed() = true;
} else if (filters[idx].type == InputEvent::ACTION) { } else if (filters[idx].type == Ref<InputEvent>::ACTION) {
filters[idx].action.pressed = true; filters[idx].action->is_pressed() = true;
} }
_change_notify(); _change_notify();
ports_changed_notify(); ports_changed_notify();
@@ -967,14 +968,14 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
switch (filters[idx].type) { switch (filters[idx].type) {
case InputEvent::KEY: { case Ref<InputEvent>::KEY: {
if (what == "scancode") { if (what == "scancode") {
String sc = p_value; String sc = p_value;
if (sc == String()) { if (sc == String()) {
filters[idx].key.scancode = 0; filters[idx]->get_scancode() = 0;
} else { } else {
filters[idx].key.scancode = find_keycode(p_value); filters[idx]->get_scancode() = find_keycode(p_value);
} }
} else if (what == "unicode") { } else if (what == "unicode") {
@@ -989,22 +990,22 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
} else if (what == "pressed") { } else if (what == "pressed") {
filters[idx].key.pressed = p_value; filters[idx]->is_pressed() = p_value;
} else if (what == "echo") { } else if (what == "echo") {
filters[idx].key.echo = p_value; filters[idx]->is_echo() = p_value;
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
filters[idx].key.mod.alt = p_value; filters[idx]->get_alt() = p_value;
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
filters[idx].key.mod.shift = p_value; filters[idx]->get_shift() = p_value;
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
filters[idx].key.mod.control = p_value; filters[idx]->get_control() = p_value;
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
filters[idx].key.mod.meta = p_value; filters[idx]->get_metakey() = p_value;
} else { } else {
return false; return false;
} }
@@ -1012,22 +1013,22 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
return true; return true;
} break; } break;
case InputEvent::MOUSE_MOTION: { case Ref<InputEvent>::MOUSE_MOTION: {
if (what == "button_mask") { if (what == "button_mask") {
filters[idx].mouse_motion.button_mask = p_value; filters[idx]->get_button_mask() = p_value;
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
filters[idx].mouse_motion.mod.alt = p_value; filters[idx].mouse_motion->get_alt() = p_value;
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
filters[idx].mouse_motion.mod.shift = p_value; filters[idx].mouse_motion->get_shift() = p_value;
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
filters[idx].mouse_motion.mod.control = p_value; filters[idx].mouse_motion->get_control() = p_value;
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
filters[idx].mouse_motion.mod.meta = p_value; filters[idx].mouse_motion->get_metakey() = p_value;
} else { } else {
return false; return false;
} }
@@ -1036,26 +1037,26 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
return true; return true;
} break; } break;
case InputEvent::MOUSE_BUTTON: { case Ref<InputEvent>::MOUSE_BUTTON: {
if (what == "button_index") { if (what == "button_index") {
filters[idx].mouse_button.button_index = p_value; filters[idx]->get_button_index() = p_value;
} else if (what == "pressed") { } else if (what == "pressed") {
filters[idx].mouse_button.pressed = p_value; filters[idx]->is_pressed() = p_value;
} else if (what == "doubleclicked") { } else if (what == "doubleclicked") {
filters[idx].mouse_button.doubleclick = p_value; filters[idx].mouse_button.doubleclick = p_value;
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
filters[idx].mouse_button.mod.alt = p_value; filters[idx].mouse_button->get_alt() = p_value;
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
filters[idx].mouse_button.mod.shift = p_value; filters[idx].mouse_button->get_shift() = p_value;
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
filters[idx].mouse_button.mod.control = p_value; filters[idx].mouse_button->get_control() = p_value;
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
filters[idx].mouse_button.mod.meta = p_value; filters[idx].mouse_button->get_metakey() = p_value;
} else { } else {
return false; return false;
} }
@@ -1063,7 +1064,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
return true; return true;
} break; } break;
case InputEvent::JOYPAD_MOTION: { case Ref<InputEvent>::JOYPAD_MOTION: {
if (what == "axis") { if (what == "axis") {
filters[idx].joy_motion.axis = int(p_value) << 1 | filters[idx].joy_motion.axis; filters[idx].joy_motion.axis = int(p_value) << 1 | filters[idx].joy_motion.axis;
@@ -1078,12 +1079,12 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
return true; return true;
} break; } break;
case InputEvent::JOYPAD_BUTTON: { case Ref<InputEvent>::JOYPAD_BUTTON: {
if (what == "button_index") { if (what == "button_index") {
filters[idx].joy_button.button_index = p_value; filters[idx].joy_button->get_button_index() = p_value;
} else if (what == "pressed") { } else if (what == "pressed") {
filters[idx].joy_button.pressed = p_value; filters[idx].joy_button->is_pressed() = p_value;
} else { } else {
return false; return false;
} }
@@ -1091,19 +1092,19 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
return true; return true;
} break; } break;
case InputEvent::SCREEN_TOUCH: { case Ref<InputEvent>::SCREEN_TOUCH: {
if (what == "finger_index") { if (what == "finger_index") {
filters[idx].screen_touch.index = p_value; filters[idx].screen_touch.index = p_value;
} else if (what == "pressed") { } else if (what == "pressed") {
filters[idx].screen_touch.pressed = p_value; filters[idx].screen_touch->is_pressed() = p_value;
} else { } else {
return false; return false;
} }
ports_changed_notify(); ports_changed_notify();
return true; return true;
} break; } break;
case InputEvent::SCREEN_DRAG: { case Ref<InputEvent>::SCREEN_DRAG: {
if (what == "finger_index") { if (what == "finger_index") {
filters[idx].screen_drag.index = p_value; filters[idx].screen_drag.index = p_value;
} else { } else {
@@ -1112,7 +1113,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
ports_changed_notify(); ports_changed_notify();
return true; return true;
} break; } break;
case InputEvent::ACTION: { case Ref<InputEvent>::ACTION: {
if (what == "action_name") { if (what == "action_name") {
@@ -1144,7 +1145,7 @@ bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_va
} else if (what == "pressed") { } else if (what == "pressed") {
filters[idx].action.pressed = p_value; filters[idx].action->is_pressed() = p_value;
ports_changed_notify(); ports_changed_notify();
return true; return true;
} }
@@ -1181,14 +1182,14 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
switch (filters[idx].type) { switch (filters[idx].type) {
case InputEvent::KEY: { case Ref<InputEvent>::KEY: {
if (what == "scancode") { if (what == "scancode") {
if (filters[idx].key.scancode == 0) if (filters[idx]->get_scancode() == 0)
r_ret = String(); r_ret = String();
else { else {
r_ret = keycode_get_string(filters[idx].key.scancode); r_ret = keycode_get_string(filters[idx]->get_scancode());
} }
} else if (what == "unicode") { } else if (what == "unicode") {
@@ -1202,44 +1203,44 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
} else if (what == "pressed") { } else if (what == "pressed") {
r_ret = filters[idx].key.pressed; r_ret = filters[idx]->is_pressed();
} else if (what == "echo") { } else if (what == "echo") {
r_ret = filters[idx].key.echo; r_ret = filters[idx]->is_echo();
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
r_ret = filters[idx].key.mod.alt; r_ret = filters[idx]->get_alt();
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
r_ret = filters[idx].key.mod.shift; r_ret = filters[idx]->get_shift();
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
r_ret = filters[idx].key.mod.control; r_ret = filters[idx]->get_control();
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
r_ret = filters[idx].key.mod.meta; r_ret = filters[idx]->get_metakey();
} else { } else {
return false; return false;
} }
return true; return true;
} break; } break;
case InputEvent::MOUSE_MOTION: { case Ref<InputEvent>::MOUSE_MOTION: {
if (what == "button_mask") { if (what == "button_mask") {
r_ret = filters[idx].mouse_motion.button_mask; r_ret = filters[idx]->get_button_mask();
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
r_ret = filters[idx].mouse_motion.mod.alt; r_ret = filters[idx].mouse_motion->get_alt();
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
r_ret = filters[idx].mouse_motion.mod.shift; r_ret = filters[idx].mouse_motion->get_shift();
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
r_ret = filters[idx].mouse_motion.mod.control; r_ret = filters[idx].mouse_motion->get_control();
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
r_ret = filters[idx].mouse_motion.mod.meta; r_ret = filters[idx].mouse_motion->get_metakey();
} else { } else {
return false; return false;
} }
@@ -1247,33 +1248,33 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
return true; return true;
} break; } break;
case InputEvent::MOUSE_BUTTON: { case Ref<InputEvent>::MOUSE_BUTTON: {
if (what == "button_index") { if (what == "button_index") {
r_ret = filters[idx].mouse_button.button_index; r_ret = filters[idx]->get_button_index();
} else if (what == "pressed") { } else if (what == "pressed") {
r_ret = filters[idx].mouse_button.pressed; r_ret = filters[idx]->is_pressed();
} else if (what == "doubleclicked") { } else if (what == "doubleclicked") {
r_ret = filters[idx].mouse_button.doubleclick; r_ret = filters[idx].mouse_button.doubleclick;
} else if (what == "mod_alt") { } else if (what == "mod_alt") {
r_ret = filters[idx].mouse_button.mod.alt; r_ret = filters[idx].mouse_button->get_alt();
} else if (what == "mod_shift") { } else if (what == "mod_shift") {
r_ret = filters[idx].mouse_button.mod.shift; r_ret = filters[idx].mouse_button->get_shift();
} else if (what == "mod_ctrl") { } else if (what == "mod_ctrl") {
r_ret = filters[idx].mouse_button.mod.control; r_ret = filters[idx].mouse_button->get_control();
} else if (what == "mod_meta") { } else if (what == "mod_meta") {
r_ret = filters[idx].mouse_button.mod.meta; r_ret = filters[idx].mouse_button->get_metakey();
} else { } else {
return false; return false;
} }
return true; return true;
} break; } break;
case InputEvent::JOYPAD_MOTION: { case Ref<InputEvent>::JOYPAD_MOTION: {
if (what == "axis_index") { if (what == "axis_index") {
r_ret = filters[idx].joy_motion.axis >> 1; r_ret = filters[idx].joy_motion.axis >> 1;
@@ -1287,30 +1288,30 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
return true; return true;
} break; } break;
case InputEvent::JOYPAD_BUTTON: { case Ref<InputEvent>::JOYPAD_BUTTON: {
if (what == "button_index") { if (what == "button_index") {
r_ret = filters[idx].joy_button.button_index; r_ret = filters[idx].joy_button->get_button_index();
} else if (what == "pressed") { } else if (what == "pressed") {
r_ret = filters[idx].joy_button.pressed; r_ret = filters[idx].joy_button->is_pressed();
} else { } else {
return false; return false;
} }
return true; return true;
} break; } break;
case InputEvent::SCREEN_TOUCH: { case Ref<InputEvent>::SCREEN_TOUCH: {
if (what == "finger_index") { if (what == "finger_index") {
r_ret = filters[idx].screen_touch.index; r_ret = filters[idx].screen_touch.index;
} else if (what == "pressed") { } else if (what == "pressed") {
r_ret = filters[idx].screen_touch.pressed; r_ret = filters[idx].screen_touch->is_pressed();
} else { } else {
return false; return false;
} }
return true; return true;
} break; } break;
case InputEvent::SCREEN_DRAG: { case Ref<InputEvent>::SCREEN_DRAG: {
if (what == "finger_index") { if (what == "finger_index") {
r_ret = filters[idx].screen_drag.index; r_ret = filters[idx].screen_drag.index;
} else { } else {
@@ -1318,7 +1319,7 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
} }
return true; return true;
} break; } break;
case InputEvent::ACTION: { case Ref<InputEvent>::ACTION: {
if (what == "action_name") { if (what == "action_name") {
@@ -1344,7 +1345,7 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
} else if (what == "pressed") { } else if (what == "pressed") {
r_ret = filters[idx].action.pressed; r_ret = filters[idx].action->is_pressed();
return true; return true;
} }
@@ -1354,7 +1355,7 @@ bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) con
return false; return false;
} }
static const char *event_type_names[InputEvent::TYPE_MAX] = { static const char *event_type_names[Ref<InputEvent>::TYPE_MAX] = {
"None", "None",
"Key", "Key",
"MouseMotion", "MouseMotion",
@@ -1371,7 +1372,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::INT, "filter_count", PROPERTY_HINT_RANGE, "0,64")); p_list->push_back(PropertyInfo(Variant::INT, "filter_count", PROPERTY_HINT_RANGE, "0,64"));
String et; String et;
for (int i = 0; i < InputEvent::TYPE_MAX; i++) { for (int i = 0; i < Ref<InputEvent>::TYPE_MAX; i++) {
if (i > 0) if (i > 0)
et += ","; et += ",";
@@ -1388,10 +1389,10 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::INT, base + "device")); p_list->push_back(PropertyInfo(Variant::INT, base + "device"));
switch (filters[i].type) { switch (filters[i].type) {
case InputEvent::NONE: { case Ref<InputEvent>::NONE: {
} break; } break;
case InputEvent::KEY: { case Ref<InputEvent>::KEY: {
if (kc == String()) { if (kc == String()) {
int kcc = keycode_get_count(); int kcc = keycode_get_count();
kc = "None"; kc = "None";
@@ -1410,7 +1411,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
} break; } break;
case InputEvent::MOUSE_MOTION: { case Ref<InputEvent>::MOUSE_MOTION: {
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::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_alt"));
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_shift"));
@@ -1418,7 +1419,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
} break; } break;
case InputEvent::MOUSE_BUTTON: { case Ref<InputEvent>::MOUSE_BUTTON: {
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::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 + "pressed"));
p_list->push_back(PropertyInfo(Variant::BOOL, base + "doubleclicked")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "doubleclicked"));
@@ -1428,26 +1429,26 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "mod_meta"));
} break; } break;
case InputEvent::JOYPAD_MOTION: { case Ref<InputEvent>::JOYPAD_MOTION: {
p_list->push_back(PropertyInfo(Variant::INT, base + "axis_index")); 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::INT, base + "mode", PROPERTY_HINT_ENUM, "Min,Max"));
p_list->push_back(PropertyInfo(Variant::REAL, base + "treshold", PROPERTY_HINT_RANGE, "0,1,0.01")); p_list->push_back(PropertyInfo(Variant::REAL, base + "treshold", PROPERTY_HINT_RANGE, "0,1,0.01"));
} break; } break;
case InputEvent::JOYPAD_BUTTON: { case Ref<InputEvent>::JOYPAD_BUTTON: {
p_list->push_back(PropertyInfo(Variant::INT, base + "button_index")); p_list->push_back(PropertyInfo(Variant::INT, base + "button_index"));
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
} break; } break;
case InputEvent::SCREEN_TOUCH: { case Ref<InputEvent>::SCREEN_TOUCH: {
p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index")); p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed"));
} break; } break;
case InputEvent::SCREEN_DRAG: { case Ref<InputEvent>::SCREEN_DRAG: {
p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index")); p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index"));
} break; } break;
case InputEvent::ACTION: { case Ref<InputEvent>::ACTION: {
if (actions == String()) { if (actions == String()) {
@@ -1485,7 +1486,7 @@ void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) con
class VisualScriptNodeInstanceInputFilter : public VisualScriptNodeInstance { class VisualScriptNodeInstanceInputFilter : public VisualScriptNodeInstance {
public: public:
VisualScriptInstance *instance; VisualScriptInstance *instance;
Vector<InputEvent> filters; Vector<Ref<InputEvent>> filters;
//virtual int get_working_memory_size() const { return 0; } //virtual int get_working_memory_size() const { return 0; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; } //virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
@@ -1499,11 +1500,11 @@ public:
return 0; return 0;
} }
InputEvent event = *p_inputs[0]; Ref<InputEvent> event = *p_inputs[0];
for (int i = 0; i < filters.size(); i++) { for (int i = 0; i < filters.size(); i++) {
const InputEvent &ie = filters[i]; const Ref<InputEvent> &ie = filters[i];
if (ie.type != event.type) if (ie.type != event.type)
continue; continue;
@@ -1511,25 +1512,25 @@ public:
switch (ie.type) { switch (ie.type) {
case InputEvent::NONE: { case Ref<InputEvent>::NONE: {
match = true; match = true;
} break; } break;
case InputEvent::KEY: { case Ref<InputEvent>::KEY: {
InputEventKey k = ie.key; InputEventKey k = ie.key;
InputEventKey k2 = event.key; InputEventKey k2 = event.key;
if (k.scancode == 0 && k.unicode == 0 && k2.scancode == 0 && k2.unicode == 0) { if (k->get_scancode() == 0 && k.unicode == 0 && k2->get_scancode() == 0 && k2.unicode == 0) {
match = true; match = true;
} else { } else {
if ((k.scancode != 0 && k.scancode == k2.scancode) || (k.unicode != 0 && k.unicode == k2.unicode)) { if ((k->get_scancode() != 0 && k->get_scancode() == k2->get_scancode()) || (k.unicode != 0 && k.unicode == k2.unicode)) {
//key valid //key valid
if ( if (
k.pressed == k2.pressed && k->is_pressed() == k2->is_pressed() &&
k.echo == k2.echo && k.echo == k2.echo &&
k.mod == k2.mod) { k.mod == k2.mod) {
match = true; match = true;
@@ -1538,30 +1539,30 @@ public:
} }
} break; } break;
case InputEvent::MOUSE_MOTION: { case Ref<InputEvent>::MOUSE_MOTION: {
InputEventMouseMotion mm = ie.mouse_motion; InputEventMouseMotion mm = ie.mouse_motion;
InputEventMouseMotion mm2 = event.mouse_motion; InputEventMouseMotion mm2 = event.mouse_motion;
if (mm.button_mask == mm2.button_mask && if (mm->get_button_mask() == mm2->get_button_mask() &&
mm.mod == mm2.mod) { mm.mod == mm2.mod) {
match = true; match = true;
} }
} break; } break;
case InputEvent::MOUSE_BUTTON: { case Ref<InputEvent>::MOUSE_BUTTON: {
InputEventMouseButton mb = ie.mouse_button; InputEventMouseButton mb = ie.mouse_button;
InputEventMouseButton mb2 = event.mouse_button; InputEventMouseButton mb2 = event.mouse_button;
if (mb.button_index == mb2.button_index && if (mb->get_button_index() == mb2->get_button_index() &&
mb.pressed == mb2.pressed && mb->is_pressed() == mb2->is_pressed() &&
mb.doubleclick == mb2.doubleclick && mb.doubleclick == mb2.doubleclick &&
mb.mod == mb2.mod) { mb.mod == mb2.mod) {
match = true; match = true;
} }
} break; } break;
case InputEvent::JOYPAD_MOTION: { case Ref<InputEvent>::JOYPAD_MOTION: {
InputEventJoypadMotion jm = ie.joy_motion; InputEventJoypadMotion jm = ie.joy_motion;
InputEventJoypadMotion jm2 = event.joy_motion; InputEventJoypadMotion jm2 = event.joy_motion;
@@ -1584,26 +1585,26 @@ public:
} }
} break; } break;
case InputEvent::JOYPAD_BUTTON: { case Ref<InputEvent>::JOYPAD_BUTTON: {
InputEventJoypadButton jb = ie.joy_button; InputEventJoypadButton jb = ie.joy_button;
InputEventJoypadButton jb2 = event.joy_button; InputEventJoypadButton jb2 = event.joy_button;
if (jb.button_index == jb2.button_index && if (jb->get_button_index() == jb2->get_button_index() &&
jb.pressed == jb2.pressed) { jb->is_pressed() == jb2->is_pressed()) {
match = true; match = true;
} }
} break; } break;
case InputEvent::SCREEN_TOUCH: { case Ref<InputEvent>::SCREEN_TOUCH: {
InputEventScreenTouch st = ie.screen_touch; InputEventScreenTouch st = ie.screen_touch;
InputEventScreenTouch st2 = event.screen_touch; InputEventScreenTouch st2 = event.screen_touch;
if (st.index == st2.index && if (st.index == st2.index &&
st.pressed == st2.pressed) { st->is_pressed() == st2->is_pressed()) {
match = true; match = true;
} }
} break; } break;
case InputEvent::SCREEN_DRAG: { case Ref<InputEvent>::SCREEN_DRAG: {
InputEventScreenDrag sd = ie.screen_drag; InputEventScreenDrag sd = ie.screen_drag;
InputEventScreenDrag sd2 = event.screen_drag; InputEventScreenDrag sd2 = event.screen_drag;
@@ -1611,13 +1612,13 @@ public:
match = true; match = true;
} }
} break; } break;
case InputEvent::ACTION: { case Ref<InputEvent>::ACTION: {
InputEventAction ia = ie.action; InputEventAction ia = ie.action;
InputEventAction ia2 = event.action; InputEventAction ia2 = event.action;
if (ia.action == ia2.action && if (ia.action == ia2.action &&
ia.pressed == ia2.pressed) { ia->is_pressed() == ia2->is_pressed()) {
match = true; match = true;
} }
} break; } break;
@@ -1643,7 +1644,7 @@ VisualScriptNodeInstance *VisualScriptInputFilter::instance(VisualScriptInstance
VisualScriptInputFilter::VisualScriptInputFilter() { VisualScriptInputFilter::VisualScriptInputFilter() {
} }
#endif
////////////////////////////////////////// //////////////////////////////////////////
////////////////TYPE CAST/////////// ////////////////TYPE CAST///////////
////////////////////////////////////////// //////////////////////////////////////////
@@ -1832,6 +1833,6 @@ void register_visual_script_flow_control_nodes() {
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator", create_node_generic<VisualScriptIterator>); 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/sequence", create_node_generic<VisualScriptSequence>);
VisualScriptLanguage::singleton->add_register_func("flow_control/switch", create_node_generic<VisualScriptSwitch>); 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/input_filter", create_node_generic<VisualScriptInputFilter>);
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>); VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
} }

View File

@@ -228,11 +228,12 @@ public:
VisualScriptSwitch(); VisualScriptSwitch();
}; };
#if 0
class VisualScriptInputFilter : public VisualScriptNode { class VisualScriptInputFilter : public VisualScriptNode {
GDCLASS(VisualScriptInputFilter, VisualScriptNode) GDCLASS(VisualScriptInputFilter, VisualScriptNode)
Vector<InputEvent> filters; Vector<Ref<InputEvent>> filters;
protected: protected:
bool _set(const StringName &p_name, const Variant &p_value); bool _set(const StringName &p_name, const Variant &p_value);
@@ -259,7 +260,7 @@ public:
VisualScriptInputFilter(); VisualScriptInputFilter();
}; };
#endif
class VisualScriptTypeCast : public VisualScriptNode { class VisualScriptTypeCast : public VisualScriptNode {
GDCLASS(VisualScriptTypeCast, VisualScriptNode) GDCLASS(VisualScriptTypeCast, VisualScriptNode)

View File

@@ -943,18 +943,6 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
////////////////SET////////////////////// ////////////////SET//////////////////////
////////////////////////////////////////// //////////////////////////////////////////
static const char *event_type_names[InputEvent::TYPE_MAX] = {
"None",
"Key",
"MouseMotion",
"MouseButton",
"JoypadMotion",
"JoypadButton",
"ScreenTouch",
"ScreenDrag",
"Action"
};
int VisualScriptPropertySet::get_output_sequence_port_count() const { int VisualScriptPropertySet::get_output_sequence_port_count() const {
return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0; return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0;
@@ -1119,24 +1107,6 @@ Variant::Type VisualScriptPropertySet::get_basic_type() const {
return basic_type; return basic_type;
} }
void VisualScriptPropertySet::set_event_type(InputEvent::Type p_type) {
if (event_type == p_type)
return;
event_type = p_type;
if (call_mode == CALL_MODE_BASIC_TYPE) {
_update_cache();
}
_change_notify();
_update_base_type();
ports_changed_notify();
}
InputEvent::Type VisualScriptPropertySet::get_event_type() const {
return event_type;
}
void VisualScriptPropertySet::set_base_type(const StringName &p_type) { void VisualScriptPropertySet::set_base_type(const StringName &p_type) {
if (base_type == p_type) if (base_type == p_type)
@@ -1182,14 +1152,8 @@ void VisualScriptPropertySet::_update_cache() {
//not super efficient.. //not super efficient..
Variant v; Variant v;
if (basic_type == Variant::INPUT_EVENT) { Variant::CallError ce;
InputEvent ev; v = Variant::construct(basic_type, NULL, 0, ce);
ev.type = event_type;
v = ev;
} else {
Variant::CallError ce;
v = Variant::construct(basic_type, NULL, 0, ce);
}
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
v.get_property_list(&pinfo); v.get_property_list(&pinfo);
@@ -1341,12 +1305,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
} }
} }
if (property.name == "property/event_type") {
if (call_mode != CALL_MODE_BASIC_TYPE || basic_type != Variant::INPUT_EVENT) {
property.usage = 0;
}
}
if (property.name == "property/node_path") { if (property.name == "property/node_path") {
if (call_mode != CALL_MODE_NODE_PATH) { if (call_mode != CALL_MODE_NODE_PATH) {
property.usage = 0; property.usage = 0;
@@ -1418,9 +1376,6 @@ void VisualScriptPropertySet::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertySet::_set_type_cache); ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertySet::_set_type_cache);
ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertySet::_get_type_cache); ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertySet::_get_type_cache);
ClassDB::bind_method(D_METHOD("set_event_type", "event_type"), &VisualScriptPropertySet::set_event_type);
ClassDB::bind_method(D_METHOD("get_event_type"), &VisualScriptPropertySet::get_event_type);
ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertySet::set_property); ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertySet::set_property);
ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertySet::get_property); ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertySet::get_property);
@@ -1438,14 +1393,6 @@ void VisualScriptPropertySet::_bind_methods() {
bt += Variant::get_type_name(Variant::Type(i)); bt += Variant::get_type_name(Variant::Type(i));
} }
String et;
for (int i = 0; i < InputEvent::TYPE_MAX; i++) {
if (i > 0)
et += ",";
et += event_type_names[i];
}
List<String> script_extensions; List<String> script_extensions;
for (int i = 0; i < ScriptServer::get_language_count(); i++) { for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions); ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions);
@@ -1463,7 +1410,6 @@ void VisualScriptPropertySet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache"); ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/event_type", PROPERTY_HINT_ENUM, et), "set_event_type", "get_event_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property");
@@ -1574,7 +1520,6 @@ VisualScriptPropertySet::VisualScriptPropertySet() {
call_mode = CALL_MODE_SELF; call_mode = CALL_MODE_SELF;
base_type = "Object"; base_type = "Object";
basic_type = Variant::NIL; basic_type = Variant::NIL;
event_type = InputEvent::NONE;
} }
template <VisualScriptPropertySet::CallMode cmode> template <VisualScriptPropertySet::CallMode cmode>
@@ -1764,14 +1709,8 @@ void VisualScriptPropertyGet::_update_cache() {
//not super efficient.. //not super efficient..
Variant v; Variant v;
if (basic_type == Variant::INPUT_EVENT) { Variant::CallError ce;
InputEvent ev; v = Variant::construct(basic_type, NULL, 0, ce);
ev.type = event_type;
v = ev;
} else {
Variant::CallError ce;
v = Variant::construct(basic_type, NULL, 0, ce);
}
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
v.get_property_list(&pinfo); v.get_property_list(&pinfo);
@@ -1919,24 +1858,6 @@ Variant::Type VisualScriptPropertyGet::get_basic_type() const {
return basic_type; return basic_type;
} }
void VisualScriptPropertyGet::set_event_type(InputEvent::Type p_type) {
if (event_type == p_type)
return;
event_type = p_type;
if (call_mode == CALL_MODE_BASIC_TYPE) {
_update_cache();
}
_change_notify();
_update_base_type();
ports_changed_notify();
}
InputEvent::Type VisualScriptPropertyGet::get_event_type() const {
return event_type;
}
void VisualScriptPropertyGet::_set_type_cache(Variant::Type p_type) { void VisualScriptPropertyGet::_set_type_cache(Variant::Type p_type) {
type_cache = p_type; type_cache = p_type;
} }
@@ -1965,11 +1886,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
property.usage = 0; property.usage = 0;
} }
} }
if (property.name == "property/event_type") {
if (call_mode != CALL_MODE_BASIC_TYPE || basic_type != Variant::INPUT_EVENT) {
property.usage = 0;
}
}
if (property.name == "property/node_path") { if (property.name == "property/node_path") {
if (call_mode != CALL_MODE_NODE_PATH) { if (call_mode != CALL_MODE_NODE_PATH) {
@@ -2041,9 +1957,6 @@ void VisualScriptPropertyGet::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertyGet::_set_type_cache); ClassDB::bind_method(D_METHOD("_set_type_cache", "type_cache"), &VisualScriptPropertyGet::_set_type_cache);
ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertyGet::_get_type_cache); ClassDB::bind_method(D_METHOD("_get_type_cache"), &VisualScriptPropertyGet::_get_type_cache);
ClassDB::bind_method(D_METHOD("set_event_type", "event_type"), &VisualScriptPropertyGet::set_event_type);
ClassDB::bind_method(D_METHOD("get_event_type"), &VisualScriptPropertyGet::get_event_type);
ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertyGet::set_property); ClassDB::bind_method(D_METHOD("set_property", "property"), &VisualScriptPropertyGet::set_property);
ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertyGet::get_property); ClassDB::bind_method(D_METHOD("get_property"), &VisualScriptPropertyGet::get_property);
@@ -2061,14 +1974,6 @@ void VisualScriptPropertyGet::_bind_methods() {
bt += Variant::get_type_name(Variant::Type(i)); bt += Variant::get_type_name(Variant::Type(i));
} }
String et;
for (int i = 0; i < InputEvent::TYPE_MAX; i++) {
if (i > 0)
et += ",";
et += event_type_names[i];
}
List<String> script_extensions; List<String> script_extensions;
for (int i = 0; i < ScriptServer::get_language_count(); i++) { for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions); ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions);
@@ -2086,7 +1991,6 @@ void VisualScriptPropertyGet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache"); ADD_PROPERTY(PropertyInfo(Variant::INT, "property/type_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_type_cache", "_get_type_cache");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "property/basic_type", PROPERTY_HINT_ENUM, bt), "set_basic_type", "get_basic_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "property/event_type", PROPERTY_HINT_ENUM, et), "set_event_type", "get_event_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "property/node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "property/property"), "set_property", "get_property");
@@ -2184,7 +2088,6 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() {
call_mode = CALL_MODE_SELF; call_mode = CALL_MODE_SELF;
base_type = "Object"; base_type = "Object";
basic_type = Variant::NIL; basic_type = Variant::NIL;
event_type = InputEvent::NONE;
type_cache = Variant::NIL; type_cache = Variant::NIL;
} }

View File

@@ -155,7 +155,6 @@ private:
String base_script; String base_script;
NodePath base_path; NodePath base_path;
StringName property; StringName property;
InputEvent::Type event_type;
Node *_get_base_node() const; Node *_get_base_node() const;
StringName _get_base_type() const; StringName _get_base_type() const;
@@ -197,9 +196,6 @@ public:
void set_basic_type(Variant::Type p_type); void set_basic_type(Variant::Type p_type);
Variant::Type get_basic_type() const; Variant::Type get_basic_type() const;
void set_event_type(InputEvent::Type p_type);
InputEvent::Type get_event_type() const;
void set_property(const StringName &p_type); void set_property(const StringName &p_type);
StringName get_property() const; StringName get_property() const;
@@ -238,7 +234,6 @@ private:
String base_script; String base_script;
NodePath base_path; NodePath base_path;
StringName property; StringName property;
InputEvent::Type event_type;
void _update_base_type(); void _update_base_type();
Node *_get_base_node() const; Node *_get_base_node() const;
@@ -279,9 +274,6 @@ public:
void set_basic_type(Variant::Type p_type); void set_basic_type(Variant::Type p_type);
Variant::Type get_basic_type() const; Variant::Type get_basic_type() const;
void set_event_type(InputEvent::Type p_type);
InputEvent::Type get_event_type() const;
void set_property(const StringName &p_type); void set_property(const StringName &p_type);
StringName get_property() const; StringName get_property() const;

View File

@@ -3460,14 +3460,8 @@ void VisualScriptDeconstruct::_update_elements() {
elements.clear(); elements.clear();
Variant v; Variant v;
if (type == Variant::INPUT_EVENT) { Variant::CallError ce;
InputEvent ie; v = Variant::construct(type, NULL, 0, ce);
ie.type = input_type;
v = ie;
} else {
Variant::CallError ce;
v = Variant::construct(type, NULL, 0, ce);
}
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
v.get_property_list(&pinfo); v.get_property_list(&pinfo);
@@ -3497,21 +3491,6 @@ Variant::Type VisualScriptDeconstruct::get_deconstruct_type() const {
return type; return type;
} }
void VisualScriptDeconstruct::set_deconstruct_input_type(InputEvent::Type p_input_type) {
if (input_type == p_input_type)
return;
input_type = p_input_type;
_update_elements();
ports_changed_notify();
}
InputEvent::Type VisualScriptDeconstruct::get_deconstruct_input_type() const {
return input_type;
}
void VisualScriptDeconstruct::_set_elem_cache(const Array &p_elements) { void VisualScriptDeconstruct::_set_elem_cache(const Array &p_elements) {
ERR_FAIL_COND(p_elements.size() % 2 == 1); ERR_FAIL_COND(p_elements.size() % 2 == 1);
@@ -3570,12 +3549,6 @@ VisualScriptNodeInstance *VisualScriptDeconstruct::instance(VisualScriptInstance
} }
void VisualScriptDeconstruct::_validate_property(PropertyInfo &property) const { void VisualScriptDeconstruct::_validate_property(PropertyInfo &property) const {
if (property.name == "input_type") {
if (type != Variant::INPUT_EVENT) {
property.usage = 0;
}
}
} }
void VisualScriptDeconstruct::_bind_methods() { void VisualScriptDeconstruct::_bind_methods() {
@@ -3583,9 +3556,6 @@ void VisualScriptDeconstruct::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_deconstruct_type", "type"), &VisualScriptDeconstruct::set_deconstruct_type); ClassDB::bind_method(D_METHOD("set_deconstruct_type", "type"), &VisualScriptDeconstruct::set_deconstruct_type);
ClassDB::bind_method(D_METHOD("get_deconstruct_type"), &VisualScriptDeconstruct::get_deconstruct_type); ClassDB::bind_method(D_METHOD("get_deconstruct_type"), &VisualScriptDeconstruct::get_deconstruct_type);
ClassDB::bind_method(D_METHOD("set_deconstruct_input_type", "input_type"), &VisualScriptDeconstruct::set_deconstruct_input_type);
ClassDB::bind_method(D_METHOD("get_deconstruct_input_type"), &VisualScriptDeconstruct::get_deconstruct_input_type);
ClassDB::bind_method(D_METHOD("_set_elem_cache", "_cache"), &VisualScriptDeconstruct::_set_elem_cache); ClassDB::bind_method(D_METHOD("_set_elem_cache", "_cache"), &VisualScriptDeconstruct::_set_elem_cache);
ClassDB::bind_method(D_METHOD("_get_elem_cache"), &VisualScriptDeconstruct::_get_elem_cache); ClassDB::bind_method(D_METHOD("_get_elem_cache"), &VisualScriptDeconstruct::_get_elem_cache);
@@ -3594,17 +3564,13 @@ void VisualScriptDeconstruct::_bind_methods() {
argt += "," + Variant::get_type_name(Variant::Type(i)); argt += "," + Variant::get_type_name(Variant::Type(i));
} }
String iet = "None,Key,MouseMotion,MouseButton,JoypadMotion,JoypadButton,ScreenTouch,ScreenDrag,Action";
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_deconstruct_type", "get_deconstruct_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_deconstruct_type", "get_deconstruct_type");
ADD_PROPERTY(PropertyInfo(Variant::INT, "input_type", PROPERTY_HINT_ENUM, iet), "set_deconstruct_input_type", "get_deconstruct_input_type");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "elem_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_elem_cache", "_get_elem_cache"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "elem_cache", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_elem_cache", "_get_elem_cache");
} }
VisualScriptDeconstruct::VisualScriptDeconstruct() { VisualScriptDeconstruct::VisualScriptDeconstruct() {
type = Variant::NIL; type = Variant::NIL;
input_type = InputEvent::NONE;
} }
void register_visual_script_nodes() { void register_visual_script_nodes() {

View File

@@ -923,7 +923,6 @@ class VisualScriptDeconstruct : public VisualScriptNode {
void _update_elements(); void _update_elements();
Variant::Type type; Variant::Type type;
InputEvent::Type input_type;
void _set_elem_cache(const Array &p_elements); void _set_elem_cache(const Array &p_elements);
Array _get_elem_cache() const; Array _get_elem_cache() const;
@@ -952,9 +951,6 @@ public:
void set_deconstruct_type(Variant::Type p_type); void set_deconstruct_type(Variant::Type p_type);
Variant::Type get_deconstruct_type() const; Variant::Type get_deconstruct_type() const;
void set_deconstruct_input_type(InputEvent::Type p_input_type);
InputEvent::Type get_deconstruct_input_type() const;
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
VisualScriptDeconstruct(); VisualScriptDeconstruct();