tile_proxies_manager_dialog.cpp 22 KB

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