#undef NDEBUG #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "signal_handler.h" #include "editor_event.h" #include "world_editor.h" #include "from_string.h" #include "road_lines_data.h" #include "road_processing.h" #include "buildings_data.h" #include "road_lines_editor.h" static ImmediateGeometry *line_im = nullptr; // static ImmediateGeometry *debug_im = nullptr; static Ref debug_material; #define __evhandler(vname, mtype) \ template class GDEventHandler_##vname : public Object { \ GDCLASS(GDEventHandler_##vname, Object) \ T *obj; \ \ public: \ GDEventHandler_##vname(T *obj) \ : Object() \ , obj(obj) \ { \ } \ virtual ~GDEventHandler_##vname() \ { \ } \ bool connect(Object *obj, const String &signal) \ { \ return obj->connect(signal, this, "handler"); \ } \ void disconnect(Object *obj, const String &signal) \ { \ obj->disconnect(signal, this, "handler"); \ } \ \ protected: \ void handler(const String &event, const Vector &args) \ { \ obj->vname(event, args); \ } \ static void _bind_methods() \ { \ ClassDB::bind_method( \ D_METHOD("handler", "args"), \ &GDEventHandler_##vname::handler); \ } \ } #define __evhandler_type(vname, mtype) GDEventHandler_##vname __evhandler(editor_event, RoadLinesEditor); static __evhandler_type(editor_event, RoadLinesEditor) * gd_editor_event; static String current_line = ""; class HandlePointSelection : public Object { GDCLASS(HandlePointSelection, Object) RoadLinesEditor *editor; public: HandlePointSelection(RoadLinesEditor *editor) : Object() , editor(editor) { #if 0 SpinBox *sp_line_point = editor->get_as_node("%line_index"); sp_line_point->connect("value_changed", this, "handle_value_change"); #endif } virtual ~HandlePointSelection() { #if 0 SpinBox *sp_line_point = editor->get_as_node("%line_index"); sp_line_point->disconnect("value_changed", this, "handle_value_change"); #endif } protected: void handle_value_change(float value) { int index = (int)value; editor->set_line_index(index); } void handle_set_point() { editor->set_point_to_cursor(); } void handle_move_cursor() { editor->move_cursor_to_point(); } static void _bind_methods() { ClassDB::bind_method( D_METHOD("handle_value_change", "value"), &HandlePointSelection::handle_value_change); ClassDB::bind_method(D_METHOD("handle_set_point"), &HandlePointSelection::handle_set_point); ClassDB::bind_method(D_METHOD("handle_move_cursor"), &HandlePointSelection::handle_move_cursor); } }; class HandleCreateNewLine : public Object { GDCLASS(HandleCreateNewLine, Object) RoadLinesEditor *editor; public: HandleCreateNewLine(RoadLinesEditor *editor) : Object() , editor(editor) { Button *cancel_metadata_button = editor->get_as_node