Change GridMap and Replication to EditorDock
This commit is contained in:
@@ -32,11 +32,11 @@
|
||||
|
||||
#include "core/math/geometry_2d.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "editor/docks/editor_dock_manager.h"
|
||||
#include "editor/editor_main_screen.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/gui/editor_bottom_panel.h"
|
||||
#include "editor/gui/editor_zoom_widget.h"
|
||||
#include "editor/scene/3d/node_3d_editor_plugin.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
@@ -799,8 +799,8 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D
|
||||
return EditorPlugin::AFTER_GUI_INPUT_STOP;
|
||||
}
|
||||
for (int i = 0; i < options->get_popup()->get_item_count(); ++i) {
|
||||
const Ref<Shortcut> &shortcut = options->get_popup()->get_item_shortcut(i);
|
||||
if (shortcut.is_valid() && shortcut->matches_event(p_event)) {
|
||||
const Ref<Shortcut> &option_shortcut = options->get_popup()->get_item_shortcut(i);
|
||||
if (option_shortcut.is_valid() && option_shortcut->matches_event(p_event)) {
|
||||
// Consume input to avoid conflicts with other plugins.
|
||||
accept_event();
|
||||
_menu_option(options->get_popup()->get_item_id(i));
|
||||
@@ -1399,6 +1399,16 @@ void GridMapEditor::_bind_methods() {
|
||||
}
|
||||
|
||||
GridMapEditor::GridMapEditor() {
|
||||
set_name(TTRC("GridMap"));
|
||||
set_icon_name("GridMapDock");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_grid_map_bottom_panel", TTRC("Toggle GridMap Dock")));
|
||||
set_default_slot(EditorDock::DOCK_SLOT_BOTTOM);
|
||||
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||
set_global(false);
|
||||
set_transient(true);
|
||||
set_custom_minimum_size(Size2(0, 200 * EDSCALE));
|
||||
set_theme_type_variation("NoBorderBottomPanel");
|
||||
|
||||
ED_SHORTCUT("grid_map/previous_floor", TTRC("Previous Floor"), Key::KEY_1, true);
|
||||
ED_SHORTCUT("grid_map/next_floor", TTRC("Next Floor"), Key::KEY_3, true);
|
||||
ED_SHORTCUT("grid_map/edit_x_axis", TTRC("Edit X Axis"), KeyModifierMask::SHIFT + Key::Z, true);
|
||||
@@ -1439,9 +1449,12 @@ GridMapEditor::GridMapEditor() {
|
||||
|
||||
options->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &GridMapEditor::_menu_option));
|
||||
|
||||
VBoxContainer *main_vb = memnew(VBoxContainer);
|
||||
add_child(main_vb);
|
||||
|
||||
toolbar = memnew(HBoxContainer);
|
||||
add_child(toolbar);
|
||||
toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
main_vb->add_child(toolbar);
|
||||
|
||||
HBoxContainer *mode_buttons = memnew(HBoxContainer);
|
||||
toolbar->add_child(mode_buttons);
|
||||
@@ -1638,15 +1651,11 @@ GridMapEditor::GridMapEditor() {
|
||||
|
||||
toolbar->add_child(options);
|
||||
|
||||
MarginContainer *mc = memnew(MarginContainer);
|
||||
mc->set_theme_type_variation("NoBorderBottomPanel");
|
||||
mc->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
add_child(mc);
|
||||
|
||||
mesh_library_palette = memnew(ItemList);
|
||||
mesh_library_palette->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
mesh_library_palette->set_scroll_hint_mode(ItemList::SCROLL_HINT_MODE_BOTH);
|
||||
mc->add_child(mesh_library_palette);
|
||||
mesh_library_palette->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
main_vb->add_child(mesh_library_palette);
|
||||
mesh_library_palette->connect(SceneStringName(gui_input), callable_mp(this, &GridMapEditor::_mesh_library_palette_input));
|
||||
mesh_library_palette->connect(SceneStringName(item_selected), callable_mp(this, &GridMapEditor::_item_selected_cbk));
|
||||
|
||||
@@ -1859,19 +1868,13 @@ void GridMapEditorPlugin::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
grid_map_editor = memnew(GridMapEditor);
|
||||
grid_map_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_map_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_map_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
grid_map_editor->hide();
|
||||
|
||||
panel_button = EditorNode::get_bottom_panel()->add_item(TTRC("GridMap"), grid_map_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_grid_map_bottom_panel", TTRC("Toggle GridMap Bottom Panel")));
|
||||
panel_button->hide();
|
||||
EditorDockManager::get_singleton()->add_dock(grid_map_editor);
|
||||
grid_map_editor->close();
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
EditorNode::get_bottom_panel()->remove_item(grid_map_editor);
|
||||
EditorDockManager::get_singleton()->remove_dock(grid_map_editor);
|
||||
memdelete_notnull(grid_map_editor);
|
||||
grid_map_editor = nullptr;
|
||||
panel_button = nullptr;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -1904,16 +1907,12 @@ void GridMapEditorPlugin::make_visible(bool p_visible) {
|
||||
grid_map_editor->select_mode_button->set_pressed(true);
|
||||
}
|
||||
grid_map_editor->_on_tool_mode_changed();
|
||||
panel_button->show();
|
||||
EditorNode::get_bottom_panel()->make_item_visible(grid_map_editor);
|
||||
grid_map_editor->make_visible();
|
||||
grid_map_editor->set_process(true);
|
||||
} else {
|
||||
grid_map_editor->_cancel_pending_move();
|
||||
grid_map_editor->_show_viewports_transform_gizmo(true);
|
||||
panel_button->hide();
|
||||
if (grid_map_editor->is_visible_in_tree()) {
|
||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
||||
}
|
||||
grid_map_editor->close();
|
||||
grid_map_editor->set_process(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "../grid_map.h"
|
||||
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/item_list.h"
|
||||
@@ -45,8 +46,8 @@ class ButtonGroup;
|
||||
class EditorZoomWidget;
|
||||
class BaseButton;
|
||||
|
||||
class GridMapEditor : public VBoxContainer {
|
||||
GDCLASS(GridMapEditor, VBoxContainer);
|
||||
class GridMapEditor : public EditorDock {
|
||||
GDCLASS(GridMapEditor, EditorDock);
|
||||
|
||||
static constexpr int32_t GRID_CURSOR_SIZE = 50;
|
||||
|
||||
@@ -274,7 +275,6 @@ class GridMapEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(GridMapEditorPlugin, EditorPlugin);
|
||||
|
||||
GridMapEditor *grid_map_editor = nullptr;
|
||||
Button *panel_button = nullptr;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="m8 1-6 3v8l6 3 6-3v-2l-2-1-4 2-2-1v-4l2-1v-2l2-1zm4 2-2 1v2l2 1 2-1v-2z"/></svg>
|
||||
|
After Width: | Height: | Size: 168 B |
@@ -34,10 +34,9 @@
|
||||
#include "editor_network_profiler.h"
|
||||
#include "replication_editor.h"
|
||||
|
||||
#include "editor/docks/editor_dock_manager.h"
|
||||
#include "editor/editor_interface.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/gui/editor_bottom_panel.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
|
||||
void MultiplayerEditorDebugger::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("open_request", PropertyInfo(Variant::STRING, "path")));
|
||||
@@ -116,8 +115,8 @@ void MultiplayerEditorDebugger::setup_session(int p_session_id) {
|
||||
|
||||
MultiplayerEditorPlugin::MultiplayerEditorPlugin() {
|
||||
repl_editor = memnew(ReplicationEditor);
|
||||
button = EditorNode::get_bottom_panel()->add_item(TTRC("Replication"), repl_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_replication_bottom_panel", TTRC("Toggle Replication Bottom Panel")));
|
||||
button->hide();
|
||||
EditorDockManager::get_singleton()->add_dock(repl_editor);
|
||||
repl_editor->close();
|
||||
repl_editor->get_pin()->connect(SceneStringName(pressed), callable_mp(this, &MultiplayerEditorPlugin::_pinned));
|
||||
debugger.instantiate();
|
||||
debugger->connect("open_request", callable_mp(this, &MultiplayerEditorPlugin::_open_request));
|
||||
@@ -142,20 +141,14 @@ void MultiplayerEditorPlugin::_notification(int p_what) {
|
||||
void MultiplayerEditorPlugin::_node_removed(Node *p_node) {
|
||||
if (p_node && p_node == repl_editor->get_current()) {
|
||||
repl_editor->edit(nullptr);
|
||||
if (repl_editor->is_visible_in_tree()) {
|
||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
||||
}
|
||||
button->hide();
|
||||
repl_editor->close();
|
||||
repl_editor->get_pin()->set_pressed(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiplayerEditorPlugin::_pinned() {
|
||||
if (!repl_editor->get_pin()->is_pressed() && repl_editor->get_current() == nullptr) {
|
||||
if (repl_editor->is_visible_in_tree()) {
|
||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
||||
}
|
||||
button->hide();
|
||||
repl_editor->close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,12 +162,8 @@ bool MultiplayerEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
void MultiplayerEditorPlugin::make_visible(bool p_visible) {
|
||||
if (p_visible) {
|
||||
button->show();
|
||||
EditorNode::get_bottom_panel()->make_item_visible(repl_editor);
|
||||
repl_editor->make_visible();
|
||||
} else if (!repl_editor->get_pin()->is_pressed()) {
|
||||
if (repl_editor->is_visible_in_tree()) {
|
||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
||||
}
|
||||
button->hide();
|
||||
repl_editor->close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ class MultiplayerEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(MultiplayerEditorPlugin, EditorPlugin);
|
||||
|
||||
private:
|
||||
Button *button = nullptr;
|
||||
ReplicationEditor *repl_editor = nullptr;
|
||||
Ref<MultiplayerEditorDebugger> debugger;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/inspector/property_selector.h"
|
||||
#include "editor/scene/scene_tree_editor.h"
|
||||
#include "editor/settings/editor_command_palette.h"
|
||||
#include "editor/settings/editor_settings.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme_manager.h"
|
||||
@@ -152,6 +153,13 @@ void ReplicationEditor::_pick_node_property_selected(String p_name) {
|
||||
|
||||
/// ReplicationEditor
|
||||
ReplicationEditor::ReplicationEditor() {
|
||||
set_name(TTRC("Replication"));
|
||||
set_icon_name("ReplicationDock");
|
||||
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_replication_bottom_panel", TTRC("Toggle Replication Dock")));
|
||||
set_default_slot(EditorDock::DOCK_SLOT_BOTTOM);
|
||||
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||
set_global(false);
|
||||
set_transient(true);
|
||||
set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
#include "../scene_replication_config.h"
|
||||
|
||||
#include "editor/docks/editor_dock.h"
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
|
||||
class ConfirmationDialog;
|
||||
class MultiplayerSynchronizer;
|
||||
@@ -44,8 +44,8 @@ class TreeItem;
|
||||
class PropertySelector;
|
||||
class SceneTreeDialog;
|
||||
|
||||
class ReplicationEditor : public VBoxContainer {
|
||||
GDCLASS(ReplicationEditor, VBoxContainer);
|
||||
class ReplicationEditor : public EditorDock {
|
||||
GDCLASS(ReplicationEditor, EditorDock);
|
||||
|
||||
private:
|
||||
MultiplayerSynchronizer *current = nullptr;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#e0e0e0" d="m8 10-2 4-2-4ZM12 14l-2-4-2 4Z"/><path fill="none" stroke="#e0e0e0" stroke-linecap="round" stroke-width="2" d="M4.936 7.429a4 4 0 0 1 6.128 0M1.872 4.858a8 8 0 0 1 12.256 0"/></svg>
|
||||
|
After Width: | Height: | Size: 269 B |
Reference in New Issue
Block a user