Backported returning AfterGUIInput from forward_spatial_gui_input from Godot4. Also removed the first index parameter. This fully broke the skeleton editor, it will be fixed soon.

This commit is contained in:
Relintai 2022-08-11 02:24:30 +02:00
parent 061bdd1f2e
commit b6eb2db442
22 changed files with 152 additions and 127 deletions

View File

@ -243,25 +243,23 @@
</description> </description>
</method> </method>
<method name="forward_spatial_gui_input" qualifiers="virtual"> <method name="forward_spatial_gui_input" qualifiers="virtual">
<return type="bool" /> <return type="int" />
<argument index="0" name="index" type="int" /> <argument index="0" name="camera" type="Camera" />
<argument index="1" name="camera" type="Camera" /> <argument index="1" name="event" type="InputEvent" />
<argument index="2" name="event" type="InputEvent" />
<description> <description>
Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example:
[codeblock] [codeblock]
# Prevents the InputEvent to reach other Editor classes # Prevents the InputEvent to reach other Editor classes
func forward_spatial_gui_input(index, camera, event): func forward_spatial_gui_input(camera, event):
var forward = true return EditorPlugin.AFTER_GUI_INPUT_STOP
return forward
[/codeblock] [/codeblock]
Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example: Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example:
[codeblock] [codeblock]
# Consumes InputEventMouseMotion and forwards other InputEvent types # Consumes InputEventMouseMotion and forwards other InputEvent types
func forward_spatial_gui_input(index, camera, event): func forward_spatial_gui_input(camera, event):
var forward = false var forward = EditorPlugin.AFTER_GUI_INPUT_STOP
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
forward = true forward = EditorPlugin.AFTER_GUI_INPUT_PASS
return forward return forward
[/codeblock] [/codeblock]
</description> </description>

View File

@ -7022,20 +7022,25 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
return discard; return discard;
} }
bool EditorPluginList::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) { EditorPlugin::AfterGUIInput EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false; EditorPlugin::AfterGUIInput after = EditorPlugin::AFTER_GUI_INPUT_PASS;
for (int i = 0; i < plugins_list.size(); i++) { for (int i = 0; i < plugins_list.size(); i++) {
if ((!serve_when_force_input_enabled) && plugins_list[i]->is_input_event_forwarding_always_enabled()) { if ((!serve_when_force_input_enabled) && plugins_list[i]->is_input_event_forwarding_always_enabled()) {
continue; continue;
} }
if (plugins_list[i]->forward_spatial_gui_input(p_index, p_camera, p_event)) { EditorPlugin::AfterGUIInput current_after = plugins_list[i]->forward_spatial_gui_input(p_camera, p_event);
discard = true; if (current_after == EditorPlugin::AFTER_GUI_INPUT_STOP) {
after = EditorPlugin::AFTER_GUI_INPUT_STOP;
}
if (after != EditorPlugin::AFTER_GUI_INPUT_STOP && current_after == EditorPlugin::AFTER_GUI_INPUT_DESELECT) {
after = EditorPlugin::AFTER_GUI_INPUT_DESELECT;
} }
} }
return discard; return after;
} }
void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) { void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) {

View File

@ -962,7 +962,7 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event); bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay); void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay); void forward_canvas_force_draw_over_viewport(Control *p_overlay);
bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled); EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_spatial_draw_over_viewport(Control *p_overlay); void forward_spatial_draw_over_viewport(Control *p_overlay);
void forward_spatial_force_draw_over_viewport(Control *p_overlay); void forward_spatial_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin); void add_plugin(EditorPlugin *p_plugin);

View File

@ -621,12 +621,13 @@ int EditorPlugin::update_overlays() const {
} }
} }
bool EditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) { if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
return get_script_instance()->call("forward_spatial_gui_input", p_index, p_camera, p_event); int success = get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
return static_cast<EditorPlugin::AfterGUIInput>(success);
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) { void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
@ -895,7 +896,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
@ -943,6 +944,10 @@ void EditorPlugin::_bind_methods() {
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR); BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR); BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
BIND_ENUM_CONSTANT(DOCK_SLOT_MAX); BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_DESELECT);
} }
EditorPlugin::EditorPlugin() : EditorPlugin::EditorPlugin() :

View File

@ -40,16 +40,16 @@
#include "core/dictionary.h" #include "core/dictionary.h"
#include "core/error_list.h" #include "core/error_list.h"
#include "core/error_macros.h" #include "core/error_macros.h"
#include "core/io/config_file.h"
#include "core/list.h" #include "core/list.h"
#include "core/method_bind.h" #include "core/method_bind.h"
#include "core/object.h" #include "core/object.h"
#include "core/os/memory.h" #include "core/os/memory.h"
#include "core/reference.h" #include "core/reference.h"
#include "core/undo_redo.h"
#include "core/ustring.h" #include "core/ustring.h"
#include "core/variant.h" #include "core/variant.h"
#include "core/vector.h" #include "core/vector.h"
#include "core/io/config_file.h"
#include "core/undo_redo.h"
class EditorNode; class EditorNode;
class Spatial; class Spatial;
@ -191,6 +191,12 @@ public:
DOCK_SLOT_MAX DOCK_SLOT_MAX
}; };
enum AfterGUIInput {
AFTER_GUI_INPUT_PASS,
AFTER_GUI_INPUT_STOP,
AFTER_GUI_INPUT_DESELECT
};
//TODO: send a resource for editing to the editor node? //TODO: send a resource for editing to the editor node?
void add_control_to_container(CustomControlContainer p_location, Control *p_control); void add_control_to_container(CustomControlContainer p_location, Control *p_control);
@ -219,7 +225,7 @@ public:
virtual void forward_canvas_draw_over_viewport(Control *p_overlay); virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay); virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event); virtual AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual void forward_spatial_draw_over_viewport(Control *p_overlay); virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay); virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
@ -282,6 +288,7 @@ public:
VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer); VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer);
VARIANT_ENUM_CAST(EditorPlugin::DockSlot); VARIANT_ENUM_CAST(EditorPlugin::DockSlot);
VARIANT_ENUM_CAST(EditorPlugin::AfterGUIInput);
typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *); typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *);

View File

