mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #102640 from olanti-p/fix-add-alt-tile-button
Fix multiple issues with 'add alternative tile' tileset editor button
This commit is contained in:
commit
4a08fdc2a7
2 changed files with 47 additions and 31 deletions
|
@ -971,6 +971,7 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
|
|||
tile_create_help->set_visible(tools_button_group->get_pressed_button() == tool_setup_atlas_source_button);
|
||||
}
|
||||
|
||||
if (tools_button_group->get_pressed_button() != tool_paint_button) {
|
||||
Vector2i pos;
|
||||
Vector2 texture_region_base_size = tile_set_atlas_source->get_texture_region_size();
|
||||
int texture_region_base_size_min = MIN(texture_region_base_size.x, texture_region_base_size.y);
|
||||
|
@ -996,7 +997,9 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
|
|||
button->add_theme_style_override(SceneStringName(hover), memnew(StyleBoxEmpty));
|
||||
button->add_theme_style_override("focus", memnew(StyleBoxEmpty));
|
||||
button->add_theme_style_override(SceneStringName(pressed), memnew(StyleBoxEmpty));
|
||||
button->connect(SceneStringName(pressed), callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile).bind(tile_id, TileSetSource::INVALID_TILE_ALTERNATIVE));
|
||||
button->add_theme_constant_override("align_to_largest_stylebox", false);
|
||||
button->set_mouse_filter(Control::MOUSE_FILTER_PASS);
|
||||
button->connect(SceneStringName(pressed), callable_mp(this, &TileSetAtlasSourceEditor::_tile_alternatives_create_button_pressed).bind(tile_id));
|
||||
button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min)));
|
||||
button->set_expand_icon(true);
|
||||
alternative_tiles_control->add_child(button);
|
||||
|
@ -1005,6 +1008,7 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
|
|||
}
|
||||
}
|
||||
tile_atlas_view->set_padding(Side::SIDE_RIGHT, texture_region_base_size_min);
|
||||
}
|
||||
|
||||
// Redraw everything.
|
||||
tile_atlas_control->queue_redraw();
|
||||
|
@ -2009,6 +2013,17 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() {
|
|||
alternative_tiles_control_unscaled->queue_redraw();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_create_button_pressed(const Vector2i &p_atlas_coords) {
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
|
||||
// FIXME: Doesn't undo changes to `next_alternative_id` counter.
|
||||
undo_redo->create_action(TTR("Create tile alternatives"));
|
||||
int next_id = tile_set_atlas_source->get_next_alternative_tile_id(p_atlas_coords);
|
||||
undo_redo->add_do_method(tile_set_atlas_source, "create_alternative_tile", p_atlas_coords, next_id);
|
||||
undo_redo->add_undo_method(tile_set_atlas_source, "remove_alternative_tile", p_atlas_coords, next_id);
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() {
|
||||
// Update the hovered alternative tile.
|
||||
if (tools_button_group->get_pressed_button() == tool_select_button) {
|
||||
|
|
|
@ -253,6 +253,7 @@ private:
|
|||
PopupMenu *alternative_tile_popup_menu = nullptr;
|
||||
Control *alternative_tiles_control = nullptr;
|
||||
Control *alternative_tiles_control_unscaled = nullptr;
|
||||
void _tile_alternatives_create_button_pressed(const Vector2i &p_atlas_coords);
|
||||
void _tile_alternatives_control_draw();
|
||||
void _tile_alternatives_control_unscaled_draw();
|
||||
void _tile_alternatives_control_mouse_exited();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue