mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
Move 2d navigation related editor plugins to navigation_2d module
Moves 2d navigation related editor plugins to navigation_2d module.
This commit is contained in:
parent
8f78e7510d
commit
cc1b51e8a2
9 changed files with 50 additions and 41 deletions
|
|
@ -97,9 +97,6 @@
|
|||
#include "editor/plugins/mesh_instance_3d_editor_plugin.h"
|
||||
#include "editor/plugins/mesh_library_editor_plugin.h"
|
||||
#include "editor/plugins/multimesh_editor_plugin.h"
|
||||
#include "editor/plugins/navigation_link_2d_editor_plugin.h"
|
||||
#include "editor/plugins/navigation_obstacle_2d_editor_plugin.h"
|
||||
#include "editor/plugins/navigation_polygon_editor_plugin.h"
|
||||
#include "editor/plugins/node_3d_editor_gizmos.h"
|
||||
#include "editor/plugins/occluder_instance_3d_editor_plugin.h"
|
||||
#include "editor/plugins/packed_scene_editor_plugin.h"
|
||||
|
|
@ -264,9 +261,6 @@ void register_editor_types() {
|
|||
EditorPlugins::add_by_type<GPUParticles2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<LightOccluder2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<Line2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<NavigationLink2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<NavigationObstacle2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<NavigationPolygonEditorPlugin>();
|
||||
EditorPlugins::add_by_type<Path2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<Polygon2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<Cast2DEditorPlugin>();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ module_obj = []
|
|||
|
||||
env_navigation_2d.add_source_files(module_obj, "*.cpp")
|
||||
env_navigation_2d.add_source_files(module_obj, "2d/*.cpp")
|
||||
if env.editor_build:
|
||||
env_navigation_2d.add_source_files(module_obj, "editor/*.cpp")
|
||||
env.modules_sources += module_obj
|
||||
|
||||
# Needed to force rebuilding the module files when the thirdparty library is updated.
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
#include "navigation_link_2d_editor_plugin.h"
|
||||
|
||||
#include "canvas_item_editor_plugin.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void NavigationLink2DEditor::_notification(int p_what) {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**************************************************************************/
|
||||
/* navigation_polygon_editor_plugin.cpp */
|
||||
/* navigation_region_2d_editor_plugin.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "navigation_polygon_editor_plugin.h"
|
||||
#include "navigation_region_2d_editor_plugin.h"
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
#include "scene/2d/navigation/navigation_region_2d.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
|
||||
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
|
||||
Ref<NavigationPolygon> NavigationRegion2DEditor::_ensure_navpoly() const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (navpoly.is_null()) {
|
||||
navpoly.instantiate();
|
||||
|
|
@ -45,11 +45,11 @@ Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
|
|||
return navpoly;
|
||||
}
|
||||
|
||||
Node2D *NavigationPolygonEditor::_get_node() const {
|
||||
Node2D *NavigationRegion2DEditor::_get_node() const {
|
||||
return node;
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_set_node(Node *p_polygon) {
|
||||
void NavigationRegion2DEditor::_set_node(Node *p_polygon) {
|
||||
node = Object::cast_to<NavigationRegion2D>(p_polygon);
|
||||
if (node) {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
|
|
@ -60,7 +60,7 @@ void NavigationPolygonEditor::_set_node(Node *p_polygon) {
|
|||
}
|
||||
}
|
||||
|
||||
int NavigationPolygonEditor::_get_polygon_count() const {
|
||||
int NavigationRegion2DEditor::_get_polygon_count() const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (navpoly.is_valid()) {
|
||||
return navpoly->get_outline_count();
|
||||
|
|
@ -69,7 +69,7 @@ int NavigationPolygonEditor::_get_polygon_count() const {
|
|||
}
|
||||
}
|
||||
|
||||
Variant NavigationPolygonEditor::_get_polygon(int p_idx) const {
|
||||
Variant NavigationRegion2DEditor::_get_polygon(int p_idx) const {
|
||||
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
|
||||
if (navpoly.is_valid()) {
|
||||
return navpoly->get_outline(p_idx);
|
||||
|
|
@ -78,7 +78,7 @@ Variant NavigationPolygonEditor::_get_polygon(int p_idx) const {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
|
||||
void NavigationRegion2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
navpoly->set_outline(p_idx, p_polygon);
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ void NavigationPolygonEditor::_set_polygon(int p_idx, const Variant &p_polygon)
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) {
|
||||
void NavigationRegion2DEditor::_action_add_polygon(const Variant &p_polygon) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->add_do_method(navpoly.ptr(), "add_outline", p_polygon);
|
||||
|
|
@ -98,7 +98,7 @@ void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_remove_polygon(int p_idx) {
|
||||
void NavigationRegion2DEditor::_action_remove_polygon(int p_idx) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->add_do_method(navpoly.ptr(), "remove_outline", p_idx);
|
||||
|
|
@ -109,7 +109,7 @@ void NavigationPolygonEditor::_action_remove_polygon(int p_idx) {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
|
||||
void NavigationRegion2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) {
|
||||
Ref<NavigationPolygon> navpoly = _ensure_navpoly();
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->add_do_method(navpoly.ptr(), "set_outline", p_idx, p_polygon);
|
||||
|
|
@ -120,11 +120,11 @@ void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_pr
|
|||
}
|
||||
}
|
||||
|
||||
bool NavigationPolygonEditor::_has_resource() const {
|
||||
bool NavigationRegion2DEditor::_has_resource() const {
|
||||
return node && node->get_navigation_polygon().is_valid();
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_create_resource() {
|
||||
void NavigationRegion2DEditor::_create_resource() {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ void NavigationPolygonEditor::_create_resource() {
|
|||
_menu_option(MODE_CREATE);
|
||||
}
|
||||
|
||||
NavigationPolygonEditor::NavigationPolygonEditor() {
|
||||
NavigationRegion2DEditor::NavigationRegion2DEditor() {
|
||||
bake_hbox = memnew(HBoxContainer);
|
||||
add_child(bake_hbox);
|
||||
|
||||
|
|
@ -148,14 +148,14 @@ NavigationPolygonEditor::NavigationPolygonEditor() {
|
|||
button_bake->set_toggle_mode(true);
|
||||
button_bake->set_text(TTR("Bake NavigationPolygon"));
|
||||
button_bake->set_tooltip_text(TTR("Bakes the NavigationPolygon by first parsing the scene for source geometry and then creating the navigation polygon vertices and polygons."));
|
||||
button_bake->connect(SceneStringName(pressed), callable_mp(this, &NavigationPolygonEditor::_bake_pressed));
|
||||
button_bake->connect(SceneStringName(pressed), callable_mp(this, &NavigationRegion2DEditor::_bake_pressed));
|
||||
|
||||
button_reset = memnew(Button);
|
||||
button_reset->set_flat(true);
|
||||
bake_hbox->add_child(button_reset);
|
||||
button_reset->set_text(TTR("Clear NavigationPolygon"));
|
||||
button_reset->set_tooltip_text(TTR("Clears the internal NavigationPolygon outlines, vertices and polygons."));
|
||||
button_reset->connect(SceneStringName(pressed), callable_mp(this, &NavigationPolygonEditor::_clear_pressed));
|
||||
button_reset->connect(SceneStringName(pressed), callable_mp(this, &NavigationRegion2DEditor::_clear_pressed));
|
||||
|
||||
bake_info = memnew(Label);
|
||||
bake_info->set_focus_mode(FOCUS_ACCESSIBILITY);
|
||||
|
|
@ -168,14 +168,14 @@ NavigationPolygonEditor::NavigationPolygonEditor() {
|
|||
if (_rebake_timer_delay >= 0.0) {
|
||||
rebake_timer->set_wait_time(_rebake_timer_delay);
|
||||
}
|
||||
rebake_timer->connect("timeout", callable_mp(this, &NavigationPolygonEditor::_rebake_timer_timeout));
|
||||
rebake_timer->connect("timeout", callable_mp(this, &NavigationRegion2DEditor::_rebake_timer_timeout));
|
||||
|
||||
err_dialog = memnew(AcceptDialog);
|
||||
add_child(err_dialog);
|
||||
node = nullptr;
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_notification(int p_what) {
|
||||
void NavigationRegion2DEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
button_bake->set_button_icon(get_editor_theme_icon(SNAME("Bake")));
|
||||
|
|
@ -192,7 +192,7 @@ void NavigationPolygonEditor::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_bake_pressed() {
|
||||
void NavigationRegion2DEditor::_bake_pressed() {
|
||||
if (rebake_timer) {
|
||||
rebake_timer->stop();
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ void NavigationPolygonEditor::_bake_pressed() {
|
|||
node->queue_redraw();
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_clear_pressed() {
|
||||
void NavigationRegion2DEditor::_clear_pressed() {
|
||||
if (rebake_timer) {
|
||||
rebake_timer->stop();
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ void NavigationPolygonEditor::_clear_pressed() {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_update_polygon_editing_state() {
|
||||
void NavigationRegion2DEditor::_update_polygon_editing_state() {
|
||||
if (!_get_node()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ void NavigationPolygonEditor::_update_polygon_editing_state() {
|
|||
}
|
||||
}
|
||||
|
||||
void NavigationPolygonEditor::_rebake_timer_timeout() {
|
||||
void NavigationRegion2DEditor::_rebake_timer_timeout() {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -256,6 +256,6 @@ void NavigationPolygonEditor::_rebake_timer_timeout() {
|
|||
node->queue_redraw();
|
||||
}
|
||||
|
||||
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin() :
|
||||
AbstractPolygon2DEditorPlugin(memnew(NavigationPolygonEditor), "NavigationRegion2D") {
|
||||
NavigationRegion2DEditorPlugin::NavigationRegion2DEditorPlugin() :
|
||||
AbstractPolygon2DEditorPlugin(memnew(NavigationRegion2DEditor), "NavigationRegion2D") {
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**************************************************************************/
|
||||
/* navigation_polygon_editor_plugin.h */
|
||||
/* navigation_region_2d_editor_plugin.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
|
@ -31,7 +31,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "editor/plugins/abstract_polygon_2d_editor.h"
|
||||
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
|
||||
class AcceptDialog;
|
||||
|
|
@ -39,10 +38,10 @@ class HBoxContainer;
|
|||
class NavigationPolygon;
|
||||
class NavigationRegion2D;
|
||||
|
||||
class NavigationPolygonEditor : public AbstractPolygon2DEditor {
|
||||
friend class NavigationPolygonEditorPlugin;
|
||||
class NavigationRegion2DEditor : public AbstractPolygon2DEditor {
|
||||
friend class NavigationRegion2DEditorPlugin;
|
||||
|
||||
GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor);
|
||||
GDCLASS(NavigationRegion2DEditor, AbstractPolygon2DEditor);
|
||||
|
||||
NavigationRegion2D *node = nullptr;
|
||||
|
||||
|
|
@ -82,14 +81,14 @@ protected:
|
|||
virtual void _create_resource() override;
|
||||
|
||||
public:
|
||||
NavigationPolygonEditor();
|
||||
NavigationRegion2DEditor();
|
||||
};
|
||||
|
||||
class NavigationPolygonEditorPlugin : public AbstractPolygon2DEditorPlugin {
|
||||
GDCLASS(NavigationPolygonEditorPlugin, AbstractPolygon2DEditorPlugin);
|
||||
class NavigationRegion2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
|
||||
GDCLASS(NavigationRegion2DEditorPlugin, AbstractPolygon2DEditorPlugin);
|
||||
|
||||
NavigationPolygonEditor *navigation_polygon_editor = nullptr;
|
||||
NavigationRegion2DEditor *navigation_polygon_editor = nullptr;
|
||||
|
||||
public:
|
||||
NavigationPolygonEditorPlugin();
|
||||
NavigationRegion2DEditorPlugin();
|
||||
};
|
||||
|
|
@ -35,6 +35,12 @@
|
|||
#include "core/config/engine.h"
|
||||
#include "servers/navigation_server_2d.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/navigation_link_2d_editor_plugin.h"
|
||||
#include "editor/navigation_obstacle_2d_editor_plugin.h"
|
||||
#include "editor/navigation_region_2d_editor_plugin.h"
|
||||
#endif
|
||||
|
||||
NavigationServer2D *new_navigation_server_2d() {
|
||||
return memnew(GodotNavigationServer2D);
|
||||
}
|
||||
|
|
@ -43,6 +49,14 @@ void initialize_navigation_2d_module(ModuleInitializationLevel p_level) {
|
|||
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
|
||||
NavigationServer2DManager::set_default_server(new_navigation_server_2d);
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
EditorPlugins::add_by_type<NavigationLink2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<NavigationRegion2DEditorPlugin>();
|
||||
EditorPlugins::add_by_type<NavigationObstacle2DEditorPlugin>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void uninitialize_navigation_2d_module(ModuleInitializationLevel p_level) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue