Debian Codegraph @

editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp

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