Added a button to the TilesetEditor to easily select the TilesetEditorContext when needed.

This commit is contained in:
Relintai 2023-12-22 20:15:33 +01:00
parent f9cbc81492
commit be379405d2
2 changed files with 12 additions and 0 deletions

View File

@ -302,6 +302,7 @@ void TileSetEditor::_bind_methods() {
ClassDB::bind_method("_zoom_reset", &TileSetEditor::_zoom_reset);
ClassDB::bind_method("_select_edited_shape_coord", &TileSetEditor::_select_edited_shape_coord);
ClassDB::bind_method("_sort_tiles", &TileSetEditor::_sort_tiles);
ClassDB::bind_method("_on_select_context_button_pressed", &TileSetEditor::_on_select_context_button_pressed);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &TileSetEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &TileSetEditor::can_drop_data_fw);
@ -435,6 +436,12 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb->add_child(tool_workspacemode[i]);
}
Button *select_context_button = memnew(Button);
select_context_button->set_text("->");
select_context_button->set_tooltip("Select TilesetEditorContext.");
select_context_button->connect("pressed", this, "_on_select_context_button_pressed");
tool_hb->add_child(select_context_button);
Control *spacer = memnew(Control);
spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL);
tool_hb->add_child(spacer);
@ -2412,6 +2419,10 @@ void TileSetEditor::_set_snap_sep(Vector2 p_val) {
workspace->update();
}
void TileSetEditor::_on_select_context_button_pressed() {
editor->get_inspector()->edit(helper);
}
void TileSetEditor::_validate_current_tile_id() {
if (get_current_tile() >= 0 && !tileset->has_tile(get_current_tile())) {
set_current_tile(-1);

View File

@ -236,6 +236,7 @@ private:
void _set_snap_step(Vector2 p_val);
void _set_snap_off(Vector2 p_val);
void _set_snap_sep(Vector2 p_val);
void _on_select_context_button_pressed();
void _validate_current_tile_id();
void _select_edited_shape_coord();