summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-08-22 01:54:59 +0200
committerGitHub <noreply@github.com>2018-08-22 01:54:59 +0200
commit0e6551d8e2c080149bedcefd6c9dd0061261ea3f (patch)
tree5331774b8620ef051f0f599f03cdd7bff1ab7e6d
parent4d6a6e08136a24e40f0e1a81a9425de7dee9a7a9 (diff)
parentd0f55ab6e4687c0a3c52379ee9fbb31a121cc196 (diff)
Merge pull request #21274 from YeldhamDev/meshlib_editor_fixes
Fix MeshLibrary editor
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp (renamed from editor/plugins/cube_grid_theme_editor_plugin.cpp)41
-rw-r--r--editor/plugins/mesh_library_editor_plugin.h (renamed from editor/plugins/cube_grid_theme_editor_plugin.h)10
3 files changed, 29 insertions, 24 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 98206f9443..0ca70c41fa 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -84,7 +84,6 @@
#include "editor/plugins/collision_polygon_editor_plugin.h"
#include "editor/plugins/collision_shape_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_editor_plugin.h"
-#include "editor/plugins/cube_grid_theme_editor_plugin.h"
#include "editor/plugins/curve_editor_plugin.h"
#include "editor/plugins/editor_preview_plugins.h"
#include "editor/plugins/gi_probe_editor_plugin.h"
@@ -95,6 +94,7 @@
#include "editor/plugins/material_editor_plugin.h"
#include "editor/plugins/mesh_editor_plugin.h"
#include "editor/plugins/mesh_instance_editor_plugin.h"
+#include "editor/plugins/mesh_library_editor_plugin.h"
#include "editor/plugins/multimesh_editor_plugin.h"
#include "editor/plugins/navigation_polygon_editor_plugin.h"
#include "editor/plugins/particles_2d_editor_plugin.h"
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index 68d5ea5247..a4d2905c0e 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cube_grid_theme_editor_plugin.cpp */
+/* mesh_library_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 "cube_grid_theme_editor_plugin.h"
+#include "mesh_library_editor_plugin.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
@@ -38,6 +38,7 @@
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
+#include "spatial_editor_plugin.h"
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_theme) {
@@ -241,21 +242,20 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
add_child(file);
file->connect("file_selected", this, "_import_scene_cbk");
- Panel *panel = memnew(Panel);
- panel->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- add_child(panel);
- MenuButton *options = memnew(MenuButton);
- panel->add_child(options);
- options->set_position(Point2(1, 1));
- options->set_text("Theme");
- options->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM);
- options->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM);
- options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Import from Scene"), MENU_OPTION_IMPORT_FROM_SCENE);
- options->get_popup()->add_item(TTR("Update from Scene"), MENU_OPTION_UPDATE_FROM_SCENE);
- options->get_popup()->set_item_disabled(options->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), true);
- options->get_popup()->connect("id_pressed", this, "_menu_cbk");
- menu = options;
+ menu = memnew(MenuButton);
+ SpatialEditor::get_singleton()->add_control_to_menu_panel(menu);
+ menu->set_position(Point2(1, 1));
+ menu->set_text("Mesh Library");
+ menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshLibrary", "EditorIcons"));
+ menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM);
+ menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM);
+ menu->get_popup()->add_separator();
+ menu->get_popup()->add_item(TTR("Import from Scene"), MENU_OPTION_IMPORT_FROM_SCENE);
+ menu->get_popup()->add_item(TTR("Update from Scene"), MENU_OPTION_UPDATE_FROM_SCENE);
+ menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), true);
+ menu->get_popup()->connect("id_pressed", this, "_menu_cbk");
+ menu->hide();
+
editor = p_editor;
cd = memnew(ConfirmationDialog);
add_child(cd);
@@ -278,10 +278,13 @@ bool MeshLibraryEditorPlugin::handles(Object *p_node) const {
void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
- if (p_visible)
+ if (p_visible) {
theme_editor->show();
- else
+ theme_editor->get_menu_button()->show();
+ } else {
theme_editor->hide();
+ theme_editor->get_menu_button()->hide();
+ }
}
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h
index 36a8f8f203..dc2d488bd6 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.h
+++ b/editor/plugins/mesh_library_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cube_grid_theme_editor_plugin.h */
+/* mesh_library_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CUBE_GRID_THEME_EDITOR_PLUGIN_H
-#define CUBE_GRID_THEME_EDITOR_PLUGIN_H
+#ifndef MESH_LIBRARY_EDITOR_PLUGIN_H
+#define MESH_LIBRARY_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "scene/resources/mesh_library.h"
@@ -65,6 +65,8 @@ protected:
static void _bind_methods();
public:
+ MenuButton *get_menu_button() const { return menu; }
+
void edit(const Ref<MeshLibrary> &p_theme);
static Error update_library_file(Node *p_base_scene, Ref<MeshLibrary> ml, bool p_merge = true);
@@ -88,4 +90,4 @@ public:
MeshLibraryEditorPlugin(EditorNode *p_node);
};
-#endif // CUBE_GRID_THEME_EDITOR_PLUGIN_H
+#endif // MESH_LIBRARY_EDITOR_PLUGIN_H