tile_proxies_manager_dialog.cpp 22 KB

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