diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-12-17 15:43:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-17 15:43:11 +0100 |
commit | cacab4ba6204aa36ddbc85d55705ab82b45e7930 (patch) | |
tree | 9a498561f69431b1656106198323eb9a5cd38a1c /modules | |
parent | 8821f9b750a59ca3ec7465ce54a472eb541d7181 (diff) | |
parent | 8f25a2dc11b73cd440adcd341e4180f6f93877aa (diff) |
Merge pull request #14769 from akien-mga/if-0-cleanup
Cleanup some #if 0'd code
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_function.cpp | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_flow_control.cpp | 915 | ||||
-rw-r--r-- | modules/visual_script/visual_script_flow_control.h | 34 |
3 files changed, 2 insertions, 949 deletions
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index ee23f0ea0f..d6352f1e6e 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -1257,6 +1257,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a exit_ok = true; OPCODE_BREAK; } + +// Enable for debugging #if 0 default: { diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index a38266acc0..147761783a 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -731,921 +731,6 @@ void VisualScriptSwitch::_bind_methods() { VisualScriptSwitch::VisualScriptSwitch() { } - ////////////////////////////////////////// - ////////////////EVENT ACTION FILTER/////////// - ////////////////////////////////////////// - -#if 0 -int VisualScriptInputFilter::get_output_sequence_port_count() const { - - return filters.size(); -} - -bool VisualScriptInputFilter::has_input_sequence_port() const { - - return true; -} - -int VisualScriptInputFilter::get_input_value_port_count() const { - - return 1; -} -int VisualScriptInputFilter::get_output_value_port_count() const { - - return 1; -} - -String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const { - - String text; - - switch (filters[p_port].type) { - case Ref<InputEvent>::NONE: { - text = "None"; - } break; - case Ref<InputEvent>::KEY: { - - InputEventKey k = filters[p_port].key; - - if (k->get_scancode() == 0 && k.unicode == 0) { - text = "No Key"; - } else { - if (k->get_scancode() != 0) { - text = "KeyCode: " + keycode_get_string(k->get_scancode()); - } else if (k.unicode != 0) { - text = "Uniode: " + String::chr(k.unicode); - } - - if (k->is_pressed()) - text += ", Pressed"; - else - text += ", Released"; - - if (k.echo) - text += ", Echo"; - if (k->get_alt()) - text = "Alt+" + text; - if (k->get_shift()) - text = "Shift+" + text; - if (k->get_control()) - text = "Ctrl+" + text; - if (k->get_metakey()) - text = "Meta+" + text; - } - - } break; - case Ref<InputEvent>::MOUSE_MOTION: { - InputEventMouseMotion mm = filters[p_port].mouse_motion; - text = "Mouse Motion"; - - String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; - - for (int i = 0; i < 7; i++) { - if (mm->get_button_mask() & (1 << i)) { - text = b.get_slice(",", i) + "+" + text; - } - } - if (mm->get_alt()) - text = "Alt+" + text; - if (mm->get_shift()) - text = "Shift+" + text; - if (mm->get_control()) - text = "Ctrl+" + text; - if (mm->get_metakey()) - text = "Meta+" + text; - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - InputEventMouseButton mb = filters[p_port].mouse_button; - - String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; - - text = b.get_slice(",", mb->get_button_index()) + " Mouse Button"; - - if (mb->is_pressed()) - text += ", Pressed"; - else - text += ", Released"; - - if (mb.doubleclick) - text += ", DblClick"; - if (mb->get_alt()) - text = "Alt+" + text; - if (mb->get_shift()) - text = "Shift+" + text; - if (mb->get_control()) - text = "Ctrl+" + text; - if (mb->get_metakey()) - text = "Meta+" + text; - - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - InputEventJoypadMotion jm = filters[p_port].joy_motion; - - text = "JoyMotion Axis " + itos(jm.axis >> 1); - if (jm.axis & 1) - text += " > " + rtos(jm.axis_value); - else - text += " < " + rtos(-jm.axis_value); - - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - InputEventJoypadButton jb = filters[p_port].joy_button; - - text = "JoyButton " + itos(jb->get_button_index()); - if (jb->is_pressed()) - text += ", Pressed"; - else - text += ", Released"; - } break; - case Ref<InputEvent>::SCREEN_TOUCH: { - InputEventScreenTouch sd = filters[p_port].screen_touch; - - text = "Touch Finger " + itos(sd.index); - if (sd->is_pressed()) - text += ", Pressed"; - else - text += ", Released"; - } break; - case Ref<InputEvent>::SCREEN_DRAG: { - InputEventScreenDrag sd = filters[p_port].screen_drag; - text = "Drag Finger " + itos(sd.index); - } break; - case Ref<InputEvent>::ACTION: { - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - int index = 1; - - text = "No Action"; - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - if (filters[p_port].action.action == index) { - text = "Action " + pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - break; - } - index++; - } - - if (filters[p_port].action->is_pressed()) - text += ", Pressed"; - else - text += ", Released"; - - } break; - } - - return text + " - " + itos(p_port); -} - -PropertyInfo VisualScriptInputFilter::get_input_value_port_info(int p_idx) const { - - return PropertyInfo(Variant::INPUT_EVENT, "event"); -} - -PropertyInfo VisualScriptInputFilter::get_output_value_port_info(int p_idx) const { - - return PropertyInfo(Variant::INPUT_EVENT, ""); -} - -String VisualScriptInputFilter::get_caption() const { - - return "InputFilter"; -} - -String VisualScriptInputFilter::get_text() const { - - return ""; -} - -bool VisualScriptInputFilter::_set(const StringName &p_name, const Variant &p_value) { - - if (p_name == "filter_count") { - filters.resize(p_value); - _change_notify(); - ports_changed_notify(); - return true; - } - - if (String(p_name).begins_with("filter_")) { - - 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") { - filters[idx] = Ref<InputEvent>(); - filters[idx].type = Ref<InputEvent>::Type(int(p_value)); - if (filters[idx].type == Ref<InputEvent>::JOYPAD_MOTION) { - filters[idx].joy_motion.axis_value = 0.5; //for threshold - } 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; - } - _change_notify(); - ports_changed_notify(); - - return true; - } - if (what == "device") { - filters[idx].device = p_value; - ports_changed_notify(); - return true; - } - - switch (filters[idx].type) { - - case Ref<InputEvent>::KEY: { - - if (what == "scancode") { - String sc = p_value; - if (sc == String()) { - filters[idx]->get_scancode() = 0; - } else { - filters[idx]->get_scancode() = find_keycode(p_value); - } - - } else if (what == "unicode") { - - String uc = p_value; - - if (uc == String()) { - filters[idx].key.unicode = 0; - } else { - filters[idx].key.unicode = uc[0]; - } - - } else if (what == "pressed") { - - filters[idx]->is_pressed() = p_value; - } else if (what == "echo") { - - filters[idx]->is_echo() = p_value; - - } else if (what == "mod_alt") { - filters[idx]->get_alt() = p_value; - - } else if (what == "mod_shift") { - filters[idx]->get_shift() = p_value; - - } else if (what == "mod_ctrl") { - filters[idx]->get_control() = p_value; - - } else if (what == "mod_meta") { - filters[idx]->get_metakey() = p_value; - } else { - return false; - } - ports_changed_notify(); - - return true; - } break; - case Ref<InputEvent>::MOUSE_MOTION: { - - if (what == "button_mask") { - filters[idx]->get_button_mask() = p_value; - - } else if (what == "mod_alt") { - filters[idx].mouse_motion->get_alt() = p_value; - - } else if (what == "mod_shift") { - filters[idx].mouse_motion->get_shift() = p_value; - - } else if (what == "mod_ctrl") { - filters[idx].mouse_motion->get_control() = p_value; - - } else if (what == "mod_meta") { - filters[idx].mouse_motion->get_metakey() = p_value; - } else { - return false; - } - - ports_changed_notify(); - return true; - - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - if (what == "button_index") { - filters[idx]->get_button_index() = p_value; - } else if (what == "pressed") { - filters[idx]->is_pressed() = p_value; - } else if (what == "doubleclicked") { - filters[idx].mouse_button.doubleclick = p_value; - - } else if (what == "mod_alt") { - filters[idx].mouse_button->get_alt() = p_value; - - } else if (what == "mod_shift") { - filters[idx].mouse_button->get_shift() = p_value; - - } else if (what == "mod_ctrl") { - filters[idx].mouse_button->get_control() = p_value; - - } else if (what == "mod_meta") { - filters[idx].mouse_button->get_metakey() = p_value; - } else { - return false; - } - ports_changed_notify(); - return true; - - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - 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 == "threshold") { - filters[idx].joy_motion.axis_value = p_value; - } else { - return false; - } - ports_changed_notify(); - return true; - - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - - if (what == "button_index") { - filters[idx].joy_button->get_button_index() = p_value; - } else if (what == "pressed") { - filters[idx].joy_button->is_pressed() = p_value; - } else { - return false; - } - ports_changed_notify(); - return true; - - } break; - case Ref<InputEvent>::SCREEN_TOUCH: { - - if (what == "finger_index") { - filters[idx].screen_touch.index = p_value; - } else if (what == "pressed") { - filters[idx].screen_touch->is_pressed() = p_value; - } else { - return false; - } - ports_changed_notify(); - return true; - } break; - case Ref<InputEvent>::SCREEN_DRAG: { - if (what == "finger_index") { - filters[idx].screen_drag.index = p_value; - } else { - return false; - } - ports_changed_notify(); - return true; - } break; - case Ref<InputEvent>::ACTION: { - - if (what == "action_name") { - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - int index = 1; - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - if (name == String(p_value)) { - - filters[idx].action.action = index; - ports_changed_notify(); - return true; - } - - index++; - } - - filters[idx].action.action = 0; - ports_changed_notify(); - - return false; - - } else if (what == "pressed") { - - filters[idx].action->is_pressed() = p_value; - ports_changed_notify(); - return true; - } - - } break; - } - } - return false; -} - -bool VisualScriptInputFilter::_get(const StringName &p_name, Variant &r_ret) const { - - if (p_name == "filter_count") { - r_ret = filters.size(); - return true; - } - - if (String(p_name).begins_with("filter_")) { - - 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") { - r_ret = filters[idx].type; - return true; - } - if (what == "device") { - r_ret = filters[idx].device; - return true; - } - - switch (filters[idx].type) { - - case Ref<InputEvent>::KEY: { - - if (what == "scancode") { - if (filters[idx]->get_scancode() == 0) - r_ret = String(); - else { - - r_ret = keycode_get_string(filters[idx]->get_scancode()); - } - - } else if (what == "unicode") { - - if (filters[idx].key.unicode == 0) { - r_ret = String(); - } else { - CharType str[2] = { (CharType)filters[idx].key.unicode, 0 }; - r_ret = String(str); - } - - } else if (what == "pressed") { - - r_ret = filters[idx]->is_pressed(); - } else if (what == "echo") { - - r_ret = filters[idx]->is_echo(); - - } else if (what == "mod_alt") { - r_ret = filters[idx]->get_alt(); - - } else if (what == "mod_shift") { - r_ret = filters[idx]->get_shift(); - - } else if (what == "mod_ctrl") { - r_ret = filters[idx]->get_control(); - - } else if (what == "mod_meta") { - r_ret = filters[idx]->get_metakey(); - } else { - return false; - } - - return true; - } break; - case Ref<InputEvent>::MOUSE_MOTION: { - - if (what == "button_mask") { - r_ret = filters[idx]->get_button_mask(); - - } else if (what == "mod_alt") { - r_ret = filters[idx].mouse_motion->get_alt(); - - } else if (what == "mod_shift") { - r_ret = filters[idx].mouse_motion->get_shift(); - - } else if (what == "mod_ctrl") { - r_ret = filters[idx].mouse_motion->get_control(); - - } else if (what == "mod_meta") { - r_ret = filters[idx].mouse_motion->get_metakey(); - } else { - return false; - } - - return true; - - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - if (what == "button_index") { - r_ret = filters[idx]->get_button_index(); - } else if (what == "pressed") { - r_ret = filters[idx]->is_pressed(); - } else if (what == "doubleclicked") { - r_ret = filters[idx].mouse_button.doubleclick; - - } else if (what == "mod_alt") { - r_ret = filters[idx].mouse_button->get_alt(); - - } else if (what == "mod_shift") { - r_ret = filters[idx].mouse_button->get_shift(); - - } else if (what == "mod_ctrl") { - r_ret = filters[idx].mouse_button->get_control(); - - } else if (what == "mod_meta") { - r_ret = filters[idx].mouse_button->get_metakey(); - } else { - return false; - } - return true; - - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - 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 == "threshold") { - r_ret = filters[idx].joy_motion.axis_value; - } else { - return false; - } - return true; - - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - - if (what == "button_index") { - r_ret = filters[idx].joy_button->get_button_index(); - } else if (what == "pressed") { - r_ret = filters[idx].joy_button->is_pressed(); - } else { - return false; - } - return true; - - } break; - case Ref<InputEvent>::SCREEN_TOUCH: { - - if (what == "finger_index") { - r_ret = filters[idx].screen_touch.index; - } else if (what == "pressed") { - r_ret = filters[idx].screen_touch->is_pressed(); - } else { - return false; - } - return true; - } break; - case Ref<InputEvent>::SCREEN_DRAG: { - if (what == "finger_index") { - r_ret = filters[idx].screen_drag.index; - } else { - return false; - } - return true; - } break; - case Ref<InputEvent>::ACTION: { - - if (what == "action_name") { - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - int index = 1; - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - if (filters[idx].action.action == index) { - r_ret = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - return true; - } - index++; - } - - r_ret = "None"; //no index - return false; - - } else if (what == "pressed") { - - r_ret = filters[idx].action->is_pressed(); - return true; - } - - } break; - } - } - return false; -} - -static const char *event_type_names[Ref<InputEvent>::TYPE_MAX] = { - "None", - "Key", - "MouseMotion", - "MouseButton", - "JoypadMotion", - "JoypadButton", - "ScreenTouch", - "ScreenDrag", - "Action" -}; - -void VisualScriptInputFilter::_get_property_list(List<PropertyInfo> *p_list) const { - - p_list->push_back(PropertyInfo(Variant::INT, "filter_count", PROPERTY_HINT_RANGE, "0,64")); - - String et; - for (int i = 0; i < Ref<InputEvent>::TYPE_MAX; i++) { - if (i > 0) - et += ","; - - et += event_type_names[i]; - } - - String kc; - String actions; - - for (int i = 0; i < filters.size(); i++) { - - 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) { - - case Ref<InputEvent>::NONE: { - - } break; - case Ref<InputEvent>::KEY: { - if (kc == String()) { - int kcc = keycode_get_count(); - kc = "None"; - for (int i = 0; i < kcc; i++) { - kc += ","; - kc += String(keycode_get_name_by_index(i)); - } - } - 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")); - - } break; - 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::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")); - - } break; - 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::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")); - - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - 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 + "threshold", PROPERTY_HINT_RANGE, "0,1,0.01")); - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - p_list->push_back(PropertyInfo(Variant::INT, base + "button_index")); - p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed")); - - } break; - case Ref<InputEvent>::SCREEN_TOUCH: { - p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index")); - p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed")); - - } break; - case Ref<InputEvent>::SCREEN_DRAG: { - p_list->push_back(PropertyInfo(Variant::INT, base + "finger_index")); - } break; - case Ref<InputEvent>::ACTION: { - - if (actions == String()) { - - actions = "None"; - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - Vector<String> al; - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - - al.push_back(name); - } - - for (int i = 0; i < al.size(); i++) { - actions += ","; - actions += al[i]; - } - } - - p_list->push_back(PropertyInfo(Variant::STRING, base + "action_name", PROPERTY_HINT_ENUM, actions)); - p_list->push_back(PropertyInfo(Variant::BOOL, base + "pressed")); - - } break; - } - } -} - -class VisualScriptNodeInstanceInputFilter : public VisualScriptNodeInstance { -public: - VisualScriptInstance *instance; - Vector<Ref<InputEvent>> filters; - - //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; } - - virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) { - - if (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; - return 0; - } - - Ref<InputEvent> event = *p_inputs[0]; - - for (int i = 0; i < filters.size(); i++) { - - const Ref<InputEvent> &ie = filters[i]; - if (ie.type != event.type) - continue; - - bool match = false; - - switch (ie.type) { - - case Ref<InputEvent>::NONE: { - - match = true; - } break; - case Ref<InputEvent>::KEY: { - - InputEventKey k = ie.key; - InputEventKey k2 = event.key; - - if (k->get_scancode() == 0 && k.unicode == 0 && k2->get_scancode() == 0 && k2.unicode == 0) { - match = true; - - } else { - - if ((k->get_scancode() != 0 && k->get_scancode() == k2->get_scancode()) || (k.unicode != 0 && k.unicode == k2.unicode)) { - //key valid - - if ( - k->is_pressed() == k2->is_pressed() && - k.echo == k2.echo && - k.mod == k2.mod) { - match = true; - } - } - } - - } break; - case Ref<InputEvent>::MOUSE_MOTION: { - InputEventMouseMotion mm = ie.mouse_motion; - InputEventMouseMotion mm2 = event.mouse_motion; - - if (mm->get_button_mask() == mm2->get_button_mask() && - mm.mod == mm2.mod) { - match = true; - } - - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - InputEventMouseButton mb = ie.mouse_button; - InputEventMouseButton mb2 = event.mouse_button; - - if (mb->get_button_index() == mb2->get_button_index() && - mb->is_pressed() == mb2->is_pressed() && - mb.doubleclick == mb2.doubleclick && - mb.mod == mb2.mod) { - match = true; - } - - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - InputEventJoypadMotion jm = ie.joy_motion; - InputEventJoypadMotion jm2 = event.joy_motion; - - int axis = jm.axis >> 1; - - if (axis == jm2.axis) { - - if (jm.axis & 1) { - //greater - if (jm2.axis_value > jm.axis_value) { - match = true; - } - } else { - //less - if (jm2.axis_value < -jm.axis_value) { - match = true; - } - } - } - - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - InputEventJoypadButton jb = ie.joy_button; - InputEventJoypadButton jb2 = event.joy_button; - - if (jb->get_button_index() == jb2->get_button_index() && - jb->is_pressed() == jb2->is_pressed()) { - match = true; - } - } break; - case Ref<InputEvent>::SCREEN_TOUCH: { - InputEventScreenTouch st = ie.screen_touch; - InputEventScreenTouch st2 = event.screen_touch; - - if (st.index == st2.index && - st->is_pressed() == st2->is_pressed()) { - match = true; - } - - } break; - case Ref<InputEvent>::SCREEN_DRAG: { - InputEventScreenDrag sd = ie.screen_drag; - InputEventScreenDrag sd2 = event.screen_drag; - - if (sd.index == sd2.index) { - match = true; - } - } break; - case Ref<InputEvent>::ACTION: { - - InputEventAction ia = ie.action; - InputEventAction ia2 = event.action; - - if (ia.action == ia2.action && - ia->is_pressed() == ia2->is_pressed()) { - match = true; - } - } break; - } - - *p_outputs[0] = event; - - if (match) - return i; //go through match output - } - - return STEP_NO_ADVANCE_BIT; //none found, don't advance - } -}; - -VisualScriptNodeInstance *VisualScriptInputFilter::instance(VisualScriptInstance *p_instance) { - - VisualScriptNodeInstanceInputFilter *instance = memnew(VisualScriptNodeInstanceInputFilter); - instance->instance = p_instance; - instance->filters = filters; - return instance; -} - -VisualScriptInputFilter::VisualScriptInputFilter() { -} -#endif ////////////////////////////////////////// ////////////////TYPE CAST/////////// ////////////////////////////////////////// diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h index 380eb76c45..4766bbef6b 100644 --- a/modules/visual_script/visual_script_flow_control.h +++ b/modules/visual_script/visual_script_flow_control.h @@ -228,40 +228,6 @@ public: VisualScriptSwitch(); }; -#if 0 -class VisualScriptInputFilter : public VisualScriptNode { - - GDCLASS(VisualScriptInputFilter, VisualScriptNode) - - Vector<Ref<InputEvent>> filters; - -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - -public: - virtual int get_output_sequence_port_count() const; - virtual bool has_input_sequence_port() const; - - virtual String get_output_sequence_port_text(int p_port) const; - - virtual int get_input_value_port_count() const; - virtual int get_output_value_port_count() const; - - virtual PropertyInfo get_input_value_port_info(int p_idx) const; - virtual PropertyInfo get_output_value_port_info(int p_idx) const; - - virtual String get_caption() const; - virtual String get_text() const; - virtual String get_category() const { return "flow_control"; } - - virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); - - VisualScriptInputFilter(); -}; -#endif - class VisualScriptTypeCast : public VisualScriptNode { GDCLASS(VisualScriptTypeCast, VisualScriptNode) |