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