@ -128,9 +128,9 @@ void Polygon3DEditor::_wip_close() {
undo_redo->commit_action(); undo_redo->commit_action();
} }
bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!node) { if (!node) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Transform gt = node->get_global_transform(); Transform gt = node->get_global_transform();
@ -149,7 +149,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
Vector3 spoint; Vector3 spoint;
if (!p.intersects_ray(ray_from, ray_dir, &spoint)) { if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
spoint = gi.xform(spoint); spoint = gi.xform(spoint);
@ -176,19 +176,19 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
snap_ignore = false; snap_ignore = false;
_polygon_draw(); _polygon_draw();
edited_point = 1; edited_point = 1;
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else { } else {
if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) { if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) {
//wip closed //wip closed
_wip_close(); _wip_close();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else { } else {
wip.push_back(cpoint); wip.push_back(cpoint);
edited_point = wip.size(); edited_point = wip.size();
snap_ignore = false; snap_ignore = false;
_polygon_draw(); _polygon_draw();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} }
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) { } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
@ -209,7 +209,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->add_do_method(this, "_polygon_draw"); undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw"); undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action(); undo_redo->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
//search edges //search edges
@ -244,7 +244,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
_polygon_draw(); _polygon_draw();
snap_ignore = true; snap_ignore = true;
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} else { } else {
//look for points to move //look for points to move
@ -269,7 +269,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
edited_point_pos = poly[closest_idx]; edited_point_pos = poly[closest_idx];
_polygon_draw(); _polygon_draw();
snap_ignore = false; snap_ignore = false;
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} }
} else { } else {
@ -278,7 +278,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
if (edited_point != -1) { if (edited_point != -1) {
//apply //apply
ERR_FAIL_INDEX_V(edited_point, poly.size(), false); ERR_FAIL_INDEX_V(edited_point, poly.size(), EditorPlugin::AFTER_GUI_INPUT_PASS);
poly.write[edited_point] = edited_point_pos; poly.write[edited_point] = edited_point_pos;
undo_redo->create_action(TTR("Edit Poly")); undo_redo->create_action(TTR("Edit Poly"));
undo_redo->add_do_method(node, "set_polygon", poly); undo_redo->add_do_method(node, "set_polygon", poly);
@ -288,7 +288,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->commit_action(); undo_redo->commit_action();
edited_point = -1; edited_point = -1;
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} }
} }
@ -315,7 +315,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->add_do_method(this, "_polygon_draw"); undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw"); undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action(); undo_redo->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} }
@ -335,7 +335,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
Vector3 spoint; Vector3 spoint;
if (!p.intersects_ray(ray_from, ray_dir, &spoint)) { if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
spoint = gi.xform(spoint); spoint = gi.xform(spoint);
@ -357,7 +357,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
float Polygon3DEditor::_get_depth() { float Polygon3DEditor::_get_depth() {

View File

@ -103,7 +103,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon); void edit(Node *p_collision_polygon);
Polygon3DEditor(EditorNode *p_editor); Polygon3DEditor(EditorNode *p_editor);
~Polygon3DEditor(); ~Polygon3DEditor();
@ -116,7 +116,7 @@ class Polygon3DEditorPlugin : public EditorPlugin {
EditorNode *editor; EditorNode *editor;
public: public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual String get_name() const { return "Polygon3DEditor"; } virtual String get_name() const { return "Polygon3DEditor"; }
bool has_main_screen() const { return false; } bool has_main_screen() const { return false; }

View File

@ -311,13 +311,13 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
set_spatial_node(p_path); set_spatial_node(p_path);
} }
bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!path) { if (!path) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Ref<Curve3D> c = path->get_curve(); Ref<Curve3D> c = path->get_curve();
if (c.is_null()) { if (c.is_null()) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Transform gt = path->get_global_transform(); Transform gt = path->get_global_transform();
Transform it = gt.affine_inverse(); Transform it = gt.affine_inverse();
@ -346,14 +346,14 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
PoolVector<Vector3>::Read r = v3a.read(); PoolVector<Vector3>::Read r = v3a.read();
if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) { if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) {
return false; //nope, existing return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing
} }
for (int i = 0; i < c->get_point_count() - 1; i++) { for (int i = 0; i < c->get_point_count() - 1; i++) {
//find the offset and point index of the place to break up //find the offset and point index of the place to break up
int j = idx; int j = idx;
if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) { if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) {
return false; //nope, existing return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing
} }
while (j < rc && c->get_point_position(i + 1) != r[j]) { while (j < rc && c->get_point_position(i + 1) != r[j]) {
@ -403,7 +403,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "add_point", closest_seg_point, Vector3(), Vector3(), closest_seg + 1); ur->add_do_method(c.ptr(), "add_point", closest_seg_point, Vector3(), Vector3(), closest_seg + 1);
ur->add_undo_method(c.ptr(), "remove_point", closest_seg + 1); ur->add_undo_method(c.ptr(), "remove_point", closest_seg + 1);
ur->commit_action(); ur->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else { } else {
Vector3 org; Vector3 org;
@ -422,7 +422,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1); ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1);
ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count()); ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
ur->commit_action(); ur->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
//add new at pos //add new at pos
@ -442,27 +442,27 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "remove_point", i); ur->add_do_method(c.ptr(), "remove_point", i);
ur->add_undo_method(c.ptr(), "add_point", c->get_point_position(i), c->get_point_in(i), c->get_point_out(i), i); ur->add_undo_method(c.ptr(), "add_point", c->get_point_position(i), c->get_point_in(i), c->get_point_out(i), i);
ur->commit_action(); ur->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else if (dist_to_p_out < click_dist) { } else if (dist_to_p_out < click_dist) {
UndoRedo *ur = editor->get_undo_redo(); UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Out-Control Point")); ur->create_action(TTR("Remove Out-Control Point"));
ur->add_do_method(c.ptr(), "set_point_out", i, Vector3()); ur->add_do_method(c.ptr(), "set_point_out", i, Vector3());
ur->add_undo_method(c.ptr(), "set_point_out", i, c->get_point_out(i)); ur->add_undo_method(c.ptr(), "set_point_out", i, c->get_point_out(i));
ur->commit_action(); ur->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else if (dist_to_p_in < click_dist) { } else if (dist_to_p_in < click_dist) {
UndoRedo *ur = editor->get_undo_redo(); UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove In-Control Point")); ur->create_action(TTR("Remove In-Control Point"));
ur->add_do_method(c.ptr(), "set_point_in", i, Vector3()); ur->add_do_method(c.ptr(), "set_point_in", i, Vector3());
ur->add_undo_method(c.ptr(), "set_point_in", i, c->get_point_in(i)); ur->add_undo_method(c.ptr(), "set_point_in", i, c->get_point_in(i));
ur->commit_action(); ur->commit_action();
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
} }
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void PathEditorPlugin::edit(Object *p_object) { void PathEditorPlugin::edit(Object *p_object) {

View File

@ -114,7 +114,7 @@ public:
Path *get_edited_path() { return path; } Path *get_edited_path() { return path; }
static PathEditorPlugin *singleton; static PathEditorPlugin *singleton;
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event); virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
//virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); } //virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
//virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); //virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);

View File

@ -1365,7 +1365,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = editor; EditorNode *en = editor;
EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding(); EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding();
if (!force_input_forwarding_list->empty()) { if (!force_input_forwarding_list->empty()) {
bool discard = force_input_forwarding_list->forward_spatial_gui_input(index, camera, p_event, true); bool discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true);
if (discard) { if (discard) {
return; return;
} }
@ -1375,7 +1375,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = editor; EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->empty()) { if (!over_plugin_list->empty()) {
bool discard = over_plugin_list->forward_spatial_gui_input(index, camera, p_event, false); bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
if (discard) { if (discard) {
return; return;
} }

View File

@ -131,19 +131,19 @@ Ref<MeshDataResource> MDIEdPlugin::get_mdr() {
return Ref<MeshDataResource>(); return Ref<MeshDataResource>();
} }
bool MDIEdPlugin::forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput MDIEdPlugin::forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &p_event) {
if (!ObjectDB::instance_validate(current_mesh_data_instance)) { if (!ObjectDB::instance_validate(current_mesh_data_instance)) {
current_mesh_data_instance = nullptr; current_mesh_data_instance = nullptr;
} }
if (current_mesh_data_instance) { if (current_mesh_data_instance) {
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance); Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
if (g.is_valid() && g->forward_spatial_gui_input(index, camera, p_event)) { if (g.is_valid()) {
return true; return g->forward_spatial_gui_input(camera, p_event);
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void MDIEdPlugin::add_box() { void MDIEdPlugin::add_box() {

View File

@ -61,7 +61,7 @@ public:
Ref<MeshDataResource> get_mdr(); Ref<MeshDataResource> get_mdr();
bool forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &p_event); EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &p_event);
void add_box(); void add_box();
void add_triangle(); void add_triangle();

View File

@ -228,13 +228,13 @@ void MDIGizmo::select_all() {
redraw(); redraw();
} }
bool MDIGizmo::selection_click(int index, Camera *camera, const Ref<InputEventMouse> &event) { bool MDIGizmo::selection_click(Camera *camera, const Ref<InputEventMouse> &event) {
if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) { if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) {
return selection_click_select_front_or_back(index, camera, event); return selection_click_select_front_or_back(camera, event);
} else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) { } else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) {
return selection_click_select_front_or_back(index, camera, event); return selection_click_select_front_or_back(camera, event);
} else { } else {
return selection_click_select_through(index, camera, event); return selection_click_select_through(camera, event);
} }
return false; return false;
@ -271,7 +271,7 @@ bool MDIGizmo::is_point_visible(const Vector3 &point_orig, const Vector3 &camera
return true; return true;
} }
bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, const Ref<InputEventMouse> &event) { bool MDIGizmo::selection_click_select_front_or_back(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform(); Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin; Vector3 ray_from = camera->get_global_transform().origin;
Vector2 gpoint = event->get_position(); Vector2 gpoint = event->get_position();
@ -349,7 +349,7 @@ bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, c
return false; return false;
} }
bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event) { bool MDIGizmo::selection_click_select_through(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform(); Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin; Vector3 ray_from = camera->get_global_transform().origin;
Vector2 gpoint = event->get_position(); Vector2 gpoint = event->get_position();
@ -415,16 +415,16 @@ bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const R
return false; return false;
} }
void MDIGizmo::selection_drag(int index, Camera *camera, const Ref<InputEventMouse> &event) { void MDIGizmo::selection_drag(Camera *camera, const Ref<InputEventMouse> &event) {
if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) { if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) {
selection_drag_rect_select_front_back(index, camera, event); selection_drag_rect_select_front_back(camera, event);
} else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) { } else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) {
selection_drag_rect_select_front_back(index, camera, event); selection_drag_rect_select_front_back(camera, event);
} else { } else {
selection_drag_rect_select_through(index, camera, event); selection_drag_rect_select_through(camera, event);
} }
} }
void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera, const Ref<InputEventMouse> &event) { void MDIGizmo::selection_drag_rect_select_front_back(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform(); Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin; Vector3 ray_from = camera->get_global_transform().origin;
@ -512,7 +512,7 @@ void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera,
redraw(); redraw();
} }
void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event) { void MDIGizmo::selection_drag_rect_select_through(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform(); Transform gt = get_spatial_node()->get_global_transform();
Vector2 mouse_pos = event->get_position(); Vector2 mouse_pos = event->get_position();
@ -578,7 +578,7 @@ void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, con
redraw(); redraw();
} }
bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &event) { EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &event) {
_last_known_camera_facing = camera->get_transform().basis.xform(Vector3(0, 0, -1)); _last_known_camera_facing = camera->get_transform().basis.xform(Vector3(0, 0, -1));
Ref<InputEventMouseButton> event_button = event; Ref<InputEventMouseButton> event_button = event;
@ -606,7 +606,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
// Dont consume the event here, because the handles will get stuck // Dont consume the event here, because the handles will get stuck
// to the mouse pointer if we return true // to the mouse pointer if we return true
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
if (!event_button->is_pressed()) { if (!event_button->is_pressed()) {
@ -622,11 +622,16 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
} }
if (!had_rect_drag) { if (!had_rect_drag) {
return selection_click(index, camera, event); if (selection_click(camera, event)) {
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
} else { } else {
selection_drag(index, camera, event_button); selection_drag(camera, event_button);
// Always return false here, so the drag rect thing disappears in the editor // Always return false here, so the drag rect thing disappears in the editor
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
} else { } else {
// event is pressed // event is pressed
@ -636,7 +641,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void MDIGizmo::add_to_all_selected(const Vector3 &ofs) { void MDIGizmo::add_to_all_selected(const Vector3 &ofs) {
for (int i = 0; i < _selected_points.size(); ++i) { for (int i = 0; i < _selected_points.size(); ++i) {

View File

@ -83,15 +83,15 @@ public:
void select_all(); void select_all();
bool selection_click(int index, Camera *camera, const Ref<InputEventMouse> &event); bool selection_click(Camera *camera, const Ref<InputEventMouse> &event);
bool is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform &gt); bool is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform &gt);
bool selection_click_select_front_or_back(int index, Camera *camera, const Ref<InputEventMouse> &event); bool selection_click_select_front_or_back(Camera *camera, const Ref<InputEventMouse> &event);
bool selection_click_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event); bool selection_click_select_through(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag(int index, Camera *camera, const Ref<InputEventMouse> &event); void selection_drag(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_front_back(int index, Camera *camera, const Ref<InputEventMouse> &event); void selection_drag_rect_select_front_back(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event); void selection_drag_rect_select_through(Camera *camera, const Ref<InputEventMouse> &event);
bool forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &event); EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &event);
void add_to_all_selected(const Vector3 &ofs); void add_to_all_selected(const Vector3 &ofs);
void mul_all_selected_with_basis(const Basis &b); void mul_all_selected_with_basis(const Basis &b);

View File

@ -1151,13 +1151,17 @@ void ModuleSkeletonEditor::_draw_handles() {
am->surface_set_material(0, handle_material); am->surface_set_material(0, handle_material);
} }
bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput ModuleSkeletonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!skeleton || tool_mode == TOOL_MODE_BONE_NONE) { if (!skeleton || tool_mode == TOOL_MODE_BONE_NONE) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
return EditorPlugin::AFTER_GUI_INPUT_PASS;
//TODO
/*
SpatialEditor *se = SpatialEditor::get_singleton(); SpatialEditor *se = SpatialEditor::get_singleton();
SpatialEditorViewport *sev = se->get_editor_viewport(p_index); SpatialEditorViewport *sev = se->get_editor_viewport();
Ref<InputEventMouseButton> mb = p_event; Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) { if (mb.is_valid()) {
@ -1504,6 +1508,7 @@ bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_came
} }
return false; return false;
*/
} }
void ModuleSkeletonEditor::add_bone() { void ModuleSkeletonEditor::add_bone() {

View File

@ -236,7 +236,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event); virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx); void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx);
// Transform can be keyed, whether or not to show the button // Transform can be keyed, whether or not to show the button
@ -287,7 +287,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return skel_editor->forward_spatial_gui_input(p_index, p_camera, p_event); } virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return skel_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual bool can_handle(Object *p_object); virtual bool can_handle(Object *p_object);
virtual void parse_begin(Object *p_object); virtual void parse_begin(Object *p_object);
UndoRedo *get_undo_redo() { return undo_redo; } UndoRedo *get_undo_redo() { return undo_redo; }
@ -300,11 +300,11 @@ class ModuleSkeletonEditorPlugin : public EditorPlugin {
EditorNode *editor; EditorNode *editor;
public: public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (SpatialEditor::get_singleton()->get_tool_mode() != SpatialEditor::TOOL_MODE_EXTERNAL) { if (SpatialEditor::get_singleton()->get_tool_mode() != SpatialEditor::TOOL_MODE_EXTERNAL) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
return skeleton_plugin->forward_spatial_gui_input(p_index, p_camera, p_event); return skeleton_plugin->forward_spatial_gui_input(p_camera, p_event);
} }
bool has_main_screen() const { return false; } bool has_main_screen() const { return false; }
virtual bool handles(Object *p_object) const; virtual bool handles(Object *p_object) const;

