Merge pull request #81971 from KoBeWi/there_is_only_one_scene
Don't allow transforming scene tiles
This commit is contained in:
commit
fb4c0cf462
@ -107,17 +107,33 @@ void TileMapEditorTilesPlugin::_update_transform_buttons() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile_set->get_tile_shape() == TileSet::TILE_SHAPE_SQUARE || selection_pattern->get_size() == Vector2i(1, 1)) {
|
||||
transform_button_rotate_left->set_disabled(false);
|
||||
transform_button_rotate_left->set_tooltip_text("");
|
||||
transform_button_rotate_right->set_disabled(false);
|
||||
transform_button_rotate_right->set_tooltip_text("");
|
||||
bool has_scene_tile = false;
|
||||
for (const KeyValue<Vector2i, TileMapCell> &E : selection_pattern->get_pattern()) {
|
||||
if (Object::cast_to<TileSetScenesCollectionSource>(tile_set->get_source(E.value.source_id).ptr())) {
|
||||
has_scene_tile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_scene_tile) {
|
||||
_set_transform_buttons_state({}, { transform_button_rotate_left, transform_button_rotate_right, transform_button_flip_h, transform_button_flip_v },
|
||||
TTR("Can't transform scene tiles."));
|
||||
} else if (tile_set->get_tile_shape() != TileSet::TILE_SHAPE_SQUARE && selection_pattern->get_size() != Vector2i(1, 1)) {
|
||||
_set_transform_buttons_state({ transform_button_flip_h, transform_button_flip_v }, { transform_button_rotate_left, transform_button_rotate_right },
|
||||
TTR("Can't rotate patterns when using non-square tile grid."));
|
||||
} else {
|
||||
const String tooltip_text = TTR("Can't rotate patterns when using non-square tile grid.");
|
||||
transform_button_rotate_left->set_disabled(true);
|
||||
transform_button_rotate_left->set_tooltip_text(tooltip_text);
|
||||
transform_button_rotate_right->set_disabled(true);
|
||||
transform_button_rotate_right->set_tooltip_text(tooltip_text);
|
||||
_set_transform_buttons_state({ transform_button_rotate_left, transform_button_rotate_right, transform_button_flip_h, transform_button_flip_v }, {}, "");
|
||||
}
|
||||
}
|
||||
|
||||
void TileMapEditorTilesPlugin::_set_transform_buttons_state(const Vector<Button *> &p_enabled_buttons, const Vector<Button *> &p_disabled_buttons, const String &p_why_disabled) {
|
||||
for (Button *button : p_enabled_buttons) {
|
||||
button->set_disabled(false);
|
||||
button->set_tooltip_text("");
|
||||
}
|
||||
for (Button *button : p_disabled_buttons) {
|
||||
button->set_disabled(true);
|
||||
button->set_tooltip_text(p_why_disabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ private:
|
||||
|
||||
void _update_toolbar();
|
||||
void _update_transform_buttons();
|
||||
void _set_transform_buttons_state(const Vector<Button *> &p_enabled_buttons, const Vector<Button *> &p_disabled_buttons, const String &p_why_disabled);
|
||||
|
||||
///// Tilemap editing. /////
|
||||
bool has_mouse = false;
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
Vector2i get_cell_atlas_coords(const Vector2i &p_coords) const;
|
||||
int get_cell_alternative_tile(const Vector2i &p_coords) const;
|
||||
|
||||
const HashMap<Vector2i, TileMapCell> &get_pattern() const { return pattern; }
|
||||
TypedArray<Vector2i> get_used_cells() const;
|
||||
|
||||
Size2i get_size() const;
|
||||
|
Loading…
Reference in New Issue
Block a user