tile_proxies_manager_dialog.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. /**************************************************************************/
  2. /* tile_proxies_manager_dialog.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 "tile_proxies_manager_dialog.h"
  31. #include "editor/editor_properties_vector.h"
  32. #include "editor/editor_settings.h"
  33. #include "editor/editor_undo_redo_manager.h"
  34. #include "scene/gui/popup_menu.h"
  35. #include "scene/gui/separator.h"
  36. void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index, Object *p_item_list) {
  37. if (p_mouse_button_index != MouseButton::RIGHT) {
  38. return;
  39. }
  40. ItemList *item_list = Object::cast_to<ItemList>(p_item_list);
  41. popup_menu->reset_size();
  42. popup_menu->set_position(get_position() + item_list->get_global_mouse_position());
  43. popup_menu->popup();
  44. }
  45. void TileProxiesManagerDialog::_menu_id_pressed(int p_id) {
  46. if (p_id == 0) {
  47. // Delete.
  48. _delete_selected_bindings();
  49. }
  50. }
  51. void TileProxiesManagerDialog::_delete_selected_bindings() {
  52. EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
  53. undo_redo->create_action(TTR("Remove Tile Proxies"));
  54. Vector<int> source_level_selected = source_level_list->get_selected_items();
  55. for (int i = 0; i < source_level_selected.size(); i++) {
  56. int key = source_level_list->get_item_metadata(source_level_selected[i]);
  57. int val = tile_set->get_source_level_tile_proxy(key);
  58. undo_redo->add_do_method(*tile_set, "remove_source_level_tile_proxy", key);
  59. undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", key, val);
  60. }
  61. Vector<int> coords_level_selected = coords_level_list->get_selected_items();
  62. for (int i = 0; i < coords_level_selected.size(); i++) {
  63. Array key = coords_level_list->get_item_metadata(coords_level_selected[i]);
  64. Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]);
  65. undo_redo->add_do_method(*tile_set, "remove_coords_level_tile_proxy", key[0], key[1]);
  66. undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", key[0], key[1], val[0], val[1]);
  67. }
  68. Vector<int> alternative_level_selected = alternative_level_list->get_selected_items();
  69. for (int i = 0; i < alternative_level_selected.size(); i++) {
  70. Array key = alternative_level_list->get_item_metadata(alternative_level_selected[i]);
  71. Array val = tile_set->get_alternative_level_tile_proxy(key[0], key[1], key[2]);
  72. undo_redo->add_do_method(*tile_set, "remove_alternative_level_tile_proxy", key[0], key[1], key[2]);
  73. undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", key[0], key[1], key[2], val[0], val[1], val[2]);
  74. }
  75. undo_redo->add_do_method(this, "_update_lists");
  76. undo_redo->add_undo_method(this, "_update_lists");
  77. undo_redo->commit_action();
  78. committed_actions_count += 1;
  79. }
  80. void TileProxiesManagerDialog::_update_lists() {
  81. source_level_list->clear();
  82. coords_level_list->clear();
  83. alternative_level_list->clear();
  84. Array proxies = tile_set->get_source_level_tile_proxies();
  85. for (int i = 0; i < proxies.size(); i++) {
  86. Array proxy = proxies[i];
  87. String text = vformat("%s", proxy[0]).rpad(5) + "-> " + vformat("%s", proxy[1]);
  88. int id = source_level_list->add_item(text);
  89. source_level_list->set_item_metadata(id, proxy[0]);
  90. }
  91. proxies = tile_set->get_coords_level_tile_proxies();
  92. for (int i = 0; i < proxies.size(); i++) {
  93. Array proxy = proxies[i];
  94. String text = vformat("%s, %s", proxy[0], proxy[1]).rpad(17) + "-> " + vformat("%s, %s", proxy[2], proxy[3]);
  95. int id = coords_level_list->add_item(text);
  96. coords_level_list->set_item_metadata(id, proxy.slice(0, 2));
  97. }
  98. proxies = tile_set->get_alternative_level_tile_proxies();
  99. for (int i = 0; i < proxies.size(); i++) {
  100. Array proxy = proxies[i];
  101. String text = vformat("%s, %s, %s", proxy[0], proxy[1], proxy[2]).rpad(24) + "-> " + vformat("%s, %s, %s", proxy[3], proxy[4], proxy[5]);
  102. int id = alternative_level_list->add_item(text);
  103. alternative_level_list->set_item_metadata(id, proxy.slice(0, 3));
  104. }
  105. }
  106. void TileProxiesManagerDialog::_update_enabled_property_editors() {
  107. if (from.source_id == TileSet::INVALID_SOURCE) {
  108. from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
  109. to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS);
  110. from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
  111. to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
  112. coords_from_property_editor->hide();
  113. coords_to_property_editor->hide();
  114. alternative_from_property_editor->hide();
  115. alternative_to_property_editor->hide();
  116. } else if (from.get_atlas_coords().x == -1 || from.get_atlas_coords().y == -1) {
  117. from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
  118. to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE;
  119. coords_from_property_editor->show();
  120. coords_to_property_editor->show();
  121. alternative_from_property_editor->hide();
  122. alternative_to_property_editor->hide();
  123. } else {
  124. coords_from_property_editor->show();
  125. coords_to_property_editor->show();
  126. alternative_from_property_editor->show();
  127. alternative_to_property_editor->show();
  128. }
  129. source_from_property_editor->update_property();
  130. source_to_property_editor->update_property();
  131. coords_from_property_editor->update_property();
  132. coords_to_property_editor->update_property();
  133. alternative_from_property_editor->update_property();
  134. alternative_to_property_editor->update_property();
  135. }
  136. void TileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) {
  137. _set(p_path, p_value);
  138. }
  139. void TileProxiesManagerDialog::_add_button_pressed() {
  140. EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
  141. if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) {
  142. Vector2i from_coords = from.get_atlas_coords();
  143. Vector2i to_coords = to.get_atlas_coords();
  144. if (from_coords.x >= 0 && from_coords.y >= 0 && to_coords.x >= 0 && to_coords.y >= 0) {
  145. if (from.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE) {
  146. undo_redo->create_action(TTR("Create Alternative-level Tile Proxy"));
  147. undo_redo->add_do_method(*tile_set, "set_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile, to.source_id, to.get_atlas_coords(), to.alternative_tile);
  148. if (tile_set->has_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile)) {
  149. Array a = tile_set->get_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile);
  150. undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", to.source_id, to.get_atlas_coords(), to.alternative_tile, a[0], a[1], a[2]);
  151. } else {
  152. undo_redo->add_undo_method(*tile_set, "remove_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile);
  153. }
  154. } else {
  155. undo_redo->create_action(TTR("Create Coords-level Tile Proxy"));
  156. undo_redo->add_do_method(*tile_set, "set_coords_level_tile_proxy", from.source_id, from.get_atlas_coords(), to.source_id, to.get_atlas_coords());
  157. if (tile_set->has_coords_level_tile_proxy(from.source_id, from.get_atlas_coords())) {
  158. Array a = tile_set->get_coords_level_tile_proxy(from.source_id, from.get_atlas_coords());
  159. undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", to.source_id, to.get_atlas_coords(), a[0], a[1]);
  160. } else {
  161. undo_redo->add_undo_method(*tile_set, "remove_coords_level_tile_proxy", from.source_id, from.get_atlas_coords());
  162. }
  163. }
  164. } else {
  165. undo_redo->create_action(TTR("Create source-level Tile Proxy"));
  166. undo_redo->add_do_method(*tile_set, "set_source_level_tile_proxy", from.source_id, to.source_id);
  167. if (tile_set->has_source_level_tile_proxy(from.source_id)) {
  168. undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", to.source_id, tile_set->get_source_level_tile_proxy(from.source_id));
  169. } else {
  170. undo_redo->add_undo_method(*tile_set, "remove_source_level_tile_proxy", from.source_id);
  171. }
  172. }
  173. undo_redo->add_do_method(this, "_update_lists");
  174. undo_redo->add_undo_method(this, "_update_lists");
  175. undo_redo->commit_action();
  176. committed_actions_count++;
  177. }
  178. }
  179. void TileProxiesManagerDialog::_clear_invalid_button_pressed() {
  180. EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
  181. undo_redo->create_action(TTR("Delete All Invalid Tile Proxies"));
  182. undo_redo->add_do_method(*tile_set, "cleanup_invalid_tile_proxies");
  183. Array proxies = tile_set->get_source_level_tile_proxies();
  184. for (int i = 0; i < proxies.size(); i++) {
  185. Array proxy = proxies[i];
  186. undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]);
  187. }
  188. proxies = tile_set->get_coords_level_tile_proxies();
  189. for (int i = 0; i < proxies.size(); i++) {
  190. Array proxy = proxies[i];
  191. undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]);
  192. }
  193. proxies = tile_set->get_alternative_level_tile_proxies();
  194. for (int i = 0; i < proxies.size(); i++) {
  195. Array proxy = proxies[i];
  196. undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]);
  197. }
  198. undo_redo->add_do_method(this, "_update_lists");
  199. undo_redo->add_undo_method(this, "_update_lists");
  200. undo_redo->commit_action();
  201. }
  202. void TileProxiesManagerDialog::_clear_all_button_pressed() {
  203. EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
  204. undo_redo->create_action(TTR("Delete All Tile Proxies"));
  205. undo_redo->add_do_method(*tile_set, "clear_tile_proxies");
  206. Array proxies = tile_set->get_source_level_tile_proxies();
  207. for (int i = 0; i < proxies.size(); i++) {
  208. Array proxy = proxies[i];
  209. undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]);
  210. }
  211. proxies = tile_set->get_coords_level_tile_proxies();
  212. for (int i = 0; i < proxies.size(); i++) {
  213. Array proxy = proxies[i];
  214. undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]);
  215. }
  216. proxies = tile_set->get_alternative_level_tile_proxies();
  217. for (int i = 0; i < proxies.size(); i++) {
  218. Array proxy = proxies[i];
  219. undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]);
  220. }
  221. undo_redo->add_do_method(this, "_update_lists");
  222. undo_redo->add_undo_method(this, "_update_lists");
  223. undo_redo->commit_action();
  224. }
  225. bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) {
  226. if (p_name == "from_source") {
  227. from.source_id = MAX(int(p_value), -1);
  228. } else if (p_name == "from_coords") {
  229. from.set_atlas_coords(Vector2i(p_value).maxi(-1));
  230. } else if (p_name == "from_alternative") {
  231. from.alternative_tile = MAX(int(p_value), -1);
  232. } else if (p_name == "to_source") {
  233. to.source_id = MAX(int(p_value), 0);
  234. } else if (p_name == "to_coords") {
  235. to.set_atlas_coords(Vector2i(p_value).maxi(0));
  236. } else if (p_name == "to_alternative") {
  237. to.alternative_tile = MAX(int(p_value), 0);
  238. } else {
  239. return false;
  240. }
  241. _update_enabled_property_editors();
  242. return true;
  243. }
  244. bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const {
  245. if (p_name == "from_source") {
  246. r_ret = from.source_id;
  247. } else if (p_name == "from_coords") {
  248. r_ret = from.get_atlas_coords();
  249. } else if (p_name == "from_alternative") {
  250. r_ret = from.alternative_tile;
  251. } else if (p_name == "to_source") {
  252. r_ret = to.source_id;
  253. } else if (p_name == "to_coords") {
  254. r_ret = to.get_atlas_coords();
  255. } else if (p_name == "to_alternative") {
  256. r_ret = to.alternative_tile;
  257. } else {
  258. return false;
  259. }
  260. return true;
  261. }
  262. void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) {
  263. ERR_FAIL_COND(p_event.is_null());
  264. if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
  265. if (!is_inside_tree() || !is_visible()) {
  266. return;
  267. }
  268. if (popup_menu->activate_item_by_event(p_event, false)) {
  269. set_input_as_handled();
  270. }
  271. }
  272. }
  273. void TileProxiesManagerDialog::cancel_pressed() {
  274. EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
  275. for (int i = 0; i < committed_actions_count; i++) {
  276. undo_redo->undo();
  277. }
  278. committed_actions_count = 0;
  279. }
  280. void TileProxiesManagerDialog::_bind_methods() {
  281. ClassDB::bind_method(D_METHOD("_update_lists"), &TileProxiesManagerDialog::_update_lists);
  282. ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileProxiesManagerDialog::_unhandled_key_input);
  283. }
  284. void TileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) {
  285. ERR_FAIL_COND(p_tile_set.is_null());
  286. tile_set = p_tile_set;
  287. committed_actions_count = 0;
  288. _update_lists();
  289. }
  290. TileProxiesManagerDialog::TileProxiesManagerDialog() {
  291. // Tile proxy management window.
  292. set_title(TTR("Tile Proxies Management"));
  293. set_process_unhandled_key_input(true);
  294. to.source_id = 0;
  295. to.set_atlas_coords(Vector2i());
  296. to.alternative_tile = 0;
  297. VBoxContainer *vbox_container = memnew(VBoxContainer);
  298. vbox_container->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  299. vbox_container->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  300. add_child(vbox_container);
  301. Label *source_level_label = memnew(Label);
  302. source_level_label->set_text(TTR("Source-level proxies"));
  303. vbox_container->add_child(source_level_label);
  304. source_level_list = memnew(ItemList);
  305. source_level_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
  306. source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  307. source_level_list->set_select_mode(ItemList::SELECT_MULTI);
  308. source_level_list->set_allow_rmb_select(true);
  309. source_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(source_level_list));
  310. vbox_container->add_child(source_level_list);
  311. Label *coords_level_label = memnew(Label);
  312. coords_level_label->set_text(TTR("Coords-level proxies"));
  313. vbox_container->add_child(coords_level_label);
  314. coords_level_list = memnew(ItemList);
  315. coords_level_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
  316. coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  317. coords_level_list->set_select_mode(ItemList::SELECT_MULTI);
  318. coords_level_list->set_allow_rmb_select(true);
  319. coords_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(coords_level_list));
  320. vbox_container->add_child(coords_level_list);
  321. Label *alternative_level_label = memnew(Label);
  322. alternative_level_label->set_text(TTR("Alternative-level proxies"));
  323. vbox_container->add_child(alternative_level_label);
  324. alternative_level_list = memnew(ItemList);
  325. alternative_level_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
  326. alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  327. alternative_level_list->set_select_mode(ItemList::SELECT_MULTI);
  328. alternative_level_list->set_allow_rmb_select(true);
  329. alternative_level_list->connect("item_clicked", callable_mp(this, &TileProxiesManagerDialog::_right_clicked).bind(alternative_level_list));
  330. vbox_container->add_child(alternative_level_list);
  331. popup_menu = memnew(PopupMenu);
  332. popup_menu->add_shortcut(ED_GET_SHORTCUT("ui_text_delete"));
  333. popup_menu->connect(SceneStringName(id_pressed), callable_mp(this, &TileProxiesManagerDialog::_menu_id_pressed));
  334. add_child(popup_menu);
  335. // Add proxy panel.
  336. HSeparator *h_separator = memnew(HSeparator);
  337. vbox_container->add_child(h_separator);
  338. Label *add_label = memnew(Label);
  339. add_label->set_text(TTR("Add a new tile proxy:"));
  340. vbox_container->add_child(add_label);
  341. HBoxContainer *hboxcontainer = memnew(HBoxContainer);
  342. vbox_container->add_child(hboxcontainer);
  343. // From
  344. VBoxContainer *vboxcontainer_from = memnew(VBoxContainer);
  345. vboxcontainer_from->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  346. hboxcontainer->add_child(vboxcontainer_from);
  347. source_from_property_editor = memnew(EditorPropertyInteger);
  348. source_from_property_editor->set_label(TTR("From Source"));
  349. source_from_property_editor->set_object_and_property(this, "from_source");
  350. source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  351. source_from_property_editor->set_selectable(false);
  352. source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  353. source_from_property_editor->setup(-1, 99999, 1, false, true, false);
  354. vboxcontainer_from->add_child(source_from_property_editor);
  355. coords_from_property_editor = memnew(EditorPropertyVector2i);
  356. coords_from_property_editor->set_label(TTR("From Coords"));
  357. coords_from_property_editor->set_object_and_property(this, "from_coords");
  358. coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  359. coords_from_property_editor->set_selectable(false);
  360. coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  361. coords_from_property_editor->setup(-1, 99999, true);
  362. coords_from_property_editor->hide();
  363. vboxcontainer_from->add_child(coords_from_property_editor);
  364. alternative_from_property_editor = memnew(EditorPropertyInteger);
  365. alternative_from_property_editor->set_label(TTR("From Alternative"));
  366. alternative_from_property_editor->set_object_and_property(this, "from_alternative");
  367. alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  368. alternative_from_property_editor->set_selectable(false);
  369. alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  370. alternative_from_property_editor->setup(-1, 99999, 1, false, true, false);
  371. alternative_from_property_editor->hide();
  372. vboxcontainer_from->add_child(alternative_from_property_editor);
  373. // To
  374. VBoxContainer *vboxcontainer_to = memnew(VBoxContainer);
  375. vboxcontainer_to->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  376. hboxcontainer->add_child(vboxcontainer_to);
  377. source_to_property_editor = memnew(EditorPropertyInteger);
  378. source_to_property_editor->set_label(TTR("To Source"));
  379. source_to_property_editor->set_object_and_property(this, "to_source");
  380. source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  381. source_to_property_editor->set_selectable(false);
  382. source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  383. source_to_property_editor->setup(-1, 99999, 1, false, true, false);
  384. vboxcontainer_to->add_child(source_to_property_editor);
  385. coords_to_property_editor = memnew(EditorPropertyVector2i);
  386. coords_to_property_editor->set_label(TTR("To Coords"));
  387. coords_to_property_editor->set_object_and_property(this, "to_coords");
  388. coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  389. coords_to_property_editor->set_selectable(false);
  390. coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  391. coords_to_property_editor->setup(-1, 99999, true);
  392. coords_to_property_editor->hide();
  393. vboxcontainer_to->add_child(coords_to_property_editor);
  394. alternative_to_property_editor = memnew(EditorPropertyInteger);
  395. alternative_to_property_editor->set_label(TTR("To Alternative"));
  396. alternative_to_property_editor->set_object_and_property(this, "to_alternative");
  397. alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
  398. alternative_to_property_editor->set_selectable(false);
  399. alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  400. alternative_to_property_editor->setup(-1, 99999, 1, false, true, false);
  401. alternative_to_property_editor->hide();
  402. vboxcontainer_to->add_child(alternative_to_property_editor);
  403. Button *add_button = memnew(Button);
  404. add_button->set_text(TTR("Add"));
  405. add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
  406. add_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed));
  407. vbox_container->add_child(add_button);
  408. h_separator = memnew(HSeparator);
  409. vbox_container->add_child(h_separator);
  410. // Generic actions.
  411. Label *generic_actions_label = memnew(Label);
  412. generic_actions_label->set_text(TTR("Global actions:"));
  413. vbox_container->add_child(generic_actions_label);
  414. hboxcontainer = memnew(HBoxContainer);
  415. vbox_container->add_child(hboxcontainer);
  416. Button *clear_invalid_button = memnew(Button);
  417. clear_invalid_button->set_text(TTR("Clear Invalid"));
  418. clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
  419. clear_invalid_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed));
  420. hboxcontainer->add_child(clear_invalid_button);
  421. Button *clear_all_button = memnew(Button);
  422. clear_all_button->set_text(TTR("Clear All"));
  423. clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
  424. clear_all_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed));
  425. hboxcontainer->add_child(clear_all_button);
  426. h_separator = memnew(HSeparator);
  427. vbox_container->add_child(h_separator);
  428. }