View File

@ -44,9 +44,9 @@ SOFTWARE.
#include "scene/gui/slider.h" #include "scene/gui/slider.h"
#include "scene/gui/scroll_container.h" #include "scene/gui/scroll_container.h"
bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) { if (!_world || !_world->get_editable()) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Ref<InputEventMouseButton> mb = p_event; Ref<InputEventMouseButton> mb = p_event;
@ -56,24 +56,24 @@ bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref
Ref<TerrainLibrary> lib = _world->get_library(); Ref<TerrainLibrary> lib = _world->get_library();
if (!lib.is_valid()) if (!lib.is_valid())
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) { if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else { } else {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { EditorPlugin::AfterGUIInput TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor || !_world || !_world->is_inside_world()) if (!spatial_editor || !_world || !_world->is_inside_world())
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
Camera *camera = p_camera; Camera *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point); Vector3 from = camera->project_ray_origin(p_point);
@ -94,7 +94,7 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point
channel = _channel_type; channel = _channel_type;
if (channel == -1) if (channel == -1)
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
int isolevel = _current_isolevel; int isolevel = _current_isolevel;
bool mode_add = false; bool mode_add = false;
@ -110,10 +110,10 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point
_world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel); _world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel);
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void TerrainWorldEditor::edit(TerrainWorld *p_world) { void TerrainWorldEditor::edit(TerrainWorld *p_world) {

View File

@ -39,10 +39,10 @@ public:
}; };
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event); EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(TerrainWorld *p_world); void edit(TerrainWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
TerrainWorldEditor(); TerrainWorldEditor();
TerrainWorldEditor(EditorNode *p_editor); TerrainWorldEditor(EditorNode *p_editor);
@ -90,7 +90,7 @@ protected:
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "TerrainWorldEditor"; } virtual String get_name() const { return "TerrainWorldEditor"; }
bool has_main_screen() const { return false; } bool has_main_screen() const { return false; }
virtual void edit(Object *p_object); virtual void edit(Object *p_object);

