Skip to content

Commit

Permalink
Added a button to the TilesetEditor to easily select the TilesetEdito…
Browse files Browse the repository at this point in the history
…rContext when needed.
  • Loading branch information
Relintai committed Dec 22, 2023
1 parent f9cbc81 commit be37940
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/tile_map/tile_set_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions modules/tile_map/tile_set_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class TileSetEditor : public HSplitContainer {
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();
Expand Down

0 comments on commit be37940

Please sign in to comment.