replication_editor_plugin.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*************************************************************************/
  2. /* replication_editor_plugin.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "replication_editor_plugin.h"
  31. #include "editor/editor_node.h"
  32. #include "editor/editor_scale.h"
  33. #include "editor/editor_settings.h"
  34. #include "editor/editor_undo_redo_manager.h"
  35. #include "editor/inspector_dock.h"
  36. #include "editor/scene_tree_editor.h"
  37. #include "modules/multiplayer/multiplayer_synchronizer.h"
  38. #include "scene/gui/dialogs.h"
  39. #include "scene/gui/separator.h"
  40. #include "scene/gui/tree.h"
  41. void ReplicationEditor::_pick_node_filter_text_changed(const String &p_newtext) {
  42. TreeItem *root_item = pick_node->get_scene_tree()->get_scene_tree()->get_root();
  43. Vector<Node *> select_candidates;
  44. Node *to_select = nullptr;
  45. String filter = pick_node->get_filter_line_edit()->get_text();
  46. _pick_node_select_recursive(root_item, filter, select_candidates);
  47. if (!select_candidates.is_empty()) {
  48. for (int i = 0; i < select_candidates.size(); ++i) {
  49. Node *candidate = select_candidates[i];
  50. if (((String)candidate->get_name()).to_lower().begins_with(filter.to_lower())) {
  51. to_select = candidate;
  52. break;
  53. }
  54. }
  55. if (!to_select) {
  56. to_select = select_candidates[0];
  57. }
  58. }
  59. pick_node->get_scene_tree()->set_selected(to_select);
  60. }
  61. void ReplicationEditor::_pick_node_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates) {
  62. if (!p_item) {
  63. return;
  64. }
  65. NodePath np = p_item->get_metadata(0);
  66. Node *node = get_node(np);
  67. if (!p_filter.is_empty() && ((String)node->get_name()).findn(p_filter) != -1) {
  68. p_select_candidates.push_back(node);
  69. }
  70. TreeItem *c = p_item->get_first_child();
  71. while (c) {
  72. _pick_node_select_recursive(c, p_filter, p_select_candidates);
  73. c = c->get_next();
  74. }
  75. }
  76. void ReplicationEditor::_pick_node_filter_input(const Ref<InputEvent> &p_ie) {
  77. Ref<InputEventKey> k = p_ie;
  78. if (k.is_valid()) {
  79. switch (k->get_keycode()) {
  80. case Key::UP:
  81. case Key::DOWN:
  82. case Key::PAGEUP:
  83. case Key::PAGEDOWN: {
  84. pick_node->get_scene_tree()->get_scene_tree()->gui_input(k);
  85. pick_node->get_filter_line_edit()->accept_event();
  86. } break;
  87. default:
  88. break;
  89. }
  90. }
  91. }
  92. void ReplicationEditor::_pick_node_selected(NodePath p_path) {
  93. Node *root = current->get_node(current->get_root_path());
  94. ERR_FAIL_COND(!root);
  95. Node *node = get_node(p_path);
  96. ERR_FAIL_COND(!node);
  97. NodePath path_to = root->get_path_to(node);
  98. adding_node_path = path_to;
  99. prop_selector->select_property_from_instance(node);
  100. }
  101. void ReplicationEditor::_pick_new_property() {
  102. if (current == nullptr) {
  103. EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
  104. return;
  105. }
  106. Node *root = current->get_node(current->get_root_path());
  107. if (!root) {
  108. EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
  109. return;
  110. }
  111. pick_node->popup_scenetree_dialog();
  112. pick_node->get_filter_line_edit()->clear();
  113. pick_node->get_filter_line_edit()->grab_focus();
  114. }
  115. void ReplicationEditor::_add_sync_property(String p_path) {
  116. config = current->get_replication_config();
  117. if (config.is_valid() && config->has_property(p_path)) {
  118. EditorNode::get_singleton()->show_warning(TTR("Property is already being synchronized."));
  119. return;
  120. }
  121. Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo();
  122. undo_redo->create_action(TTR("Add property to synchronizer"));
  123. if (config.is_null()) {
  124. config.instantiate();
  125. current->set_replication_config(config);
  126. undo_redo->add_do_method(current, "set_replication_config", config);
  127. undo_redo->add_undo_method(current, "set_replication_config", Ref<SceneReplicationConfig>());
  128. _update_config();
  129. }
  130. undo_redo->add_do_method(config.ptr(), "add_property", p_path);
  131. undo_redo->add_undo_method(config.ptr(), "remove_property", p_path);
  132. undo_redo->add_do_method(this, "_update_config");
  133. undo_redo->add_undo_method(this, "_update_config");
  134. undo_redo->commit_action();
  135. }
  136. void ReplicationEditor::_pick_node_property_selected(String p_name) {
  137. String adding_prop_path = String(adding_node_path) + ":" + p_name;
  138. _add_sync_property(adding_prop_path);
  139. }
  140. /// ReplicationEditor
  141. ReplicationEditor::ReplicationEditor() {
  142. set_v_size_flags(SIZE_EXPAND_FILL);
  143. set_custom_minimum_size(Size2(0, 200) * EDSCALE);
  144. delete_dialog = memnew(ConfirmationDialog);
  145. delete_dialog->connect("cancelled", callable_mp(this, &ReplicationEditor::_dialog_closed).bind(false));
  146. delete_dialog->connect("confirmed", callable_mp(this, &ReplicationEditor::_dialog_closed).bind(true));
  147. add_child(delete_dialog);
  148. error_dialog = memnew(AcceptDialog);
  149. error_dialog->set_ok_button_text(TTR("Close"));
  150. error_dialog->set_title(TTR("Error!"));
  151. add_child(error_dialog);
  152. VBoxContainer *vb = memnew(VBoxContainer);
  153. vb->set_v_size_flags(SIZE_EXPAND_FILL);
  154. add_child(vb);
  155. pick_node = memnew(SceneTreeDialog);
  156. add_child(pick_node);
  157. pick_node->register_text_enter(pick_node->get_filter_line_edit());
  158. pick_node->set_title(TTR("Pick a node to synchronize:"));
  159. pick_node->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_selected));
  160. pick_node->get_filter_line_edit()->connect("text_changed", callable_mp(this, &ReplicationEditor::_pick_node_filter_text_changed));
  161. pick_node->get_filter_line_edit()->connect("gui_input", callable_mp(this, &ReplicationEditor::_pick_node_filter_input));
  162. prop_selector = memnew(PropertySelector);
  163. add_child(prop_selector);
  164. prop_selector->connect("selected", callable_mp(this, &ReplicationEditor::_pick_node_property_selected));
  165. HBoxContainer *hb = memnew(HBoxContainer);
  166. vb->add_child(hb);
  167. add_pick_button = memnew(Button);
  168. add_pick_button->connect("pressed", callable_mp(this, &ReplicationEditor::_pick_new_property));
  169. add_pick_button->set_text(TTR("Add property to sync.."));
  170. hb->add_child(add_pick_button);
  171. VSeparator *vs = memnew(VSeparator);
  172. vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0));
  173. hb->add_child(vs);
  174. hb->add_child(memnew(Label(TTR("Path:"))));
  175. np_line_edit = memnew(LineEdit);
  176. np_line_edit->set_placeholder(":property");
  177. np_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
  178. hb->add_child(np_line_edit);
  179. add_from_path_button = memnew(Button);
  180. add_from_path_button->connect("pressed", callable_mp(this, &ReplicationEditor::_add_pressed));
  181. add_from_path_button->set_text(TTR("Add from path"));
  182. hb->add_child(add_from_path_button);
  183. vs = memnew(VSeparator);
  184. vs->set_custom_minimum_size(Size2(30 * EDSCALE, 0));
  185. hb->add_child(vs);
  186. pin = memnew(Button);
  187. pin->set_flat(true);
  188. pin->set_toggle_mode(true);
  189. hb->add_child(pin);
  190. tree = memnew(Tree);
  191. tree->set_hide_root(true);
  192. tree->set_columns(4);
  193. tree->set_column_titles_visible(true);
  194. tree->set_column_title(0, TTR("Properties"));
  195. tree->set_column_expand(0, true);
  196. tree->set_column_title(1, TTR("Spawn"));
  197. tree->set_column_expand(1, false);
  198. tree->set_column_custom_minimum_width(1, 100);
  199. tree->set_column_title(2, TTR("Sync"));
  200. tree->set_column_custom_minimum_width(2, 100);
  201. tree->set_column_expand(2, false);
  202. tree->set_column_expand(3, false);
  203. tree->create_item();
  204. tree->connect("button_clicked", callable_mp(this, &ReplicationEditor::_tree_button_pressed));
  205. tree->connect("item_edited", callable_mp(this, &ReplicationEditor::_tree_item_edited));
  206. tree->set_v_size_flags(SIZE_EXPAND_FILL);
  207. vb->add_child(tree);
  208. drop_label = memnew(Label);
  209. drop_label->set_text(TTR("Add properties using the buttons above or\ndrag them them from the inspector and drop them here."));
  210. drop_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  211. drop_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
  212. tree->add_child(drop_label);
  213. drop_label->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
  214. tree->set_drag_forwarding(this);
  215. }
  216. void ReplicationEditor::_bind_methods() {
  217. ClassDB::bind_method(D_METHOD("_update_config"), &ReplicationEditor::_update_config);
  218. ClassDB::bind_method(D_METHOD("_update_checked", "property", "column", "checked"), &ReplicationEditor::_update_checked);
  219. ClassDB::bind_method("_can_drop_data_fw", &ReplicationEditor::_can_drop_data_fw);
  220. ClassDB::bind_method("_drop_data_fw", &ReplicationEditor::_drop_data_fw);
  221. }
  222. bool ReplicationEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
  223. Dictionary d = p_data;
  224. if (!d.has("type")) {
  225. return false;
  226. }
  227. String t = d["type"];
  228. if (t != "obj_property") {
  229. return false;
  230. }
  231. Object *obj = d["object"];
  232. if (!obj) {
  233. return false;
  234. }
  235. Node *node = Object::cast_to<Node>(obj);
  236. if (!node) {
  237. return false;
  238. }
  239. return true;
  240. }
  241. void ReplicationEditor::_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
  242. if (current == nullptr) {
  243. EditorNode::get_singleton()->show_warning(TTR("Select a replicator node in order to pick a property to add to it."));
  244. return;
  245. }
  246. Node *root = current->get_node(current->get_root_path());
  247. if (!root) {
  248. EditorNode::get_singleton()->show_warning(TTR("Not possible to add a new property to synchronize without a root."));
  249. return;
  250. }
  251. Dictionary d = p_data;
  252. if (!d.has("type")) {
  253. return;
  254. }
  255. String t = d["type"];
  256. if (t != "obj_property") {
  257. return;
  258. }
  259. Object *obj = d["object"];
  260. if (!obj) {
  261. return;
  262. }
  263. Node *node = Object::cast_to<Node>(obj);
  264. if (!node) {
  265. return;
  266. }
  267. String path = root->get_path_to(node);
  268. path += ":" + String(d["property"]);
  269. _add_sync_property(path);
  270. }
  271. void ReplicationEditor::_notification(int p_what) {
  272. switch (p_what) {
  273. case NOTIFICATION_ENTER_TREE:
  274. case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
  275. add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel")));
  276. add_pick_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
  277. pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")));
  278. } break;
  279. }
  280. }
  281. void ReplicationEditor::_add_pressed() {
  282. if (!current) {
  283. error_dialog->set_text(TTR("Please select a MultiplayerSynchronizer first."));
  284. error_dialog->popup_centered();
  285. return;
  286. }
  287. if (current->get_root_path().is_empty()) {
  288. error_dialog->set_text(TTR("The MultiplayerSynchronizer needs a root path."));
  289. error_dialog->popup_centered();
  290. return;
  291. }
  292. String np_text = np_line_edit->get_text();
  293. int idx = np_text.find(":");
  294. if (idx == -1) {
  295. np_text = ".:" + np_text;
  296. } else if (idx == 0) {
  297. np_text = "." + np_text;
  298. }
  299. NodePath path = NodePath(np_text);
  300. _add_sync_property(path);
  301. }
  302. void ReplicationEditor::_tree_item_edited() {
  303. TreeItem *ti = tree->get_edited();
  304. if (!ti || config.is_null()) {
  305. return;
  306. }
  307. int column = tree->get_edited_column();
  308. ERR_FAIL_COND(column < 1 || column > 2);
  309. const NodePath prop = ti->get_metadata(0);
  310. Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
  311. bool value = ti->is_checked(column);
  312. String method;
  313. if (column == 1) {
  314. undo_redo->create_action(TTR("Set spawn property"));
  315. method = "property_set_spawn";
  316. } else {
  317. undo_redo->create_action(TTR("Set sync property"));
  318. method = "property_set_sync";
  319. }
  320. undo_redo->add_do_method(config.ptr(), method, prop, value);
  321. undo_redo->add_undo_method(config.ptr(), method, prop, !value);
  322. undo_redo->add_do_method(this, "_update_checked", prop, column, value);
  323. undo_redo->add_undo_method(this, "_update_checked", prop, column, !value);
  324. undo_redo->commit_action();
  325. }
  326. void ReplicationEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
  327. if (p_button != MouseButton::LEFT) {
  328. return;
  329. }
  330. TreeItem *ti = Object::cast_to<TreeItem>(p_item);
  331. if (!ti) {
  332. return;
  333. }
  334. deleting = ti->get_metadata(0);
  335. delete_dialog->set_text(TTR("Delete Property?") + "\n\"" + ti->get_text(0) + "\"");
  336. delete_dialog->popup_centered();
  337. }
  338. void ReplicationEditor::_dialog_closed(bool p_confirmed) {
  339. if (deleting.is_empty() || config.is_null()) {
  340. return;
  341. }
  342. if (p_confirmed) {
  343. const NodePath prop = deleting;
  344. int idx = config->property_get_index(prop);
  345. bool spawn = config->property_get_spawn(prop);
  346. bool sync = config->property_get_sync(prop);
  347. Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
  348. undo_redo->create_action(TTR("Remove Property"));
  349. undo_redo->add_do_method(config.ptr(), "remove_property", prop);
  350. undo_redo->add_undo_method(config.ptr(), "add_property", prop, idx);
  351. undo_redo->add_undo_method(config.ptr(), "property_set_spawn", prop, spawn);
  352. undo_redo->add_undo_method(config.ptr(), "property_set_sync", prop, sync);
  353. undo_redo->add_do_method(this, "_update_config");
  354. undo_redo->add_undo_method(this, "_update_config");
  355. undo_redo->commit_action();
  356. }
  357. deleting = NodePath();
  358. }
  359. void ReplicationEditor::_update_checked(const NodePath &p_prop, int p_column, bool p_checked) {
  360. if (!tree->get_root()) {
  361. return;
  362. }
  363. TreeItem *ti = tree->get_root()->get_first_child();
  364. while (ti) {
  365. if (ti->get_metadata(0).operator NodePath() == p_prop) {
  366. ti->set_checked(p_column, p_checked);
  367. return;
  368. }
  369. ti = ti->get_next();
  370. }
  371. }
  372. void ReplicationEditor::_update_config() {
  373. deleting = NodePath();
  374. tree->clear();
  375. tree->create_item();
  376. drop_label->set_visible(true);
  377. if (!config.is_valid()) {
  378. return;
  379. }
  380. TypedArray<NodePath> props = config->get_properties();
  381. if (props.size()) {
  382. drop_label->set_visible(false);
  383. }
  384. for (int i = 0; i < props.size(); i++) {
  385. const NodePath path = props[i];
  386. _add_property(path, config->property_get_spawn(path), config->property_get_sync(path));
  387. }
  388. }
  389. void ReplicationEditor::edit(MultiplayerSynchronizer *p_sync) {
  390. if (current == p_sync) {
  391. return;
  392. }
  393. current = p_sync;
  394. if (current) {
  395. config = current->get_replication_config();
  396. } else {
  397. config.unref();
  398. }
  399. _update_config();
  400. }
  401. Ref<Texture2D> ReplicationEditor::_get_class_icon(const Node *p_node) {
  402. if (!p_node || !has_theme_icon(p_node->get_class(), "EditorIcons")) {
  403. return get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
  404. }
  405. return get_theme_icon(p_node->get_class(), "EditorIcons");
  406. }
  407. void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, bool p_sync) {
  408. String prop = String(p_property);
  409. TreeItem *item = tree->create_item();
  410. item->set_selectable(0, false);
  411. item->set_selectable(1, false);
  412. item->set_selectable(2, false);
  413. item->set_selectable(3, false);
  414. item->set_text(0, prop);
  415. item->set_metadata(0, prop);
  416. Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr;
  417. Ref<Texture2D> icon = _get_class_icon(root_node);
  418. if (root_node) {
  419. String path = prop.substr(0, prop.find(":"));
  420. String subpath = prop.substr(path.size());
  421. Node *node = root_node->get_node_or_null(path);
  422. if (!node) {
  423. node = root_node;
  424. }
  425. item->set_text(0, String(node->get_name()) + ":" + subpath);
  426. icon = _get_class_icon(node);
  427. }
  428. item->set_icon(0, icon);
  429. item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
  430. item->set_text_alignment(1, HORIZONTAL_ALIGNMENT_CENTER);
  431. item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
  432. item->set_checked(1, p_spawn);
  433. item->set_editable(1, true);
  434. item->set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER);
  435. item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
  436. item->set_checked(2, p_sync);
  437. item->set_editable(2, true);
  438. }
  439. /// ReplicationEditorPlugin
  440. ReplicationEditorPlugin::ReplicationEditorPlugin() {
  441. repl_editor = memnew(ReplicationEditor);
  442. button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Replication"), repl_editor);
  443. button->hide();
  444. repl_editor->get_pin()->connect("pressed", callable_mp(this, &ReplicationEditorPlugin::_pinned));
  445. }
  446. ReplicationEditorPlugin::~ReplicationEditorPlugin() {
  447. }
  448. void ReplicationEditorPlugin::_notification(int p_what) {
  449. switch (p_what) {
  450. case NOTIFICATION_ENTER_TREE: {
  451. get_tree()->connect("node_removed", callable_mp(this, &ReplicationEditorPlugin::_node_removed));
  452. } break;
  453. }
  454. }
  455. void ReplicationEditorPlugin::_node_removed(Node *p_node) {
  456. if (p_node && p_node == repl_editor->get_current()) {
  457. repl_editor->edit(nullptr);
  458. if (repl_editor->is_visible_in_tree()) {
  459. EditorNode::get_singleton()->hide_bottom_panel();
  460. }
  461. button->hide();
  462. repl_editor->get_pin()->set_pressed(false);
  463. }
  464. }
  465. void ReplicationEditorPlugin::_pinned() {
  466. if (!repl_editor->get_pin()->is_pressed()) {
  467. if (repl_editor->is_visible_in_tree()) {
  468. EditorNode::get_singleton()->hide_bottom_panel();
  469. }
  470. button->hide();
  471. }
  472. }
  473. void ReplicationEditorPlugin::edit(Object *p_object) {
  474. repl_editor->edit(Object::cast_to<MultiplayerSynchronizer>(p_object));
  475. }
  476. bool ReplicationEditorPlugin::handles(Object *p_object) const {
  477. return p_object->is_class("MultiplayerSynchronizer");
  478. }
  479. void ReplicationEditorPlugin::make_visible(bool p_visible) {
  480. if (p_visible) {
  481. button->show();
  482. EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor);
  483. } else if (!repl_editor->get_pin()->is_pressed()) {
  484. if (repl_editor->is_visible_in_tree()) {
  485. EditorNode::get_singleton()->hide_bottom_panel();
  486. }
  487. button->hide();
  488. }
  489. }