View File

@ -43,9 +43,9 @@ SOFTWARE.
#include "scene/gui/scroll_container.h" #include "scene/gui/scroll_container.h"
#include "scene/gui/slider.h" #include "scene/gui/slider.h"
bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) { if (!_world || !_world->get_editable()) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Ref<InputEventMouseButton> mb = p_event; Ref<InputEventMouseButton> mb = p_event;
@ -55,22 +55,22 @@ bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const R
Ref<Terrain2DLibrary> lib = _world->get_library(); Ref<Terrain2DLibrary> lib = _world->get_library();
if (!lib.is_valid()) if (!lib.is_valid())
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) { if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else { } else {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { EditorPlugin::AfterGUIInput Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
/* /*
if (!spatial_editor || !_world || !_world->is_inside_world()) if (!spatial_editor || !_world || !_world->is_inside_world())
return false; return false;
@ -113,7 +113,7 @@ bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_poi
return true; return true;
} }
*/ */
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void Terrain2DWorldEditor::edit(Terrain2DWorld *p_world) { void Terrain2DWorldEditor::edit(Terrain2DWorld *p_world) {

View File

@ -41,10 +41,10 @@ public:
}; };
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event); EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Terrain2DWorld *p_world); void edit(Terrain2DWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
Terrain2DWorldEditor(); Terrain2DWorldEditor();
Terrain2DWorldEditor(EditorNode *p_editor); Terrain2DWorldEditor(EditorNode *p_editor);
@ -92,7 +92,7 @@ protected:
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "Terrain2DWorldEditor"; } virtual String get_name() const { return "Terrain2DWorldEditor"; }
bool has_main_screen() const { return false; } bool has_main_screen() const { return false; }
virtual void edit(Object *p_object); virtual void edit(Object *p_object);

View File

@ -44,9 +44,9 @@ SOFTWARE.
#include "scene/gui/slider.h" #include "scene/gui/slider.h"
#include "scene/gui/scroll_container.h" #include "scene/gui/scroll_container.h"
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { EditorPlugin::AfterGUIInput VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) { if (!_world || !_world->get_editable()) {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
Ref<InputEventMouseButton> mb = p_event; Ref<InputEventMouseButton> mb = p_event;
@ -56,24 +56,24 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<I
Ref<VoxelLibrary> lib = _world->get_library(); Ref<VoxelLibrary> lib = _world->get_library();
if (!lib.is_valid()) if (!lib.is_valid())
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) { if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else { } else {
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} }
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { EditorPlugin::AfterGUIInput VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor || !_world || !_world->is_inside_world()) if (!spatial_editor || !_world || !_world->is_inside_world())
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
Camera *camera = p_camera; Camera *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point); Vector3 from = camera->project_ray_origin(p_point);
@ -94,7 +94,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
channel = _channel_type; channel = _channel_type;
if (channel == -1) if (channel == -1)
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
int isolevel = _current_isolevel; int isolevel = _current_isolevel;
bool mode_add = false; bool mode_add = false;
@ -110,10 +110,10 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
_world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel); _world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel);
return true; return EditorPlugin::AFTER_GUI_INPUT_STOP;
} }
return false; return EditorPlugin::AFTER_GUI_INPUT_PASS;
} }
void VoxelWorldEditor::edit(VoxelWorld *p_world) { void VoxelWorldEditor::edit(VoxelWorld *p_world) {

View File

@ -41,10 +41,10 @@ public:
}; };
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event); EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(VoxelWorld *p_world); void edit(VoxelWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
VoxelWorldEditor(); VoxelWorldEditor();
VoxelWorldEditor(EditorNode *p_editor); VoxelWorldEditor(EditorNode *p_editor);
@ -92,7 +92,7 @@ protected:
public: public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "VoxelWorldEditor"; } virtual String get_name() const { return "VoxelWorldEditor"; }
bool has_main_screen() const { return false; } bool has_main_screen() const { return false; }
virtual void edit(Object *p_object); virtual void edit(Object *p_object);