Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/2d/tiles/tile_proxies_manager_dialog.cpp
9913 views
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) + "-> " + 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) + "-> " + 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) + "-> " + 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
// From
394
VBoxContainer *vboxcontainer_from = memnew(VBoxContainer);
395
vboxcontainer_from->set_h_size_flags(Control::SIZE_EXPAND_FILL);
396
hboxcontainer->add_child(vboxcontainer_from);
397
398
source_from_property_editor = memnew(EditorPropertyInteger);
399
source_from_property_editor->set_label(TTR("From Source"));
400
source_from_property_editor->set_object_and_property(this, "from_source");
401
source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
402
source_from_property_editor->set_selectable(false);
403
source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
404
source_from_property_editor->setup(-1, 99999, 1, false, true, false);
405
vboxcontainer_from->add_child(source_from_property_editor);
406
407
coords_from_property_editor = memnew(EditorPropertyVector2i);
408
coords_from_property_editor->set_label(TTR("From Coords"));
409
coords_from_property_editor->set_object_and_property(this, "from_coords");
410
coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
411
coords_from_property_editor->set_selectable(false);
412
coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
413
coords_from_property_editor->setup(-1, 99999, true);
414
coords_from_property_editor->hide();
415
vboxcontainer_from->add_child(coords_from_property_editor);
416
417
alternative_from_property_editor = memnew(EditorPropertyInteger);
418
alternative_from_property_editor->set_label(TTR("From Alternative"));
419
alternative_from_property_editor->set_object_and_property(this, "from_alternative");
420
alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
421
alternative_from_property_editor->set_selectable(false);
422
alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
423
alternative_from_property_editor->setup(-1, 99999, 1, false, true, false);
424
alternative_from_property_editor->hide();
425
vboxcontainer_from->add_child(alternative_from_property_editor);
426
427
// To
428
VBoxContainer *vboxcontainer_to = memnew(VBoxContainer);
429
vboxcontainer_to->set_h_size_flags(Control::SIZE_EXPAND_FILL);
430
hboxcontainer->add_child(vboxcontainer_to);
431
432
source_to_property_editor = memnew(EditorPropertyInteger);
433
source_to_property_editor->set_label(TTR("To Source"));
434
source_to_property_editor->set_object_and_property(this, "to_source");
435
source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
436
source_to_property_editor->set_selectable(false);
437
source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
438
source_to_property_editor->setup(-1, 99999, 1, false, true, false);
439
vboxcontainer_to->add_child(source_to_property_editor);
440
441
coords_to_property_editor = memnew(EditorPropertyVector2i);
442
coords_to_property_editor->set_label(TTR("To Coords"));
443
coords_to_property_editor->set_object_and_property(this, "to_coords");
444
coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
445
coords_to_property_editor->set_selectable(false);
446
coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
447
coords_to_property_editor->setup(-1, 99999, true);
448
coords_to_property_editor->hide();
449
vboxcontainer_to->add_child(coords_to_property_editor);
450
451
alternative_to_property_editor = memnew(EditorPropertyInteger);
452
alternative_to_property_editor->set_label(TTR("To Alternative"));
453
alternative_to_property_editor->set_object_and_property(this, "to_alternative");
454
alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed));
455
alternative_to_property_editor->set_selectable(false);
456
alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL);
457
alternative_to_property_editor->setup(-1, 99999, 1, false, true, false);
458
alternative_to_property_editor->hide();
459
vboxcontainer_to->add_child(alternative_to_property_editor);
460
461
Button *add_button = memnew(Button);
462
add_button->set_text(TTR("Add"));
463
add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
464
add_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed));
465
vbox_container->add_child(add_button);
466
467
h_separator = memnew(HSeparator);
468
vbox_container->add_child(h_separator);
469
470
// Generic actions.
471
Label *generic_actions_label = memnew(Label);
472
generic_actions_label->set_text(TTR("Global actions:"));
473
vbox_container->add_child(generic_actions_label);
474
475
hboxcontainer = memnew(HBoxContainer);
476
vbox_container->add_child(hboxcontainer);
477
478
Button *clear_invalid_button = memnew(Button);
479
clear_invalid_button->set_text(TTR("Clear Invalid"));
480
clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
481
clear_invalid_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed));
482
hboxcontainer->add_child(clear_invalid_button);
483
484
Button *clear_all_button = memnew(Button);
485
clear_all_button->set_text(TTR("Clear All"));
486
clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
487
clear_all_button->connect(SceneStringName(pressed), callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed));
488
hboxcontainer->add_child(clear_all_button);
489
490
h_separator = memnew(HSeparator);
491
vbox_container->add_child(h_separator);
492
}
493
494